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

Sar*_*tts 6 swagger swagger-ui swagger-2.0 swagger-editor

我想在我的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"
        }
    }
    ```
Run Code Online (Sandbox Code Playgroud)

显示为:

Swagger UI屏幕截图

但是,Swagger编辑器显示正确的代码块:

Swagger编辑器屏幕截图

Swagger UI不支持此功能吗?

Hel*_*len 5

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

Swagger UI 显示的 Markdown 代码块

data请注意文本中“a key”和“that contains”之间的换行符- 它是由|文字块样式引起的,它保留了 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"
          }
      }
      ```
Run Code Online (Sandbox Code Playgroud)