## Problem Turning models into JSON for APIs is done ad-hoc in controllers. There is no reusable transformation layer, so output shape drifts across endpoints. ## Proposal API resource classes: - A single-resource transformer mapping a model to a JSON structure. - A resource collection wrapper. - Conditional fields and relationship inclusion. - Pagination-aware wrapping (works with the framework paginator, #2) with a `meta` block. - `make:resource` command + stub. ## Scope Resource + ResourceCollection classes, Response integration, paginator integration, command + stub. ## Definition of Done - [ ] Implementation. - [ ] `pytest` covers single/collection transforms, conditional fields, and paginated wrapping (suite green). - [ ] Docs page + nav entry. - [ ] Release notes entry. > Depends on #2 (framework-level pagination) for paginated collections.
Problem
Turning models into JSON for APIs is done ad-hoc in controllers. There is no reusable transformation layer, so output shape drifts across endpoints.
Proposal
API resource classes:
metablock.make:resourcecommand + stub.Scope
Resource + ResourceCollection classes, Response integration, paginator integration, command + stub.
Definition of Done
pytestcovers single/collection transforms, conditional fields, and paginated wrapping (suite green).