Skip to content

Commit e2cf2d7

Browse files
ran-isenbergRan Isenberg
and
Ran Isenberg
authored
feature: add swagger generation script and PR swagger check (#790)
Co-authored-by: Ran Isenberg <ran.isenberg@ranthebuilder.cloud>
1 parent db6f62f commit e2cf2d7

File tree

5 files changed

+315
-180
lines changed

5 files changed

+315
-180
lines changed

.github/workflows/pr-serverless-service.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ jobs:
100100
verbose: yes # optional (default = false)
101101
- name: Run E2E tests
102102
run: make e2e
103+
- name: Validate OpenAPI Documentation
104+
run: make compare-openapi
103105
- name: Destroy stack
104106
if: always()
105107
run: make destroy

Makefile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
.PHONY: dev lint complex coverage pre-commit sort deploy destroy deps unit infra-tests integration e2e coverage-tests docs lint-docs build format
1+
.PHONY: dev lint complex coverage pre-commit sort deploy destroy deps unit infra-tests integration e2e coverage-tests docs lint-docs build format compare-openapi openapi
22
PYTHON := ".venv/bin/python3"
3-
43
.ONESHELL: # run all commands in a single shell, ensuring it runs within a local virtual env
4+
5+
OPENAPI_DIR := ./docs/swagger
6+
CURRENT_OPENAPI := $(OPENAPI_DIR)/openapi.json
7+
LATEST_OPENAPI := openapi_latest.json
8+
9+
510
dev:
611
pip install --upgrade pip pre-commit poetry
712
pre-commit install
@@ -52,7 +57,7 @@ integration:
5257
e2e:
5358
poetry run pytest tests/e2e --cov-config=.coveragerc --cov=service --cov-report xml
5459

55-
pr: deps format pre-commit complex lint lint-docs unit deploy coverage-tests e2e
60+
pr: deps format pre-commit complex lint lint-docs unit deploy coverage-tests e2e openapi
5661

5762
coverage-tests:
5863
poetry run pytest tests/unit tests/integration --cov-config=.coveragerc --cov=service --cov-report xml
@@ -76,3 +81,17 @@ update-deps:
7681
poetry update
7782
pre-commit autoupdate
7883
npm i --package-lock-only
84+
85+
openapi:
86+
poetry run python generate_openapi.py
87+
88+
compare-openapi:
89+
poetry run python generate_openapi.py --out-destination '.' --out-filename 'openapi_latest.json'
90+
@if cmp --silent $(CURRENT_OPENAPI) $(LATEST_OPENAPI); then \
91+
rm $(LATEST_OPENAPI); \
92+
echo "Swagger file is up to date"; \
93+
else \
94+
echo "Swagger files are not equal, did you run 'make pr' or 'make openapi'?"; \
95+
rm $(LATEST_OPENAPI); \
96+
exit 1; \
97+
fi

docs/cdk.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,4 @@ For more information click [here](https://docs.aws.amazon.com/prescriptive-guida
6363

6464
In the picture below you can see all the deployed resources ordered into domain groups. The image was created with the IDE plugin of AWS Application Composer.
6565

66-
6766
<img alt="alt_text" src="../media/application-composer-main-Orders-dev.template.json.png" />

0 commit comments

Comments
 (0)