如何格式化 Swagger UI 3.x 描述中的代码块?

How to format code blocks in descriptions in Swagger UI 3.x?

我想在我的 API 的描述中放置一个 Markdown 代码块,但是 Swagger UI 看起来好像是一个单行代码片段。我目前有:

description: |
    This API was created to allow interaction with the Image Status Database (ISD)

    ## Requests

    ## Responses
    In the case of a successful response, you will always receive a `data` key
    that contains your data.
    ```
    {
        "meta": {
            "code": 200
        },
        "data": {
            ...
        },
        "pagination": {
            "next_url": "...",
            "next_max_id": "13872296"
        }
    }
    ```

这显示为:

然而,Swagger 编辑器显示正确的代码块:

Swagger UI 不支持吗?

代码块格式问题已在 Swagger UI 3.22.0 和 Swagger Editor 3.6.26 中修复。代码块在这些版本中正确显示:

注意文本中 "a data key" 和 "that contains" 之间的换行符 - 它是由 | literal block style 引起的,它保留了 YAML 多行字符串中的换行符。为避免换行,您可以 1) 在 YAML 中删除它,或 2) 使用 > 折叠样式并缩进代码块(以防止它被折叠),如下所示:

  description: >
    This API was created to allow interaction with the Image Status Database (ISD)

    ## Requests

    ## Responses

    In the case of a successful response, you will always receive a `data` key
    that contains your data.

      ```
      {
          "meta": {
              "code": 200
          },
          "data": {
              ...
          },
          "pagination": {
              "next_url": "...",
              "next_max_id": "13872296"
          }
      }
      ```