Skip to content

Regenerating the API Client

The frontend and backend communicate via an API defined in the backend's Rust code. The API is defined using utoipa macros. The main definition is in the ApiDoc struct in src/main.rs, and the various types and handlers are elsewhere in the codebase. When you make changes to that affect the API, you must regenerate the frontend's TypeScript client.

To do this, simply run:

just api-update

This command will:

  1. Build and run a small part of the backend to generate an updated trufotbot-openapi.json schema file.
  2. Run the frontend's code generation script to create updated TypeScript client code based on the new schema.

Note

utoipa only collects schemas that are referenced from request and response bodies. A type that is used only as a path or query parameter (such as MessageId) must also be listed under components(schemas(...)) on ApiDoc; otherwise just api-update fails because of a $ref with no matching component.

After regeneration, it's a good idea to run the frontend's type checker and tests to ensure the new API client is integrated correctly. You may need to update frontend code to match the new API.

just frontend-check