openapi v3响应体中的多行示例[重复]

问题描述 投票:1回答:1

这个问题在这里已有答案:

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

Desired result

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

Single line example

swagger swagger-ui openapi
1个回答
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"
          ]
        }
      }
    ],
...
© www.soinside.com 2019 - 2024. All rights reserved.