Skip to content

Commit 728d2c3

Browse files
committed
OpenAPIService minor refactor and test fix.
1 parent 338574d commit 728d2c3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIService.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,17 @@ public Operation buildTags(HandlerMethod handlerMethod, Operation operation, Ope
359359
if (isAutoTagClasses(operation)) {
360360
String tagAutoName = splitCamelCase(handlerMethod.getBeanType().getSimpleName());
361361
operation.addTagsItem(tagAutoName);
362-
io.swagger.v3.oas.models.tags.Tag tag = new io.swagger.v3.oas.models.tags.Tag();
363-
tag.setName(tagAutoName);
364362
if (javadocProvider.isPresent()) {
365-
tag.setDescription(javadocProvider.get().getClassJavadoc(handlerMethod.getBeanType()));
366-
}
367-
if (openAPI.getTags() == null || !openAPI.getTags().contains(tag)) {
368-
openAPI.addTagsItem(tag);
363+
String description = javadocProvider.get().getClassJavadoc(handlerMethod.getBeanType());
364+
if (StringUtils.isNotBlank(description)) {
365+
io.swagger.v3.oas.models.tags.Tag tag = new io.swagger.v3.oas.models.tags.Tag();
366+
tag.setName(tagAutoName);
367+
tag.setDescription(description);
368+
if (openAPI.getTags() == null || !openAPI.getTags().contains(tag)) {
369+
openAPI.addTagsItem(tag);
370+
}
371+
}
369372
}
370-
371373
}
372374

373375
if (!CollectionUtils.isEmpty(tags)) {

springdoc-openapi-javadoc/src/test/resources/results/app126.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"operationId": "getAllCurrencies",
2828
"responses": {
2929
"401": {
30-
"$ref": "#/components/responses/http401BadToken"
30+
"$ref": "#/components/responses/http401NoToken"
3131
},
3232
"403": {
3333
"$ref": "#/components/responses/http403"

0 commit comments

Comments
 (0)