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 ;
@@ -119,12 +119,12 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
119
119
/**
120
120
* The Open api builder.
121
121
*/
122
- protected OpenAPIBuilder openAPIBuilder ;
122
+ protected OpenAPIService openAPIService ;
123
123
124
124
/**
125
125
* The open api builder object factory.
126
126
*/
127
- private final ObjectFactory <OpenAPIBuilder > openAPIBuilderObjectFactory ;
127
+ private final ObjectFactory <OpenAPIService > openAPIBuilderObjectFactory ;
128
128
129
129
/**
130
130
* The Spring doc config properties.
@@ -139,17 +139,17 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
139
139
/**
140
140
* The Request builder.
141
141
*/
142
- private final AbstractRequestBuilder requestBuilder ;
142
+ private final AbstractRequestService requestBuilder ;
143
143
144
144
/**
145
145
* The Response builder.
146
146
*/
147
- private final GenericResponseBuilder responseBuilder ;
147
+ private final GenericResponseService responseBuilder ;
148
148
149
149
/**
150
150
* The Operation parser.
151
151
*/
152
- private final OperationBuilder operationParser ;
152
+ private final OperationService operationParser ;
153
153
154
154
/**
155
155
* The Open api customisers.
@@ -184,17 +184,17 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
184
184
* @param springDocConfigProperties the spring doc config properties
185
185
* @param actuatorProvider the actuator provider
186
186
*/
187
- protected AbstractOpenApiResource (String groupName , ObjectFactory <OpenAPIBuilder > openAPIBuilderObjectFactory ,
188
- AbstractRequestBuilder requestBuilder ,
189
- GenericResponseBuilder responseBuilder , OperationBuilder operationParser ,
187
+ protected AbstractOpenApiResource (String groupName , ObjectFactory <OpenAPIService > openAPIBuilderObjectFactory ,
188
+ AbstractRequestService requestBuilder ,
189
+ GenericResponseService responseBuilder , OperationService operationParser ,
190
190
Optional <List <OperationCustomizer >> operationCustomizers ,
191
191
Optional <List <OpenApiCustomiser >> openApiCustomisers ,
192
192
SpringDocConfigProperties springDocConfigProperties ,
193
193
Optional <ActuatorProvider > actuatorProvider ) {
194
194
super ();
195
195
this .groupName = Objects .requireNonNull (groupName , "groupName" );
196
196
this .openAPIBuilderObjectFactory = openAPIBuilderObjectFactory ;
197
- this .openAPIBuilder = openAPIBuilderObjectFactory .getObject ();
197
+ this .openAPIService = openAPIBuilderObjectFactory .getObject ();
198
198
this .requestBuilder = requestBuilder ;
199
199
this .responseBuilder = responseBuilder ;
200
200
this .operationParser = operationParser ;
@@ -251,44 +251,44 @@ public static void addHiddenRestControllers(String... classes) {
251
251
*/
252
252
protected synchronized OpenAPI getOpenApi () {
253
253
OpenAPI openApi ;
254
- if (openAPIBuilder .getCachedOpenAPI () == null || springDocConfigProperties .isCacheDisabled ()) {
254
+ if (openAPIService .getCachedOpenAPI () == null || springDocConfigProperties .isCacheDisabled ()) {
255
255
Instant start = Instant .now ();
256
- openAPIBuilder .build ();
257
- Map <String , Object > mappingsMap = openAPIBuilder .getMappingsMap ().entrySet ().stream ()
256
+ openAPIService .build ();
257
+ Map <String , Object > mappingsMap = openAPIService .getMappingsMap ().entrySet ().stream ()
258
258
.filter (controller -> (AnnotationUtils .findAnnotation (controller .getValue ().getClass (),
259
259
Hidden .class ) == null ))
260
260
.filter (controller -> !AbstractOpenApiResource .isHiddenRestControllers (controller .getValue ().getClass ()))
261
261
.collect (Collectors .toMap (Map .Entry ::getKey , Map .Entry ::getValue , (a1 , a2 ) -> a1 ));
262
262
263
- Map <String , Object > findControllerAdvice = openAPIBuilder .getControllerAdviceMap ();
263
+ Map <String , Object > findControllerAdvice = openAPIService .getControllerAdviceMap ();
264
264
// calculate generic responses
265
- openApi = openAPIBuilder .getCalculatedOpenAPI ();
265
+ openApi = openAPIService .getCalculatedOpenAPI ();
266
266
if (springDocConfigProperties .isOverrideWithGenericResponse () && !CollectionUtils .isEmpty (findControllerAdvice )) {
267
267
if (!CollectionUtils .isEmpty (mappingsMap ))
268
268
findControllerAdvice .putAll (mappingsMap );
269
269
responseBuilder .buildGenericResponse (openApi .getComponents (), findControllerAdvice );
270
270
}
271
271
getPaths (mappingsMap );
272
272
if (!CollectionUtils .isEmpty (openApi .getServers ()))
273
- openAPIBuilder .setServersPresent (true );
274
- openAPIBuilder .updateServers (openApi );
273
+ openAPIService .setServersPresent (true );
274
+ openAPIService .updateServers (openApi );
275
275
276
276
if (springDocConfigProperties .isRemoveBrokenReferenceDefinitions ())
277
277
this .removeBrokenReferenceDefinitions (openApi );
278
278
279
279
// run the optional customisers
280
280
openApiCustomisers .ifPresent (apiCustomisers -> apiCustomisers .forEach (openApiCustomiser -> openApiCustomiser .customise (openApi )));
281
281
282
- openAPIBuilder .setCachedOpenAPI (openApi );
283
- openAPIBuilder .resetCalculatedOpenAPI ();
282
+ openAPIService .setCachedOpenAPI (openApi );
283
+ openAPIService .resetCalculatedOpenAPI ();
284
284
285
285
LOGGER .info ("Init duration for springdoc-openapi is: {} ms" ,
286
286
Duration .between (start , Instant .now ()).toMillis ());
287
287
}
288
288
else {
289
- if (!CollectionUtils .isEmpty (openAPIBuilder .getCachedOpenAPI ().getServers ()))
290
- openAPIBuilder .setServersPresent (true );
291
- openApi = openAPIBuilder .updateServers (openAPIBuilder .getCachedOpenAPI ());
289
+ if (!CollectionUtils .isEmpty (openAPIService .getCachedOpenAPI ().getServers ()))
290
+ openAPIService .setServersPresent (true );
291
+ openApi = openAPIService .updateServers (openAPIService .getCachedOpenAPI ());
292
292
}
293
293
return openApi ;
294
294
}
@@ -315,7 +315,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
315
315
String [] headers = routerOperation .getHeaders ();
316
316
Map <String , String > queryParams = routerOperation .getQueryParams ();
317
317
318
- OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
318
+ OpenAPI openAPI = openAPIService .getCalculatedOpenAPI ();
319
319
Components components = openAPI .getComponents ();
320
320
Paths paths = openAPI .getPaths ();
321
321
@@ -361,7 +361,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
361
361
fillParametersList (operation , queryParams , methodAttributes );
362
362
363
363
// compute tags
364
- operation = openAPIBuilder .buildTags (handlerMethod , operation , openAPI );
364
+ operation = openAPIService .buildTags (handlerMethod , operation , openAPI );
365
365
366
366
io .swagger .v3 .oas .annotations .parameters .RequestBody requestBodyDoc = AnnotatedElementUtils .findMergedAnnotation (method ,
367
367
io .swagger .v3 .oas .annotations .parameters .RequestBody .class );
@@ -411,7 +411,7 @@ private void buildCallbacks(OpenAPI openAPI, MethodAttributes methodAttributes,
411
411
* @param routerOperationList the router operation list
412
412
*/
413
413
protected void calculatePath (List <RouterOperation > routerOperationList ) {
414
- ApplicationContext applicationContext = openAPIBuilder .getContext ();
414
+ ApplicationContext applicationContext = openAPIService .getContext ();
415
415
if (!CollectionUtils .isEmpty (routerOperationList )) {
416
416
Collections .sort (routerOperationList );
417
417
for (RouterOperation routerOperation : routerOperationList ) {
@@ -464,7 +464,7 @@ protected void calculatePath(RouterOperation routerOperation) {
464
464
String [] headers = routerOperation .getHeaders ();
465
465
Map <String , String > queryParams = routerOperation .getQueryParams ();
466
466
467
- OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
467
+ OpenAPI openAPI = openAPIService .getCalculatedOpenAPI ();
468
468
Paths paths = openAPI .getPaths ();
469
469
Map <HttpMethod , Operation > operationMap = null ;
470
470
if (paths .containsKey (operationPath )) {
@@ -516,7 +516,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
516
516
*/
517
517
protected void getRouterFunctionPaths (String beanName , AbstractRouterFunctionVisitor routerFunctionVisitor ) {
518
518
List <org .springdoc .core .annotations .RouterOperation > routerOperationList = new ArrayList <>();
519
- ApplicationContext applicationContext = openAPIBuilder .getContext ();
519
+ ApplicationContext applicationContext = openAPIService .getContext ();
520
520
RouterOperations routerOperations = applicationContext .findAnnotationOnBean (beanName , RouterOperations .class );
521
521
if (routerOperations == null ) {
522
522
org .springdoc .core .annotations .RouterOperation routerOperation = applicationContext .findAnnotationOnBean (beanName , org .springdoc .core .annotations .RouterOperation .class );
@@ -839,7 +839,7 @@ private void fillParametersList(Operation operation, Map<String, String> queryPa
839
839
List <Parameter > parametersList = operation .getParameters ();
840
840
if (parametersList == null )
841
841
parametersList = new ArrayList <>();
842
- Collection <Parameter > headersMap = AbstractRequestBuilder .getHeaders (methodAttributes , new LinkedHashMap <>());
842
+ Collection <Parameter > headersMap = AbstractRequestService .getHeaders (methodAttributes , new LinkedHashMap <>());
843
843
parametersList .addAll (headersMap );
844
844
if (!CollectionUtils .isEmpty (queryParams )) {
845
845
for (Map .Entry <String , String > entry : queryParams .entrySet ()) {
@@ -848,7 +848,7 @@ private void fillParametersList(Operation operation, Map<String, String> queryPa
848
848
parameter .setSchema (new StringSchema ()._default (entry .getValue ()));
849
849
parameter .setRequired (true );
850
850
parameter .setIn (ParameterIn .QUERY .toString ());
851
- GenericParameterBuilder .mergeParameter (parametersList , parameter );
851
+ GenericParameterService .mergeParameter (parametersList , parameter );
852
852
}
853
853
operation .setParameters (parametersList );
854
854
}
@@ -992,8 +992,8 @@ else if (existingOperation != null) {
992
992
* Init open api builder.
993
993
*/
994
994
protected void initOpenAPIBuilder () {
995
- if (openAPIBuilder .getCachedOpenAPI () != null && springDocConfigProperties .isCacheDisabled ()) {
996
- openAPIBuilder = openAPIBuilderObjectFactory .getObject ();
995
+ if (openAPIService .getCachedOpenAPI () != null && springDocConfigProperties .isCacheDisabled ()) {
996
+ openAPIService = openAPIBuilderObjectFactory .getObject ();
997
997
}
998
998
}
999
999
0 commit comments