Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
DanielLiu1123 opened this issue Jul 5, 2024 · 0 comments

Comments

@DanielLiu1123
Copy link

DanielLiu1123 commented Jul 5, 2024

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"
    }
  }
]
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant