如何在swagger.json文件的“ description”属性中使用html标记?

时间:2019-10-21 20:43:32

标签: c# swagger openapi nswag

环境:

NSwag.AspNetCore(12.2.5);

Microsoft.NETCore.App(3.0.0);

语言:C#

我用以下表达式标记某些控制器的标题:

///<summary>Controller description</summary>
/// <remarks>
/// <details>
///    <summary>Expand here</summary>
///    <p>Hidden content</p>
///</details>
/// </remarks>
[HttpGet]
[SwaggerTags("NF-e (Nota Fiscal Eletrônica)")]
[Route("api/testes/")]
public string tests()
{
    return "tests";
}

目的是获取具有以下内容的摇摇欲坠的规范文件:

"paths": {
...
    "/api/testes": {
      "get": {
        "tags": [
          "NF-e (Nota Fiscal Eletrônica)"
        ],
        "summary": "Controller description",
        "description": "<details><summary>Expand here</summary><p>Hidden content</p></details>"
        "operationId": "NFe_tests",
        "parameters": [
          {
            "name": "token",
            "in": "header",
            "description": "Chave de acesso à API",
            "schema": {
              "type": "string"
            },
            "default": "980fb195fdecc68069deb67f987573837cf67e0e"
          }
        ],
        "responses": {
          "200": {
            "x-nullable": true,
            "description": "",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    }
...

要在灵活的GUI上具有以下行为:

enter image description here

但是,我得到的如下:

"paths": {
...
    "/api/testes": {
      "get": {
        "tags": [
          "NF-e (Nota Fiscal Eletrônica)"
        ],
        "summary": "Controller description",
        "description": "   Expand here\n   Hiden content\n            ",
        "operationId": "NFe_tests",
        "parameters": [
          {
            "name": "token",
            "in": "header",
            "description": "Chave de acesso à API",
            "schema": {
              "type": "string"
            },
            "default": "980fb195fdecc68069deb67f987573837cf67e0e"
          }
        ],
        "responses": {
          "200": {
            "x-nullable": true,
            "description": "",
            "schema": {
              "type": "string"
            }
          }
        }
      }
    }
...

有什么方法可以通过在swagger.json文件中生成“ description”属性来防止抑制html标签吗?

我试图用![CDATA [html content here]]标记包装内容。但是它仍然无法按预期工作。

任何帮助都将受到欢迎。

0 个答案:

没有答案