Skip to content

Commit

Permalink
Merge pull request #851 from tsokalski/fix-deprecated-field
Browse files Browse the repository at this point in the history
Fix conversion of deprecated flag on parameters
  • Loading branch information
lafrech authored Aug 5, 2023
2 parents ee2e20c + 8cbbbeb commit c0fd185
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ Contributors (chronological)
- Edwin Erdmanis `@vorticity <https://github.com/vorticity>`_
- Mounier Florian `@paradoxxxzero <https://github.com/paradoxxxzero>`_
- Renato Damas `@codectl <https://github.com/codectl>`_
- Tayler Sokalski `@tsokalski <https://github.com/tsokalski>`_
2 changes: 2 additions & 0 deletions src/apispec/ext/marshmallow/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_ext_marshmallow_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c0fd185

Please sign in to comment.