openapi v3响应体中的多行示例

时间:2017-12-27 20:19:47

标签: swagger swagger-ui openapi

有没有办法在请求正文中编写多行示例?如果可能的话,我希望我的OpenApi文档在Swagger-UI下运行时显示如下。

Desired result

到目前为止,我所能实现的只是一个单行示例,如下所示:

Single line example

1 个答案:

答案 0 :(得分: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"
          ]
        }
      }
    ],
...
相关问题