diff --git a/AUTHORS.rst b/AUTHORS.rst index e2b6758b..3ca744b4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -88,3 +88,4 @@ Contributors (chronological) - Robin `@allrob23 `_ - Xingang Zhang `@0x0400 `_ - Lewis Haley `@LewisHaley `_ +- Felix Claessen `@Flix6x `_ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 98aabc10..bc96b069 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,8 @@ Other changes: - Officially support Python 3.14 (:pr:`998`). - Drop support for Python 3.8 (:pr:`994`). +- Support ``examples`` property from field metadata (:pr:`999`). + Thanks :user:`Flix6x` for the PR. 6.8.4 (2025-09-22) ****************** @@ -22,10 +24,10 @@ Bug fixes: Bug fixes: -- ``MarshmallowPlugin``: set ``additionnalProperties`` to ``False`` if +- ``MarshmallowPlugin``: set ``additionalProperties`` to ``False`` if ``unknown`` is not set (:pr:`988`). Thanks :user:`mwgamble` for reporting. -- ``MarshmallowPlugin``: set ``additionnalProperties`` according to ``unknown`` +- ``MarshmallowPlugin``: set ``additionalProperties`` according to ``unknown`` value passed at schema instantiation, not only as ``Meta`` attribute (:pr:`988`). diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py index b26972a3..fdaa5a9f 100644 --- a/src/apispec/ext/marshmallow/field_converter.py +++ b/src/apispec/ext/marshmallow/field_converter.py @@ -80,6 +80,7 @@ "xml", "externalDocs", "example", + "examples", "nullable", "deprecated", } diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py index 4833a5a6..7fcb07db 100644 --- a/tests/test_ext_marshmallow_field.py +++ b/tests/test_ext_marshmallow_field.py @@ -685,3 +685,11 @@ class _DesertSentinel: field.metadata[_DesertSentinel()] = "to be ignored" result = spec_fixture.openapi.field2property(field) assert result == {"description": "A description", "type": "boolean"} + + +def test_field2property_examples(spec_fixture): + field = fields.Raw(metadata={"examples": ["foo", "bar"]}) + res = spec_fixture.openapi.field2property(field) + assert res == { + "examples": ["foo", "bar"], + }