Repository navigation
Treat merged schemas with no valid enum values as unsatisfiable - #1128
Open
shaurya703 wants to merge 1 commit into
Open
shaurya703 wants to merge 1 commit into
shaurya703 wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Merging an
enumwith a type that none of its values has doesn't report the result as unsatisfiable. It leaves a schema with an empty list of enum values, and that either fails generation or adds an uninhabited variant.This schema:
{ "enum": ["north", "south"], "anyOf": [{ "type": "string" }, { "type": "null" }] }fails the whole run:
allOf: [{ "enum": ["a", "b"] }, { "type": "integer" }]fails the same way.allOf: [{ "enum": [1, 2] }, { "oneOf": [{ "type": "string" }, { "type": "integer" }] }]generates, but with a bogusVariant0wrapping an empty enum.merge_schema_objectfilters out enum values that don't validate against the merged schema, but it didn't check whether any were left. It now returnsErr(())in that case, asmerge_so_enum_valuesalready does when two enums don't intersect. Subschemas that admit none of the values are then dropped, so the schema above becomes a plainNorth/Southenum. When nothing is left, the type is the usual empty enum.I added a unit test in
merge.rsand two cases inmerged-schemas.json. Without the change,test_schemasfails with the error above. No other generated output changed.