Skip to content

Instantly share code, notes, and snippets.

@ksurendra
Created April 26, 2019 18:12
Show Gist options
  • Save ksurendra/fc4a7ddbf1f7410b22e0282ff7f3f1ab to your computer and use it in GitHub Desktop.
Save ksurendra/fc4a7ddbf1f7410b22e0282ff7f3f1ab to your computer and use it in GitHub Desktop.
Swagger configuration file
package com.weathertracker;
import static springfox.documentation.builders.PathSelectors.regex;
import java.util.Collections;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
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.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* Swagger configuration file to generate API documentation
*/
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select()
.apis(RequestHandlerSelectors
.basePackage("com.capitalone.weathertracker"))
.paths(PathSelectors.regex("/.*"))
.build()
.apiInfo(apiEndPointsInfo());
}
private ApiInfo apiEndPointsInfo() {
return new ApiInfoBuilder()
.title("Weather Tracker API Documentation")
.description("Weather Tracker REST API")
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.version("1.0.0")
.build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment