Skip to content

Instantly share code, notes, and snippets.

@atishn
Created July 22, 2015 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atishn/317d8abbcd1654aec728 to your computer and use it in GitHub Desktop.
Save atishn/317d8abbcd1654aec728 to your computer and use it in GitHub Desktop.
import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
import com.wordnik.swagger.model.ApiInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
/**
* Swagger configuration for easy API development.
*/
@Configuration
@EnableSwagger
public class SwaggerConfig {
/**
* The Spring swagger config.
*/
@Autowired
private SpringSwaggerConfig springSwaggerConfig;
/**
* Custom implementation.
*
* @return the swagger spring mvc plugin
*/
@Bean
public SwaggerSpringMvcPlugin customImplementation() {
return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
.apiInfo(apiInfo()).includePatterns(swaggerPatterns());
}
/**
* List of API EndPoints to be included in Swagger UI.
*
* @return Array of Patterns.
*/
private String[] swaggerPatterns() {
List<String> patterns = newArrayList();
patterns.add("/product/.*");
patterns.add("/category/.*");
patterns.add("/cache");
return patterns.toArray(new String[patterns.size()]);
}
/**
* Api info.
*
* @return the api info
*/
private ApiInfo apiInfo() {
return new ApiInfo(
"Development API",
"Mobile applications and beyond!",
"https://xxxx.com",
"xxx@xxxxxx.com",
"Spring Boot",
""
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment