Created
July 22, 2015 01:48
-
-
Save atishn/317d8abbcd1654aec728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | |
"[email protected]", | |
"Spring Boot", | |
"" | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment