3333import java .util .stream .Stream ;
3434
3535import io .swagger .v3 .core .util .AnnotationsUtils ;
36- import io .swagger .v3 .core .util .ReflectionUtils ;
3736import io .swagger .v3 .oas .annotations .Hidden ;
3837import io .swagger .v3 .oas .annotations .OpenAPIDefinition ;
3938import io .swagger .v3 .oas .annotations .tags .Tag ;
5453import org .springframework .boot .autoconfigure .AutoConfigurationPackages ;
5554import org .springframework .context .ApplicationContext ;
5655import org .springframework .context .annotation .ClassPathScanningCandidateComponentProvider ;
56+ import org .springframework .core .annotation .AnnotatedElementUtils ;
5757import org .springframework .core .annotation .AnnotationUtils ;
5858import org .springframework .core .type .filter .AnnotationTypeFilter ;
5959import org .springframework .stereotype .Controller ;
@@ -167,12 +167,12 @@ public boolean isServersPresent() {
167167
168168 public Operation buildTags (HandlerMethod handlerMethod , Operation operation , OpenAPI openAPI ) {
169169 // class tags
170- List <Tag > classTags =
171- ReflectionUtils . getRepeatableAnnotations (handlerMethod .getBeanType (), Tag .class );
170+ Set <Tag > classTags =
171+ AnnotatedElementUtils . findAllMergedAnnotations (handlerMethod .getBeanType (), Tag .class );
172172
173173 // method tags
174- List <Tag > methodTags =
175- ReflectionUtils . getRepeatableAnnotations (handlerMethod .getMethod (), Tag .class );
174+ Set <Tag > methodTags =
175+ AnnotatedElementUtils . findAllMergedAnnotations (handlerMethod .getMethod (), Tag .class );
176176
177177 List <Tag > allTags = new ArrayList <>();
178178 Set <String > tagsStr = new HashSet <>();
@@ -244,7 +244,7 @@ private Optional<OpenAPIDefinition> getOpenAPIDefinition() {
244244 if (openAPIDefinitionMap .size () > 0 ) {
245245 Map .Entry <String , Object > entry = openAPIDefinitionMap .entrySet ().iterator ().next ();
246246 Class <?> objClz = entry .getValue ().getClass ();
247- apiDef = ReflectionUtils . getAnnotation (objClz , OpenAPIDefinition .class );
247+ apiDef = AnnotatedElementUtils . findMergedAnnotation (objClz , OpenAPIDefinition .class );
248248 }
249249
250250 // Look for OpenAPIDefinition in the spring classpath
@@ -319,8 +319,7 @@ private void calculateSecuritySchemes(Components components) {
319319 if (securitySchemeBeans .size () > 0 ) {
320320 for (Map .Entry <String , Object > entry : securitySchemeBeans .entrySet ()) {
321321 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 );
324323 this .addSecurityScheme (apiSecurityScheme , components );
325324 }
326325 }
@@ -333,15 +332,15 @@ private void calculateSecuritySchemes(Components components) {
333332 new AnnotationTypeFilter (io .swagger .v3 .oas .annotations .security .SecurityScheme .class ));
334333 if (AutoConfigurationPackages .has (context )) {
335334 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 (
337336 scanner , packagesToScan );
338337 this .addSecurityScheme (apiSecurityScheme , components );
339338 }
340339
341340 }
342341 }
343342
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 ,
345344 Components components ) {
346345 for (io .swagger .v3 .oas .annotations .security .SecurityScheme securitySchemeAnnotation : apiSecurityScheme ) {
347346 Optional <SecuritySchemePair > securityScheme = securityParser .getSecurityScheme (securitySchemeAnnotation );
@@ -377,9 +376,9 @@ private OpenAPIDefinition getApiDefClass(ClassPathScanningCandidateComponentProv
377376 return null ;
378377 }
379378
380- private List <io .swagger .v3 .oas .annotations .security .SecurityScheme > getSecuritySchemesClasses (
379+ private Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > getSecuritySchemesClasses (
381380 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 <>();
383382 for (String pack : packagesToScan ) {
384383 for (BeanDefinition bd : scanner .findCandidateComponents (pack )) {
385384 try {
0 commit comments