Repository navigation
fix: merge object properties as a union in allOf intersection - #55
Open
villaverde82 wants to merge 1 commit into
Open
villaverde82 wants to merge 1 commit into
villaverde82 wants to merge 1 commit into
Conversation
villaverde82
force-pushed
the
fix/allof-object-properties
branch
from
September 30, 2026 11:09
6b28627 to
e40952a
Compare
This branch has not been deployed
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.
restcheck_schema:intersection/2, when merging two object schemas (e.g. in an allOf), keeps only the properties present in both schemas, but takes the union of their required lists. Any property declared in just one of them is dropped while still being required, so restcheck_triq:object/2 can't find it in properties and crashes with badkey.
Example:
Pet:
type: object
properties:
name: {type: string}
age: {type: integer}
required: [name, age]
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
age: {type: integer, minimum: 0}
bark: {type: boolean}
required: [bark]
Current result: properties = {age: {type: integer, minimum: 0}}, required = [name, age, bark] -> {badkey, <<"name">>}
Since allOf requires an instance to satisfy both schemas, the fix takes the union of the properties. Properties present in only one schema (name, bark) are kept as they are. Properties present in both (age) still have their schemas intersected, so they must satisfy both (maps:merge_with with intersection/1).
Expected result: properties = {name: {type: string}, age: {type: integer, minimum: 0}, bark: {type: boolean}}, required = [name, age, bark]