33
33
import java .util .stream .Stream ;
34
34
35
35
import io .swagger .v3 .core .util .AnnotationsUtils ;
36
- import io .swagger .v3 .core .util .ReflectionUtils ;
37
36
import io .swagger .v3 .oas .annotations .Hidden ;
38
37
import io .swagger .v3 .oas .annotations .OpenAPIDefinition ;
39
38
import io .swagger .v3 .oas .annotations .tags .Tag ;
54
53
import org .springframework .boot .autoconfigure .AutoConfigurationPackages ;
55
54
import org .springframework .context .ApplicationContext ;
56
55
import org .springframework .context .annotation .ClassPathScanningCandidateComponentProvider ;
56
+ import org .springframework .core .annotation .AnnotatedElementUtils ;
57
57
import org .springframework .core .annotation .AnnotationUtils ;
58
58
import org .springframework .core .type .filter .AnnotationTypeFilter ;
59
59
import org .springframework .stereotype .Controller ;
@@ -167,12 +167,12 @@ public boolean isServersPresent() {
167
167
168
168
public Operation buildTags (HandlerMethod handlerMethod , Operation operation , OpenAPI openAPI ) {
169
169
// class tags
170
- List <Tag > classTags =
171
- ReflectionUtils . getRepeatableAnnotations (handlerMethod .getBeanType (), Tag .class );
170
+ Set <Tag > classTags =
171
+ AnnotatedElementUtils . findAllMergedAnnotations (handlerMethod .getBeanType (), Tag .class );
172
172
173
173
// method tags
174
- List <Tag > methodTags =
175
- ReflectionUtils . getRepeatableAnnotations (handlerMethod .getMethod (), Tag .class );
174
+ Set <Tag > methodTags =
175
+ AnnotatedElementUtils . findAllMergedAnnotations (handlerMethod .getMethod (), Tag .class );
176
176
177
177
List <Tag > allTags = new ArrayList <>();
178
178
Set <String > tagsStr = new HashSet <>();
@@ -244,7 +244,7 @@ private Optional<OpenAPIDefinition> getOpenAPIDefinition() {
244
244
if (openAPIDefinitionMap .size () > 0 ) {
245
245
Map .Entry <String , Object > entry = openAPIDefinitionMap .entrySet ().iterator ().next ();
246
246
Class <?> objClz = entry .getValue ().getClass ();
247
- apiDef = ReflectionUtils . getAnnotation (objClz , OpenAPIDefinition .class );
247
+ apiDef = AnnotatedElementUtils . findMergedAnnotation (objClz , OpenAPIDefinition .class );
248
248
}
249
249
250
250
// Look for OpenAPIDefinition in the spring classpath
@@ -319,8 +319,7 @@ private void calculateSecuritySchemes(Components components) {
319
319
if (securitySchemeBeans .size () > 0 ) {
320
320
for (Map .Entry <String , Object > entry : securitySchemeBeans .entrySet ()) {
321
321
Class <?> objClz = entry .getValue ().getClass ();
322
- List <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme = ReflectionUtils
323
- .getRepeatableAnnotations (objClz , io .swagger .v3 .oas .annotations .security .SecurityScheme .class );
322
+ Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme = AnnotatedElementUtils .findMergedRepeatableAnnotations (objClz , io .swagger .v3 .oas .annotations .security .SecurityScheme .class );
324
323
this .addSecurityScheme (apiSecurityScheme , components );
325
324
}
326
325
}
@@ -333,15 +332,15 @@ private void calculateSecuritySchemes(Components components) {
333
332
new AnnotationTypeFilter (io .swagger .v3 .oas .annotations .security .SecurityScheme .class ));
334
333
if (AutoConfigurationPackages .has (context )) {
335
334
List <String > packagesToScan = AutoConfigurationPackages .get (context );
336
- List <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme = getSecuritySchemesClasses (
335
+ Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme = getSecuritySchemesClasses (
337
336
scanner , packagesToScan );
338
337
this .addSecurityScheme (apiSecurityScheme , components );
339
338
}
340
339
341
340
}
342
341
}
343
342
344
- private void addSecurityScheme (List <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme ,
343
+ private void addSecurityScheme (Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme ,
345
344
Components components ) {
346
345
for (io .swagger .v3 .oas .annotations .security .SecurityScheme securitySchemeAnnotation : apiSecurityScheme ) {
347
346
Optional <SecuritySchemePair > securityScheme = securityParser .getSecurityScheme (securitySchemeAnnotation );
@@ -377,9 +376,9 @@ private OpenAPIDefinition getApiDefClass(ClassPathScanningCandidateComponentProv
377
376
return null ;
378
377
}
379
378
380
- private List <io .swagger .v3 .oas .annotations .security .SecurityScheme > getSecuritySchemesClasses (
379
+ private Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > getSecuritySchemesClasses (
381
380
ClassPathScanningCandidateComponentProvider scanner , List <String > packagesToScan ) {
382
- List <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme = new ArrayList <>();
381
+ Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme = new HashSet <>();
383
382
for (String pack : packagesToScan ) {
384
383
for (BeanDefinition bd : scanner .findCandidateComponents (pack )) {
385
384
try {
0 commit comments