1
+ package org .springdoc .core ;
2
+
3
+ import io .swagger .v3 .oas .models .OpenAPI ;
4
+ import org .springdoc .api .ActuatorProvider ;
5
+ import org .springdoc .api .MultipleOpenApiResource ;
6
+ import org .springframework .beans .factory .ObjectFactory ;
7
+ import org .springframework .beans .factory .config .BeanFactoryPostProcessor ;
8
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
9
+ import org .springframework .context .annotation .Bean ;
10
+ import org .springframework .context .annotation .Configuration ;
11
+ import org .springframework .web .servlet .mvc .method .RequestMappingInfoHandlerMapping ;
12
+
13
+ import java .util .List ;
14
+ import java .util .Optional ;
15
+
16
+
17
+ @ Configuration
18
+ @ ConditionalOnBean (GroupedOpenApi .class )
19
+ public class MultipleOpenApiSupportConfiguration {
20
+
21
+ @ Bean
22
+ public BeanFactoryPostProcessor beanFactoryPostProcessor () {
23
+ return beanFactory -> {
24
+ for (String beanName : beanFactory .getBeanNamesForType (OpenAPI .class )) {
25
+ beanFactory .getBeanDefinition (beanName ).setScope ("prototype" );
26
+ }
27
+ for (String beanName : beanFactory .getBeanNamesForType (OpenAPIBuilder .class )) {
28
+ beanFactory .getBeanDefinition (beanName ).setScope ("prototype" );
29
+ }
30
+ };
31
+ }
32
+
33
+ @ Bean
34
+ public MultipleOpenApiResource multipleOpenApiResource (List <GroupedOpenApi > groupedOpenApis ,
35
+ ObjectFactory <OpenAPIBuilder > defaultOpenAPIBuilder , AbstractRequestBuilder requestBuilder ,
36
+ AbstractResponseBuilder responseBuilder , OperationBuilder operationParser ,
37
+ RequestMappingInfoHandlerMapping requestMappingHandlerMapping ,
38
+ Optional <ActuatorProvider > servletContextProvider ) {
39
+ return new MultipleOpenApiResource (groupedOpenApis ,
40
+ defaultOpenAPIBuilder , requestBuilder ,
41
+ responseBuilder , operationParser ,
42
+ requestMappingHandlerMapping , servletContextProvider );
43
+ }
44
+ }
0 commit comments