feat(web): HTTP message converter chain — JSON/XML content negotiation, read+write (v26.06.28)#53
Merged
Merged
Conversation
…n (read+write) + bump v26.06.28 Completes Jackson parity (the HttpMessageConverter model): - MessageConverter base + JsonMessageConverter/XmlMessageConverter (both via PyFlyJsonSerializer so pyfly.web.json.* applies to every format) + MessageConverterRegistry (ordered, user converters take priority via a MessageConverterRegistry bean). - Content negotiation: responses select by Accept (q-value ordered, JSON default); requests by Content-Type. XML REQUEST bodies now deserialize into models (was response-only, JSON-only reads). - fail-on-unknown-properties enforced on read via a cached extra='forbid' overlay (no model mutation). - Wired through controller response path + resolver body path; exported from pyfly.web. Tests: test_message_converters.py (7) + test_content_negotiation_e2e.py (2, real controller via TestClient: JSON<->XML response + XML request parsing); updated test_response.py to assert media-type/body not the concrete Response class. Gates: mypy --strict (611), ruff + format, full suite 3766 passed.
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
Completes Jackson parity — the
HttpMessageConvertermodel. Serialization is now a pluggable, ordered converter chain selected by media type for both read and write.MessageConverter+JsonMessageConverter/XmlMessageConverter(both backed byPyFlyJsonSerializer, sopyfly.web.json.*config applies to every format) +MessageConverterRegistry(ordered; user converters take priority — register aMessageConverterRegistrybean to add CBOR/etc.).Acceptwith q-values; requests fromContent-Type.fail-on-unknown-propertiesenforced on read via a cachedextra='forbid'overlay (no model mutation).pyfly.web; wired through the controller response path + resolver body path (both Starlette & FastAPI).Tests
test_message_converters.py(7): parse_accept q-values, JSON/XML roundtrip, fail-on-unknown, registry negotiation, custom-converter priority, response negotiation.test_content_negotiation_e2e.py(2): real controller via TestClient — GET negotiates JSON⇄XML by Accept; POST parses JSON and XML bodies.test_response.pyto assert media-type/body rather than the concreteResponseclass.Gates
mypy --strict(611) ✓ ·ruff+ruff format✓ · full suite 3766 passed, 1 skipped.Bumps
v26.06.27 → v26.06.28. Not built (noted): per-routeproduces/consumes. Next: Wave 4 (multi-datasource, SpEL, Testcontainers) + Wave 5 (docs + skills/agents).