swagger 携带taken做为登录校验

/**
 *
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ import io.swagger.annotations.ApiOperation; 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.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; /** * Swagger配置 * * @author Mark [email protected] * @since 3.0.0 2018-01-16 */ @Configuration @EnableSwagger2 public class SwaggerConfig{ @Bean public Docket createRestApi() { //添加query参数start ParameterBuilder tokenPar = new ParameterBuilder(); List pars = new ArrayList(); tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("query").required(false).build(); pars.add(tokenPar.build()); //添加query参数end return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //加了ApiOperation注解的类,生成接口文档 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) //包下的类,生成接口文档 .apis(RequestHandlerSelectors.basePackage("com.jykj.platform.modules")) .paths(PathSelectors.any()) .build() .globalOperationParameters(pars); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("精英科技") .description("jykj-platform文档") .termsOfServiceUrl("") .version("1.0.0") .build(); } }

可以根据参数权限参数类型 修改parameterType

swagger 携带taken做为登录校验_第1张图片

你可能感兴趣的:(swagger 携带taken做为登录校验)