Skip to content

Unable to pass required parameters in Swagger UI #10646

@marcominerva

Description

@marcominerva

Q&A

  • OS: Windows 11
  • Browser: Edge
  • Version: 142.0.3595.94
  • Method of installation: via Swashbuckle.AspNetCore.SwaggerUI
  • Swagger-UI version: 5.30.2
  • Swagger/OpenAPI version: OpenAPI 3.1

Describe the bug you're encountering

I have the following OpenAPI definition:

"parameters": [
    {
      "name": "Size",
      "in": "query",
      "required": true,
      "schema": {
        "pattern": "^-?(?:0|[1-9]\\d*)$",
        "type": [
          "integer",
          "string"
        ],
        "format": "int32"
      }
    }
  ],

if I try the endpoint in the Swagger UI, when I enter a value for the parameter and then press the Execute button, I get this error:

Image

To reproduce...

This is the full OpenAPI definition:

{
  "openapi": "3.1.1",
  "info": {
    "title": "WebApi | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://localhost:5000/"
    }
  ],
  "paths": {
    "/test": {
      "get": {
        "tags": [
          "WebApi"
        ],
        "parameters": [
          {
            "name": "Size",
            "in": "query",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "WebApi"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions