Added auth to swagger-ui
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
7c7045c0e1
commit
029300815e
@ -1,12 +1,18 @@
|
||||
package com.plannaplan;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import springfox.documentation.service.Parameter;
|
||||
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.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
@ -18,9 +24,15 @@ public class Swagger2Config extends WebMvcConfigurationSupport {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
Parameter authHeader = new ParameterBuilder()
|
||||
.parameterType("header")
|
||||
.name("Authorization")
|
||||
.modelRef(new ModelRef("string"))
|
||||
.build();
|
||||
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.plannaplan")).paths(PathSelectors.any())
|
||||
.build();
|
||||
.build()
|
||||
.globalOperationParameters(Collections.singletonList(authHeader));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user