3

XML としてフォーマットされたときに属性として表されるプロパティを持つ Swagger モデルを作成したいと考えています。

これが私の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 アノテーションでこれを行う方法はありますか? アドバイスや代替案は大歓迎です。事前に感謝します。

4

0 に答える 0