File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
swagger-core/src/main/java/io/swagger/v3/core/jackson
swagger-java17-support/src/test/java/io/swagger/v3/java17/resolving Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1112,7 +1112,7 @@ private Stream<Annotation> extractGenericTypeArgumentAnnotations(BeanPropertyDef
1112
1112
1113
1113
private Stream <Annotation > getRecordComponentAnnotations (BeanPropertyDefinition propDef ) {
1114
1114
try {
1115
- Method accessor = propDef .getPrimaryMember ().getDeclaringClass ().getDeclaredMethod (propDef .getName ());
1115
+ Method accessor = propDef .getPrimaryMember ().getDeclaringClass ().getDeclaredMethod (propDef .getPrimaryMember (). getName ());
1116
1116
return getGenericTypeArgumentAnnotations (accessor .getAnnotatedReturnType ());
1117
1117
} catch (NoSuchMethodException e ) {
1118
1118
LOGGER .error ("Accessor for record component not found" );
Original file line number Diff line number Diff line change 1
1
package io .swagger .v3 .java17 .resolving ;
2
2
3
+ import com .fasterxml .jackson .annotation .JsonProperty ;
3
4
import io .swagger .v3 .core .converter .ModelConverters ;
4
5
import io .swagger .v3 .oas .models .media .Schema ;
5
6
import io .swagger .v3 .java17 .matchers .SerializationMatchers ;
@@ -117,4 +118,25 @@ public record JavaRecordWithAnnotationsOnGenericType(
117
118
List <@ Min (1 )@ Max (10000 ) Integer > id
118
119
){
119
120
}
121
+
122
+ @ Test
123
+ public void testJavaRecordWithJsonPropertyAnnotationNotMatchingFieldName () {
124
+ String expectedYaml = "JavaRecordWithJsonPropertyAnnotationNotMatchingFieldName:\n " +
125
+ " type: object\n " +
126
+ " properties:\n " +
127
+ " listOfStrings:\n " +
128
+ " type: array\n " +
129
+ " items:\n " +
130
+ " maxLength: 5\n " +
131
+ " minLength: 1\n " +
132
+ " type: string" ;
133
+
134
+ Map <String , Schema > stringSchemaMap = ModelConverters .getInstance (false ).readAll (JavaRecordWithJsonPropertyAnnotationNotMatchingFieldName .class );
135
+ SerializationMatchers .assertEqualsToYaml (stringSchemaMap , expectedYaml );
136
+ }
137
+
138
+ public record JavaRecordWithJsonPropertyAnnotationNotMatchingFieldName (
139
+ @ JsonProperty ("listOfStrings" ) List <@ Size (min = 1 , max = 5 )String > stringList
140
+ ) { }
141
+
120
142
}
You can’t perform that action at this time.
0 commit comments