1 package de.spring.webservices.configuration;
3 import static com.google.common.collect.Lists.newArrayList;
4 import static springfox.documentation.builders.RequestHandlerSelectors.basePackage;
5 import static springfox.documentation.builders.RequestHandlerSelectors.withMethodAnnotation;
7 import org.springframework.context.annotation.Bean;
8 import org.springframework.context.annotation.Configuration;
9 import org.springframework.web.bind.annotation.RequestMapping;
10 import org.springframework.web.bind.annotation.RequestMethod;
12 import springfox.documentation.builders.ApiInfoBuilder;
13 import springfox.documentation.builders.PathSelectors;
14 import springfox.documentation.builders.ResponseMessageBuilder;
15 import springfox.documentation.service.ApiInfo;
16 import springfox.documentation.service.Contact;
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.swagger2.annotations.EnableSwagger2;
23 * Go to URL: http://localhost:8080/swagger-ui.html#/
28 public class Swagger2Configuration {
31 public Docket documentation() {
32 return new Docket(DocumentationType.SWAGGER_2)
34 .apis(withMethodAnnotation(RequestMapping.class))
35 .apis(basePackage("de.spring.webservices.rest.controller"))
36 .paths(PathSelectors.any())
38 .globalResponseMessage(RequestMethod.GET,
39 newArrayList(new ResponseMessageBuilder()
40 .code(500).message("Global server custom error message").build()))
41 .useDefaultResponseMessages(false)
47 UiConfiguration uiConfig() {
48 return new UiConfiguration(null);
51 private static ApiInfo metadata() {
52 return new ApiInfoBuilder()
53 .title("gumartinm REST API")
54 .description("Gustavo Martin Morcuende")
55 .version("1.0-SNAPSHOT")
60 private static Contact doContact() {
61 return new Contact("Gustavo Martin", "https://gumartinm.name", "");