From 8065c1717f2028c020cf57f40682986ab2a1404f Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Tue, 30 Dec 2025 20:57:21 +0100 Subject: [PATCH] Add support for flattening --- README.md | 3 +++ breaking/action.yml | 5 +++++ breaking/entrypoint.sh | 8 ++++++-- changelog/action.yml | 5 +++++ changelog/entrypoint.sh | 16 ++++++++++------ diff/action.yml | 5 +++++ diff/entrypoint.sh | 8 ++++++-- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c9d40a4..919dfb9 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ This action supports additional arguments. Most are converted to parameters for | --exclude-elements | exclude-elements | '' | | --filter-extension | filter-extension | '' | | --composed | composed | false | +| --flatten-allof | flatten-allof | false | | N/A | output-to-file | '' | ### Check for breaking API changes, and fail if any are found @@ -50,6 +51,7 @@ Additional arguments: | --exclude-elements | exclude-elements | '' | | --filter-extension | filter-extension | '' | | --composed | composed | false | +| --flatten-allof | flatten-allof | false | | N/A | output-to-file | '' | This action delivers a summary of breaking changes, accessible as a GitHub step output named `breaking`. @@ -72,6 +74,7 @@ Additional arguments: | --exclude-elements | exclude-elements | '' | | --filter-extension | filter-extension | '' | | --composed | composed | false | +| --flatten-allof | flatten-allof | false | | --prefix-base | prefix-base | '' | | --prefix-revision | prefix-revision | '' | | --case-insensitive-headers | case-insensitive-headers | false | diff --git a/breaking/action.yml b/breaking/action.yml index 9cdc217..7db6239 100644 --- a/breaking/action.yml +++ b/breaking/action.yml @@ -36,6 +36,10 @@ inputs: description: 'Run in composed mode' required: false default: 'false' + flatten-allof: + description: 'Merge allOf subschemas into a single schema before diff' + required: false + default: 'false' output-to-file: description: 'Output to a file at the given path' required: false @@ -57,4 +61,5 @@ runs: - ${{ inputs.exclude-elements }} - ${{ inputs.filter-extension }} - ${{ inputs.composed }} + - ${{ inputs.flatten-allof }} - ${{ inputs.output-to-file }} diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index e8af227..a75823e 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -11,7 +11,8 @@ readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly filter_extension="$9" readonly composed="${10}" -readonly output_to_file="${11}" +readonly flatten_allof="${11}" +readonly output_to_file="${12}" write_output () { _write_output_output="$1" @@ -33,7 +34,7 @@ write_output () { echo "$_write_output_output" >>"$GITHUB_OUTPUT" } -echo "running oasdiff breaking... base: $base, revision: $revision, fail_on: $fail_on, include_checks: $include_checks, include_path_params: $include_path_params, deprecation_days_beta: $deprecation_days_beta, deprecation_days_stable: $deprecation_days_stable, exclude_elements: $exclude_elements, filter_extension: $filter_extension, composed: $composed, output_to_file: $output_to_file" +echo "running oasdiff breaking... base: $base, revision: $revision, fail_on: $fail_on, include_checks: $include_checks, include_path_params: $include_path_params, deprecation_days_beta: $deprecation_days_beta, deprecation_days_stable: $deprecation_days_stable, exclude_elements: $exclude_elements, filter_extension: $filter_extension, composed: $composed, flatten_allof: $flatten_allof, output_to_file: $output_to_file" # Build flags to pass in command flags="" @@ -58,6 +59,9 @@ fi if [ "$composed" = "true" ]; then flags="$flags -c" fi +if [ "$flatten_allof" = "true" ]; then + flags="$flags --flatten-allof" +fi echo "flags: $flags" # Check for breaking changes diff --git a/changelog/action.yml b/changelog/action.yml index a404e48..a771fe0 100644 --- a/changelog/action.yml +++ b/changelog/action.yml @@ -23,6 +23,10 @@ inputs: description: 'Run in composed mode' required: false default: 'false' + flatten-allof: + description: 'Merge allOf subschemas into a single schema before diff' + required: false + default: 'false' output-to-file: description: 'Output to a file at the given path' required: false @@ -56,6 +60,7 @@ runs: - ${{ inputs.exclude-elements }} - ${{ inputs.filter-extension }} - ${{ inputs.composed }} + - ${{ inputs.flatten-allof }} - ${{ inputs.output-to-file }} - ${{ inputs.prefix-base }} - ${{ inputs.prefix-revision }} diff --git a/changelog/entrypoint.sh b/changelog/entrypoint.sh index 9c29db6..722ed48 100755 --- a/changelog/entrypoint.sh +++ b/changelog/entrypoint.sh @@ -26,13 +26,14 @@ readonly include_path_params="$3" readonly exclude_elements="$4" readonly filter_extension="$5" readonly composed="$6" -readonly output_to_file="$7" -readonly prefix_base="$8" -readonly prefix_revision="$9" -readonly case_insensitive_headers="${10}" -readonly format="${11}" +readonly flatten_allof="$7" +readonly output_to_file="$8" +readonly prefix_base="$9" +readonly prefix_revision="${10}" +readonly case_insensitive_headers="${11}" +readonly format="${12}" -echo "running oasdiff changelog base: $base, revision: $revision, include_path_params: $include_path_params, exclude_elements: $exclude_elements, filter_extension: $filter_extension, composed: $composed, output_to_file: $output_to_file, prefix_base: $prefix_base, prefix_revision: $prefix_revision, case_insensitive_headers: $case_insensitive_headers, format: $format" +echo "running oasdiff changelog base: $base, revision: $revision, include_path_params: $include_path_params, exclude_elements: $exclude_elements, filter_extension: $filter_extension, composed: $composed, flatten_allof: $flatten_allof, output_to_file: $output_to_file, prefix_base: $prefix_base, prefix_revision: $prefix_revision, case_insensitive_headers: $case_insensitive_headers, format: $format" # Build flags to pass in command flags="" @@ -48,6 +49,9 @@ fi if [ "$composed" = "true" ]; then flags="$flags -c" fi +if [ "$flatten_allof" = "true" ]; then + flags="$flags --flatten-allof" +fi if [ -n "$prefix_base" ]; then flags="$flags --prefix-base $prefix_base" fi diff --git a/diff/action.yml b/diff/action.yml index 1aa1904..847b152 100644 --- a/diff/action.yml +++ b/diff/action.yml @@ -31,6 +31,10 @@ inputs: description: 'Run in composed mode' required: false default: 'false' + flatten-allof: + description: 'Merge allOf subschemas into a single schema before diff' + required: false + default: 'false' output-to-file: description: 'Output to a file at the given path' required: false @@ -50,4 +54,5 @@ runs: - ${{ inputs.exclude-elements }} - ${{ inputs.filter-extension }} - ${{ inputs.composed }} + - ${{ inputs.flatten-allof }} - ${{ inputs.output-to-file }} diff --git a/diff/entrypoint.sh b/diff/entrypoint.sh index dab4d0d..c2bfca7 100755 --- a/diff/entrypoint.sh +++ b/diff/entrypoint.sh @@ -28,9 +28,10 @@ readonly include_path_params="$5" readonly exclude_elements="$6" readonly filter_extension="$7" readonly composed="$8" -readonly output_to_file="$9" +readonly flatten_allof="$9" +readonly output_to_file="${10}" -echo "running oasdiff diff base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff, include_path_params: $include_path_params, exclude_elements: $exclude_elements, filter_extension: $filter_extension, composed: $composed, output_to_file: $output_to_file" +echo "running oasdiff diff base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff, include_path_params: $include_path_params, exclude_elements: $exclude_elements, filter_extension: $filter_extension, composed: $composed, flatten_allof: $flatten_allof, output_to_file: $output_to_file" # Build flags to pass in command flags="" @@ -52,6 +53,9 @@ fi if [ "$composed" = "true" ]; then flags="$flags -c" fi +if [ "$flatten_allof" = "true" ]; then + flags="$flags --flatten-allof" +fi echo "flags: $flags" # *** github action step output ***