swagger API DOC

swagger引入

在pom或者上级pom中引入相关包

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.5.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.2.2</version>
</dependency>

配置swagger服务器

@Configuration
@EnableSwagger2
public class MonitorConfigSwagger {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.hisense.monitor.config.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("配置中心监控中的API")
                .description("版权所有:海信智能商用")
                .termsOfServiceUrl("http://saas.hi.com/")
                .contact("SAAS平台组")
                .version("1.0")
                .build();
    }
}

Controller中配置

@ApiOperation(value="获取当前应用的详细配置", notes="获取当前应用的详细配置")
@ApiImplicitParam(name = "params", value = "配置信息", required = true)
@RequestMapping(value = "/gettablecurpros", method = RequestMethod.POST)
public Object getCurMongoTablePro(@RequestParam String params) {
    return iConfigService.getCurMongoTablePro(params);
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容