1 package de.spring.webservices.doc;
3 import static com.google.common.collect.Lists.newArrayList;
5 import org.springframework.context.annotation.Bean;
6 import org.springframework.context.annotation.ComponentScan;
7 import org.springframework.context.annotation.Configuration;
8 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.RequestMethod;
10 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
12 import springfox.documentation.builders.ApiInfoBuilder;
13 import springfox.documentation.builders.PathSelectors;
14 import springfox.documentation.builders.RequestHandlerSelectors;
15 import springfox.documentation.builders.ResponseMessageBuilder;
16 import springfox.documentation.service.ApiInfo;
17 import springfox.documentation.spi.DocumentationType;
18 import springfox.documentation.spring.web.plugins.Docket;
19 import springfox.documentation.swagger.web.UiConfiguration;
20 import springfox.documentation.swagger1.annotations.EnableSwagger;
25 @ComponentScan("de.spring.webservices.rest.controller")
26 public class Swagger2Configuration {
29 public Docket documentation() {
30 return new Docket(DocumentationType.SWAGGER_12)
32 .apis(RequestHandlerSelectors.withMethodAnnotation(RequestMapping.class))
33 .paths(PathSelectors.any())
35 .globalResponseMessage(RequestMethod.GET,
36 newArrayList(new ResponseMessageBuilder()
37 .code(500).message("Global server custom error message").build()))
39 .useDefaultResponseMessages(false)
45 UiConfiguration uiConfig() {
46 return UiConfiguration.DEFAULT;
49 private static ApiInfo metadata() {
50 return new ApiInfoBuilder()
51 .title("gumartinm REST API")
52 .description("Gustavo Martin Morcuende")
53 .version("1.0-SNAPSHOT")
54 .contact("gumartinm.name")