How to break swagger 2.0 JSON file into multiple modules

后端 未结 8 827
半阙折子戏
半阙折子戏 2020-12-04 09:41

I\'m trying to break my API document up into multiple JSON files that can be edited independently. All the examples I\'ve been able to find use the Swagger 1.2 schema which

8条回答
  •  悲哀的现实
    2020-12-04 10:30

    Swagger JSON can be split in multiple modules by creating docket for each module like this:

    `

    @Bean
    public Docket module1() {
          return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.example.module1"))
            .paths(PathSelectors.any())
            .build()
            .groupName("module1")
            .apiInfo(apiInfo());
    }
    

    `

    For each module URL will be created like http://localhost:xxxx/context-path/v2/api-docs?group=module1

提交回复
热议问题