添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.fasterxml.classmate.TypeResolver; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.Ordered; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.schema.AlternateTypeRule; import springfox.documentation.schema.AlternateTypeRuleConvention; import springfox.documentation.schema.ModelRef; import springfox.documentation.service.ApiInfo; 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; import static springfox.documentation.schema.AlternateTypeRules.newRule; * @author wajn * @date 2019/11/15 21:15 @Profile({"dev", "test"}) @Configuration @EnableSwagger2 public class SwaggerConfig { private List getGlobalOperationParameters() { List pars = new ArrayList<>(1); ParameterBuilder parameterBuilder = new ParameterBuilder(); // header query cookie parameterBuilder.name("DM_AUTH").description("token") .modelRef(new ModelRef("string")).parameterType("header").required(false); pars.add(parameterBuilder.build()); return pars; @Value("${spring.application.name:服务名称}") private String serverName; @Bean public Docket createRestApi() { System.out.println("createRestApi Docket..."); return new Docket(DocumentationType.SWAGGER_2) .globalOperationParameters(getGlobalOperationParameters()) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.dm.td.controller")) .paths(PathSelectors.any()) .build(); private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("api接口文档, 调用此接口必须通过网关") .description("description接口详细介绍,支持markdown格式") .version("1.0") .build(); @Bean public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) { return new AlternateTypeRuleConvention() { @Override public int getOrder() { return Ordered.LOWEST_PRECEDENCE; @Override public List rules() { AlternateTypeRule alternateTypeRule = newRule( resolver.resolve(com.baomidou.mybatisplus.extension.plugins.pagination.Page.class) , resolver.resolve(Page.class)); return new ArrayList() {{ this.add(alternateTypeRule); * 自定义的分页参数说明 @ApiModel @Data static class Page { @ApiModelProperty("每页显示多少数据,默认为10") private long size = 10; * 当前页 @ApiModelProperty("第多少页,从1开始计数,默认为1") private long current = 1; * 排序字段信息 private List orders = new ArrayList<>(); io.springfox springfox-swagger2 2.9.2 io.springfox springfox-swagger-ui 2.9.2 io.swagger swagger-models 1.5.22 io.swagger swagger-annotations 1.5.22 com.github.xiaoymin swagger-bootstrap-ui 1.9.6