diff --git a/AUTHORS.rst b/AUTHORS.rst index 9d854662..bc54f7d4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -91,3 +91,4 @@ Contributors (chronological) - Felix Claessen `@Flix6x `_ - Karthik Ramadugu `@karthiksai109 `_ - Amir Kahriman `@kingdomOfIT `_ +- Jean-Baptiste Braun `@jbbqqf `_ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c47aded9..a2e8c86b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,14 @@ Changelog unreleased ********** +Bug fixes: + +- ``MarshmallowPlugin``: stop emitting ``"format": null`` and ``"pattern": null`` + for ``DateTime`` fields declared with the ``"rfc"``/``"rfc822"`` format or a + custom ``strftime`` format string. The OpenAPI 3 schema rejects null values + for these keywords, so the resulting document failed + ``openapi-spec-validator`` (:issue:`938`). + Other changes: - Drop support for marshmallow 3, which is EOL. diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py index 527fa9da..1806beda 100644 --- a/src/apispec/ext/marshmallow/field_converter.py +++ b/src/apispec/ext/marshmallow/field_converter.py @@ -566,52 +566,63 @@ def enum2properties(self, field, **kwargs: typing.Any) -> dict: ret["enum"].append(None) return ret - def datetime2properties(self, field, **kwargs: typing.Any) -> dict: + def datetime2properties(self, field, ret=None, **kwargs: typing.Any) -> dict: """Return a dictionary of properties from :class:`DateTime