Repository navigation
fix: allOf that narrows an enum, and one-option oneOf with inline models - #1499
Draft
pomykalakyle wants to merge 2 commits into
Draft
pomykalakyle wants to merge 2 commits into
pomykalakyle wants to merge 2 commits into
Conversation
A oneOf with a single $ref queues the referenced model for processing a second time, so its inline models are built twice and the second build fails as a duplicate class name. Reuse the existing class when the same schema is built again under the same name.
An allOf whose parts are all values, such as a reference to an enum plus `enum: [ONE_VALUE]`, was built as a model and failed with "Cannot take allOf a non-object". Merge its parts with merge_properties, as allOf already does for model properties.
This was referenced Oct 23, 2026
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.
Fixes #1498 and #1375.
Two schema shapes that currently fail to generate:
allOfwhere every part is a value, like a$refto an enum plusenum: [AWS]. It used to be built as a model and failed with "Cannot take allOf a non-object". Now its parts are merged withmerge_properties.oneOfpointing at an object with inline models. The single-$refshortcut queues that object twice, so its inline models were built twice and the second one failed as a duplicate. Now, when the exact same schema is built again under the same name, the existing class is reused.To be upfront: an AI agent (Claude) wrote this while I was debugging our own spec. I've checked that it fixes our spec (about 220 endpoints) and the small examples in the linked issues. The existing tests give the same results with and without the change on my machine. There are no new tests yet, so this can't merge as is. It's a draft to show the approach.