File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed
main/java/io/swagger/util
swagger-jaxrs/src/test/java/io/swagger Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public static boolean isConstructorCompatible(Constructor<?> constructor) {
145145 * @return list of Fields
146146 */
147147 public static List <Field > getDeclaredFields (Class <?> cls ) {
148- if (cls . equals ( Object .class )) {
148+ if (cls == null || Object .class . equals ( cls )) {
149149 return Collections .emptyList ();
150150 }
151151 final List <Field > fields = new ArrayList <Field >();
Original file line number Diff line number Diff line change 33import io .swagger .annotations .ApiOperation ;
44import io .swagger .annotations .ApiResponses ;
55import io .swagger .reflection .Child ;
6+ import io .swagger .reflection .IParent ;
67import io .swagger .reflection .Parent ;
78import io .swagger .util .ReflectionUtils ;
89
1213import java .lang .reflect .Method ;
1314import java .lang .reflect .Type ;
1415import java .util .Arrays ;
16+ import java .util .Collections ;
1517
1618import javax .ws .rs .Path ;
1719
@@ -114,4 +116,10 @@ public void testDerivedAnnotation() {
114116 Assert .assertNotNull (annotation );
115117 Assert .assertEquals (annotation .value (), "parentInterfacePath" );
116118 }
119+
120+ @ Test
121+ public void getDeclaredFieldsFromInterfaceTest () throws NoSuchMethodException {
122+ final Class cls = IParent .class ;
123+ Assert .assertEquals (Collections .emptyList (), ReflectionUtils .getDeclaredFields (cls ));
124+ }
117125}
Original file line number Diff line number Diff line change 5252import io .swagger .resources .SimpleResourceWithoutAnnotations ;
5353import io .swagger .resources .SimpleSelfReferencingSubResource ;
5454import io .swagger .resources .TaggedResource ;
55+ import io .swagger .resources .NicknamedOperation ;
5556
5657import org .testng .annotations .Test ;
5758
@@ -337,7 +338,7 @@ public void scanSimpleSelfReferencingSubResource() {
337338 retrieve = getGet (swagger , "/sub/recurse2" );
338339 assertNotNull (retrieve );
339340 assertEquals (retrieve .getParameters ().size (), 0 );
340- }
341+ }
341342
342343 @ Test (description = "scan resource with ApiOperation.code() value" )
343344 public void scanResourceWithApiOperationCodeValue () {
@@ -527,4 +528,17 @@ public void checkResponseModelsProcessing() {
527528 }
528529 }
529530 }
531+
532+ @ Test (description = "scan a resource with custom operation nickname" )
533+ public void scanResourceWithApiOperationNickname () {
534+ Swagger swagger = getSwagger (NicknamedOperation .class );
535+ assertEquals (swagger .getPaths ().size (), 1 );
536+
537+ assertNotNull (swagger .getPaths ().get ("/external/info" ));
538+
539+ Operation op = swagger .getPaths ().get ("/external/info" ).getGet ();
540+ assertNotNull (op );
541+
542+ assertEquals (op .getOperationId (), "getMyNicknameTest" );
543+ }
530544}
Original file line number Diff line number Diff line change 1+ package io .swagger .resources ;
2+
3+ import io .swagger .annotations .Api ;
4+ import io .swagger .annotations .ApiOperation ;
5+ import io .swagger .annotations .ApiParam ;
6+
7+ import javax .ws .rs .GET ;
8+ import javax .ws .rs .Path ;
9+ import javax .ws .rs .core .Response ;
10+ import java .util .ArrayList ;
11+
12+ @ Api (value = "/external/info/" )
13+ @ Path ("external/info/" )
14+ public class NicknamedOperation {
15+ @ ApiOperation (value = "test" , nickname = "getMyNicknameTest" )
16+ @ GET
17+ public Response .Status getTest (@ ApiParam (value = "test" ) ArrayList <String > tenantId ) {
18+ return Response .Status .OK ;
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments