Created
September 25, 2017 06:46
-
-
Save RICH0423/2515552e957e608cff973310467d5db9 to your computer and use it in GitHub Desktop.
Pass JWT token in swagger with Spring Boot and springfox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rich.api.config; | |
import java.util.Arrays; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import springfox.documentation.builders.ApiInfoBuilder; | |
import springfox.documentation.builders.PathSelectors; | |
import springfox.documentation.builders.RequestHandlerSelectors; | |
import springfox.documentation.service.ApiInfo; | |
import springfox.documentation.service.ApiKey; | |
import springfox.documentation.service.Contact; | |
import springfox.documentation.spi.DocumentationType; | |
import springfox.documentation.spring.web.plugins.Docket; | |
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |
/** | |
* | |
* @author rich | |
* | |
*/ | |
@Configuration | |
@EnableSwagger2 | |
public class SwaggerConfig { | |
@Bean | |
public Docket api() { | |
return new Docket(DocumentationType.SWAGGER_2) | |
.select() | |
.apis(RequestHandlerSelectors.basePackage("com.delta.ssir.dbee.controller")) | |
.paths(PathSelectors.any()) | |
.build() | |
.apiInfo(apiInfo()) | |
.securitySchemes(Arrays.asList(apiKey())); | |
} | |
private ApiInfo apiInfo() { | |
return new ApiInfoBuilder().title("REST API") | |
.description("The REST API for demo swagger.").termsOfServiceUrl("") | |
.contact(new Contact("RICH LEE", "", "[email protected]")) | |
.license("Apache License Version 2.0") | |
.licenseUrl("https://www.apache.org/licenses/LICENSE-2.0") | |
.version("0.0.1") | |
.build(); | |
} | |
private ApiKey apiKey() { | |
return new ApiKey("authkey", "Authorization", "header"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it's ok! Thank you)