fix: apply explicit @Schema(type) to the types set under OpenAPI 3.1#5234
Open
forhadmethun wants to merge 1 commit into
Open
fix: apply explicit @Schema(type) to the types set under OpenAPI 3.1#5234forhadmethun wants to merge 1 commit into
forhadmethun wants to merge 1 commit into
Conversation
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 swagger-api#5233
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.
Description
Under OpenAPI 3.1, an explicit
@Schema(type = ...)was applied via the legacy scalarsetType(), while the 3.1 serializer reads thetypesset. The set kept its default ("string"), sonumber/integer/booleanfields were rendered asstring. This change populates thetypesset whenopenapi31is enabled, mirroring the handling of the pluraltypes()attribute directly below.AnnotationsUtils.getSchemaFromAnnotation:Before / After (OpenAPI 3.1) — given
@Schema(type = "number") BigDecimal amount;:amount: { type: "string" }amount: { type: "number" }This is a bug fix. It is distinct from #5061 / #5062 (numeric example serialization); it concerns the property type and reproduces with no
examplepresent. Fields relying on type inference (no explicittype) were already correct.Fixes: #5233
Type of Change
Checklist
Screenshots / Additional Context
Added
io.swagger.v3.core.resolving.v31.Ticket5233Test, asserting that explicitnumber/integer/booleantypes land in thetypesset under OpenAPI 3.1, with inferred-type and enum properties as controls. The fullswagger-coremodule test suite passes locally (721 tests, 0 failures).