Recognize trace operations in docstrings#1059
Open
gaoflow wants to merge 2 commits into
Open
Conversation
load_operations_from_docstring filters docstring keys against PATH_KEYS, which omitted "trace". A trace: operation defined in a view docstring was silently dropped, even though OpenAPI v3 (VALID_METHODS_OPENAPI_V3) and the rest of apispec (e.g. resolve_refs_in_path) treat trace as a first-class operation. Add "trace" to PATH_KEYS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
load_operations_from_docstringfilters the keys of a view docstring againstPATH_KEYS, which omitted"trace":So a
trace:operation defined in a docstring is silently dropped:This is inconsistent with the rest of apispec, which treats TRACE as a first-class OpenAPI v3 operation:
core.py:VALID_METHODS_OPENAPI_V3 = VALID_METHODS_OPENAPI_V2 + ["trace"]core.py:resolve_refs_in_pathiterates all eight methods, includingtraceOnly
PATH_KEYSinyaml_utils.pywas missed. The same docstring'sget:operation is kept, confirming this is an oversight rather than intent.Fix
Add
"trace"toPATH_KEYS, mirroringVALID_METHODS_OPENAPI_V3.Verification
dev(41784ce):traceis dropped fromload_operations_from_docstring(and end-to-end, absent fromspec.to_dict()["paths"]); with the fix it is preserved.test_load_operations_from_docstring_trace; it fails before the fix and passes after.ruff checkandruff format --checkclean.This pull request was prepared with the assistance of AI, under my direction and review.