Skip to content

Generate the frontend API client from qh's OpenAPI spec #7

Description

@thorwhalen

Context

frontend/src/api/schema.ts is hand-written and verified against the live backend, because qh's /openapi.json previously emitted empty request/response schemas. With i2mint/qh#9, qh now derives full JSON Schema from the Python type hints — so the frontend's API types can be generated from the spec instead of hand-maintained.

Plan

  • Export the backend's enhanced OpenAPI document to a committed frontend/src/api/openapi.json (the API contract snapshot), via a small backend/export_openapi.py script.
  • Add openapi-typescript and a gen:api script; generate frontend/src/api/openapi.d.ts from the spec.
  • Replace hand-written schema.ts with thin named aliases (CorpusInfo, Segment, SearchHit, ExploreResult, CreateCorpusBody, QueryBody, ExploreBody) derived from the generated types — keeps all 8 consumer files untouched.
  • Verify: tsc typechecks and the app runs end-to-end against the backend.

Refs i2mint/qh#9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions