Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
unreleased
**********

Bug fixes:

- Recognize ``trace`` operations defined in view docstrings, instead of
silently dropping them (:pr:`1059`).

Other changes:

- Drop support for marshmallow 3, which is EOL.
Expand Down
2 changes: 1 addition & 1 deletion src/apispec/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_yaml_from_docstring(docstring: str) -> dict:
return yaml.safe_load(yaml_string) or {}


PATH_KEYS = {"get", "put", "post", "delete", "options", "head", "patch"}
PATH_KEYS = {"get", "put", "post", "delete", "options", "head", "patch", "trace"}


def load_operations_from_docstring(docstring: str) -> dict:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ def test_load_operations_from_docstring_empty_docstring(docstring):
assert yaml_utils.load_operations_from_docstring(docstring) == {}


def test_load_operations_from_docstring_trace():
def f():
"""Foo.
---
get:
responses:
200:
description: ok
trace:
responses:
200:
description: ok
"""

operations = yaml_utils.load_operations_from_docstring(f.__doc__)
assert set(operations) == {"get", "trace"}


def test_dict_to_yaml_unicode():
assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n'
assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n"
Expand Down