Skip to content

fix: add Pydantic response models to 25 untyped API endpoints #748

Description

@Sealjay

Context

Backend schema audit found 39% of endpoints (25/64) lack proper response_model annotations, returning dict[str, Any]. This produces unknown types in the generated TypeScript SDK.

Additionally, 11 endpoints accept raw dict[str, Any] request bodies instead of Pydantic models.

High-priority endpoints needing response models

  • GET /character/{id} — should use existing CharacterSheet
  • POST /character/{id}/level-up — should use existing LevelUpResponse
  • POST /dice/roll — create DiceRollResponse
  • GET /campaign/templates — use CampaignListResponse
  • All session endpoints (10 routes) — create typed models
  • All combat init/turn endpoints (4 routes) — create typed models

High-priority endpoints needing request models

  • POST /combat/initialize — create CombatInitializeRequest
  • POST /combat/{id}/turn — create CombatTurnRequest
  • POST /campaign/generate-world — create GenerateWorldRequest
  • POST /session/{id}/action — create PlayerActionRequest

Tasks

  • Add response_model to all 25 endpoints
  • Create Pydantic request models for 11 raw-dict endpoints
  • Regenerate openapi.json and schema.d.ts
  • Verify bunx tsc --noEmit passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions