2017-12-27 929 views
1

有沒有在請求正文中編寫多行示例的方法?如果可能的話,我希望我的OpenApi文檔在Swagger-UI下運行時顯示如下。openapi v3響應正文中的多行示例

Desired result

到目前爲止,我已經能夠做到的,是一個單行例子,如下所示:

Single line example

回答

0

你不說你的語言多選擇你的api或你如何產生你的swagger.json ...

但是,這是可能的,這裏有一些活的例子:

http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=Company#/Company/Company_Post

http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=Polygon#/PolygonVolume/PolygonVolume_Post

http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=Dictionary#/Dictionary/Dictionary_DeleteEcho



對於最後一個JSON代碼如下所示:

"delete": { 
    "tags": [ 
     "Dictionary" 
    ], 
    "operationId": "Dictionary_DeleteEcho", 
    "consumes": [ 
     "application/json", 
     "text/json", 
     "text/html" 
    ], 
    "produces": [ 
     "application/json", 
     "text/json", 
     "text/html" 
    ], 
    "parameters": [ 
     { 
     "name": "guids", 
     "in": "body", 
     "required": true, 
     "schema": { 
      "type": "array", 
      "items": { 
      "format": "uuid", 
      "type": "string", 
      "example": "00000000-0000-0000-0000-000000000000" 
      }, 
      "example": [ 
      "00000000-0000-0000-0000-000000000000", 
      "00000000-0000-0000-0000-000000000000" 
      ] 
     } 
     } 
    ], 
...