chowbea-axios
Commands

fetch

Fetch OpenAPI spec from remote endpoint and generate types.

fetch downloads your OpenAPI spec, caches it, compares hashes, and regenerates _generated/ when something changed. It's the command CI runs and the one you run when staging moved on without telling frontend.

The Fetch & Generate screen in the interactive dashboard, showing live log output and a Fetch Complete summary. Prefer buttons? The interactive dashboard runs fetch from Fetch & Generate.

Usage

chowbea-axios fetch [flags]

What it does

  1. Downloads the OpenAPI spec from your configured endpoint (or loads from local file)
  2. Caches the spec with hash for change detection
  3. Compares with previous version to detect changes
  4. Generates api.contracts.ts, api.types.ts, and api.operations.ts
  5. Creates client files if they don't exist

Operations without operationId are skipped in api.operations.ts. Path client methods still generate for every endpoint. Run validate if you're wondering why api.op.createThing doesn't exist.

Flags

FlagShortDescriptionDefault
--config-cPath to api.config.tomlAuto-detected
--endpoint-eOverride API endpoint URLFrom config
--spec-file-sUse local spec file instead of remote-
--force-fForce regeneration even if unchangedfalse
--dry-run-nPreview without writing filesfalse
--types-only-Generate only TypeScript typesfalse
--operations-only-Generate only operationsfalse
--quiet-qSuppress non-error outputfalse
--verbose-vShow detailed outputfalse

Examples

Basic fetch

chowbea-axios fetch

Force regeneration

chowbea-axios fetch --force

Hash unchanged but you don't trust it? --force. We've all been there.

Use local spec file

chowbea-axios fetch --spec-file ./openapi.json

Override endpoint

chowbea-axios fetch --endpoint https://api.example.com/docs/swagger.json

Dry run (preview)

chowbea-axios fetch --dry-run

Output:

Dry run complete - no files written
Operations found (operations=42)
Would update: app/services/api/_generated/api.types.ts
Would update: app/services/api/_generated/api.operations.ts (156 lines)

Generate only types

chowbea-axios fetch --types-only

Caching behavior

  1. SHA256 hash of spec content is computed
  2. Compared with cached hash from previous fetch
  3. Skips generation if hashes match (unless --force)

Cache lives in _internal/:

  • .api-cache.json — hash and metadata
  • openapi.json — cached spec content

Don't edit these. They'll be overwritten and you'll be sad.

Network retry logic

Endpoint down? Fetch tries like an adult:

  1. Retry 3 times with exponential backoff (1s, 2s, 4s)
  2. Fall back to cached spec if available
  3. Report error if no cache exists
│ ⚠ Fetch failed, retrying... (attempt=1, maxAttempts=3, delayMs=1000)
│ ⚠ Fetch failed, retrying... (attempt=2, maxAttempts=3, delayMs=2000)
│ ⚠ All fetch attempts failed, checking for cached spec...
│ ✓ Using cached OpenAPI spec due to network failure

Authentication

Protected spec endpoints — headers in config:

api.config.toml
[fetch]
headers = { Authorization = "Bearer $API_TOKEN" }

Environment interpolation: $VAR or ${VAR}.

Generated files

After a successful fetch:

.api-cache.json
openapi.json
api.contracts.ts # named types — import these first
api.types.ts
api.operations.ts # api.op wrappers

_internal/ and _generated/ are overwritten on each fetch. Your edits belong in api.client.ts, api.instance.ts, and the query layer.

When to use fetch vs generate

Use fetch when...Use generate when...
Your API spec changedYou have a cached/local spec
First time setupRegenerating from cache
CI/CD pipelinesQuick iteration offline
Remote endpoint availableNetwork is optional

Next Steps

On this page