Skip to content
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

Generate Date fields for "date-time" format #36

Closed
tflanitzer opened this issue Feb 21, 2018 · 6 comments
Closed

Generate Date fields for "date-time" format #36

tflanitzer opened this issue Feb 21, 2018 · 6 comments
Labels

Comments

@tflanitzer
Copy link

In our Swagger, we have several fields of format "date-time" (type "string"). Currently, these are represented as string in the generated models.

It would be very convenient if these were generated as Date objects.

@luisfpg
Copy link
Collaborator

luisfpg commented Feb 21, 2018

There's no way for this to work, because it would require the generated code to visit the entire object graph that after receiving / before sending to transform data.
That would slow down all all network communication and is out of scope for this project.

@phl3x0r
Copy link

phl3x0r commented Sep 4, 2018

this could be optional for convenience, since it won't slow things any further than having to make the coversions in other places.

@luisfpg
Copy link
Collaborator

luisfpg commented Sep 4, 2018

Still, it would require the generated code to traverse the entire object graph before requests and after responses, and this is out-of-scope for ng-swagger-gen.

@SharmaHarsh7
Copy link

Looks line ng-swagger-gen is not open for change requests.

In my opinion, on client side we should have the exact same copy of the type models on server or it could be string | Date.

@luisfpg
Copy link
Collaborator

luisfpg commented Jul 28, 2019

"Looks line ng-swagger-gen is not open for change requests."

When we started to work with Swagger in the Cyclos project, we didn't find a suitable generator and released ng-swagger-gen as open source in the hope it would be useful to others. Judging by the number of downloads, issues and pull requests, I'm particularly happy with the result.
I'm the sole maintainer of the project, but it did had a lot of PR's.
Now we no longer use Swagger 2, but moved to OpenAPI 3, and hence, ng-openapi-gen was born. We no longer use Swagger ourselves, so ng-swagger-gen is only receiving critical fixes.
For the record, no-openapi-gen won't support this particular feature either.
If this feature is critical for someone, the only way would be a fork.

@SharmaHarsh7
Copy link

Agree with the default implementation, after considering different scenarios and putting some efforts in research, I also found that the JSON string is the correct format for the date/time type and it is your application's responsibility to play around with the conversion of string to datetime when required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants