Java tutorial
package com.slf.tc.config; 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.boot.bind.RelaxedPropertyResolver; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; /** * Created by xiaobin on 2017-1-27. */ @Configuration @EnableSwagger public class SwagerConfig implements EnvironmentAware { public static final String DEFAULT_INCLUDE_PATTERN = "/api/.*"; public static final String WEB_LOGIN_PATTERN = "/web/.*"; private RelaxedPropertyResolver propertyResolver; @Override public void setEnvironment(Environment environment) { this.propertyResolver = new RelaxedPropertyResolver(environment, "swagger."); } @Bean public SwaggerSpringMvcPlugin swaggerSpringMvcPlugin(SpringSwaggerConfig springSwaggerConfig) { return new SwaggerSpringMvcPlugin(springSwaggerConfig).apiInfo(apiInfo()) //.includePatterns(DEFAULT_INCLUDE_PATTERN, WEB_LOGIN_PATTERN); .includePatterns(".*?"); } private ApiInfo apiInfo() { ApiInfo apiInfo = new ApiInfo(propertyResolver.getProperty("title"), propertyResolver.getProperty("description"), propertyResolver.getProperty("termsOfServiceUrl"), propertyResolver.getProperty("contact"), propertyResolver.getProperty("license"), propertyResolver.getProperty("licenseUrl")); return apiInfo; } }