Skip to content

TypeError when processing enums containing "null" #447

New issue

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

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

Already on GitHub? Sign in to your account

Closed
westmark opened this issue Jan 12, 2021 · 1 comment
Closed

TypeError when processing enums containing "null" #447

westmark opened this issue Jan 12, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@westmark
Copy link

Hi!

In V3(not sure about V2), null is a valid value for component enum properties. Attempting to run the swagger generator on a schema containing an enum null value will result in

TypeError: Cannot read property 'replace' of null

...on this line

https://github.com/drwpow/openapi-typescript/blob/14353afb246533a134247ccf720515dd441cddfe/src/v3.ts#L67

...since item can be null.

Assuming the property is properly marked as nullable, the generator should just skip the null value since | null will be prepended to the type definition anyway.

Found in 2.4.2

@drwpow
Copy link
Contributor

drwpow commented Jan 27, 2021

This was fixed in #234 I believe, and should have been released in v3 of this library. Please give the new version a try, and let me know if you encounter any difficulties (and if you are still seeing the same error, please post your source schema and we can add a fix quickly!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants