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

Transform Date strings #32

Closed
arkraft opened this issue Aug 22, 2019 · 3 comments
Closed

Transform Date strings #32

arkraft opened this issue Aug 22, 2019 · 3 comments

Comments

@arkraft
Copy link
Contributor

arkraft commented Aug 22, 2019

Swagger does not have an own Date type. Instead Date is supported via string (https://swagger.io/docs/specification/data-models/data-types/). The documentation might be for OpenAPI 3.0, but the part about the Date is also valid for 2.0. The format attribute supports two Date formats:

  • date – full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21
  • date-time – the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z

It would be a huge plus, if these types where transformed correctly whitin a DTO. So when receiving a response the DTO could just transform the string of these fields to date and vice versa when sending a request.

One idea might be to use https://github.com/typestack/class-transformer within the DTOs and transform them with the plainToClass method.

I know it is a lot to ask, but it would be a great feature which would save a lot of work because i work with a lot of dates.

This codegen is already great and this is the only thing i am missing so far .Thanks!

@Manweill
Copy link
Owner

@arkraft
Hi, I may not have time to deal with this issue in the short term.If you have any idea to realize it, welcome PR

@Manweill
Copy link
Owner

@arkraft
Hei,can you add some examples about this PR of you?

@arkraft
Copy link
Contributor Author

arkraft commented Oct 20, 2019

Made a new PR for the example

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

No branches or pull requests

2 participants