Repository navigation
fix: don't add an empty property for a required @JsonUnwrapped member (OpenAPI 3.1) - #5361
Merged
daniel-kmiecik merged 3 commits intoOct 27, 2026
Conversation
… (OpenAPI 3.1) With OpenAPI 3.1, a @JsonUnwrapped property annotated with @Schema(requiredMode = REQUIRED) left an empty property in the model, also listed in "required", next to the unwrapped properties. With records, Jackson 3 additionally exposes the component as a synthetic "@JsonUnwrapped/<n>" creator property, which got the same treatment: properties: value, inner: {}, number, '@JsonUnwrapped/0': {} required: ['@JsonUnwrapped/0', inner, number, value] Once the jsonUnwrappedHandler has merged the unwrapped properties, the member is no longer resolved from its remaining annotations. OpenAPI 3.0 output is unchanged. See swagger-api#4991. Signed-off-by: Badr NASS LAHSEN <badr.nasslahsen@gmail.com>
3 tasks
daniel-kmiecik
approved these changes
Oct 27, 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.
Pull Request
Description
Found while porting springdoc-openapi to Swagger Core 3.0 (feedback in #4991).
With OpenAPI 3.1, a
@JsonUnwrappedmember also annotated with@Schema(requiredMode = REQUIRED)leaves an emptyproperty in the model, listed in
requiredtoo, next to the unwrapped properties. With records, Jackson 3additionally exposes the component as a synthetic
@JsonUnwrapped/<n>creator property, which gets the sametreatment:
Cause: the
jsonUnwrappedHandlermerges the inner properties and returnsnull. Then, with OpenAPI 3.1,getSchemaFromAnnotationrebuilds a schema from the remaining@Schemaannotation, and that schema is added as aproperty. The fix stops processing the member once the handler has unwrapped it: 7 lines in
ModelResolver.The OpenAPI 3.0 output is unchanged; it was already correct.
Fixes:
Type of Change
Checklist
JacksonJsonUnwrappedTest, covering a record and a class with OpenAPI 3.1