The world's sexiest OpenAPI breaking changes detector. Discover what changed between two OpenAPI specs, or a single spec over time. Supports OpenAPI 3.1, 3.0 and Swagger
This behavior is consistent with how html-report behaves, and is desireable for CI environments such as GitHub Actions where the spinner output won't look near as pretty.
I'm attempting to embed openapi-changes into a GitHub workflow, so that I can have it error a check on a PR if a PR were to introduce any breaking changes. I'm using the summary markdown output feature, in an action a little like this:
name: 'Check for Breaking OAS Changes'
description: 'Compares the version of a spec against what is currently in main.'
inputs:
spec-to-scan: # local path to a spec to check for changes
description: 'Repository-local path to a spec to check for breaking changes.'
required: true
runs:
using: 'composite'
steps:
# Check out the repository
- uses: actions/checkout@v3
- name: Install pb33f/openapi-changes
uses: ./.github/actions/install-pb33f-openapi-breaking-changes
- name: Get all changed oas files
id: changed-oas-files
uses: tj-actions/changed-files@v44
with:
# Avoid using single or double quotes for multiline patterns
files: |
services/**.{yml,yaml}
name: 'Check for Breaking OAS Changes'
description: 'Compares the version of a spec against what is currently in main.'
inputs:
spec-to-scan: # local path to a spec to check for changes
description: 'Repository-local path to a spec to check for breaking changes.'
required: true
runs:
using: 'composite'
steps:
# Check out the repository
- uses: actions/checkout@v3
- name: Install pb33f/openapi-changes
uses: ./.github/actions/install-pb33f-openapi-breaking-changes
- name: Get all changed oas files
id: changed-oas-files
uses: tj-actions/changed-files@v44
with:
# Avoid using single or double quotes for multiline patterns
files: |
services/**.{yml,yaml}
- name: Diff all changed oas files
shell: bash
if: steps.changed-oas-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-oas-files.outputs.all_changed_files }}
run: |
set +e
MARKDOWN_OUTPUT="# Summary of changes"
SHOULD_FAIL=false
for file in ${ALL_CHANGED_FILES}; do
MARKDOWN_OUTPUT+="\n\n"
MARKDOWN_OUTPUT+="## $file"
MARKDOWN_OUTPUT+=$(openapi-changes summary --no-logo --no-color --markdown ./ "$file")
CHANGES_EXIT_CODE=$?
if [ $CHANGES_EXIT_CODE -ne 0 ]; then SHOULD_FAIL=true; fi;
done
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "breaking_changes_markdown<<$EOF" >> $GITHUB_OUTPUT
echo -e "$MARKDOWN_OUTPUT" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
echo "breaking_changes_detected=$SHOULD_FAIL" >> $GITHUB_OUTPUT
set -e
I noticed that the output from summary, even with --no-logo --no-color --markdown would include many lines from the spinner, and ultimately caused a few rendering issues within the markdown as well.
Before:
starting work.
Extracting history for 'services/my-service.yml' in repo './
extacted commit '8ce8c30'
extacted commit '639401d'
extacted commit 'a7852bf'
extacted commit '06c5e75'
extacted commit 'cd766d0'
SPEC: 5 commits extracted
Extracting 10 bytes extracted from commit '8ce8c30'
Extracting 10 bytes extracted from commit '639401d'
Extracting 9 bytes extracted from commit 'a7852bf'
Extracting 9 bytes extracted from commit '06c5e75'
Extracting 9 bytes extracted from commit 'cd766d0'
Building original model for commit 06c5e7
Building original model for commit a7852b
Building original model for commit 639401
Building original model for commit 8ce8c3
This behavior is consistent with how html-report behaves, and is desireable for CI environments such as GitHub Actions where the spinner output won't look near as pretty.
I'm attempting to embed openapi-changes into a GitHub workflow, so that I can have it error a check on a PR if a PR were to introduce any breaking changes. I'm using the summary markdown output feature, in an action a little like this:
I noticed that the output from summary, even with
--no-logo --no-color --markdown
would include many lines from the spinner, and ultimately caused a few rendering issues within the markdown as well.Before:
starting work.
Extracting history for 'services/my-service.yml' in repo './
extacted commit '8ce8c30'
extacted commit '639401d'
extacted commit 'a7852bf'
extacted commit '06c5e75'
extacted commit 'cd766d0'
SPEC: 5 commits extracted Extracting 10 bytes extracted from commit '8ce8c30' Extracting 10 bytes extracted from commit '639401d' Extracting 9 bytes extracted from commit 'a7852bf' Extracting 9 bytes extracted from commit '06c5e75' Extracting 9 bytes extracted from commit 'cd766d0' Building original model for commit 06c5e7 Building original model for commit a7852b Building original model for commit 639401 Building original model for commit 8ce8c3
Date: 07/25/24 | Commit: chore: remove test param fro my service getHealth
Date: 07/23/24 | Commit: chore: add tags and shorten server descriptions
Date: 07/23/24 | Commit: end to end test
Date: 07/22/24 | Commit: chore: add linting via spectral
SPEC: extracted 5 commits from history
DONE: completed ERROR: breaking changes discovered
After:
Date: 07/25/24 | Commit: chore: remove test param fro app hub getHealth
Date: 07/23/24 | Commit: chore: add tags and shorten server descriptions
Date: 07/23/24 | Commit: end to end test
Date: 07/22/24 | Commit: chore: add linting via spectral
ERROR: breaking changes discovered Error: breaking changes discovered