Fix: primitive boxed type schemas incorrectly cast to "string" in OAS 3.1 #4963 - #4989
Merged
ewaostrowska merged 39 commits intoAug 31, 2026
Conversation
… enum" This reverts commit 7c0a6af.
ewaostrowska
requested changes
Oct 17, 2025
ewaostrowska
approved these changes
Nov 12, 2025
… enum" This reverts commit 7c0a6af.
ewaostrowska
force-pushed
the
bug/4963-fix-schema-primitive-boxed-type-cast
branch
2 times, most recently
from
November 12, 2025 13:08
15665a4 to
13e287a
Compare
ewaostrowska
force-pushed
the
bug/4963-fix-schema-primitive-boxed-type-cast
branch
from
November 12, 2025 13:16
5af7e9b to
47009dd
Compare
Contributor
|
There are still some failing tests in |
…xed-type-cast' into bug/4963-fix-schema-primitive-boxed-type-cast
Contributor
|
Hi @K5qu4r3d!
|
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
Fixes: #4963
When generating OpenAPI 3.1 specs,
@ApiResponseannotations that reference primitive boxed types (e.g.Boolean.class) as schema implementations produce a schema where the OAS 3.1typesset is correctly populated buttypeis then overwritten to"string". This causes invalid specs and incorrect client generation.What was broken
AnnotationsUtilsfalls back tosetType("string")when a schema has no$refand notype. It did not checkgetTypes(), so OAS 3.1 schemas that already had the correcttypesset were silently clobbered.What changed
AnnotationsUtils.java: added adoesSchemaHaveNullOrEmptyTypesguard to thesetType("string")fallback so schemas already carrying an OAS 3.1typesvalue are not overwritten.Type of Change
Checklist
Screenshots / Additional Context
Added files:
modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/resources/APIResponsesResource.javamodules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/APIResponsesResourceTest.javaAffected files:
modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.javamodules/swagger-core/src/main/java/io/swagger/v3/core/util/PrimitiveType.javamodules/swagger-java17-support/src/test/java/io/swagger/v3/java17/resolving/v31/ModelResolverOAS31Test.javamodules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket2992Test.java