我试图用Spring Integration公开rest API并用swagger记录它。它甚至可能吗?我找不到任何文档或示例来使其工作。
我的招摇文章豆:
Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
简单的流程:
@Bean
public IntegrationFlow inbound() {
return IntegrationFlows.from(Http.inboundGateway("/foo")
.requestMapping(m -> m.methods(HttpMethod.GET))
.requestPayloadType(String.class))
.channel("httpRequest")
.get();
}
我使用spring boot:2.0.1和springfox-swagger2:2.8.0
提前感谢, Mateusz
答案 0 :(得分:0)
这是我的示例代码。
<强>的Maven 强>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
<强>配置强>
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/open/api/**")).build();
}
}
答案 1 :(得分:0)
springfox当前不支持Spring Integration,尽管它们基于IntegrationRequestMappingHandlerMapping提供了通用化,似乎可以实现: https://github.com/springfox/springfox/issues/550
他们要求实施PR的PR: https://github.com/springfox/springfox/issues/797