poem
poem copied to clipboard
poem-openapi: Replace `naive-date` with `date`
When a date type was specified in an openapi Object, it was previously set to the format naive-date
, which isn't recognized by doc-generators.
This replaces the openapi text format naive-date
with date
, aligning with the OAS definition which uses RFC3339 full-date (which is naive by def).
It enables doc-generators (e.g. rapidoc) to generate examples when the schema contains a time::Date
or chrono::NaiveDate
field.
how about date-time
? should we change together. ( I'm not familiar with openapi
I believe openapi uses the same date/time definitions as json schema.
A naive date-time does not exist (yet). And I do not think it would be a good idea to set it to date-time
, which is specified to contain timezone. Poem would not parse a date-time
with time zone as a naive date-time
, so the doc-generated examples would fail. And if there are any external input/output validators, they will most probably cause the request to fail.
The same goes for time
(even tough time is not in the OAS specification, but rapidoc uses it).
So in my opinion the other date/time formats are fine, at least until OAS/JSON Schema has a specification for naive formats. :)
Thanks for your reply!
If you expect a datetime in RFC3339
format, should use OffsetDateTime
instead of PrimitiveDateTime
.
@sunli829 this PR is about date, not datetime.
All date
objects are naive in OAS and that is what this PR fixes.
Can you reopen and consider merging?