2
2
*
3
3
* *
4
4
* * *
5
- * * * * Copyright 2019-2022 the original author or authors.
5
+ * * * * Copyright 2019-2023 the original author or authors.
6
6
* * * *
7
7
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8
8
* * * * you may not use this file except in compliance with the License.
@@ -109,13 +109,23 @@ else if (resolvedSchema != null && resolvedSchema.get$ref() != null && resolvedS
109
109
* @param fields the fields
110
110
* @param existingSchema the existing schema
111
111
*/
112
- private void setJavadocDescription (Class <?> cls , List <Field > fields , Schema existingSchema ) {
112
+ void setJavadocDescription (Class <?> cls , List <Field > fields , Schema existingSchema ) {
113
113
if (existingSchema != null ) {
114
114
if (StringUtils .isBlank (existingSchema .getDescription ())) {
115
115
existingSchema .setDescription (javadocProvider .getClassJavadoc (cls ));
116
116
}
117
117
Map <String , Schema > properties = existingSchema .getProperties ();
118
- if (!CollectionUtils .isEmpty (properties ))
118
+ if (!CollectionUtils .isEmpty (properties )) {
119
+ if (cls .getSuperclass () != null && "java.lang.Record" .equals (cls .getSuperclass ().getName ())) {
120
+ Map <String , String > recordParamMap = javadocProvider .getRecordClassParamJavadoc (cls );
121
+ properties .entrySet ().stream ()
122
+ .filter (stringSchemaEntry -> StringUtils .isBlank (stringSchemaEntry .getValue ().getDescription ()))
123
+ .forEach (stringSchemaEntry -> {
124
+ if (recordParamMap .containsKey (stringSchemaEntry .getKey ()))
125
+ stringSchemaEntry .getValue ().setDescription (recordParamMap .get (stringSchemaEntry .getKey ()));
126
+ });
127
+ }
128
+
119
129
properties .entrySet ().stream ()
120
130
.filter (stringSchemaEntry -> StringUtils .isBlank (stringSchemaEntry .getValue ().getDescription ()))
121
131
.forEach (stringSchemaEntry -> {
@@ -126,6 +136,7 @@ private void setJavadocDescription(Class<?> cls, List<Field> fields, Schema exis
126
136
stringSchemaEntry .getValue ().setDescription (fieldJavadoc );
127
137
});
128
138
});
139
+ }
129
140
fields .stream ().filter (f -> f .isAnnotationPresent (JsonUnwrapped .class ))
130
141
.forEach (f -> setJavadocDescription (f .getType (), FieldUtils .getAllFieldsList (f .getType ()), existingSchema ));
131
142
0 commit comments