Harden allOf merging and default-response handling#85
Merged
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.
Summary
A grab-bag of schema-composition fixes uncovered while generating against real-world specs.
The unifying theme: keep the generated types aligned with what strict response validators actually check, including in malformed but real corners.
Flattens allOf wrappers before the type-presence checks in
mergeOpenapiSchemas. A nested allOf wrapper without its owntypewas being dropped by thelen(t1) == 0short-circuit, losing its properties.Lets a parent
type: objectoverride a primitive allOf result (type: object, allOf: [SomeEnum]) - the outer object wins so the validator sees an object.Merges colliding properties via
mergePropertyProxiesso enum / pattern / format constraints survive instead of being clobbered by the second declaration.Merges array
itemsfrom both branches (previously dropped, with downstream inference falling back tostring).Treats
readOnly/writeOnlyas annotations (OR-merge), not constraints that have to match per branch.isDiscriminatedUnionWithChild: checksanyOftoo, and returnfalsewhen a discriminator+mapping describes an inheritance base rather than a union (nooneOf/anyOf).When no explicit success is documented but
defaulthas content, treatsdefaultas 200 success. Fabricating a 204struct{}made return content that didn't satisfy the real schema.Preserves the declared
ContentTypeon empty success bodies (e.g.text/html: {}) - strict validators rely on it.Refactored shared logic into
buildDefaultResponseDefinition.