openapi-diff icon indicating copy to clipboard operation
openapi-diff copied to clipboard

Add official Github action for openapi-diff

Open elsewhat opened this issue 5 years ago • 4 comments

Openapi-diff is well suited to be integrate into Github actions in order to:

  • Highlight breaking in a pull request
  • Document changes in OpenAPI
  • etc.

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

  • https://github.com/marketplace/actions/openapi-review
  • https://github.com/marketplace/actions/openapi-diff

elsewhat avatar Oct 16 '20 11:10 elsewhat

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

nickfloyd avatar May 07 '21 16:05 nickfloyd

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

cbui avatar Jun 28 '23 12:06 cbui

Heads up the schemas are backwards:

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

nickfloyd avatar Jun 28 '23 16:06 nickfloyd

It would still be nice to have an official action!

miguelappleton avatar Mar 25 '24 17:03 miguelappleton