Open elsewhat opened 3 years ago
I love this idea @elsewhat. Here's a workflow that I threw together that triggers on PR creation and updates to the given PR - it might or might not be helpful!
on: [pull_request]
name: validate-schema-changes
jobs:
detect-breaking-changes:
runs-on: ubuntu-latest
steps:
- name: Check out HEAD rev
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
path: head
- name: Check out BASE rev
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
path: base
- name: Run OpenAPI Diff (from HEAD rev)
uses: docker://openapitools/openapi-diff:latest
with:
args: --fail-on-incompatible base/schemas/YOUR-SCHEMA.yaml head/schemas/YOUR-SCHEMA.yaml
Heads up the schemas are backwards:
args: --fail-on-incompatible head/schemas/YOUR-SCHEMA.yaml base/schemas/YOUR-SCHEMA.yaml
should be
args: --fail-on-incompatible base/schemas/YOUR-SCHEMA.yaml head/schemas/YOUR-SCHEMA.yaml
Heads up the schemas are backwards:
Good catch... I have updated the original response. Thanks! ❤️
It would still be nice to have an official action!
Openapi-diff is well suited to be integrate into Github actions in order to:
For example, today we have an internal github repo which on every commit triggers generating Redoc OpenAPI documentation and publishes it to Github pages for the repository. In this documentation we'd like to include a openapi-diff markdown report of the changes.
Or, when ever we do a pull request we want to review the changes made. Openapi-diff will allow us to identify automatically breaking changes.
There are a couple of unofficial limited Github actions based on other openapi diff tool