Skip to content

Commit 534080f

Browse files
committed
JavaDoc integration not working with SnakeCaseStrategy property naming. Fixes #2484
1 parent 0fdfaba commit 534080f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Diff for: springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/JavadocPropertyCustomizer.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,21 @@ public void setJavadocDescription(Class<?> cls, List<Field> fields, List<Propert
185185
* @param field the field
186186
* @return the boolean
187187
*/
188-
private static boolean findFields(Entry<String, Schema> stringSchemaEntry, Field field) {
189-
if (field.getName().equals(stringSchemaEntry.getKey())){
188+
private boolean findFields(Entry<String, Schema> stringSchemaEntry, Field field) {
189+
if (field.getName().equals(stringSchemaEntry.getKey())) {
190190
return true;
191191
}
192192
else {
193193
JsonProperty jsonPropertyAnnotation = field.getAnnotation(JsonProperty.class);
194194
if (jsonPropertyAnnotation != null) {
195195
String jsonPropertyName = jsonPropertyAnnotation.value();
196-
if (jsonPropertyName.equals(stringSchemaEntry.getKey())){
196+
if (jsonPropertyName.equals(stringSchemaEntry.getKey())) {
197197
return true;
198198
}
199199
}
200+
else if (field.getName().equalsIgnoreCase(stringSchemaEntry.getKey().replaceAll("_", ""))) {
201+
return true;
202+
}
200203
return false;
201204
}
202205
}

Diff for: springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java

+4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818

1919
package test.org.springdoc.api.app13;
2020

21+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
22+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
23+
2124
/**
2225
* The type Person dto.
2326
*/
27+
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
2428
public class PersonDTO {
2529
/**
2630
* The Email.

Diff for: springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app13.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
"type": "string",
6161
"description": "The Email."
6262
},
63-
"firstName": {
63+
"first_name": {
6464
"type": "string",
6565
"description": "The First name."
6666
},
67-
"lastName": {
67+
"last_name": {
6868
"type": "string",
6969
"description": "The Last name."
7070
}
@@ -73,4 +73,4 @@
7373
}
7474
}
7575
}
76-
}
76+
}

0 commit comments

Comments
 (0)