swagger的一些配置



import java.util.Collections;
import java.util.List;

@Configuration
@EnableSwagger2
public class Swagger2Configure {


    public List<Parameter> createParameters() {
        ParameterBuilder token = new ParameterBuilder()
                .name("access-token")
                .description("認證token")
                .modelRef(new ModelRef("string"))
                .parameterType("header")
                .required(false);
        return Collections.singletonList(token.build());
    }


    @Bean
    public Docket createRestEccApi() {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("輸電通道API")
                .description("")
                .contact(new Contact("jinzhuan", "", ""))
                .version("1.0")
                .build();
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .groupName("輸電通道API")
                .select()
                //爲當前包下controller生成API文檔
                .apis(RequestHandlerSelectors.basePackage("com.jzxs.etp.controller"))
                .paths(PathSelectors.any())
                .build()
                .globalOperationParameters(createParameters());
    }

    @Bean
    public Docket createRestAuthApi() {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("權限API")
                .description("")
                .contact(new Contact("jinzhuan", "", ""))
                .version("1.0")
                .build();
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .groupName("權限API")
                .select()
                //爲當前包下controller生成API文檔
                .apis(RequestHandlerSelectors.basePackage("org.aurochsframework.boot.authorization.controller"))
                .paths(PathSelectors.any())
                .build()
                .globalOperationParameters(createParameters());
    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章