swagger-api / swagger-api/swagger-ui

Unable to pass required parameters in Swagger UI

Open
#10,646 8 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

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"
    }
  ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure in Swagger UI with the provided OpenAPI 3.1 definition, focusing on the Try it out and Execute flow for the required union-typed query parameter. Trace how the entered value is validated and added to the request, then verify that executing the example sends the required Size parameter without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.