diff --git a/AUTHORS.rst b/AUTHORS.rst index 02662ceb..17bea2b9 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -77,3 +77,4 @@ Contributors (chronological) - Edwin Erdmanis `@vorticity `_ - Mounier Florian `@paradoxxxzero `_ - Renato Damas `@codectl `_ +- Tayler Sokalski `@tsokalski `_ diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py index a27bc4f7..22ff6ef0 100644 --- a/src/apispec/ext/marshmallow/openapi.py +++ b/src/apispec/ext/marshmallow/openapi.py @@ -197,6 +197,8 @@ def _field2parameter( else: if "description" in prop: ret["description"] = prop.pop("description") + if "deprecated" in prop: + ret["deprecated"] = prop.pop("deprecated") ret["schema"] = prop for param_attr_func in self.parameter_attribute_functions: diff --git a/tests/test_ext_marshmallow_openapi.py b/tests/test_ext_marshmallow_openapi.py index 2617329b..ed7fb0ef 100644 --- a/tests/test_ext_marshmallow_openapi.py +++ b/tests/test_ext_marshmallow_openapi.py @@ -245,6 +245,11 @@ def test_field_required(self, openapi): res = openapi._field2parameter(field, name="field", location="query") assert res["required"] is True + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + def test_schema_partial(self, openapi): class UserSchema(Schema): field = fields.Str(required=True)