fix: apply explicit @Schema(type) to the types set under OpenAPI 3.1 - #5234
fix: apply explicit @Schema(type) to the types set under OpenAPI 3.1#5234forhadmethun 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
|
Hi @forhadmethun, thank you for putting your time into this topic. As described in the #5233 we do not want to implement the bridging in between |
|
After revisiting the topic a small update here: The bridging seems the simplest solution considering the Thank you for the PR @forhadmethun and your investigation of the topic :) |
Thanks for pulling my changes into #5304 and for the extra work on the implementation logic! Glad I could help out. 😊 |
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).