66
66
import org .apache .commons .lang3 .StringUtils ;
67
67
import org .slf4j .Logger ;
68
68
import org .slf4j .LoggerFactory ;
69
- import org .springdoc .core .AbstractRequestBuilder ;
69
+ import org .springdoc .core .AbstractRequestService ;
70
70
import org .springdoc .core .ActuatorProvider ;
71
- import org .springdoc .core .GenericParameterBuilder ;
72
- import org .springdoc .core .GenericResponseBuilder ;
71
+ import org .springdoc .core .GenericParameterService ;
72
+ import org .springdoc .core .GenericResponseService ;
73
73
import org .springdoc .core .MethodAttributes ;
74
- import org .springdoc .core .OpenAPIBuilder ;
75
- import org .springdoc .core .OperationBuilder ;
74
+ import org .springdoc .core .OpenAPIService ;
75
+ import org .springdoc .core .OperationService ;
76
76
import org .springdoc .core .SpringDocConfigProperties ;
77
77
import org .springdoc .core .SpringDocConfigProperties .GroupConfig ;
78
78
import org .springdoc .core .annotations .RouterOperations ;
@@ -121,12 +121,12 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
121
121
/**
122
122
* The Open api builder.
123
123
*/
124
- protected OpenAPIBuilder openAPIBuilder ;
124
+ protected OpenAPIService openAPIService ;
125
125
126
126
/**
127
127
* The open api builder object factory.
128
128
*/
129
- private final ObjectFactory <OpenAPIBuilder > openAPIBuilderObjectFactory ;
129
+ private final ObjectFactory <OpenAPIService > openAPIBuilderObjectFactory ;
130
130
131
131
/**
132
132
* The Spring doc config properties.
@@ -141,17 +141,17 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
141
141
/**
142
142
* The Request builder.
143
143
*/
144
- private final AbstractRequestBuilder requestBuilder ;
144
+ private final AbstractRequestService requestBuilder ;
145
145
146
146
/**
147
147
* The Response builder.
148
148
*/
149
- private final GenericResponseBuilder responseBuilder ;
149
+ private final GenericResponseService responseBuilder ;
150
150
151
151
/**
152
152
* The Operation parser.
153
153
*/
154
- private final OperationBuilder operationParser ;
154
+ private final OperationService operationParser ;
155
155
156
156
/**
157
157
* The Open api customisers.
@@ -186,17 +186,17 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
186
186
* @param springDocConfigProperties the spring doc config properties
187
187
* @param actuatorProvider the actuator provider
188
188
*/
189
- protected AbstractOpenApiResource (String groupName , ObjectFactory <OpenAPIBuilder > openAPIBuilderObjectFactory ,
190
- AbstractRequestBuilder requestBuilder ,
191
- GenericResponseBuilder responseBuilder , OperationBuilder operationParser ,
189
+ protected AbstractOpenApiResource (String groupName , ObjectFactory <OpenAPIService > openAPIBuilderObjectFactory ,
190
+ AbstractRequestService requestBuilder ,
191
+ GenericResponseService responseBuilder , OperationService operationParser ,
192
192
Optional <List <OperationCustomizer >> operationCustomizers ,
193
193
Optional <List <OpenApiCustomiser >> openApiCustomisers ,
194
194
SpringDocConfigProperties springDocConfigProperties ,
195
195
Optional <ActuatorProvider > actuatorProvider ) {
196
196
super ();
197
197
this .groupName = Objects .requireNonNull (groupName , "groupName" );
198
198
this .openAPIBuilderObjectFactory = openAPIBuilderObjectFactory ;
199
- this .openAPIBuilder = openAPIBuilderObjectFactory .getObject ();
199
+ this .openAPIService = openAPIBuilderObjectFactory .getObject ();
200
200
this .requestBuilder = requestBuilder ;
201
201
this .responseBuilder = responseBuilder ;
202
202
this .operationParser = operationParser ;
@@ -253,44 +253,44 @@ public static void addHiddenRestControllers(String... classes) {
253
253
*/
254
254
protected synchronized OpenAPI getOpenApi () {
255
255
OpenAPI openApi ;
256
- if (openAPIBuilder .getCachedOpenAPI () == null || springDocConfigProperties .isCacheDisabled ()) {
256
+ if (openAPIService .getCachedOpenAPI () == null || springDocConfigProperties .isCacheDisabled ()) {
257
257
Instant start = Instant .now ();
258
- openAPIBuilder .build ();
259
- Map <String , Object > mappingsMap = openAPIBuilder .getMappingsMap ().entrySet ().stream ()
258
+ openAPIService .build ();
259
+ Map <String , Object > mappingsMap = openAPIService .getMappingsMap ().entrySet ().stream ()
260
260
.filter (controller -> (AnnotationUtils .findAnnotation (controller .getValue ().getClass (),
261
261
Hidden .class ) == null ))
262
262
.filter (controller -> !AbstractOpenApiResource .isHiddenRestControllers (controller .getValue ().getClass ()))
263
263
.collect (Collectors .toMap (Map .Entry ::getKey , Map .Entry ::getValue , (a1 , a2 ) -> a1 ));
264
264
265
- Map <String , Object > findControllerAdvice = openAPIBuilder .getControllerAdviceMap ();
265
+ Map <String , Object > findControllerAdvice = openAPIService .getControllerAdviceMap ();
266
266
// calculate generic responses
267
- openApi = openAPIBuilder .getCalculatedOpenAPI ();
267
+ openApi = openAPIService .getCalculatedOpenAPI ();
268
268
if (springDocConfigProperties .isOverrideWithGenericResponse () && !CollectionUtils .isEmpty (findControllerAdvice )) {
269
269
if (!CollectionUtils .isEmpty (mappingsMap ))
270
270
findControllerAdvice .putAll (mappingsMap );
271
271
responseBuilder .buildGenericResponse (openApi .getComponents (), findControllerAdvice );
272
272
}
273
273
getPaths (mappingsMap );
274
274
if (!CollectionUtils .isEmpty (openApi .getServers ()))
275
- openAPIBuilder .setServersPresent (true );
276
- openAPIBuilder .updateServers (openApi );
275
+ openAPIService .setServersPresent (true );
276
+ openAPIService .updateServers (openApi );
277
277
278
278
if (springDocConfigProperties .isRemoveBrokenReferenceDefinitions ())
279
279
this .removeBrokenReferenceDefinitions (openApi );
280
280
281
281
// run the optional customisers
282
282
openApiCustomisers .ifPresent (apiCustomisers -> apiCustomisers .forEach (openApiCustomiser -> openApiCustomiser .customise (openApi )));
283
283
284
- openAPIBuilder .setCachedOpenAPI (openApi );
285
- openAPIBuilder .resetCalculatedOpenAPI ();
284
+ openAPIService .setCachedOpenAPI (openApi );
285
+ openAPIService .resetCalculatedOpenAPI ();
286
286
287
287
LOGGER .info ("Init duration for springdoc-openapi is: {} ms" ,
288
288
Duration .between (start , Instant .now ()).toMillis ());
289
289
}
290
290
else {
291
- if (!CollectionUtils .isEmpty (openAPIBuilder .getCachedOpenAPI ().getServers ()))
292
- openAPIBuilder .setServersPresent (true );
293
- openApi = openAPIBuilder .updateServers (openAPIBuilder .getCachedOpenAPI ());
291
+ if (!CollectionUtils .isEmpty (openAPIService .getCachedOpenAPI ().getServers ()))
292
+ openAPIService .setServersPresent (true );
293
+ openApi = openAPIService .updateServers (openAPIService .getCachedOpenAPI ());
294
294
}
295
295
return openApi ;
296
296
}
@@ -317,7 +317,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
317
317
String [] headers = routerOperation .getHeaders ();
318
318
Map <String , String > queryParams = routerOperation .getQueryParams ();
319
319
320
- OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
320
+ OpenAPI openAPI = openAPIService .getCalculatedOpenAPI ();
321
321
Components components = openAPI .getComponents ();
322
322
Paths paths = openAPI .getPaths ();
323
323
@@ -363,7 +363,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
363
363
fillParametersList (operation , queryParams , methodAttributes );
364
364
365
365
// compute tags
366
- operation = openAPIBuilder .buildTags (handlerMethod , operation , openAPI );
366
+ operation = openAPIService .buildTags (handlerMethod , operation , openAPI );
367
367
368
368
io .swagger .v3 .oas .annotations .parameters .RequestBody requestBodyDoc = AnnotatedElementUtils .findMergedAnnotation (method ,
369
369
io .swagger .v3 .oas .annotations .parameters .RequestBody .class );
@@ -413,7 +413,7 @@ private void buildCallbacks(OpenAPI openAPI, MethodAttributes methodAttributes,
413
413
* @param routerOperationList the router operation list
414
414
*/
415
415
protected void calculatePath (List <RouterOperation > routerOperationList ) {
416
- ApplicationContext applicationContext = openAPIBuilder .getContext ();
416
+ ApplicationContext applicationContext = openAPIService .getContext ();
417
417
if (!CollectionUtils .isEmpty (routerOperationList )) {
418
418
Collections .sort (routerOperationList );
419
419
for (RouterOperation routerOperation : routerOperationList ) {
@@ -466,7 +466,7 @@ protected void calculatePath(RouterOperation routerOperation) {
466
466
String [] headers = routerOperation .getHeaders ();
467
467
Map <String , String > queryParams = routerOperation .getQueryParams ();
468
468
469
- OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
469
+ OpenAPI openAPI = openAPIService .getCalculatedOpenAPI ();
470
470
Paths paths = openAPI .getPaths ();
471
471
Map <HttpMethod , Operation > operationMap = null ;
472
472
if (paths .containsKey (operationPath )) {
@@ -525,7 +525,7 @@ protected void getRouterFunctionPaths(String beanName, AbstractRouterFunctionVis
525
525
}
526
526
else {
527
527
List <org .springdoc .core .annotations .RouterOperation > routerOperationList = new ArrayList <>();
528
- ApplicationContext applicationContext = openAPIBuilder .getContext ();
528
+ ApplicationContext applicationContext = openAPIService .getContext ();
529
529
RouterOperations routerOperations = applicationContext .findAnnotationOnBean (beanName , RouterOperations .class );
530
530
if (routerOperations == null ) {
531
531
org .springdoc .core .annotations .RouterOperation routerOperation = applicationContext .findAnnotationOnBean (beanName , org .springdoc .core .annotations .RouterOperation .class );
@@ -542,7 +542,6 @@ protected void getRouterFunctionPaths(String beanName, AbstractRouterFunctionVis
542
542
calculatePath (operationList );
543
543
}
544
544
}
545
-
546
545
}
547
546
548
547
/**
@@ -850,7 +849,7 @@ private void fillParametersList(Operation operation, Map<String, String> queryPa
850
849
List <Parameter > parametersList = operation .getParameters ();
851
850
if (parametersList == null )
852
851
parametersList = new ArrayList <>();
853
- Collection <Parameter > headersMap = AbstractRequestBuilder .getHeaders (methodAttributes , new LinkedHashMap <>());
852
+ Collection <Parameter > headersMap = AbstractRequestService .getHeaders (methodAttributes , new LinkedHashMap <>());
854
853
parametersList .addAll (headersMap );
855
854
if (!CollectionUtils .isEmpty (queryParams )) {
856
855
for (Map .Entry <String , String > entry : queryParams .entrySet ()) {
@@ -859,7 +858,7 @@ private void fillParametersList(Operation operation, Map<String, String> queryPa
859
858
parameter .setSchema (new StringSchema ()._default (entry .getValue ()));
860
859
parameter .setRequired (true );
861
860
parameter .setIn (ParameterIn .QUERY .toString ());
862
- GenericParameterBuilder .mergeParameter (parametersList , parameter );
861
+ GenericParameterService .mergeParameter (parametersList , parameter );
863
862
}
864
863
operation .setParameters (parametersList );
865
864
}
@@ -1003,8 +1002,8 @@ else if (existingOperation != null) {
1003
1002
* Init open api builder.
1004
1003
*/
1005
1004
protected void initOpenAPIBuilder () {
1006
- if (openAPIBuilder .getCachedOpenAPI () != null && springDocConfigProperties .isCacheDisabled ()) {
1007
- openAPIBuilder = openAPIBuilderObjectFactory .getObject ();
1005
+ if (openAPIService .getCachedOpenAPI () != null && springDocConfigProperties .isCacheDisabled ()) {
1006
+ openAPIService = openAPIBuilderObjectFactory .getObject ();
1008
1007
}
1009
1008
}
1010
1009
0 commit comments