Skip to content

Commit 97f01e3

Browse files
committed
Add support for @tag description using i18n. Fixes #1355
1 parent d8fbf32 commit 97f01e3

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ public class OpenAPIService {
208208
*/
209209
public static String splitCamelCase(String str) {
210210
return str.replaceAll(
211-
String.format(
212-
"%s|%s|%s",
213-
"(?<=[A-Z])(?=[A-Z][a-z])",
214-
"(?<=[^A-Z])(?=[A-Z])",
215-
"(?<=[A-Za-z])(?=[^A-Za-z])"),
216-
"-")
211+
String.format(
212+
"%s|%s|%s",
213+
"(?<=[A-Z])(?=[A-Z][a-z])",
214+
"(?<=[^A-Z])(?=[A-Z])",
215+
"(?<=[A-Za-z])(?=[^A-Za-z])"),
216+
"-")
217217
.toLowerCase(Locale.ROOT);
218218
}
219219

@@ -372,7 +372,10 @@ private void addTags(List<Tag> sourceTags, Set<io.swagger.v3.oas.models.tags.Tag
372372
Optional<Set<io.swagger.v3.oas.models.tags.Tag>> optionalTagSet = AnnotationsUtils
373373
.getTags(sourceTags.toArray(new Tag[0]), false);
374374
optionalTagSet.ifPresent(tagsSet -> {
375-
tagsSet.forEach(tag -> tag.name(propertyResolverUtils.resolve(tag.getName(), locale)));
375+
tagsSet.forEach(tag -> {
376+
tag.name(propertyResolverUtils.resolve(tag.getName(), locale));
377+
tag.description(propertyResolverUtils.resolve(tag.getDescription(), locale));
378+
});
376379
tags.addAll(tagsSet);
377380
});
378381
}
@@ -715,7 +718,7 @@ public void addMappings(Map<String, Object> mappings) {
715718
public Map<String, Object> getControllerAdviceMap() {
716719
Map<String, Object> controllerAdviceMap = context.getBeansWithAnnotation(ControllerAdvice.class);
717720
return Stream.of(controllerAdviceMap).flatMap(mapEl -> mapEl.entrySet().stream()).filter(
718-
controller -> (AnnotationUtils.findAnnotation(controller.getValue().getClass(), Hidden.class) == null))
721+
controller -> (AnnotationUtils.findAnnotation(controller.getValue().getClass(), Hidden.class) == null))
719722
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a1, a2) -> a1, LinkedHashMap::new));
720723
}
721724

springdoc-openapi-webmvc-core/src/test/resources/messages.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ greeting=Hello! Welcome to our website!
22
lang.change=Change the language
33
lang.eng=English
44
lang.fr=French
5-
mySample=toto
5+
mySample=toto
6+
test=This is a test message

springdoc-openapi-webmvc-core/src/test/resources/results/app14.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
],
1313
"tags": [
1414
{
15-
"name": "Change the language"
15+
"name": "Hello! Welcome to our website!",
16+
"description": "This is a test message"
1617
},
1718
{
18-
"name": "Hello! Welcome to our website!",
19-
"description": "test"
19+
"name": "Change the language"
2020
}
2121
],
2222
"paths": {

0 commit comments

Comments
 (0)