Fix :@Schema(type) emitting wrong type under OpenAPI 3.1 and ALL_OF sibling modes (#5233, #5235) - #5304
Open
ewaostrowska wants to merge 8 commits into
Open
Fix :@Schema(type) emitting wrong type under OpenAPI 3.1 and ALL_OF sibling modes (#5233, #5235) #5304ewaostrowska wants to merge 8 commits into
ewaostrowska wants to merge 8 commits into
Conversation
This was referenced Aug 28, 2026
This reverts commit a23dbf2.
Under OpenAPI 3.1 an explicit @Schema(type = ...) was applied via the legacy scalar setType(), while the 3.1 serializer reads the types set. The set kept its default ("string"), so number/integer/boolean fields were rendered as string. Populate the types set when openapi31 is enabled, mirroring the handling of the plural types() attribute directly below. Fixes #5233
ewaostrowska
force-pushed
the
issue-type
branch
from
August 31, 2026 07:13
344c6ab to
e0e5fb9
Compare
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
In OpenAPI 3.1 mode, properties annotated with
@Schema(type = "number" | "integer" | "boolean")were serialized astype: "string"instead of the declared type. The same bug appeared in OAS 3.0 ALL_OF / ALL_OF_REF sibling resolution modes.Fixes: #5233
Fixes: #5235
What was broken
Issue #5233: OAS 3.1 scalar type lands in
typesas["string"]AnnotationsUtils.getSchemaFromAnnotationcalledschemaObject.setType(schema.type())in OAS 3.1 mode. That set the legacytypefield correctly, but a separate path populatedtypesfrom type inference and produced["string"]. Because the OAS 3.1 serializer readstypes, nottype, the explicit scalar was silently discarded.Issue #5235: ALL_OF sibling mode —
ctxSchema.type().getClass()always returnsString.classIn
ddTypeWhenSiblingsAllowed, the branch for an explicit@Schema(type)calledaType.setType(ctxSchema.type().getClass()).String#getClass()always returnsString.classregardless of the annotation value, so"number","integer", and"boolean"all resolved toStringtype.What changed
AnnotationsUtils.getSchemaFromAnnotation: whenopenapi31=trueand noimplementationis set, now callsschemaObject.setTypes(singleton(schema.type()))instead ofsetType(schema.type()), so the 3.1 serializer reads the correct type from thetypesset. The OAS 3.0 path is unchanged.AnnotationsUtils.ddTypeWhenSiblingsAllowed: replacesctxSchema.type().getClass()withgetSchemaType(ctxSchema, true)(the existing helper that maps annotation type strings to JavaTypeobjects), guarded by a null check.Scope
Two related issues are out of scope and tracked separately in #5240:
int32,int64, etc.) are not handled when@Schema(type)overrides the inferred type.$refleakage when the resolved type isstringor["string", "null"]: extra enum values or unintended$refentries can appear alongside the scalar type.Type of Change
Checklist
Screenshots / Additional Context