Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/openapi-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
python examples/openapi_contract/generate_schemas.py \
--output-dir "$RUNNER_TEMP/openapi-contract-schemas"

- name: Upload generated OpenAPI schemas for review
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: versioned-openapi-contract-schemas
path: ${{ runner.temp }}/openapi-contract-schemas/
if-no-files-found: error
retention-days: 7

- name: Install pinned oasdiff
run: |
archive="$RUNNER_TEMP/oasdiff_1.38.0_linux_amd64.tar.gz"
Expand All @@ -58,17 +66,10 @@ jobs:

- name: Compare candidate schemas with committed version baselines
run: |
oasdiff breaking --fail-on ERR \
oasdiff breaking --fail-on WARN \
examples/openapi_contract/schemas/v1/openapi.yaml \
"$RUNNER_TEMP/openapi-contract-schemas/v1/openapi.yaml"
oasdiff breaking --fail-on ERR \
oasdiff breaking --fail-on WARN \
examples/openapi_contract/schemas/v2/openapi.yaml \
"$RUNNER_TEMP/openapi-contract-schemas/v2/openapi.yaml"

- name: Upload generated OpenAPI schemas for review
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: versioned-openapi-contract-schemas
path: ${{ runner.temp }}/openapi-contract-schemas/
if-no-files-found: error
retention-days: 7
2 changes: 1 addition & 1 deletion docs/design/versioned-openapi-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The CI sequence is:
2. Generate one schema for each supported API version.
3. Validate schemas and fail on unresolved introspection warnings.
4. Compare each candidate only with the matching released version baseline.
5. Run oasdiff breaking and fail on breaking changes to a stable contract.
5. Run oasdiff breaking with `--fail-on WARN`; both definite breaking changes (`ERR`) and potential breaking changes (`WARN`) block the contract gate. Review and justify any exception with a narrowly scoped severity override.
6. Review additive changes and update migration/release notes deliberately.

A new API version starts with its own baseline. A breaking change to an existing
Expand Down
5 changes: 3 additions & 2 deletions examples/openapi_contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ python -m pip install -e ".[dev]"
python -m pip install -r examples/openapi_contract/requirements.txt
~~~

The example pins drf-spectacular 0.30.0. Its upstream project recommends
pinning the generator and reviewing schema diffs when upgrading.
The consumer example pins Django 5.2.19 (the current 5.2 LTS patch),
Django REST framework 3.18.3, and drf-spectacular 0.30.0. Upgrade these
versions deliberately and review regenerated schemas before changing the pins.

## Verify

Expand Down
4 changes: 2 additions & 2 deletions examples/openapi_contract/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Django>=5.2,<5.3
djangorestframework>=3.18,<3.19
Django==5.2.19
djangorestframework==3.18.3
drf-spectacular==0.30.0
Loading