2020-11-04 15:09:44 +01:00
|
|
|
package com.plannaplan;
|
|
|
|
|
2020-11-09 17:08:51 +01:00
|
|
|
import java.util.Collections;
|
|
|
|
|
2020-11-04 15:09:44 +01:00
|
|
|
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;
|
2020-11-09 17:08:51 +01:00
|
|
|
|
|
|
|
import springfox.documentation.service.Parameter;
|
2020-11-04 15:09:44 +01:00
|
|
|
import springfox.documentation.builders.ApiInfoBuilder;
|
2020-11-09 17:08:51 +01:00
|
|
|
import springfox.documentation.builders.ParameterBuilder;
|
2020-11-04 15:09:44 +01:00
|
|
|
import springfox.documentation.builders.PathSelectors;
|
|
|
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
2020-11-09 17:08:51 +01:00
|
|
|
import springfox.documentation.schema.ModelRef;
|
2020-11-04 15:09:44 +01:00
|
|
|
import springfox.documentation.service.ApiInfo;
|
|
|
|
import springfox.documentation.spi.DocumentationType;
|
|
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
|
|
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@EnableSwagger2
|
|
|
|
public class Swagger2Config extends WebMvcConfigurationSupport {
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
public Docket createRestApi() {
|
2020-11-09 17:08:51 +01:00
|
|
|
Parameter authHeader = new ParameterBuilder()
|
|
|
|
.parameterType("header")
|
|
|
|
.name("Authorization")
|
|
|
|
.modelRef(new ModelRef("string"))
|
|
|
|
.build();
|
2020-11-04 15:09:44 +01:00
|
|
|
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
|
2020-11-08 16:55:56 +01:00
|
|
|
.apis(RequestHandlerSelectors.basePackage("com.plannaplan")).paths(PathSelectors.any())
|
2020-11-09 17:08:51 +01:00
|
|
|
.build()
|
|
|
|
.globalOperationParameters(Collections.singletonList(authHeader));
|
2020-11-04 15:09:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
|
|
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
|
}
|
|
|
|
|
|
|
|
private ApiInfo apiInfo() {
|
2020-11-04 16:40:02 +01:00
|
|
|
return new ApiInfoBuilder().title("plannaplan").description("Aplikacja do zapisów na zajęcia UAM.")
|
|
|
|
.termsOfServiceUrl("https://plannaplan.pl/")
|
2020-11-04 15:09:44 +01:00
|
|
|
// .contact("")
|
|
|
|
.version("1.0").build();
|
|
|
|
}
|
|
|
|
}
|