简体   繁体   English

Swagger UI 擦除参数

[英]Swagger UI erases Parameters

The error that I'm seeing is that as soon as I enter something into a Parameter on the UI it disappears.我看到的错误是,一旦我在 UI 上的参数中输入内容,它就会消失。 用户界面是什么样的

I am creating Controllers on the fly based on method decorations, so I can't create the XML that drives swagger.json at build-time.我正在根据方法装饰动态创建控制器,因此我无法在构建时创建驱动 swagger.json 的 XML。 As a way around it, I created another controller which inspects the controllers that were added to the runtime and outputs valid swagger.json (or so I think).作为一种解决方法,我创建了另一个 controller,它检查添加到运行时的控制器并输出有效的 swagger.json(或者我认为)。 This works okay with POST, but seems fails peculiarly when trying to add route parameters to GET.这适用于 POST,但在尝试将路由参数添加到 GET 时似乎特别失败。

This is the json I generate for my GET:这是我为我的 GET 生成的 json:

"openapi": "3.0.1",

  ... // cutting out unrelated other stuff

            "/api/v1/test4/{Value2}": {
               "get": {
                  "tags": [
                     ],
                  "summary": "A sample GET",
                  "parameters": [


         {
            "name": "Value2",
            "in ": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": ""
            }
         },
,
                  ],
                  "responses": {
                     "200": {
                        "description": "Success",
                        "content": {
                           "application/json": {
                                 "$ref": "#/components/schemas/TestReply"
                              }
                           }
                        }
                     }
                  }
               }
         }

The project is a.Net Framework 4.8 one, and the packages I'm using are Microsoft.AspNetCore 2.2.0 and Swashbuckle.AspNetCore 5.5.1.该项目是一个.Net Framework 4.8,我使用的包是Microsoft.AspNetCore 2.2.0 和Swashbuckle.AspNetCore 5.5.1。

There's an extra space in the name of the in attribute: in属性的名称中有一个额外的空格:

"in ": "path",
   ^
   ^

Remove that space.删除那个空间。

You can also use https://editor.swagger.io to check your API definition for syntax errors.您还可以使用https://editor.swagger.io来检查您的 ZDB97423814D6347 语法错误的定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM