-
Notifications
You must be signed in to change notification settings - Fork 52
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
date-time format field is generated as string type #115
Comments
We should update the Typescript Type based on the I wonder if this could introduce a few breaking changes changing the type. |
P.S. official swagger-codegen is indeed generating |
This code-generator currently only supports Swagger 2.0 right now, so we need to look at the spec for 2.0 here instead. Interestingly enough dates are not mentioned explicitly for 2.0, and looking more at the documentation it only briefly mentions some date examples where they are also passed as strings. So seems like the 2.0 spec doesn't consider dates at all. Not sure if that means we should add support for it ourselves, or fall back to strings. @itamarco - Are you generating a 2.0 or 3.0 swagger spec in your example? |
I'm generating 2.0 swagger spec |
Thanks! Thoughts? |
Sound good. By union it with string we lose the date type enforcement but this is a price to pay for backward compatibility :( Appreciate your fast response! |
Cool! |
I suppose there could be an option to not have the backward compatibility, I would be interested in something like that. |
We could consider doing the string union as a backwards compatible stop-gap solution, and then remove the |
Suppose we have a Date query param
A generated swagger parameter definition for query param would be
But
swagger-typescript-codegen
would type it as stringAnd when try to use it with Date, TS error would be raised
Type 'Date' is not assignable to type 'string'
e.g.
The text was updated successfully, but these errors were encountered: