refactor: extract _collapse_versioned_paths from _custom_openapi#21
Merged
Conversation
Full-lane design.md + plan.md for extracting the OpenAPI path-collapse loop into a pure, unit-testable _collapse_versioned_paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lesnik512
added a commit
that referenced
this pull request
Jul 4, 2026
…#22) * docs(planning): add 1.4.7 release notes Case-insensitive vendor matching fix (#18) plus internal refactors (#17, #21) since 1.4.6. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(planning): record vendor-media-type process-global decision Review #2 candidate B: keep VENDOR_MEDIA_TYPE as class-global state; instance-scoping collides with the response-class mechanism and one-vendor-per-process is accepted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(architecture): seed capability pages and glossary Living-truth pages for Accept-header version negotiation and OpenAPI schema versioning, plus the ubiquitous-language glossary. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Behavior-preserving refactor from fresh architecture review #2 (candidate A). Lifts the OpenAPI path-collapse/content-rewrite loop out of the monkey-patched
_custom_openapiinto a pure module-level function:It splits the
:<version>suffix, rewrites eachrequestBodycontent key to{vendor}; version=X.Y, and merges same-path versions viahelpers.dict_merge._custom_openapinow calls it.Why
_iter_openapi_routes— the first half of the OpenAPI-versioning transform — was already a seam-testable function with a direct unit test. The collapse loop, its second half, was inline and reachable only by building an app and fetching/openapi.json. This completes the pattern: the collapse rules (colon split, content-key rewrite, per-version merge) are now verifiable without an ASGI round-trip. Vendor is a plain argument, so the function is pure w.r.t. theVENDOR_MEDIA_TYPEglobal.A dedicated
openapi.pymodule (symmetry withaccept.py) was considered and rejected as YAGNI —app.pyis ~130 lines with no size pressure. Recorded in the design doc.Tests
Four
async defunit tests intests/test_app.pybeside the_iter_openapi_routestest, one per branch: non-versioned passthrough, requestBody rewrite, two-versiondict_merge, versioned-without-requestBody. Pure addition — the existing OpenAPI integration tests (distinct-models, prefix, colon-preservation) are unchanged and still exercise the real pipeline.just test-ci— 36 passed, coverage 100%.just lint-ci— ruff + ty clean,planning: OK.Planning bundle:
planning/changes/2026-07-04.03-collapse-versioned-paths-seam/.🤖 Generated with Claude Code