-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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)
Example Spec:
[...]
paths:
/test-api:
get:
operationId: testApi
parameters:
- name: dateParameter
in: query
schema:
type: string
format: date
required: true
[...]Description
#22246 introduced a new behaviour regarding query parameter expansion. This breaks the current behaviour with non-primitive types, i.e. Date and DateTime.
The above spec generates:
if (requestParameters['dateParameter'] != null) {
queryParameters['dateParameter'] = requestParameters['dateParameter'];
}whereas v7.16.0 would have generated:
if (requestParameters['dateParameter'] != null) {
queryParameters['dateParameter'] = (requestParameters['dateParameter'] as any).toISOString().substring(0,10);
}Adding explode: false to the request parameter restores the old behaviour, but having to set explode to false for non-array types does not match my understanding of the spec. Furthermore, exploding arrays of Date/DateTime objects would not work either.
openapi-generator version
v7.17.0, it works in v7.16.0. This is a regression.
Steps to reproduce
Run the typescript-fetch generator against the provided spec with default configuration.
Related issues/PRs
Suggest a fix
I would suggest applying the Date/DateTime to String conversion regardless of explode being set or not.
I will (hopefully) provide a PR later today to address this issue.