mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
Replace typify-only type generation with progenitor, which generates both Rust types (in a `types` module) and a reqwest-based HTTP client from the OpenAPI spec. Also upgrades reqwest 0.12→0.13 and rmcp 0.15→1.3 to align dependency versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
2.5 KiB
Text
67 lines
2.5 KiB
Text
---
|
|
title: "Client SDKs"
|
|
description: "Language-specific clients generated from the Fabro OpenAPI spec"
|
|
---
|
|
|
|
The Fabro API is defined by an OpenAPI 3.1 specification (`docs/api-reference/fabro-api.yaml` in the repository) that serves as the single source of truth for all endpoints, request/response schemas, and parameter definitions. The spec is also available at runtime from the server at `GET /api/v1/openapi.json`. Both client SDKs below are generated directly from this spec.
|
|
|
|
## TypeScript (Axios)
|
|
|
|
The `@qltysh/fabro-api-client` package is a fully typed HTTP client generated with the [OpenAPI Generator](https://openapi-generator.tech/) using the `typescript-axios` template. It produces typed API classes (one per tag) and model interfaces for every schema.
|
|
|
|
### Regenerating
|
|
|
|
From the repository root:
|
|
|
|
```bash
|
|
cd lib/packages/fabro-api-client
|
|
bun run generate
|
|
```
|
|
|
|
This runs `openapi-generator-cli` against `docs/api-reference/fabro-api.yaml` and writes the generated source into `lib/packages/fabro-api-client/src/`.
|
|
|
|
### Usage
|
|
|
|
```typescript
|
|
import { RunsApi, Configuration } from "@qltysh/fabro-api-client";
|
|
|
|
const config = new Configuration({ basePath: "http://localhost:3000" });
|
|
const runs = new RunsApi(config);
|
|
|
|
const { data } = await runs.listRuns();
|
|
console.log(data);
|
|
```
|
|
|
|
The generated client includes a typed API class for each endpoint group: `RunsApi`, `WorkflowsApi`, `SessionsApi`, `VerificationsApi`, `InsightsApi`, and others.
|
|
|
|
## Rust (Types + Client)
|
|
|
|
The `fabro-api` crate generates Rust structs, enums, and a `reqwest`-based HTTP client from the full OpenAPI spec at compile time using [progenitor](https://github.com/oxidecomputer/progenitor). This provides type-safe representations of all API models and a builder-style client for every endpoint.
|
|
|
|
### How It Works
|
|
|
|
A `build.rs` script reads `docs/api-reference/fabro-api.yaml`, patches it from OpenAPI 3.1 to 3.0 for progenitor compatibility, and generates both types and a client. The generated code is written to `OUT_DIR` and included via:
|
|
|
|
```rust
|
|
// lib/crates/fabro-api/src/lib.rs
|
|
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
|
|
```
|
|
|
|
### Regenerating
|
|
|
|
The types and client are regenerated automatically on every `cargo build` when the OpenAPI spec changes:
|
|
|
|
```bash
|
|
cargo build -p fabro-api
|
|
```
|
|
|
|
### Usage
|
|
|
|
```rust
|
|
use fabro_api::types::RunListItem;
|
|
use fabro_api::Client;
|
|
|
|
let client = Client::new("http://localhost:3000");
|
|
```
|
|
|
|
All generated types derive `serde::Deserialize` and `serde::Serialize`. The client uses builder-style methods for each endpoint.
|