Skip to content

Commit

Permalink
Fix conversion of Marshmallow field to OAS parameter to specify the d…
Browse files Browse the repository at this point in the history
…eprecated flag on the parameter, not its schema.
  • Loading branch information
tsokalski committed Jul 17, 2023
1 parent 95d73b4 commit 8cbbbeb
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 8cbbbeb

Please sign in to comment.