-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When defining a query parameter in OpenAPI with type integer or boolean and an enum restriction, the generated code creates converters that expect the native type (int or boolean) directly. However, since query parameters are always transmitted as strings in HTTP requests, this leads to conversion failures.
For example, a spec like:
parameters:
- name: status
in: query
schema:
type: integer
enum: [0, 1, 2] generates a converter that doesn't account for parsing the incoming string ("0") to the enum value.
Suggestion: Update the generator to include string-to-type conversion in the enum handling for query params, ensuring it first parses the string to the base type before mapping to the enum. This would make the generated code more reliable out-of-the-box.
Tested with Java/Spring
openapi-generator version
7.13.0