Repository navigation
Generate a schema that refers to itself from the contract's $defs (0.16.0) - #135
Merged
Merged
Conversation
openapi-contract 0.13 compiles a schema whose member is the schema itself —
a tree whose children are trees — to $defs plus a local {$ref:
'#/$defs/<name>'} for every reference back into the cycle. The generator
unfolds such a def three levels below the root (Gen::recursive) and ends
at a leaf compiled with the def bound to nothing, where a reference back
to it is unproducible: an optional property is left out, an array that may
be empty is left empty, a branch of anyOf/oneOf is skipped, a member of an
allOf is inlined as the def's body. A def whose only way down is a
required member that is the def itself has no finite instance and is
refused, as is a def that is an allOf member of itself; a $ref to anything
but the schema's own $defs is refused by name.
The JSON body encoder follows the same references, so a nested empty
object three levels down is still written as {}. The zoo gains
tree.create; the corpus recorded from it grows by 25 cases.
Requires rasuvaeff/openapi-contract ^0.13.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Release 0.16.0. Wave 2 of the openapi-contract#159 follow-up.
rasuvaeff/openapi-contract0.13 compiles a schema whose member is the schema itself — a tree whosechildrenare trees — to$defsplus a local{$ref: '#/$defs/<name>'}for every reference back into the cycle. The generator now unfolds such a def three levels below the root (Gen::recursive) and ends at a leaf compiled with the def bound to nothing, where a reference back to it is unproducible: an optional property is left out, an array that may be empty is left empty, a branch ofanyOf/oneOfis skipped, a member of anallOfis inlined as the def's body. A def whose only way down is a required member that is the def itself has no finite instance and is refused; so is a def that is anallOfmember of itself; a$refto anything but the schema's own$defsis refused by name.JsonBodyEncoderfollows the same references, so a nested empty object three levels down is still written as{}(the first probe wrote[]).The zoo gains
tree.create(request and response are the tree;idreadOnly at every depth); the recorded corpus in openapi-contract grows by its 25 cases (rasuvaeff/openapi-contract#163, merged). Every generated value is checked against the contract'sSchemaCheckin the tests, and the unfolded depth is pinned.composer build: 990 tests green; rector clean; roave: no BC changebin/package-audit: cleanrasuvaeff/openapi-contract^0.13