56
56
import org .springdoc .core .OperationBuilder ;
57
57
import org .springdoc .core .SpringDocConfigProperties ;
58
58
import org .springdoc .core .SpringDocConfigProperties .GroupConfig ;
59
- import org .springdoc .core .annotations .RouterOperation ;
60
59
import org .springdoc .core .customizers .OpenApiCustomiser ;
61
60
import org .springdoc .core .customizers .OperationCustomizer ;
61
+ import org .springdoc .core .models .RouterOperation ;
62
62
63
63
import org .springframework .context .ApplicationContext ;
64
64
import org .springframework .core .annotation .AnnotatedElementUtils ;
@@ -159,7 +159,7 @@ protected synchronized OpenAPI getOpenApi() {
159
159
protected abstract void getPaths (Map <String , Object > findRestControllers );
160
160
161
161
protected void calculatePath (HandlerMethod handlerMethod , String operationPath ,
162
- Set <RequestMethod > requestMethods , String [] methodConsumes , String [] methodProduces ) {
162
+ Set <RequestMethod > requestMethods , String [] methodConsumes , String [] methodProduces , String [] headers ) {
163
163
OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
164
164
Components components = openAPI .getComponents ();
165
165
Paths paths = openAPI .getPaths ();
@@ -180,7 +180,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
180
180
RequestMapping reqMappingClass = AnnotatedElementUtils .findMergedAnnotation (handlerMethod .getBeanType (),
181
181
RequestMapping .class );
182
182
183
- MethodAttributes methodAttributes = new MethodAttributes (springDocConfigProperties .getDefaultConsumesMediaType (), springDocConfigProperties .getDefaultProducesMediaType (), methodConsumes , methodProduces );
183
+ MethodAttributes methodAttributes = new MethodAttributes (springDocConfigProperties .getDefaultConsumesMediaType (), springDocConfigProperties .getDefaultProducesMediaType (), methodConsumes , methodProduces , headers );
184
184
methodAttributes .setMethodOverloaded (existingOperation != null );
185
185
186
186
if (reqMappingClass != null ) {
@@ -238,11 +238,11 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
238
238
}
239
239
}
240
240
241
- protected void calculatePath (String operationPath , Set <RequestMethod > requestMethods , io .swagger .v3 .oas .annotations .Operation apiOperation , String [] methodConsumes , String [] methodProduces ) {
241
+ protected void calculatePath (String operationPath , Set <RequestMethod > requestMethods , io .swagger .v3 .oas .annotations .Operation apiOperation , String [] methodConsumes , String [] methodProduces , String [] headers ) {
242
242
OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
243
243
Paths paths = openAPI .getPaths ();
244
244
for (RequestMethod requestMethod : requestMethods ) {
245
- MethodAttributes methodAttributes = new MethodAttributes (springDocConfigProperties .getDefaultConsumesMediaType (), springDocConfigProperties .getDefaultProducesMediaType (), methodConsumes , methodProduces );
245
+ MethodAttributes methodAttributes = new MethodAttributes (springDocConfigProperties .getDefaultConsumesMediaType (), springDocConfigProperties .getDefaultProducesMediaType (), methodConsumes , methodProduces , headers );
246
246
Operation operation = new Operation ();
247
247
openAPI = operationParser .parse (apiOperation , operation , openAPI , methodAttributes );
248
248
PathItem pathItemObject = buildPathItem (requestMethod , operation , operationPath , paths );
@@ -251,42 +251,42 @@ protected void calculatePath(String operationPath, Set<RequestMethod> requestMet
251
251
}
252
252
253
253
protected void calculatePath (HandlerMethod handlerMethod , String operationPath ,
254
- Set <RequestMethod > requestMethods ){
255
- this .calculatePath (handlerMethod , operationPath ,requestMethods ,null , null );
254
+ Set <RequestMethod > requestMethods ) {
255
+ this .calculatePath (handlerMethod , operationPath , requestMethods , null , null , null );
256
256
}
257
257
258
258
protected void calculatePath (List <RouterOperation > routerOperationList ) {
259
259
ApplicationContext applicationContext = openAPIBuilder .getContext ();
260
260
if (!CollectionUtils .isEmpty (routerOperationList )) {
261
261
for (RouterOperation routerOperation : routerOperationList ) {
262
- if (!Void .class .equals (routerOperation .beanClass ())) {
263
- Object handlerBean = applicationContext .getBean (routerOperation .beanClass ());
262
+ if (!Void .class .equals (routerOperation .getBeanClass ())) {
263
+ Object handlerBean = applicationContext .getBean (routerOperation .getBeanClass ());
264
264
HandlerMethod handlerMethod = null ;
265
- if (StringUtils .isNotBlank (routerOperation .beanMethod ())) {
265
+ if (StringUtils .isNotBlank (routerOperation .getBeanMethod ())) {
266
266
try {
267
- if (ArrayUtils .isEmpty (routerOperation .parameterTypes ())) {
267
+ if (ArrayUtils .isEmpty (routerOperation .getParameterTypes ())) {
268
268
Optional <Method > methodOptional = Arrays .stream (handlerBean .getClass ().getDeclaredMethods ())
269
- .filter (method -> routerOperation .beanMethod ().equals (method .getName ()) && method .getParameters ().length == 0 )
269
+ .filter (method -> routerOperation .getBeanMethod ().equals (method .getName ()) && method .getParameters ().length == 0 )
270
270
.findAny ();
271
271
if (!methodOptional .isPresent ())
272
272
methodOptional = Arrays .stream (handlerBean .getClass ().getDeclaredMethods ())
273
- .filter (method1 -> routerOperation .beanMethod ().equals (method1 .getName ()))
273
+ .filter (method1 -> routerOperation .getBeanMethod ().equals (method1 .getName ()))
274
274
.findAny ();
275
275
if (methodOptional .isPresent ())
276
276
handlerMethod = new HandlerMethod (handlerBean , methodOptional .get ());
277
277
}
278
278
else
279
- handlerMethod = new HandlerMethod (handlerBean , routerOperation .beanMethod (), routerOperation .parameterTypes ());
279
+ handlerMethod = new HandlerMethod (handlerBean , routerOperation .getBeanMethod (), routerOperation .getParameterTypes ());
280
280
}
281
281
catch (NoSuchMethodException e ) {
282
282
LOGGER .error (e .getMessage ());
283
283
}
284
- if (handlerMethod != null && isPackageToScan (handlerMethod .getBeanType ().getPackage ().getName ()) && isPathToMatch (routerOperation .path ()))
285
- calculatePath (handlerMethod , routerOperation .path (), new HashSet <>(Arrays .asList (routerOperation .method ())), routerOperation .consumes (), routerOperation .produces ());
284
+ if (handlerMethod != null && isPackageToScan (handlerMethod .getBeanType ().getPackage ().getName ()) && isPathToMatch (routerOperation .getPath ()))
285
+ calculatePath (handlerMethod , routerOperation .getPath (), new HashSet <>(Arrays .asList (routerOperation .getMethod ())), routerOperation .getConsumes (), routerOperation .getProduces (), routerOperation . getHeaders ());
286
286
}
287
287
}
288
- else if (StringUtils .isNotBlank (routerOperation .operation ().operationId ())) {
289
- calculatePath (routerOperation .path (), new HashSet <>(Arrays .asList (routerOperation .method ())), routerOperation .operation (), routerOperation .consumes (), routerOperation .produces ());
288
+ else if (StringUtils .isNotBlank (routerOperation .getOperation ().operationId ())) {
289
+ calculatePath (routerOperation .getPath (), new HashSet <>(Arrays .asList (routerOperation .getMethod ())), routerOperation .getOperation (), routerOperation .getConsumes (), routerOperation .getProduces (), routerOperation . getHeaders ());
290
290
}
291
291
}
292
292
}
0 commit comments