You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you define a non required query parameter in components section, it will always generated as required.
Name
Version
openapi-typescript
6.2.0
Node.js
16.14.1
OS + version
Ubuntu 22.04.2 LTS (WSL)
Reproduction
How can this be reproduced / when did the error occur?
We extended the petstore openapi yaml with an optional non required query parameters and let openapi-typescript generate the types.
)
* Add missing 'vite' dependency
* Ensure not required params are created as optional properties (#1052)
According to the OpenAPI 3.1.0 spec, a parameter is required if one of these matches:
- it has 'in: "path"'
- it has 'required: true'
See spec at Parameter Object - Fixed Fields:
https://spec.openapis.org/oas/v3.1.0#fixed-fields-9Fixes#1052
Description
When you define a non required query parameter in components section, it will always generated as required.
openapi-typescript
6.2.0
16.14.1
Ubuntu 22.04.2 LTS (WSL)
Reproduction
How can this be reproduced / when did the error occur?
We extended the petstore openapi yaml with an optional non required query parameters and let openapi-typescript generate the types.
npx openapi-typescript https://gist.githubusercontent.com/WtfJoke/cc2f3d56262c19be11c035c2db90e1ea/raw/ac42890b9e4d0d1b8f76eb44434b5aedb32f21e5/petstore-openapi.yml --output generated/petstore.ts
optionalUserNameQueryParam
is of typestring
instead of typestring | undefined
Expected result
optionalUserNameQueryParam
in petstore.ts should be of typestring | undefined
(in case it’s not obvious)
Checklist
Additional information
The modified petstore can be found in my gist here: https://gist.github.com/WtfJoke/cc2f3d56262c19be11c035c2db90e1ea (we simply added the optional query parameter to the components section, see revisions)
The text was updated successfully, but these errors were encountered: