Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conversion of deprecated flag on parameters #851

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading