Skip to content

Commit 1fc8f9d

Browse files
committed
Boolean Parameter with @Schema Annotation Changes Type to string in OpenAPI Documentation Fixes #2638
1 parent feb7f6c commit 1fc8f9d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Com
321321
else {
322322
Schema schema = null;
323323
try {
324-
schema = AnnotationsUtils.getSchema(parameterDoc.schema(), null, false, parameterDoc.schema().implementation(), components, jsonView, propertyResolverUtils.isOpenapi31()).orElse(null);
324+
if(StringUtils.isNotEmpty(parameterDoc.schema().type()) || !Void.class.equals(parameterDoc.schema().implementation())){
325+
schema = AnnotationsUtils.getSchema(parameterDoc.schema(), null, false, parameterDoc.schema().implementation(), components, jsonView, propertyResolverUtils.isOpenapi31()).orElse(null);
326+
}
325327
// Cast default value
326328
if (schema != null && schema.getDefault() != null) {
327329
PrimitiveType primitiveType = PrimitiveType.fromTypeAndFormat(schema.getType(), schema.getFormat());

Diff for: springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app206.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"in": "query",
2424
"required": true,
2525
"schema": {
26-
"type": "string"
26+
"type": "integer",
27+
"format": "int64"
2728
}
2829
},
2930
{
@@ -57,7 +58,8 @@
5758
"in": "query",
5859
"required": true,
5960
"schema": {
60-
"type": "string"
61+
"type": "integer",
62+
"format": "int32"
6163
}
6264
}
6365
],

0 commit comments

Comments
 (0)