Conversation
ModelResolver.resolveWrapping() nested the whole model inside a new wrapper schema that only copied the name and properties, so a model carrying a oneOf (from @Schema(oneOf) or @JsonSubTypes) lost its composition and became a plain object schema with a single property. When the model already has a non-empty oneOf, add the wrapper property directly to the model and return it, preserving the composition. Behavior is unchanged for models without oneOf. Adds WrapperObjectOneOfTest, which fails before the fix (ObjectSchema with no oneOf) and passes after it.
This was referenced Sep 26, 2026
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.
Summary
A schema that already carries a
oneOfnow keeps it when Jackson'sWRAPPER_OBJECTtype info is applied. Previously the composition was silently dropped and the schema became a plain object with a single property.Problem
ModelResolver.resolveWrapping(...)builds a new wrapper schema and nests the model inside it:The wrapper copies only the name and the single property. If
modelhad aoneOf(from@Schema(oneOf = ...),@Schema(subTypes = ...)or@JsonSubTypes), it is lost: the returned schema is anObjectSchema, not aComposedSchema, and theoneOfis gone.Reproduction (
@JsonTypeInfo(include = WRAPPER_OBJECT)+@Schema(oneOf)):ObjectSchema, properties[Pet], nooneOfComposedSchema,oneOf= 2 refs, wrapper property presentChange
When the model already has a non-empty
oneOf, add the wrapper property directly to the model and return it, instead of nesting it in a wrapper schema:The empty-object-schema expression was already used once in this method, so instead of repeating it a second time it is extracted to a small helper:
Behavior is unchanged for models without
oneOf.Tests
Adds
WrapperObjectOneOfTest. It fails before the change (ObjectSchemawith nooneOf) and passes after it.Notes
This is the small stack split out of #5320. It is a standalone bug fix, reproducible on unmodified
3.0.0, and does not depend on@JsonSubTypeswork.