package com.chinaweal.youfool.prj.config; import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.schema.ModelRef; import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; import springfox.documentation.service.Parameter; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.ArrayList; import java.util.List; @Configuration @EnableSwagger2 @EnableKnife4j public class SwaggerKnife4j { @Value("${applicationName}") private String applicationName; @Value("${version}") private String version; @Value("${description}") private String description; @Value("${license}") private String license; @Bean("youfool") public Docket youfoolApi() { //添加head参数start return new Docket(DocumentationType.SWAGGER_2) .enable(true) .apiInfo(apiInfo()) .groupName("基础框架") .select() .apis(RequestHandlerSelectors.basePackage("com.chinaweal.youfool.framework.springboot.cms")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title(applicationName) .description(description) .termsOfServiceUrl("https://www.chinaweal.com.cn") .version(version) .contact(new Contact("chinaweal", "https://www.chinaweal.com.cn", "")) .license(license) .licenseUrl("https://www.chinaweal.com.cn") .build(); } }