Commands
fetch
Fetch OpenAPI spec from remote endpoint and generate types.
The fetch command downloads your OpenAPI specification, caches it locally, and generates TypeScript types and operation functions.
Usage
chowbea-axios fetch [flags]What It Does
- Downloads the OpenAPI spec from your configured endpoint (or loads from local file)
- Caches the spec with hash for change detection
- Compares with previous version to detect changes
- Generates
api.types.tsandapi.operations.ts - Creates client files if they don't exist
Flags
| Flag | Short | Description | Default |
|---|---|---|---|
--config | -c | Path to api.config.toml | Auto-detected |
--endpoint | -e | Override API endpoint URL | From config |
--spec-file | -s | Use local spec file instead of remote | - |
--force | -f | Force regeneration even if unchanged | false |
--dry-run | -n | Preview without writing files | false |
--types-only | - | Generate only TypeScript types | false |
--operations-only | - | Generate only operations | false |
--quiet | -q | Suppress non-error output | false |
--verbose | -v | Show detailed output | false |
Examples
Basic Fetch
chowbea-axios fetchForce Regeneration
# Regenerate even if spec hasn't changed
chowbea-axios fetch --forceUse Local Spec File
chowbea-axios fetch --spec-file ./openapi.jsonOverride Endpoint
chowbea-axios fetch --endpoint https://api.example.com/docs/swagger.jsonDry Run (Preview)
chowbea-axios fetch --dry-runOutput:
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
# Skip operations, only generate api.types.ts
chowbea-axios fetch --types-onlyCaching Behavior
The fetch command uses smart caching to avoid unnecessary regeneration:
- SHA256 hash of spec content is computed
- Compared with cached hash from previous fetch
- Skips generation if hashes match (unless
--force)
Cache files are stored in _internal/:
.api-cache.json- Hash and metadataopenapi.json- Cached spec content
Network Retry Logic
If the endpoint is unreachable, fetch will:
- Retry 3 times with exponential backoff (1s, 2s, 4s delays)
- Fall back to cached spec if available
- 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 failureAuthentication
For protected spec endpoints, add headers in your config:
[fetch]
headers = { Authorization = "Bearer $API_TOKEN" }Headers support environment variable interpolation with $VAR or ${VAR} syntax.
Generated Files
After a successful fetch:
.api-cache.json
openapi.json
api.types.ts
api.operations.ts
Files in _internal/ and _generated/ are overwritten on each fetch. Don't edit them.
When to Use fetch vs generate
Use fetch when... | Use generate when... |
|---|---|
| Your API spec changed | You have a local spec file |
| First time setup | Regenerating from cache |
| CI/CD pipelines | Quick iteration |
| Remote endpoint available | Working offline |