42
42
import java .util .stream .Collectors ;
43
43
import java .util .stream .Stream ;
44
44
45
- import com .fasterxml .jackson .annotation .JsonInclude .Include ;
46
45
import com .fasterxml .jackson .core .JsonProcessingException ;
47
46
import com .fasterxml .jackson .databind .ObjectMapper ;
48
47
import io .swagger .v3 .core .jackson .TypeNameResolver ;
71
70
import org .springdoc .core .customizers .ServerBaseUrlCustomizer ;
72
71
import org .springdoc .core .properties .SpringDocConfigProperties ;
73
72
import org .springdoc .core .providers .JavadocProvider ;
74
- import org .springdoc .core .providers .ObjectMapperProvider ;
75
73
import org .springdoc .core .utils .PropertyResolverUtils ;
76
74
77
75
import org .springframework .beans .BeansException ;
97
95
98
96
/**
99
97
* The type Open api builder.
98
+ *
100
99
* @author bnasslahsen
101
100
*/
102
101
public class OpenAPIService implements ApplicationContextAware {
@@ -179,13 +178,13 @@ public class OpenAPIService implements ApplicationContextAware {
179
178
/**
180
179
* Instantiates a new Open api builder.
181
180
*
182
- * @param openAPI the open api
183
- * @param securityParser the security parser
181
+ * @param openAPI the open api
182
+ * @param securityParser the security parser
184
183
* @param springDocConfigProperties the spring doc config properties
185
- * @param propertyResolverUtils the property resolver utils
184
+ * @param propertyResolverUtils the property resolver utils
186
185
* @param openApiBuilderCustomizers the open api builder customisers
187
- * @param serverBaseUrlCustomizers the server base url customizers
188
- * @param javadocProvider the javadoc provider
186
+ * @param serverBaseUrlCustomizers the server base url customizers
187
+ * @param javadocProvider the javadoc provider
189
188
*/
190
189
public OpenAPIService (Optional <OpenAPI > openAPI , SecurityService securityParser ,
191
190
SpringDocConfigProperties springDocConfigProperties , PropertyResolverUtils propertyResolverUtils ,
@@ -230,6 +229,7 @@ public static String splitCamelCase(String str) {
230
229
231
230
/**
232
231
* Build.
232
+ *
233
233
* @param locale the locale
234
234
* @return the open api
235
235
*/
@@ -317,9 +317,9 @@ public void setServersPresent(boolean serversPresent) {
317
317
* Build tags operation.
318
318
*
319
319
* @param handlerMethod the handler method
320
- * @param operation the operation
321
- * @param openAPI the open api
322
- * @param locale the locale
320
+ * @param operation the operation
321
+ * @param openAPI the open api
322
+ * @param locale the locale
323
323
* @return the operation
324
324
*/
325
325
public Operation buildTags (HandlerMethod handlerMethod , Operation operation , OpenAPI openAPI , Locale locale ) {
@@ -394,10 +394,10 @@ public Operation buildTags(HandlerMethod handlerMethod, Operation operation, Ope
394
394
/**
395
395
* Build tags from method.
396
396
*
397
- * @param method the method
398
- * @param tags the tags
397
+ * @param method the method
398
+ * @param tags the tags
399
399
* @param tagsStr the tags str
400
- * @param locale the locale
400
+ * @param locale the locale
401
401
*/
402
402
private void buildTagsFromMethod (Method method , Set <io .swagger .v3 .oas .models .tags .Tag > tags , Set <String > tagsStr , Locale locale ) {
403
403
// method tags
@@ -417,8 +417,8 @@ private void buildTagsFromMethod(Method method, Set<io.swagger.v3.oas.models.tag
417
417
* Add tags.
418
418
*
419
419
* @param sourceTags the source tags
420
- * @param tags the tags
421
- * @param locale the locale
420
+ * @param tags the tags
421
+ * @param locale the locale
422
422
*/
423
423
private void addTags (List <Tag > sourceTags , Set <io .swagger .v3 .oas .models .tags .Tag > tags , Locale locale ) {
424
424
Optional <Set <io .swagger .v3 .oas .models .tags .Tag >> optionalTagSet = AnnotationsUtils
@@ -437,9 +437,9 @@ private void addTags(List<Tag> sourceTags, Set<io.swagger.v3.oas.models.tags.Tag
437
437
* Build tags from class.
438
438
*
439
439
* @param beanType the bean type
440
- * @param tags the tags
441
- * @param tagsStr the tags str
442
- * @param locale the locale
440
+ * @param tags the tags
441
+ * @param tagsStr the tags str
442
+ * @param locale the locale
443
443
*/
444
444
public void buildTagsFromClass (Class <?> beanType , Set <io .swagger .v3 .oas .models .tags .Tag > tags , Set <String > tagsStr , Locale locale ) {
445
445
List <Tag > allTags = new ArrayList <>();
@@ -473,7 +473,7 @@ public Schema resolveProperties(Schema schema, Locale locale) {
473
473
if (!CollectionUtils .isEmpty (properties )) {
474
474
LinkedHashMap <String , Schema > resolvedSchemas = properties .entrySet ().stream ().map (es -> {
475
475
es .setValue (resolveProperties (es .getValue (), locale ));
476
- if (es .getValue () instanceof ArraySchema arraySchema ){
476
+ if (es .getValue () instanceof ArraySchema arraySchema ) {
477
477
resolveProperties (arraySchema .getItems (), locale );
478
478
}
479
479
return es ;
@@ -539,8 +539,8 @@ private Optional<OpenAPIDefinition> getOpenAPIDefinition() {
539
539
* Build open api with open api definition.
540
540
*
541
541
* @param openAPI the open api
542
- * @param apiDef the api def
543
- * @param locale the locale
542
+ * @param apiDef the api def
543
+ * @param locale the locale
544
544
*/
545
545
private void buildOpenAPIWithOpenAPIDefinition (OpenAPI openAPI , OpenAPIDefinition apiDef , Locale locale ) {
546
546
// info
@@ -568,7 +568,7 @@ private void buildOpenAPIWithOpenAPIDefinition(OpenAPI openAPI, OpenAPIDefinitio
568
568
* Resolve properties info.
569
569
*
570
570
* @param servers the servers
571
- * @param locale the locale
571
+ * @param locale the locale
572
572
* @return the servers
573
573
*/
574
574
private List <Server > resolveProperties (List <Server > servers , Locale locale ) {
@@ -584,7 +584,7 @@ private List<Server> resolveProperties(List<Server> servers, Locale locale) {
584
584
/**
585
585
* Resolve properties info.
586
586
*
587
- * @param info the info
587
+ * @param info the info
588
588
* @param locale the locale
589
589
* @return the info
590
590
*/
@@ -606,16 +606,24 @@ private Info resolveProperties(Info info, Locale locale) {
606
606
resolveProperty (contact ::getEmail , contact ::email , propertyResolverUtils , locale );
607
607
resolveProperty (contact ::getUrl , contact ::url , propertyResolverUtils , locale );
608
608
}
609
+
610
+ if (propertyResolverUtils .isResolveExtensionsProperties ()){
611
+ Map <String , Object > extensionsResolved = propertyResolverUtils .resolveExtensions (locale , info .getExtensions ());
612
+ info .setExtensions (extensionsResolved );
613
+ }
614
+
609
615
return info ;
610
616
}
611
617
618
+
619
+
612
620
/**
613
621
* Resolve property.
614
622
*
615
- * @param getProperty the get property
616
- * @param setProperty the set property
623
+ * @param getProperty the get property
624
+ * @param setProperty the set property
617
625
* @param propertyResolverUtils the property resolver utils
618
- * @param locale the locale
626
+ * @param locale the locale
619
627
*/
620
628
private void resolveProperty (Supplier <String > getProperty , Consumer <String > setProperty ,
621
629
PropertyResolverUtils propertyResolverUtils , Locale locale ) {
@@ -629,7 +637,7 @@ private void resolveProperty(Supplier<String> getProperty, Consumer<String> setP
629
637
* Calculate security schemes.
630
638
*
631
639
* @param components the components
632
- * @param locale the locale
640
+ * @param locale the locale
633
641
*/
634
642
private void calculateSecuritySchemes (Components components , Locale locale ) {
635
643
// Look for SecurityScheme in a spring managed bean
@@ -664,8 +672,8 @@ private void calculateSecuritySchemes(Components components, Locale locale) {
664
672
* Add security scheme.
665
673
*
666
674
* @param apiSecurityScheme the api security scheme
667
- * @param components the components
668
- * @param locale the locale
675
+ * @param components the components
676
+ * @param locale the locale
669
677
*/
670
678
private void addSecurityScheme (Set <io .swagger .v3 .oas .annotations .security .SecurityScheme > apiSecurityScheme ,
671
679
Components components , Locale locale ) {
@@ -689,7 +697,7 @@ private void addSecurityScheme(Set<io.swagger.v3.oas.annotations.security.Securi
689
697
/**
690
698
* Gets api def class.
691
699
*
692
- * @param scanner the scanner
700
+ * @param scanner the scanner
693
701
* @param packagesToScan the packages to scan
694
702
* @return the api def class
695
703
*/
@@ -723,7 +731,7 @@ public boolean isAutoTagClasses(Operation operation) {
723
731
/**
724
732
* Gets security schemes classes.
725
733
*
726
- * @param scanner the scanner
734
+ * @param scanner the scanner
727
735
* @param packagesToScan the packages to scan
728
736
* @return the security schemes classes
729
737
*/
@@ -752,7 +760,7 @@ private Set<io.swagger.v3.oas.annotations.security.SecurityScheme> getSecuritySc
752
760
* Add tag.
753
761
*
754
762
* @param handlerMethods the handler methods
755
- * @param tag the tag
763
+ * @param tag the tag
756
764
*/
757
765
public void addTag (Set <HandlerMethod > handlerMethods , io .swagger .v3 .oas .models .tags .Tag tag ) {
758
766
handlerMethods .forEach (handlerMethod -> springdocTags .put (handlerMethod , tag ));
@@ -802,7 +810,7 @@ public OpenAPI getCachedOpenAPI(Locale locale) {
802
810
* Sets cached open api.
803
811
*
804
812
* @param cachedOpenAPI the cached open api
805
- * @param locale associated the the cache entry
813
+ * @param locale associated the the cache entry
806
814
*/
807
815
public void setCachedOpenAPI (OpenAPI cachedOpenAPI , Locale locale ) {
808
816
this .cachedOpenAPI .put (locale .toLanguageTag (), cachedOpenAPI );
0 commit comments