Generate swagger JSON file at compile time for springfox based project

10,028

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

Share:
10,028

Related videos on Youtube

Mayur
Author by

Mayur

Expertises in JAVA, AWS, Python with 4+ years of development experience

Updated on June 04, 2022

Comments

  • Mayur
    Mayur almost 2 years

    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