diff --git a/README.md b/README.md index dcbd9cd..fdb5385 100644 --- a/README.md +++ b/README.md @@ -10,50 +10,51 @@ Depends on your use case: Copy and paste the following snippet into your build .yml file: ``` - name: Running OpenAPI Spec diff action - id: test_ete uses: oasdiff/oasdiff-action/diff@main with: base: 'specs/base.yaml' revision: 'specs/revision.yaml' - format: 'text' - fail-on-diff: false ``` +This action supports additional arguments that are converted to parameters for the `oasdiff` CLI. + +| CLI | Action input | Default | +|--------|--------|--------| +| --fail-on-diff | fail-on-diff | false | +| --format | format | yaml | +| --include-path-params | include-path-params | false | + ### Check for breaking API changes, and fail if any are found Copy and paste the following snippet into your build .yml file: ``` - name: Running OpenAPI Spec diff action - id: test_ete uses: oasdiff/oasdiff-action/breaking@main with: base: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test1.yaml revision: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test3.yaml - fail-on-diff: true ``` -#### Include optional breaking change checks -In order to ensure even stricter breaking policies, oasdiff provides with a few optional checks. -Complete list can be found [here](https://github.com/Tufin/oasdiff/blob/main/BREAKING-CHANGES.md#optional-breaking-changes-checks). +Additional arguments: + +| CLI | Action input | Default | +|-----------------------|--------|--------| +| --fail-on WARN | fail-on-diff | true | +| --include-checks | include-checks | csv | +| --include-path-params | include-path-params | false | -These checks can be added by filling the `include-checks` argument in the action like the following: -``` -- name: Running OpenAPI Spec diff action - id: test_ete - uses: oasdiff/oasdiff-action/breaking@main - with: - base: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test1.yaml - revision: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test3.yaml - fail-on-diff: true - include-checks: "response-non-success-status-removed,api-operation-id-removed" -``` ### Generate a changelog Copy and paste the following snippet into your build .yml file: ``` - name: Running OpenAPI Spec diff action - id: test_ete uses: oasdiff/oasdiff-action/changelog@main with: base: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test1.yaml revision: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test3.yaml ``` + +Additional arguments: + +| CLI | Action input | Default | +|--------|--------|--------| +| --include-path-params | include-path-params | false | \ No newline at end of file diff --git a/breaking/action.yml b/breaking/action.yml index 959428f..94eaf74 100644 --- a/breaking/action.yml +++ b/breaking/action.yml @@ -14,6 +14,10 @@ inputs: include-checks: description: 'Include any of the defined optional breaking changes checks' required: false + include-path-params: + description: 'Include path parameter names in endpoint matching' + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' @@ -22,3 +26,4 @@ runs: - ${{ inputs.revision }} - ${{ inputs.fail-on-diff }} - ${{ inputs.include-checks }} + - ${{ inputs.include-path-params }} diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 946c346..8f44441 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -4,14 +4,19 @@ set -e readonly base="$1" readonly revision="$2" readonly fail_on_diff="$3" -readonly include_checks="$4" -echo "running oasdiff breaking base: $base, revision: $revision, fail_on_diff: $fail_on_diff, include_checks: $include_checks" +readonly include_checks="$4" +readonly include_path_params="$5" + +echo "running oasdiff breaking base: $base, revision: $revision, fail_on_diff: $fail_on_diff, include_checks: $include_checks, include_path_params: $include_path_params" # Build flags to pass in command flags="" if [ "$fail_on_diff" = "true" ]; then flags="${flags} --fail-on WARN" fi +if [ "$include_path_params" = "true" ]; then + flags="${flags} --include-path-params" +fi if [ -n "$include_checks" ]; then flags="${flags} --include-checks $include_checks" fi diff --git a/changelog/action.yml b/changelog/action.yml index 1fd7801..6f66fc5 100644 --- a/changelog/action.yml +++ b/changelog/action.yml @@ -7,9 +7,14 @@ inputs: revision: description: 'Path of revised OpenAPI spec in YAML or JSON format' required: true + include-path-params: + description: 'Include path parameter names in endpoint matching' + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' args: - ${{ inputs.base }} - ${{ inputs.revision }} + - ${{ inputs.include-path-params }} diff --git a/changelog/entrypoint.sh b/changelog/entrypoint.sh index 386c68a..1c922a4 100755 --- a/changelog/entrypoint.sh +++ b/changelog/entrypoint.sh @@ -3,9 +3,21 @@ set -e readonly base="$1" readonly revision="$2" +readonly include_path_params="$3" -echo "running oasdiff changelog base: $base, revision: $revision" +echo "running oasdiff changelog base: $base, revision: $revision, include_path_params: $include_path_params" + +# Build flags to pass in command +flags="" +if [ "$include_path_params" = "true" ]; then + flags="${flags} --include-path-params" +fi +echo "flags: $flags" set -o pipefail -oasdiff changelog "$base" "$revision" +if [ -n "$flags" ]; then + oasdiff changelog "$base" "$revision" $flags +else + oasdiff changelog "$base" "$revision" +fi diff --git a/diff/action.yml b/diff/action.yml index af7e65c..95a2f2f 100644 --- a/diff/action.yml +++ b/diff/action.yml @@ -15,6 +15,10 @@ inputs: description: 'Fail with exit code 1 if a difference is found' required: false default: 'false' + include-path-params: + description: 'Include path parameter names in endpoint matching' + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' @@ -23,3 +27,4 @@ runs: - ${{ inputs.revision }} - ${{ inputs.format }} - ${{ inputs.fail-on-diff }} + - ${{ inputs.include-path-params }} diff --git a/diff/entrypoint.sh b/diff/entrypoint.sh index 657fc02..53d2c5e 100755 --- a/diff/entrypoint.sh +++ b/diff/entrypoint.sh @@ -5,13 +5,27 @@ readonly base="$1" readonly revision="$2" readonly format="$3" readonly fail_on_diff="$4" +readonly include_path_params="$5" -echo "running oasdiff diff base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff" +echo "running oasdiff diff base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff, include_path_params: $include_path_params" + +# Build flags to pass in command +flags="" +if [ "$format" != "yaml" ]; then + flags="${flags} --format ${format}" +fi +if [ "$fail_on_diff" = "true" ]; then + flags="${flags} --fail-on-diff" +fi +if [ "$include_path_params" = "true" ]; then + flags="${flags} --include-path-params" +fi +echo "flags: $flags" set -o pipefail -if [[ $fail_on_diff == "true" ]]; then - oasdiff diff "$base" "$revision" --fail-on-diff --format "$format" +if [ -n "$flags" ]; then + oasdiff diff "$base" "$revision" $flags else - oasdiff diff "$base" "$revision" --format "$format" + oasdiff diff "$base" "$revision" fi