Skip to content
Open
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
21 changes: 21 additions & 0 deletions openapi/diff-optic/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Compare OpenAPI specs
inputs:
openapi-uri-original:
description: URI (file or URL) to the original OpenAPI spec ("before")
required: true
openapi-uri-updated:
description: URI (file or URL) to the updated OpenAPI spec ("after")
required: true
optic-yaml-path:
description: (Optional) Path to an Optic YAML file, for customizing the Optic diff ruleset
required: false

runs:
using: composite
steps:
- shell: bash
run: ${{ github.action_path }}/run.sh
env:
OPENAPI_URI_ORIGINAL: ${{ inputs.openapi-uri-original }}
OPENAPI_URI_UPDATED: ${{ inputs.openapi-uri-updated }}
OPTIC_YAML_PATH: ${{ inputs.optic-yaml-path }}
42 changes: 42 additions & 0 deletions openapi/diff-optic/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
set -xe

echo "🔍 Checking for API breaking changes..."

npm install -g @useoptic/optic

OPTIC_ARGS=(diff "${OPENAPI_URI_ORIGINAL}" "${OPENAPI_URI_UPDATED}")

if [ -n "${OPTIC_YAML_PATH}" ]; then
OPTIC_ARGS+=(--standard "${OPTIC_YAML_PATH}")
fi

if ! optic "${OPTIC_ARGS[@]}" --severity error 2>/dev/null; then
echo "❌ Breaking API changes detected!"
BREAKING_CHANGES=true
else
echo "✅ No breaking API changes"
fi

echo ""
echo "=================================================================="

if [ "$BREAKING_CHANGES" = true ]; then
echo "❌ API BREAKING CHANGES DETECTED!"
echo ""
echo "🚨 This PR contains potentially breaking changes:"
echo " • .NET assembly API changes, or"
echo " • HTTP endpoint route changes, or"
echo " • Removed HTTP endpoints"
echo ""
echo "If these changes are intentional:"
echo "1. 📈 Update version numbers appropriately"
echo "2. 📝 Document breaking changes in your PR description"
echo "3. 🤔 Consider the impact on existing API consumers"
echo "4. 📧 Notify teams that depend on these APIs"
echo ""
exit 1
else
echo "✅ API COMPATIBILITY CHECK PASSED!"
echo "No breaking changes detected in HTTP endpoints."
fi