Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

Transform Date strings #32

Closed arkraft closed 5 years ago

arkraft commented 5 years ago

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:

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 commented 5 years ago

@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 commented 5 years ago

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

arkraft commented 5 years ago

Made a new PR for the example