Skip to content

Instantly share code, notes, and snippets.

@DengYiping
Created November 26, 2018 13:15
Show Gist options
  • Save DengYiping/32413c679174181c1e83ad7c7795c53d to your computer and use it in GitHub Desktop.
Save DengYiping/32413c679174181c1e83ad7c7795c53d to your computer and use it in GitHub Desktop.
package com.billboard.demo.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.Collections;
@Configuration
@EnableSwagger2WebMvc
@Import(SpringDataRestConfiguration.class)
public class SwaggerConfig {
/**
* method to create Swagger Endpoints
* @return Docket
*/
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo("Billboard"));
}
private ApiInfo apiInfo(String name){
return new ApiInfo(
name + " API",
"API documents for " + name,
"0.1",
"Terms of service",
new Contact("Yiping Deng", "ydeng.me", "[email protected]"),
"License of API", "API license URL", Collections.emptyList());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment