5757import java .util .ArrayList ;
5858import java .util .Arrays ;
5959import java .util .Collections ;
60- import java .util .Comparator ;
6160import java .util .HashMap ;
6261import java .util .HashSet ;
6362import java .util .Iterator ;
@@ -130,9 +129,7 @@ public OpenAPI read(Class<?> cls) {
130129 * @return the generated OpenAPI definition
131130 */
132131 public OpenAPI read (Set <Class <?>> classes ) {
133- Set <Class <?>> sortedClasses = new TreeSet <>(new Comparator <Class <?>>() {
134- @ Override
135- public int compare (Class <?> class1 , Class <?> class2 ) {
132+ Set <Class <?>> sortedClasses = new TreeSet <>((class1 , class2 ) -> {
136133 if (class1 .equals (class2 )) {
137134 return 0 ;
138135 } else if (class1 .isAssignableFrom (class2 )) {
@@ -141,8 +138,7 @@ public int compare(Class<?> class1, Class<?> class2) {
141138 return 1 ;
142139 }
143140 return class1 .getName ().compareTo (class2 .getName ());
144- }
145- });
141+ });
146142 sortedClasses .addAll (classes );
147143
148144 Map <Class <?>, ReaderListener > listeners = new HashMap <>();
@@ -192,6 +188,7 @@ public void setConfiguration(OpenAPIConfiguration openApiConfiguration) {
192188 }
193189 }
194190
191+ @ Override
195192 public OpenAPI read (Set <Class <?>> classes , Map <String , Object > resources ) {
196193 return read (classes );
197194 }
@@ -213,9 +210,9 @@ protected String resolveApplicationPath() {
213210 // look for inner application, e.g. ResourceConfig
214211 try {
215212 Application innerApp = application ;
216- Method m = application .getClass ().getMethod ("getApplication" , null );
213+ Method m = application .getClass ().getMethod ("getApplication" );
217214 while (m != null ) {
218- Application retrievedApp = (Application ) m .invoke (innerApp , null );
215+ Application retrievedApp = (Application ) m .invoke (innerApp );
219216 if (retrievedApp == null ) {
220217 break ;
221218 }
@@ -229,7 +226,7 @@ protected String resolveApplicationPath() {
229226 return applicationPath .value ();
230227 }
231228 }
232- m = innerApp .getClass ().getMethod ("getApplication" , null );
229+ m = innerApp .getClass ().getMethod ("getApplication" );
233230 }
234231 } catch (NoSuchMethodException e ) {
235232 // no inner application found
@@ -340,8 +337,8 @@ public OpenAPI read(Class<?> cls,
340337 .getTags (apiTags , false ).ifPresent (tags ->
341338 tags
342339 .stream ()
343- .map (t -> t . getName () )
344- .forEach (t -> classTags . add ( t ) )
340+ .map (Tag :: getName )
341+ .forEach (classTags :: add )
345342 );
346343 }
347344
@@ -355,7 +352,7 @@ public OpenAPI read(Class<?> cls,
355352 // servers
356353 final List <io .swagger .v3 .oas .models .servers .Server > classServers = new ArrayList <>();
357354 if (apiServers != null ) {
358- AnnotationsUtils .getServers (apiServers ).ifPresent (servers -> classServers . addAll ( servers ) );
355+ AnnotationsUtils .getServers (apiServers ).ifPresent (classServers :: addAll );
359356 }
360357
361358 // class external docs
@@ -374,7 +371,7 @@ public OpenAPI read(Class<?> cls,
374371 globalParameters .addAll (ReaderUtils .collectFieldParameters (cls , components , classConsumes , null ));
375372
376373 // iterate class methods
377- Method methods [] = cls .getMethods ();
374+ Method [] methods = cls .getMethods ();
378375 for (Method method : methods ) {
379376 if (isOperationHidden (method )) {
380377 continue ;
@@ -529,7 +526,7 @@ public OpenAPI read(Class<?> cls,
529526 }
530527 }
531528 // if we have form parameters, need to merge them into single schema and use as request body..
532- if (formParameters .size () > 0 ) {
529+ if (! formParameters .isEmpty () ) {
533530 Schema mergedSchema = new ObjectSchema ();
534531 for (Parameter formParam : formParameters ) {
535532 mergedSchema .addProperties (formParam .getName (), formParam .getSchema ());
@@ -549,7 +546,7 @@ public OpenAPI read(Class<?> cls,
549546 jsonViewAnnotationForRequestBody );
550547
551548 }
552- if (operationParameters .size () > 0 ) {
549+ if (! operationParameters .isEmpty () ) {
553550 for (Parameter operationParameter : operationParameters ) {
554551 operation .addParametersItem (operationParameter );
555552 }
@@ -908,7 +905,7 @@ protected Operation parseMethod(
908905 if (apiTags != null ) {
909906 apiTags .stream ()
910907 .filter (t -> operation .getTags () == null || (operation .getTags () != null && !operation .getTags ().contains (t .name ())))
911- .map (t -> t . name () )
908+ .map (io . swagger . v3 . oas . annotations . tags . Tag :: name )
912909 .forEach (operation ::addTagsItem );
913910 AnnotationsUtils .getTags (apiTags .toArray (new io .swagger .v3 .oas .annotations .tags .Tag [apiTags .size ()]), true ).ifPresent (tags -> openApiTags .addAll (tags ));
914911 }
@@ -961,7 +958,7 @@ protected Operation parseMethod(
961958 }
962959
963960 // apiResponses
964- if (apiResponses != null && apiResponses .size () > 0 ) {
961+ if (apiResponses != null && ! apiResponses .isEmpty () ) {
965962 OperationParser .getApiResponses (
966963 apiResponses .toArray (new io .swagger .v3 .oas .annotations .responses .ApiResponse [apiResponses .size ()]),
967964 classProduces ,
@@ -1074,7 +1071,7 @@ private boolean shouldIgnoreClass(String className) {
10741071 rawClassName = className .replace ("[simple type, class " , "" );
10751072 rawClassName = rawClassName .substring (0 , rawClassName .length () -1 );
10761073 }
1077- ignore = ignore || rawClassName .startsWith ("javax.ws.rs." );
1074+ ignore = rawClassName .startsWith ("javax.ws.rs." );
10781075 ignore = ignore || rawClassName .equalsIgnoreCase ("void" );
10791076 ignore = ignore || ModelConverters .getInstance ().isRegisteredAsSkippedClass (rawClassName );
10801077 return ignore ;
@@ -1171,11 +1168,10 @@ private void setOperationObjectFromApiOperationAnnotation(
11711168 operation .setDeprecated (apiOperation .deprecated ());
11721169 }
11731170
1174- ReaderUtils .getStringListFromStringArray (apiOperation .tags ()).ifPresent (tags -> {
1171+ ReaderUtils .getStringListFromStringArray (apiOperation .tags ()).ifPresent (tags ->
11751172 tags .stream ()
11761173 .filter (t -> operation .getTags () == null || (operation .getTags () != null && !operation .getTags ().contains (t )))
1177- .forEach (operation ::addTagsItem );
1178- });
1174+ .forEach (operation ::addTagsItem ));
11791175
11801176 if (operation .getExternalDocs () == null ) { // if not set in root annotation
11811177 AnnotationsUtils .getExternalDocumentation (apiOperation .externalDocs ()).ifPresent (operation ::setExternalDocs );
@@ -1206,18 +1202,16 @@ private void setOperationObjectFromApiOperationAnnotation(
12061202 }
12071203
12081204 // RequestBody in Operation
1209- if (apiOperation != null && apiOperation .requestBody () != null && operation .getRequestBody () == null ) {
1205+ if (apiOperation .requestBody () != null && operation .getRequestBody () == null ) {
12101206 OperationParser .getRequestBody (apiOperation .requestBody (), classConsumes , methodConsumes , components , jsonViewAnnotation ).ifPresent (
1211- requestBodyObject -> operation . setRequestBody ( requestBodyObject ) );
1207+ operation :: setRequestBody );
12121208 }
12131209
12141210 // Extensions in Operation
12151211 if (apiOperation .extensions ().length > 0 ) {
12161212 Map <String , Object > extensions = AnnotationsUtils .getExtensions (apiOperation .extensions ());
12171213 if (extensions != null ) {
1218- for (String ext : extensions .keySet ()) {
1219- operation .addExtension (ext , extensions .get (ext ));
1220- }
1214+ extensions .forEach (operation ::addExtension );
12211215 }
12221216 }
12231217 }
@@ -1262,7 +1256,7 @@ protected Optional<List<Parameter>> getParametersListFromAnnotation(io.swagger.v
12621256 ResolvedParameter resolvedParameter = getParameters (ParameterProcessor .getParameterType (parameter ), Collections .singletonList (parameter ), operation , classConsumes , methodConsumes , jsonViewAnnotation );
12631257 parametersObject .addAll (resolvedParameter .parameters );
12641258 }
1265- if (parametersObject .size () == 0 ) {
1259+ if (parametersObject .isEmpty () ) {
12661260 return Optional .empty ();
12671261 }
12681262 return Optional .of (parametersObject );
@@ -1279,8 +1273,7 @@ protected ResolvedParameter getParameters(Type type, List<Annotation> annotation
12791273 final OpenAPIExtension extension = chain .next ();
12801274 LOGGER .debug ("trying extension {}" , extension );
12811275
1282- final ResolvedParameter extractParametersResult = extension .extractParameters (annotations , type , typesToSkip , components , classConsumes , methodConsumes , true , jsonViewAnnotation , chain );
1283- return extractParametersResult ;
1276+ return extension .extractParameters (annotations , type , typesToSkip , components , classConsumes , methodConsumes , true , jsonViewAnnotation , chain );
12841277 }
12851278
12861279 private Set <String > extractOperationIdFromPathItem (PathItem path ) {
@@ -1395,10 +1388,7 @@ protected boolean ignoreOperationPath(String path, String parentPath) {
13951388 path = path .substring (0 , path .length () - 1 );
13961389 }
13971390 }
1398- if (path .equals (parentPath )) {
1399- return true ;
1400- }
1401- return false ;
1391+ return path .equals (parentPath );
14021392 }
14031393
14041394 protected Class <?> getSubResourceWithJaxRsSubresourceLocatorSpecs (Method method ) {
0 commit comments