Skip to content

API resources and response transformers #31

Description

@eaguad1337

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, Add Redis queue driver #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiAPI building: resources, transformersenhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions