OpenAPITools / openapi-diff

Utility for comparing two OpenAPI specifications.
Apache License 2.0
808 stars 154 forks source link

Add official Github action for openapi-diff #186

Open elsewhat opened 3 years ago

elsewhat commented 3 years ago

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

nickfloyd commented 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
cbui commented 1 year ago

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
nickfloyd commented 1 year ago

Heads up the schemas are backwards:

Good catch... I have updated the original response. Thanks! ❤️

miguelappleton commented 6 months ago

It would still be nice to have an official action!