2
我有一個使用Spring Boot 1.4和Swagger和Swagger UI的問題。使用@RequestBody參數時顯示爲數據類型字符串。這似乎不正確。Spring Boot + Swagger + Swagger UI和@RequestBody有數據類型字符串
@ApiOperation(value = "simple message resource")
@ApiImplicitParams({
@ApiImplicitParam(name = "message", value = "Message to send", required = true, dataType = "com.larmic.springboot.swagger.rest.dto.MessageDto", paramType = "body")
})
@RequestMapping(value = "/api/message", method = RequestMethod.POST,
consumes = {"application/json", "application/xml"})
public void sendMessage(@RequestBody MessageDto message) {
System.out.println("ping");
}
和
@XmlRootElement(name = "MessageDto")
@XmlAccessorType(XmlAccessType.FIELD)
@ApiModel(value = "MessageDto", description = "TODO")
public class MessageDto {
@ApiModelProperty(value = "Message content text", required = true, example = "some demo message")
private String content;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
我發現了很多使用MessageDto的全名或設置@ApiModel的正確價值,但似乎沒有任何工作的修正。
我已經在這裏創造一個完整的例子https://github.com/larmic/SpringBootAndSwaggerUI
也許有人可以提供幫助。
非常感謝!這工作!我已將解決方案推送到https://github.com/larmic/SpringBootAndSwaggerUI –