6e0de247644ceda08caf707a0fbeb076fdc75567
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.rest.doc;
2
3 import org.springframework.context.annotation.Bean;
4 import org.springframework.context.annotation.Configuration;
5 import org.springframework.web.bind.annotation.RequestMapping;
6 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7
8 import springfox.documentation.builders.ApiInfoBuilder;
9 import springfox.documentation.builders.PathSelectors;
10 import springfox.documentation.builders.RequestHandlerSelectors;
11 import springfox.documentation.service.ApiInfo;
12 import springfox.documentation.spi.DocumentationType;
13 import springfox.documentation.spring.web.plugins.Docket;
14 import springfox.documentation.swagger.web.UiConfiguration;
15 import springfox.documentation.swagger2.annotations.EnableSwagger2;
16
17 @Configuration
18 @EnableWebMvc
19 @EnableSwagger2
20 public class Swagger2Configuration {
21         private static final String DOCKET_ID = "web-services-spring-rest";
22         
23         @Bean
24         public Docket documentation() {
25                 return new Docket(DocumentationType.SWAGGER_2)
26                                 .groupName(DOCKET_ID)
27                                 .select()
28                                         .apis(RequestHandlerSelectors.withMethodAnnotation(RequestMapping.class))
29                                         .paths(PathSelectors.any())
30                                         .build()
31                         .pathMapping("/")
32                         .useDefaultResponseMessages(false)
33                         .apiInfo(metadata())
34                         .enable(true);
35         }
36
37         @Bean
38         UiConfiguration uiConfig() {
39                 return UiConfiguration.DEFAULT;
40         }
41
42         
43         private static ApiInfo metadata() {
44                 return new ApiInfoBuilder()
45                                 .title("gumartinm REST API")
46                                 .description("Gustavo Martin Morcuende")
47                                 .version("1.0-SNAPSHOT")
48                         .contact("gumartinm.name")
49                         .build();
50         }
51
52 }