You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The order of injection and execution of user-defined OpenApiCustomiser beans appears to be controllable via the standard Spring means (annotate with @Order or implement org.springframework.core.Ordered). However, this is not true of GlobalOpenApiCustomizer beans which appear to be injected/executed in the order they happened to be defined in the backend configuration. It is particularly confusing when there are multiple beans that implement both interfaces - the order of execution changes depending on whether the api-docs URL used is grouped vs non-grouped.
To Reproduce
Steps to reproduce the behavior:
Using spring-boot 2.7.6
Using springdoc-openapi 1.6.14.
Run the below Spring Boot app
Open http://localhost:8080/v3/api-docs in a browser
Observe the console output and notice that customizers are executed in order 1, 2, 3.
Open http://localhost:8080/v3/api-docs/mygroup in a browser
Observe the console output and notice that customizers are executed in order 3, 2, 1.
The ordering behavior should be the same for GlobalOpenApiCustomizer and OpenApiCustomiser beans.
Ideally ordering would be controllable via standard Spring means (e.g. @Order).
Additional Context
I believe this is due to the fact that MultipleOpenApiResource.afterPropertiesSet() (only used for group-configs?) obtains its list of GlobalOpenApiCustomizers via ApplicationContext.getBeansOfType(Class), which is documented to return beans in the "order of the backend configuration", whereas the OpenApiWebResource (used for non-grouped) is autowired and therefore is controllable via standard means (e.g @Order).
The text was updated successfully, but these errors were encountered:
Describe the bug
The order of injection and execution of user-defined
OpenApiCustomiser
beans appears to be controllable via the standard Spring means (annotate with@Order
or implementorg.springframework.core.Ordered
). However, this is not true ofGlobalOpenApiCustomizer
beans which appear to be injected/executed in the order they happened to be defined in the backend configuration. It is particularly confusing when there are multiple beans that implement both interfaces - the order of execution changes depending on whether the api-docs URL used is grouped vs non-grouped.To Reproduce
Steps to reproduce the behavior:
http://localhost:8080/v3/api-docs
in a browserhttp://localhost:8080/v3/api-docs/mygroup
in a browserExpected behavior
GlobalOpenApiCustomizer
andOpenApiCustomiser
beans.@Order
).Additional Context
I believe this is due to the fact that
MultipleOpenApiResource.afterPropertiesSet()
(only used for group-configs?) obtains its list ofGlobalOpenApiCustomizer
s viaApplicationContext.getBeansOfType(Class)
, which is documented to return beans in the "order of the backend configuration", whereas theOpenApiWebResource
(used for non-grouped) is autowired and therefore is controllable via standard means (e.g@Order
).The text was updated successfully, but these errors were encountered: