Generate swagger JSON file at compile time for springfox based project

拜拜、爱过 提交于 2020-05-13 05:07:16

问题


I have working project which is using springfox to generate API documentations.

I want to generate swagger.json at compile time.

following is sample springfox configuration,

@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


回答1:


This is achieved using JUnit test case, follow https://github.com/springfox/springfox/issues/1959 for more details.



来源:https://stackoverflow.com/questions/53848917/generate-swagger-json-file-at-compile-time-for-springfox-based-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!