在信息部分包含 Swagger-UI 代码块

Include Swagger-UI code blocks in the info section

看起来 Swagger UI 正在撕掉并弄乱看起来像 HTML 标签的东西,即使在 markdown 三重反引号分隔的代码块中也是如此!

我写了

swagger: '2.0'
info:
  title: My Title
  description: |
    Hello here is some Python code
    ```
      def hello():
          return "hello"
    ```
    and here is some HTML
    ```
      <body>
      <p>Hello</p>
      <script>x = 1</script>
      </body>

    ```
    That is all

不幸的是,Swagger-UI 将其呈现为

我不是在抱怨它没有在 markdown 中使用 highlight.js 的事实;它毕竟是一个开源项目,可以修复。但是,我注意到它删除了 HTML 标签,这很好,除了当我试图像这样转义尖括号时:

swagger: '2.0'
info:
  title: My Title
  description: |
    Hello here is some Python code
    ```
      def hello():
          return "hello"
    ```
    and here is some HTML
    ```
      &lt;body>
      &lt;p>Hello</p>
      &lt;script>x = 1</script>
      &lt;/body>

    ```
    That is all

然后工具返回

有谁知道我如何打败 Swagger-UI 并显示 HTML 代码片段?

Swagger UI v. 3 在代码块中正确显示 HTML 标签:

这是我使用的 YAML:

  description: |
    Hello here is some Python code
    ```
    def hello():
      return "hello"
    ```
    and here is some HTML
    ```
    <body>
      <p>Hello</p>
      <script>x = 1</script>
    </body>
    ```
    That is all


注意:如果您的代码块存在如下所示的样式问题,请升级到 Swagger UI 3.22.0+ 或 Swagger Editor 3.6.26+。旧版本有一个 CSS issue 已在上述版本中修复。