Created
October 1, 2014 18:59
-
-
Save ae6rt/2caef0df93d29a60ec8a to your computer and use it in GitHub Desktop.
Autowired no more
This file contains hidden or 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
Good: | |
@Configuration | |
@EnableSwagger | |
public class SwaggerConfiguration { | |
public static final List<String> DEFAULT_INCLUDE_PATTERNS = Arrays.asList("^(?!/error|/internal/).*$"); | |
private static final String SWAGGER_GROUP = ""; | |
@Bean | |
public SwaggerSpringMvcPlugin swaggerPlugin(SpringSwaggerConfig springSwaggerConfig) { | |
return new SwaggerSpringMvcPlugin(springSwaggerConfig) | |
.apiInfo(new ApiInfo("Acme APIs", "REST documentation for Acme APIs", "http://example.com", "[email protected]", "Copyright Example.com", "http://example.com")) | |
.includePatterns(DEFAULT_INCLUDE_PATTERNS.toArray(new String[DEFAULT_INCLUDE_PATTERNS.size()])) | |
.swaggerGroup(SWAGGER_GROUP) | |
; | |
} | |
} | |
Not so good: | |
@Configuration | |
@EnableSwagger | |
public class SwaggerConfiguration { | |
private SpringSwaggerConfig springSwaggerConfig; | |
@Autowired | |
public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) { | |
this.springSwaggerConfig = springSwaggerConfig; | |
} | |
@Bean | |
public SwaggerSpringMvcPlugin swaggerPlugin() { | |
return new SwaggerSpringMvcPlugin(springSwaggerConfig) | |
.apiInfo(new ApiInfo("Acme APIs", "REST documentation for Acme APIs", "http://example.com", "[email protected]", "Copyright Example.com", "http://example.com")) | |
.includePatterns(DEFAULT_INCLUDE_PATTERNS.toArray(new String[DEFAULT_INCLUDE_PATTERNS.size()])) | |
.swaggerGroup(SWAGGER_GROUP) | |
; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment