2017-12-27 71 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" 
      ] 
     } 
     } 
    ], 
...