diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c47aded9..3aaf89e5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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. diff --git a/src/apispec/yaml_utils.py b/src/apispec/yaml_utils.py index 52985dc5..6bc4c94b 100644 --- a/src/apispec/yaml_utils.py +++ b/src/apispec/yaml_utils.py @@ -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: diff --git a/tests/test_yaml_utils.py b/tests/test_yaml_utils.py index 6d7dd28c..2d22f266 100644 --- a/tests/test_yaml_utils.py +++ b/tests/test_yaml_utils.py @@ -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"