swagger2笔记

2020-03-30  本文已影响0人  我是电饭煲

swagger2搭建

<!-- swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>26.0-jre</version>
        </dependency>
/**
 * Swagger2 配置类
 * @author yuanfeng.z
 * @date 2019/11/25 16:28
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {
    @Bean
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()// 指定需要展现的api接口
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)) // 扫描接口
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfo("用户服务",
                "用户服务",
                "v0.0.1",
                "",
                null,
                "",
                "",
                new ArrayList<>());
    }
}
@Api(tags = "会员管理")
@ApiOperation(value = "register", notes = "注册", httpMethod = "POST")

https://blog.csdn.net/liuchuanhong1/article/details/59064794
https://blog.csdn.net/liuchuanhong1/article/details/58594045

上一篇 下一篇

猜你喜欢

热点阅读