sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.93k stars 1.26k forks source link

Endpoint RESTful 接口是否支持 Swagger #338

Closed alswl closed 5 years ago

alswl commented 5 years ago

测试下来 8341 端口里面的 javax.ws.rs 接口无法通过包扫描暴露到 Swagger UI 上,只能将 8080 端口里面的 Controller API 暴露出来。

有人遇到这个问题么?是否有什么额外配置。我目前 SwaggerConfig 配置如下:

@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurationSupport {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.test.module.endpoint.facade"))
                .paths(PathSelectors.any())
                .build();

    }

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");

        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
alswl commented 5 years ago

https://github.com/alipay/sofa-rpc/issues/377

alswl commented 5 years ago

搞了一会还挺麻烦,springfox / swagger 对 ws.rs 的支持就假设了前提:使用 Jersey 实现 javax.ws.rs。 SOFA Boot 是 sofa-rest-api 提供了实现(不确定)。

QilongZhang commented 5 years ago

关于和 swagger 集成的方案参考 https://www.sofastack.tech/sofa-rpc/docs/RESTful-Swagger 文档。