Repository navigation
Fix response-header documentation on marshalling decorators - #655
Open
2836048681 wants to merge 1 commit into
Open
2836048681 wants to merge 1 commit into
2836048681 wants to merge 1 commit into
Conversation
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.
Fixes #601.
Passing
headersto@api.marshal_with()currently raisesTypeErrorwhiledefining the resource. The namespace decorator already stores these descriptions
in response metadata, and Swagger already knows how to render them, but the same
keyword arguments are forwarded to the runtime marshaller, which does not accept
headers.Copy the runtime marshalling options and remove
headersfrom that copy, keepingthe original response metadata intact. This also fixes
@api.marshal_list_with()and preserves header documentation when the same decorator is reused.
The regression cases cover both decorators, reusable decorators, string and typed
header descriptions, response-code scoping, envelopes, filtered response bodies,
and preservation of runtime response headers and status codes. Document the
parameter and add a changelog entry.
Validation
Environment: CPython 3.12.3, Flask 3.1.3, Werkzeug 3.1.9, pytest 8.4.2.
unexpected-
headersTypeError (screening/regression-before.log).(
screening/targeted-after.log).(
screening/full-after.log). The failures are existing DNS-dependent tests:tests/test_inputs.py::URLTest::test_checkandtests/test_inputs.py::EmailTest::test_invalid_values_check[coucou@not-found.test].Both fail identically against an untouched export of base commit
30abd919e7c6bb2533eef57ec9c2339d7de69b39(
screening/baseline-dns.log). The baseline import was verified to come fromscreening/baseline/flask_restx/, not the edited checkout. This runner resolvesboth supposedly nonexistent hosts to 198.18.x.x addresses; see
screening/dns-environment.json.1,231 passed, 6 skipped, 2 deselected (
screening/full-isolated.log).screening/black.log).inv qapackaging/rendering check: passed (screening/qa.log).pip checkandgit diff --check: passed.Commands, from the checkout: