SwaggerConfig.java 1.34 KB
Newer Older
xd's avatar
xd committed
1 2 3 4 5
package com.tanpu.community.config;

import com.tanpu.community.api.CommunityConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
刘基明's avatar
刘基明 committed
6
import org.springframework.context.annotation.Profile;
xd's avatar
xd committed
7 8 9 10 11 12
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
刘基明's avatar
刘基明 committed
13
import springfox.documentation.swagger2.annotations.EnableSwagger2;
xd's avatar
xd committed
14 15 16 17

/**
 * created by xd on 2021/5/17
 */
刘基明's avatar
刘基明 committed
18
@Profile("test")
xd's avatar
xd committed
19
@Configuration
刘基明's avatar
刘基明 committed
20
@EnableSwagger2
xd's avatar
xd committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
public class SwaggerConfig {

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("community title")
                .description("community description")
                .version("1.0.0")
                .build();
    }

    @Bean
    public Docket restApi() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
刘基明's avatar
刘基明 committed
36
                .apis(RequestHandlerSelectors.basePackage(CommunityConstant.PACKAGE_BASE+".controller"))
xd's avatar
xd committed
37 38 39 40 41 42
                .paths(PathSelectors.any())
                .build();

        return docket;
    }
}