RequestHandlerProvider evaluated too early for Spring-Integration
See original GitHub issueVersion 3.0.0-SNAPSHOT
Issue Kind: Bug Report (possibly)
Following https://github.com/springfox/springfox/issues/550 I have started to implement support for spring-integration in spring-boot 2.
I have tried to follow the approach taken by the WebFlux support by adding a RequestHandlerProvider
plugin which uses the IntegrationRequestMappingHandlerMapping
internally.
The Springfox DocumentationPluginsBootstrapper
evaluates my RequestHandlerProvider
, but at that point, the mappingRegistry
of the IntegrationRequestMappingHandlerMapping
is still empty. The reason is that the IntegrationRequestMappingHandlerMapping
purposefully postpones the call to detectHandlerMethods
, it happens not in afterPropertiesSet
, but on ContextRefreshedEvent
. This code is from IntegrationRequestMappingHandlerMapping
:
@Override
public void afterPropertiesSet() {
// No-op in favor of onApplicationEvent
}
/**
* {@link HttpRequestHandlingEndpointSupport}s may depend on auto-created
* {@code requestChannel}s, so MVC Handlers detection should be postponed
* as late as possible.
* @see RequestMappingHandlerMapping#afterPropertiesSet()
*/
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (!this.initialized.getAndSet(true)) {
super.afterPropertiesSet();
}
}
It seems that DocumentationPluginsBootstrapper
wrongly assumes it can rely on all RequestHandlerProvider
s to be initialized when it collects the request handlers. It returns Integer.MAX_VALUE in getPhase
to ensure this, but apparently that is not enough.
One possibility might be to change DocumentationPluginsBootstrapper
so that it initializes last on ContextRefreshedEvent (with very low precedence) or something else which is more appropriate.
What do you think?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
PR: https://github.com/springfox/springfox/pull/2793, closing
The usual swagger annotations are a challenge, since there is no code to annotate in SI. I am considering to use spring-restdoc or a similar approach: mvc or webclient tests document inputs and outputs as documentation snippets. They generate adoc snippets. Is there a plugin to include external documentation fragments already?