我想创建一个具有属性的 Swagger 模型,该属性在格式化为 XML 时应表示为属性。
这是我的 Swagger 模型课
@ApiModel
@JacksonXmlRootElement(localName = "LeadInformation")
public class LeadRequestVO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "Request type", required = true, example="POST")
@JacksonXmlProperty(localName = "RequestType", isAttribute = true)
private String requestType;
public String getRequestType() {
return requestType;
}
public void setRequestType(String requestType) {
this.requestType = requestType;
}
}
在 Swagger UI 中,这显示为
<?xml version="1.0"?>
<LeadRequestVO>
<RequestType>POST</RequestType>
</LeadRequestVO>
但我希望“RequestType”改为 XML 属性:
<?xml version="1.0"?>
<LeadRequestVO RequestType="POST"></LeadRequestVO>
根据我的阅读,我需要在 Swagger 规范中添加以下内容
xml:
attribute: true
有没有办法用 Swagger 注释做到这一点?欢迎任何建议或替代方案,并提前致谢!