|
1 | | -//package com.urunov.configureAPI; |
2 | | -// |
3 | | -//import org.springframework.context.annotation.Bean; |
4 | | -//import org.springframework.context.annotation.Configuration; |
5 | | -//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
6 | | -//import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; |
7 | | -//import springfox.documentation.builders.ApiInfoBuilder; |
8 | | -//import springfox.documentation.builders.RequestHandlerSelectors; |
9 | | -//import springfox.documentation.service.ApiInfo; |
10 | | -//import springfox.documentation.service.Contact; |
11 | | -//import springfox.documentation.spi.DocumentationType; |
12 | | -//import springfox.documentation.spring.web.plugins.Docket; |
13 | | -//import springfox.documentation.swagger2.annotations.EnableSwagger2; |
14 | | -// |
15 | | -//import static springfox.documentation.builders.PathSelectors.regex; |
16 | | -// |
17 | | -///** |
18 | | -// * User: hamdamboy |
19 | | -// * Project: security |
20 | | -// * Github: @urunov |
21 | | -// */ |
22 | | -//@Configuration |
23 | | -//@EnableSwagger2 |
24 | | -//public class modelAPI extends WebMvcConfigurationSupport { |
25 | | -// |
26 | | -// @Bean |
27 | | -// public Docket postsApi() { |
28 | | -// |
29 | | -// return new Docket(DocumentationType.SWAGGER_2) |
30 | | -// .select() |
31 | | -// .apis(RequestHandlerSelectors.basePackage("com.urunov.controller")) |
32 | | -// .paths(regex("/api/v1.*")) |
33 | | -// .build() |
34 | | -// .apiInfo(metaData()); |
35 | | -// } |
36 | | -// |
37 | | -// private ApiInfo metaData() { |
38 | | -// return new ApiInfoBuilder() |
39 | | -// .title("Ecommerce Platform: Shopping Mall") |
40 | | -// .description("\"Spring Boot REST API for Employee") |
41 | | -// .version("1.0.0") |
42 | | -// .license("Apache License Version 2.0") |
43 | | -// .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0\"") |
44 | | -// .contact(new Contact("Urunov Hamdamboy", "https://github.com/urunov/", "myindexu@gamil.com")) |
45 | | -// .build(); |
46 | | -// } |
47 | | -// @Override |
48 | | -// protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
49 | | -// registry.addResourceHandler("swagger-ui.html") |
50 | | -// .addResourceLocations("classpath:/META-INF/resources/"); |
51 | | -// registry.addResourceHandler("/webjars/**") |
52 | | -// .addResourceLocations("classpath:/META-INF/resources/webjars/"); |
53 | | -// } |
54 | | -// |
55 | | -//} |
| 1 | +package com.urunov.configureAPI; |
| 2 | + |
| 3 | +import org.springframework.context.annotation.Bean; |
| 4 | +import org.springframework.context.annotation.Configuration; |
| 5 | +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| 6 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; |
| 7 | +import springfox.documentation.builders.ApiInfoBuilder; |
| 8 | +import springfox.documentation.builders.RequestHandlerSelectors; |
| 9 | +import springfox.documentation.service.ApiInfo; |
| 10 | +import springfox.documentation.service.Contact; |
| 11 | +import springfox.documentation.spi.DocumentationType; |
| 12 | +import springfox.documentation.spring.web.plugins.Docket; |
| 13 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| 14 | + |
| 15 | +import static springfox.documentation.builders.PathSelectors.regex; |
| 16 | + |
| 17 | +/** |
| 18 | + * User: hamdamboy |
| 19 | + * Project: security |
| 20 | + * Github: @urunov |
| 21 | + */ |
| 22 | +@Configuration |
| 23 | +@EnableSwagger2 |
| 24 | +public class modelAPI extends WebMvcConfigurationSupport { |
| 25 | + |
| 26 | + @Bean |
| 27 | + public Docket postsApi() { |
| 28 | + |
| 29 | + return new Docket(DocumentationType.SWAGGER_2) |
| 30 | + .select() |
| 31 | + .apis(RequestHandlerSelectors.basePackage("com.urunov.controller")) |
| 32 | + .paths(regex("/api/v1.*")) |
| 33 | + .build() |
| 34 | + .apiInfo(metaData()); |
| 35 | + } |
| 36 | + |
| 37 | + private ApiInfo metaData() { |
| 38 | + return new ApiInfoBuilder() |
| 39 | + .title("Ecommerce Platform: Shopping Mall") |
| 40 | + .description("\"Spring Boot REST API for Employee") |
| 41 | + .version("1.0.0") |
| 42 | + .license("Apache License Version 2.0") |
| 43 | + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0\"") |
| 44 | + .contact(new Contact("Urunov Hamdamboy", "https://github.com/urunov/", "myindexu@gamil.com")) |
| 45 | + .build(); |
| 46 | + } |
| 47 | + @Override |
| 48 | + protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
| 49 | + registry.addResourceHandler("swagger-ui.html") |
| 50 | + .addResourceLocations("classpath:/META-INF/resources/"); |
| 51 | + registry.addResourceHandler("/webjars/**") |
| 52 | + .addResourceLocations("classpath:/META-INF/resources/webjars/"); |
| 53 | + } |
| 54 | + |
| 55 | +} |
0 commit comments