-
Notifications
You must be signed in to change notification settings - Fork 0
[7/7] add multi-element oneOf/anyOf/allOf tests #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sunshowers
merged 4 commits into
main
from
sunshowers/spr/77-add-multi-element-oneofanyofallof-tests
Feb 2, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,7 +435,7 @@ impl Compare { | |
| if old_boolean != new_boolean { | ||
| self.schema_push_change( | ||
| dry_run, | ||
| "integer schema changed", | ||
| "boolean schema changed", | ||
| &old_schema_type, | ||
| &new_schema_type, | ||
| comparison, | ||
|
|
@@ -733,44 +733,29 @@ impl Compare { | |
| Ok(ret) | ||
| } | ||
|
|
||
| // NOTE: Single-element allOf schemas are flattened by `try_compare_flattened` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was this something we just missed when introducing try_compare_flattened?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. |
||
| // before reaching this function. Multi-element allOf would require semantic | ||
| // merging for proper comparison, so we just do an equality check. | ||
| fn compare_schema_type_all_of( | ||
| &mut self, | ||
| comparison: SchemaComparison, | ||
| dry_run: bool, | ||
| old_all_of: Contextual<'_, &Vec<ReferenceOr<Schema>>>, | ||
| new_all_of: Contextual<'_, &Vec<ReferenceOr<Schema>>>, | ||
| ) -> anyhow::Result<bool> { | ||
| let old_schemas = old_all_of.as_ref(); | ||
| let new_schemas = new_all_of.as_ref(); | ||
|
|
||
| if old_schemas.len() != new_schemas.len() { | ||
| return self.schema_push_change( | ||
| dry_run, | ||
| "allOf schema count changed", | ||
| &old_all_of, | ||
| &new_all_of, | ||
| comparison, | ||
| ChangeClass::Unhandled, | ||
| ChangeDetails::UnknownDifference, | ||
| ); | ||
| } | ||
|
|
||
| if old_schemas.len() != 1 { | ||
| return self.schema_push_change( | ||
| if old_all_of.as_ref() != new_all_of.as_ref() { | ||
| self.schema_push_change( | ||
| dry_run, | ||
| "allOf with multiple schemas is unhandled", | ||
| "unhandled, 'allOf' schema", | ||
| &old_all_of, | ||
| &new_all_of, | ||
| comparison, | ||
| ChangeClass::Unhandled, | ||
| ChangeDetails::UnknownDifference, | ||
| ); | ||
| ) | ||
| } else { | ||
| Ok(true) | ||
| } | ||
|
|
||
| let old_single_schema = old_all_of.append_deref(old_all_of.first().unwrap(), "0"); | ||
| let new_single_schema = new_all_of.append_deref(new_all_of.first().unwrap(), "0"); | ||
|
|
||
| self.compare_schema_ref_helper(dry_run, comparison, old_single_schema, new_single_schema) | ||
| } | ||
|
|
||
| #[allow(clippy::too_many_arguments)] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- add-operation.json | ||
| +++ patched | ||
| @@ -202,6 +202,16 @@ | ||
| @@ -238,6 +238,16 @@ | ||
| "summary": "Get arrays" | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- body-description-change.json | ||
| +++ patched | ||
| @@ -249,6 +249,7 @@ | ||
| @@ -285,6 +285,7 @@ | ||
| } | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- body-extension-change.json | ||
| +++ patched | ||
| @@ -249,7 +249,8 @@ | ||
| @@ -285,7 +285,8 @@ | ||
| } | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- body-optional-to-required.json | ||
| +++ patched | ||
| @@ -268,7 +268,7 @@ | ||
| @@ -304,7 +304,7 @@ | ||
| } | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- body-required-to-optional.json | ||
| +++ patched | ||
| @@ -249,7 +249,7 @@ | ||
| @@ -285,7 +285,7 @@ | ||
| } | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- boolean-enum-change.json | ||
| +++ patched | ||
| @@ -159,6 +159,9 @@ | ||
| "type": "integer" | ||
| }, | ||
| "enabled": { | ||
| + "enum": [ | ||
| + true | ||
| + ], | ||
| "type": "boolean" | ||
| }, | ||
| "ratio": { | ||
|
|
||
|
|
||
| Result for patch: | ||
| [ | ||
| Change { | ||
| message: "boolean schema changed", | ||
| old_path: [ | ||
| "#/components/schemas/TypedProperties/properties/enabled", | ||
| "#/paths/~1typed/get/responses/200/content/application~1json/schema/$ref", | ||
| ], | ||
| new_path: [ | ||
| "#/components/schemas/TypedProperties/properties/enabled", | ||
| "#/paths/~1typed/get/responses/200/content/application~1json/schema/$ref", | ||
| ], | ||
| comparison: Output, | ||
| class: Unhandled, | ||
| details: UnknownDifference, | ||
| }, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- change-default-response.json | ||
| +++ patched | ||
| @@ -397,7 +397,7 @@ | ||
| @@ -451,7 +451,7 @@ | ||
| } | ||
| } | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/cases/simple/output/change-operation-parameter-requirement.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- multi-allof-variant-change.json | ||
| +++ patched | ||
| @@ -95,7 +95,7 @@ | ||
| { | ||
| "properties": { | ||
| "id": { | ||
| - "type": "string" | ||
| + "type": "integer" | ||
| } | ||
| }, | ||
| "type": "object" | ||
|
|
||
|
|
||
| Result for patch: | ||
| [ | ||
| Change { | ||
| message: "unhandled, 'allOf' schema", | ||
| old_path: [ | ||
| "#/components/schemas/MultiAllOf/allOf", | ||
| "#/paths/~1allof/get/responses/200/content/application~1json/schema/$ref", | ||
| ], | ||
| new_path: [ | ||
| "#/components/schemas/MultiAllOf/allOf", | ||
| "#/paths/~1allof/get/responses/200/content/application~1json/schema/$ref", | ||
| ], | ||
| comparison: Output, | ||
| class: Unhandled, | ||
| details: UnknownDifference, | ||
| }, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- multi-anyof-variant-change.json | ||
| +++ patched | ||
| @@ -4,7 +4,7 @@ | ||
| "AnyOfExample": { | ||
| "anyOf": [ | ||
| { | ||
| - "type": "string" | ||
| + "type": "integer" | ||
| }, | ||
| { | ||
| "type": "number" | ||
|
|
||
|
|
||
| Result for patch: | ||
| [ | ||
| Change { | ||
| message: "unhandled, 'anyOf' schema", | ||
| old_path: [ | ||
| "#/components/schemas/AnyOfExample", | ||
| "#/paths/~1anyof/get/responses/200/content/application~1json/schema/$ref", | ||
| ], | ||
| new_path: [ | ||
| "#/components/schemas/AnyOfExample", | ||
| "#/paths/~1anyof/get/responses/200/content/application~1json/schema/$ref", | ||
| ], | ||
| comparison: Output, | ||
| class: Unhandled, | ||
| details: UnknownDifference, | ||
| }, | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
untested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test for this.