5656import org .springdoc .core .OperationBuilder ;
5757import org .springdoc .core .SpringDocConfigProperties ;
5858import org .springdoc .core .SpringDocConfigProperties .GroupConfig ;
59- import org .springdoc .core .annotations .RouterOperation ;
6059import org .springdoc .core .customizers .OpenApiCustomiser ;
6160import org .springdoc .core .customizers .OperationCustomizer ;
61+ import org .springdoc .core .models .RouterOperation ;
6262
6363import org .springframework .context .ApplicationContext ;
6464import org .springframework .core .annotation .AnnotatedElementUtils ;
@@ -159,7 +159,7 @@ protected synchronized OpenAPI getOpenApi() {
159159 protected abstract void getPaths (Map <String , Object > findRestControllers );
160160
161161 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 ) {
163163 OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
164164 Components components = openAPI .getComponents ();
165165 Paths paths = openAPI .getPaths ();
@@ -180,7 +180,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
180180 RequestMapping reqMappingClass = AnnotatedElementUtils .findMergedAnnotation (handlerMethod .getBeanType (),
181181 RequestMapping .class );
182182
183- MethodAttributes methodAttributes = new MethodAttributes (springDocConfigProperties .getDefaultConsumesMediaType (), springDocConfigProperties .getDefaultProducesMediaType (), methodConsumes , methodProduces );
183+ MethodAttributes methodAttributes = new MethodAttributes (springDocConfigProperties .getDefaultConsumesMediaType (), springDocConfigProperties .getDefaultProducesMediaType (), methodConsumes , methodProduces , headers );
184184 methodAttributes .setMethodOverloaded (existingOperation != null );
185185
186186 if (reqMappingClass != null ) {
@@ -238,11 +238,11 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
238238 }
239239 }
240240
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 ) {
242242 OpenAPI openAPI = openAPIBuilder .getCalculatedOpenAPI ();
243243 Paths paths = openAPI .getPaths ();
244244 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 );
246246 Operation operation = new Operation ();
247247 openAPI = operationParser .parse (apiOperation , operation , openAPI , methodAttributes );
248248 PathItem pathItemObject = buildPathItem (requestMethod , operation , operationPath , paths );
@@ -251,42 +251,42 @@ protected void calculatePath(String operationPath, Set<RequestMethod> requestMet
251251 }
252252
253253 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 );
256256 }
257257
258258 protected void calculatePath (List <RouterOperation > routerOperationList ) {
259259 ApplicationContext applicationContext = openAPIBuilder .getContext ();
260260 if (!CollectionUtils .isEmpty (routerOperationList )) {
261261 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 ());
264264 HandlerMethod handlerMethod = null ;
265- if (StringUtils .isNotBlank (routerOperation .beanMethod ())) {
265+ if (StringUtils .isNotBlank (routerOperation .getBeanMethod ())) {
266266 try {
267- if (ArrayUtils .isEmpty (routerOperation .parameterTypes ())) {
267+ if (ArrayUtils .isEmpty (routerOperation .getParameterTypes ())) {
268268 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 )
270270 .findAny ();
271271 if (!methodOptional .isPresent ())
272272 methodOptional = Arrays .stream (handlerBean .getClass ().getDeclaredMethods ())
273- .filter (method1 -> routerOperation .beanMethod ().equals (method1 .getName ()))
273+ .filter (method1 -> routerOperation .getBeanMethod ().equals (method1 .getName ()))
274274 .findAny ();
275275 if (methodOptional .isPresent ())
276276 handlerMethod = new HandlerMethod (handlerBean , methodOptional .get ());
277277 }
278278 else
279- handlerMethod = new HandlerMethod (handlerBean , routerOperation .beanMethod (), routerOperation .parameterTypes ());
279+ handlerMethod = new HandlerMethod (handlerBean , routerOperation .getBeanMethod (), routerOperation .getParameterTypes ());
280280 }
281281 catch (NoSuchMethodException e ) {
282282 LOGGER .error (e .getMessage ());
283283 }
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 ());
286286 }
287287 }
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 ());
290290 }
291291 }
292292 }
0 commit comments