swagger API DOC

swagger引入

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


    io.springfox
    springfox-swagger2
    2.5.0


    io.springfox
    springfox-swagger-ui
    2.2.2

配置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);
}

你可能感兴趣的:(swagger API DOC)