对比新文件 |
| | |
| | | package com.gk.firework.Config.Swagger; |
| | | |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | 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.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.*; |
| | | |
| | | @Configuration |
| | | @EnableSwagger2 |
| | | public class SwaggerConfig { |
| | | |
| | | @Bean |
| | | public Docket docket() { |
| | | ParameterBuilder ticketPar = new ParameterBuilder(); |
| | | List<Parameter> pars = new ArrayList<Parameter>(); |
| | | ticketPar.name("Authorization").description("token") |
| | | .modelRef(new ModelRef("string")).parameterType("header") |
| | | .required(false).build(); //header中的ticket参数非必填,传空也可以 |
| | | pars.add(ticketPar.build()); |
| | | |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | .select().apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)) |
| | | .paths(PathSelectors.any()) |
| | | .build().globalOperationParameters(pars).apiInfo(new ApiInfoBuilder() |
| | | .description("烟花爆竹流向管理系统接口文档").contact(new Contact("李宇", "", "986321569@qq.com")) |
| | | .version("1.0").title("API文档").license("Apache2.0") |
| | | .licenseUrl("http://www.apache.org/licnesens/LINCENSE-2.0").build()); |
| | | } |
| | | |
| | | } |