-
-
Notifications
You must be signed in to change notification settings - Fork 200
Recognize trace operations in docstrings
#1059
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
base: dev
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -708,6 +708,15 @@ def test_path_methods_maintain_order(self, spec): | |
| spec.path(path="/path", operations={method: {}}) | ||
| assert list(spec.to_dict()["paths"]["/path"]) == methods | ||
|
|
||
| def test_trace_path_method_is_openapi3_only(self): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't even test that. Also, my comment about |
||
| spec_v3 = APISpec(title="Test API", version="1.0", openapi_version="3.0.0") | ||
| spec_v3.path(path="/path", operations={"trace": {}}) | ||
| assert "trace" in spec_v3.to_dict()["paths"]["/path"] | ||
|
|
||
| spec_v2 = APISpec(title="Test API", version="1.0", openapi_version="2.0") | ||
| with pytest.raises(APISpecError, match="One or more HTTP methods are invalid"): | ||
| spec_v2.path(path="/path", operations={"trace": {}}) | ||
|
|
||
| def test_path_merges_paths(self, spec): | ||
| """Test that adding a second HTTP method to an existing path performs | ||
| a merge operation instead of an overwrite""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,22 @@ def test_load_operations_from_docstring_empty_docstring(docstring): | |
| assert yaml_utils.load_operations_from_docstring(docstring) == {} | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is fine. |
||
| "method", ("get", "put", "post", "delete", "options", "head", "patch", "trace") | ||
| ) | ||
| def test_load_operations_from_docstring_path_methods(method): | ||
| docstring = f"""Foo. | ||
| --- | ||
| {method}: | ||
| responses: | ||
| 200: | ||
| description: ok | ||
| """ | ||
|
|
||
| operations = yaml_utils.load_operations_from_docstring(docstring) | ||
| assert operations == {method: {"responses": {200: {"description": "ok"}}}} | ||
|
|
||
|
|
||
| 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" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand the benefit of avoiding redundancy, I believe this set just "happens" to be equal to the v3 list.
To be precise, it should be the union of the valid methods for all OpenAPI versions. Frankly, we can keep it as it was defined before. It is not really duplication. And it doesn't change every other day.