apispec icon indicating copy to clipboard operation
apispec copied to clipboard

iso8601 format not detected correctly

Open matejsp opened this issue 11 months ago • 1 comments

Date and DateTime with format argument as iso8601 it is not rendered correctly.

Actually marshallow supports also the following:

        "iso": utils.isoformat,
        "iso8601": utils.isoformat,
        "rfc": utils.rfcformat,
        "rfc822": utils.rfcformat,
works:
datetime = fields.DateTime(dump_only=True, format='iso')
does not work:
datetime2 = fields.DateTime(dump_only=True, format='iso8601')

https://github.com/marshmallow-code/marshmallow/blob/dev/src/marshmallow/fields.py#L1275-L1291

matejsp avatar Mar 30 '25 13:03 matejsp

We haven't explicitly supported "iso8601" and "rfc822" (the docs only mention iso). But given that they're supported in marshmallow makes sense to support them here, too.

looks like the relevant check is here: https://github.com/marshmallow-code/apispec/blob/9c3ac165bc08af856b13d283c82e838c57919ffa/src/apispec/ext/marshmallow/field_converter.py#L571

PR welcome!

sloria avatar Mar 30 '25 15:03 sloria