Skip to content

Commit 96b707c

Browse files
ran-isenbergRan Isenberg
andauthored
docs: add swagger protection docs (#791)
Co-authored-by: Ran Isenberg <ran.isenberg@ranthebuilder.cloud>
1 parent e2cf2d7 commit 96b707c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ This project aims to reduce cognitive load and answer these questions for you by
9494
- CloudWatch dashboards - High level and low level including CloudWatch alarms
9595
- Unit, infrastructure, security, integration and end to end tests.
9696
- Automatically generated OpenAPI endpoint: /swagger with Pydnatic schemas for both requests and responses
97+
- CI swagger protection - fails the PR if your swagger JSON file (stored at docs/swagger/openapi.json) is out of date
9798

9899

99100
## CDK Deployment

docs/getting_started.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ CDK destroy can be run with ``make destroy``.
6868

6969
## **Preparing Code for PR**
7070

71-
Run ``make pr``. This command will run all the required checks, pre commit hooks, linters, code formatters, import sorting and tests, so you can be sure GitHub's pipeline will pass.
71+
Run ``make pr``. This command will run all the required checks, pre commit hooks, linters, code formatters, import sorting and tests, so you can be sure GitHub's pipeline will pass. It will also generate an updated swagger OpenAPI JSON file and place it at docs/swagger/openapi.json location.
7272

7373
The command auto fixes errors in the code for you.
7474

7575
If there's an error in the pre-commit stage, it gets auto fixed. However, are required to run ``make pr`` again so it continues to the next stages.
7676

7777
Be sure to commit all the changes that ``make pr`` does for you.
7878

79+
## **OpenAPI Swagger Generation**
80+
Run either ``make pr`` or ``make openopi`` to generate an updated swagger OpenAPI JSON file and place it at docs/swagger/openapi.json location.
81+
82+
7983
## **GitHub Pages Documentation**
8084

8185
``make docs`` can be run to start a local HTTP server with the project's documentation pages.

docs/pipeline.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ All steps can be run locally using the makefile. See details below:
2828
- Infrastructure test. Run `make infra-tests` to run the CDK infrastructure tests in the IDE
2929
- Code coverage by [codecov.io](https://about.codecov.io/)
3030
- Deploy CDK - run `make deploy` in the IDE, will also run security tests based on cdk_nag
31+
- Integration tests - run `make integration` in the IDE.
3132
- E2E tests - run `make e2e` in the IDE
3233
- Code coverage tests - run `make coverage-tests` in the IDE after CDK dep
34+
- OpenAPI Swagger file - run
3335
- Update GitHub documentation branch
3436

3537
### **Other Capabilities**
@@ -49,11 +51,11 @@ The two most important ones are `pr-serverless-service` and `main-serverless-se
4951

5052
<img alt="alt_text" src="../media/cicd_pr.png" />
5153

52-
`pr-serverless-service` runs for every pull request you open. It expects you defined a GitHub environment by the name `dev` and that it includes a secret by the name of `AWS_ROLE`.
54+
`pr-serverless-service` runs for every pull request you open. It expects you defined a GitHub environments by the name `dev`, `staging` and `production` and for each environments to have the following variables: `CODECOV_TOKEN ` for CodeCov integration and `AWS_ROLE` that allows GitHub to deploy to that AWS account (one for dev, one for staging and one for production accounts).
5355

5456
It includes two jobs: 'quality_standards' and 'tests' where a failure in 'quality_standards' does not trigger 'tests'. Both jobs MUST pass in order to to be able to merge.
5557

56-
'quality_standards' includes all linters, pre-commit checks and units tests and 'tests' deploys the service to AWS, runs code coverage checks, security checks and E2E tests. Stack is destroyed at the end. Stack has a 'dev' prefix as part of its name.
58+
'quality_standards' includes all linters, pre-commit checks and units tests and 'tests' deploys the service to AWS, runs code coverage checks, checks that your OpenAPI file is up to date and corresponds to the actual deployment (fails if it does not, hence your documentation is out of date), security checks and E2E tests. Stack is destroyed at the end. Stack has a 'dev' prefix as part of its name. Each environment has a pre-defined stack prefix.
5759

5860
Once merged, `main-serverless-service` will run.
5961

0 commit comments

Comments
 (0)