Skip to content

Boolean Parameter with @Schema Annotation Changes Type to string in OpenAPI Documentation #2638

Closed
@DanielLiu1123

Description

@DanielLiu1123

When a boolean type parameter is annotated with @Schema (specifying description but not type), resulting in the OpenAPI type being changed to string.

Example:

@PostMapping("/testBoolean")
public void testBoolean(
    boolean bool,
    @Schema(description = "foo") boolean boolWithSchema
) {
}
~ curl http://localhost:62535/v3/api-docs | jq '.paths."/testBoolean".post.parameters'
[
  {
    "name": "bool",
    "in": "query",
    "required": true,
    "schema": {
      "type": "boolean"
    }
  },
  {
    "name": "boolWithSchema",
    "in": "query",
    "description": "foo",
    "required": true,
    "schema": {
      "type": "string",
      "description": "foo"
    }
  }
]

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