我正在使用Swagger 2(OAS 2 | OpenAPI Specification V2)在响应中显示XML示例。 以下是XML示例。
<GetShipmentsResponse xmlns="http://tempuri.org/">
<GetShipmentsResult xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ShipmentDetailDC>
<a:AirWayNo/>
<a:CurrentStatus>Shipment delivered</a:CurrentStatus>
<a:CurrentStatusCategory>C100</a:CurrentStatusCategory>
<a:CurrentStatusCode>1000</a:CurrentStatusCode>
<a:DeliveredDate>2019-05-02T18:03:28</a:DeliveredDate>
<a:DestinationName>SRI LANKA</a:DestinationName>
<a:OrderDate>2016-01-20T00:00:00</a:OrderDate>
<a:OriginName>SRI LANKA</a:OriginName>
<a:Quantity>1</a:Quantity>
<a:ReceiverName>SRI LANKA SHIPPING INC.</a:ReceiverName>
<a:ReferenceNo>100000</a:ReferenceNo>
<a:Remarks>Delivery complete and dues received</a:Remarks>
<a:StatusCount>8</a:StatusCount>
<a:TrackingNo>QS10711700286</a:TrackingNo>
<a:Weight>20</a:Weight>
</a:ShipmentDetailDC>
</GetShipmentsResult>
</GetShipmentsResponse>
我想在回复的示例部分中展示这一点。 OpenAPI 3 here中描述了类似的内容。但是我需要在Swagger 2(OAS2)中做到这一点
我尝试关注。
responses:
'200':
description: "OK"
examples:
application/xml: "
<GetShipmentsResponse xmlns='http://tempuri.org/'> \n
<GetShipmentsResult xmlns:a='http://schemas.datacontract.org/2004/07/QS.TrackNTraceService.DataContract' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'> \n
<a:ShipmentDetailDC> \n
<a:AirWayNo/> \n
<a:CurrentStatus>Shipment delivered</a:CurrentStatus> \n
<a:CurrentStatusCategory>C600</a:CurrentStatusCategory>\n
<a:CurrentStatusCode>6034</a:CurrentStatusCode>\n
<a:DeliveredDate>2016-01-20T18:03:28</a:DeliveredDate>\n
<a:DestinationName>PHILIPPINES</a:DestinationName>\n
<a:OrderDate>2016-01-20T00:00:00</a:OrderDate>\n
<a:OriginName>PHILIPPINES</a:OriginName>\n
<a:Quantity>1</a:Quantity>\n
<a:ReceiverName>BIG GUYS PIZZA PHILS., INC.</a:ReceiverName>\n
<a:ReferenceNo>107117</a:ReferenceNo>\n
<a:Remarks>Delivery complete and dues received</a:Remarks>\n
<a:StatusCount>8</a:StatusCount>\n
<a:TrackingNo>QS10711700286</a:TrackingNo>\n
<a:Weight>20</a:Weight>\n
</a:ShipmentDetailDC>\n
</GetShipmentsResult>\n
</GetShipmentsResponse>
"
与Swagger 2(OAS2)中的这种方法相比,还有其他方法可以轻松地在Swagger Response示例中显示良好缩进的XML(上述XML)吗?