yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dateEncodingFormatter inconsitent format?HI,

b00tsy opened this issue · comments

Excellent framework which makes my live a lot easier! Although the learning curve could be less steep as I believe that the auto-generated documentation is out of date.

I have problems with dateEncodingFormatter of Coding. Is there a reason why the used format differs from the ones defined in dateDecodingFormatters?

yyyy-MM-dd'T'HH:mm:ss.Z the dot just before Z seems wrong to me and it makes my swagger validator on the backend reject the submitted date, eg. 2019-01-01T12:12:12.Z. On top of that I need fractional accuracy as in one of the formats in the decoding formatter. Is it possible to customize the encoding formatter somehow without manually adjusting Coding.swift every time after an export?

Hi @b00tsy, glad you’re getting some use of of it! Those date formatters are public properties so they can be modified. You can just set DateTime.dateEncodingFormatter.formatString = “...”.
The reason why decoding uses an array of formatters is so it can decode a few different types, as backend formats can vary slightly. On encoding though we have to have a single explicit format

Yeah I'm not sure actually. I think a backend on a project a few years ago must of passed strings back in that format, so it's been there ever since

I'll close this for now. Let me know if you have any more questions or issues