简体   繁体   English

在编译时为基于springfox的项目生成swagger JSON文件

[英]Generate swagger JSON file at compile time for springfox based project

I have working project which is using springfox to generate API documentations. 我有一个工作项目,它使用springfox生成API文档。

I want to generate swagger.json at compile time . 我想在编译时生成swagger.json。

following is sample springfox configuration, 以下是springfox配置示例,

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()                 
                .apis(RequestHandlerSelectors.basePackage("com.abc.xyz"))
                .paths(regex("/*.*"))
                .build();
    }
}

FYI : I have also tried https://github.com/kongchen/swagger-maven-plugin plugin but it's not working 仅供参考:我也尝试过https://github.com/kongchen/swagger-maven-plugin插件,但它不能正常工作

这是使用JUnit测试用例实现的, 请访问https://github.com/springfox/springfox/issues/1959以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM