[英]How to provide texts to swagger in a properties file for spring restful service?
我正在以昂首阔步的方式创建我的Spring restful service文档。
示例请求处理程序方法及其下面的文档。 有用:
@ApiOperation(value = "Returns user details", notes = "Returns a complete list of users details with a date of last modification.", response = User.class)
public Response getUser(@ApiParam(name = "userName", value = "Alphanumeric login to the application", required = true) @PathParam("userName") String userName) {
...
}
但是我希望将请求处理程序方法的文本提供给属性文件中的swagger注释(这样做是为了不使用文档文本增加类大小)。
因此,我创建了一个名为“application-swagger.properties”的属性文件,并在“application.properties”(spring.profiles.active = swagger)中启用它。 当我创建如下的api文档时,不显示文本。
application-swagger.properties:
value=Returns user details
notes=Returns a complete list of users details with a date of last modification.
控制器类:
@Controller
@Profile("swagger")
public class UserController{
.
.
@ApiOperation(value = "${value}", notes = ${notes}", response = User.class)
public Response getUser(@ApiParam(name = "userName", value = "Alphanumeric login to the application", required = true) @PathParam("userName") String userName) {
...
}
.
.
}
有没有办法将文本放入属性文件中的swagger注释? 谢谢你的帮助。
回答问题一直很安静,但如果有人需要帮助,可以参考。
脚步:
使用Spring Boot 1.5和Swagger 2.8,不确定以前的版本。
参考文献摘自一篇详细的文章 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.