docs(planning): record decision to keep ClassProperty media_type#20
Merged
Conversation
Architecture-review candidate 3 proposed collapsing the ClassProperty descriptor + per-route VersionedJSONResponse. Rejected: the descriptor's lazy class-level read is what decouples init_fastapi_versioning timing from route registration. The README calls init after include_router; the tests call it before; both work only because of that laziness. Every collapse (eager init resolution, startup hook, or middleware content-type) trades it for an init-ordering contract, lifespan coupling, or over-stamping non-versioned responses. Records the constraint and revisit triggers. 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
Records the outcome of architecture-review candidate 3 (collapse the
ClassPropertydescriptor + per-routeVersionedJSONResponse).Decision: rejected. The descriptor stays.
Why
The deciding discovery:
ClassProperty's lazy class-level read is what makesinit_fastapi_versioningorder-independent with respect toinclude_router. The two shipped usages prove it by disagreeing:README.md—include_router(...)theninit_fastapi_versioning(...)(init last).tests/conftest.py—init_fastapi_versioning(...)theninclude_router(...)(init first).Both work only because the vendor is read lazily at access time. Every proposed collapse trades that away:
initby iteratingapp.routes) requires routes to be mounted first → imposes an "init last" contract and breaks the init-first order.initinto app lifespan.VersionedAPIRouteresponse from a plain one at ASGI send time, so it would over-stamp the vendor content-type onto non-versioned responses.Mechanics verified against FastAPI 0.139.0 / Starlette 1.3.1 (
openapi/utils.py:279readsresponse_class.media_typelive at schema-gen;APIRoute.__init__captures the class object in the handler closure). Full rationale and revisit triggers in the decision file.No code changes.
just check-planning→planning: OK; appears under## Decisionsinjust index.