简体   繁体   中英

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. 用户界面是什么样的

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. 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). This works okay with POST, but seems fails peculiarly when trying to add route parameters to GET.

This is the json I generate for my GET:

"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.

There's an extra space in the name of the in attribute:

"in ": "path",
   ^
   ^

Remove that space.

You can also use https://editor.swagger.io to check your API definition for syntax errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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