1
扬鞭配置:扬鞭includePatterns()
@EnableSwagger
@Configuration
public class SwaggerConfig {
private SpringSwaggerConfig springSwaggerConfig;
@Autowired
public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
this.springSwaggerConfig = springSwaggerConfig;
}
@Bean
public SwaggerSpringMvcPlugin swaggerSpringMvcPlugin() {
return new SwaggerSpringMvcPlugin(springSwaggerConfig)
.swaggerGroup("sample-app")
.includePatterns(
"/account/*"
)
.apiInfo(apiInfo())
.build();
}
private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo(
"sample-app",
"sample-app doc",
"",
"[email protected]",
"",
""
);
return apiInfo;
}
休息控制器
@RestController
@RequestMapping(value = "/account")
@Api(value = "Change Account details", description = "")
public class ChangeAccountController {
@ApiOperation(value = "Change address")
@RequestMapping(value = "/addresschange", method = RequestMethod.POST)
public String addressChange(HttpServletRequest httpRequest, HttpServletResponse httpResponse,
@Valid @RequestBody User user) throws ServletException, IOException {
// logic and return something!
}
}
参考:一些信息已从这里被称作:HTTP:// java的。 dzone.com/articles/how-configure-swagger-generate
问题/问题:
在SwaggerConfig.java
,在includePatterns()
方法中,当我请图案 为/account/*
API不出现在扬鞭输出页面,反之,如果 我包括图案作为/account/.*
它出现。 为什么?在这个用例中,/account/*
和/account/.*
之间有什么区别?
更新:
另一个用例
@RestController
@RequestMapping(value = "/score")
@ApiOperation(value = "All score", notes = "")
@RequestMapping(value = "", method = RequestMethod.GET)
public @ResponseBody ActionResult allScores(HttpServletRequest httpRequest,
HttpServletResponse httpResponse) {
}
如果我添加的图案作为/score/*
,那么API是出现在扬鞭。 我不需要把模式作为/score/.*