Skip to main content

Crate pathbase_client

Crate pathbase_client 

Source
Expand description

§pathbase-client

Auto-generated typed Rust client for the Pathbase HTTP API.

The client is derived at build time from openapi.json (committed alongside the crate) via progenitor. Spec drift surfaces as a cargo build failure rather than a runtime “HTML where JSON was expected” error.

§What’s in here

use pathbase_client::Client;

let client = Client::new("https://pathbase.dev");
// `client.health()`, `client.create_anon_path(...)`, `client.create_path(...)`, etc.

The full surface mirrors the OpenAPI document. Only the operations actually documented there are available. The CLI auth-redeem endpoint (POST /api/v1/auth/cli/redeem) is real in production but absent from the spec, so it is not present in this client — path-cli keeps a hand-rolled redeem implementation.

§Build pipeline

  1. The committed spec is OAS 3.1; progenitor’s openapiv3 dependency only understands 3.0.
  2. build.rs reads the spec, downgrades 3.1 idioms in-memory ("type": ["string", "null"]"type": "string", "nullable": true; injects permissive schemas for empty media-type bodies), then hands the result to progenitor::Generator.
  3. The generated code lands in $OUT_DIR/pathbase_client.rs and is included from src/lib.rs.

§Refreshing the spec

From the workspace root:

scripts/refresh-pathbase-openapi.sh                              # defaults to https://pathbase.dev
PATHBASE_URL=https://staging.example.com scripts/refresh-pathbase-openapi.sh

The script overwrites crates/pathbase-client/openapi.json (the same file build.rs reads). After refresh, cargo build -p pathbase-client regenerates the client against the new spec.

§License

Apache-2.0.

Modules§

prelude
Items consumers will typically use such as the Client.
types
Types used as operation parameters and responses.

Structs§

ByteStream
Untyped byte stream used for both success and error responses.
Client
Client for Pathbase API
ResponseValue
Typed value returned by generated client methods.

Enums§

Error
Error produced by generated client methods.

Traits§

ClientInfo
Interface for which an implementation is generated for all clients.