yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator
MIT License
625 stars 147 forks source link

Sending DateTime (through request) sends as integer instead of date formatted string #147

Closed cerupcat closed 4 years ago

cerupcat commented 5 years ago

I'm trying to send a DateTime as a paramter. The server is expecting a date formatted string, but instead, it's sending the timeIntervalSinceReferenceDate integer instead. I'm not sure where to find the encoding of the DateTime => string.

cerupcat commented 5 years ago

I'm not sure if Date.encode() via the extension is supposed to be called, but it doesn't appear to be in my case.

jrcmramos commented 5 years ago

I have got the same issue, did you find a way to fix this without modifying the framework? Otherwise I will probably submit a pull request for a dateEncoder in the same way we already have a dateDecoder

yonaskolb commented 5 years ago

Thanks for the PR @jrcmramos. This will allow customization on a request basis. Would a good default be for the default JSONEncoder to use API.dateEncodingFormatter as well? It's used when dates are encoded as strings, but not within json bodies at the moment

jrcmramos commented 5 years ago

Thank you for the feedback @yonaskolb. That's a really good suggestion, I will adjust the PR