chowbea-axios

Configuration

Complete reference for api.config.toml configuration options.

chowbea-axios uses a TOML configuration file (api.config.toml) in your project root.

Full Configuration Reference

api.config.toml
# Remote OpenAPI spec endpoint URL
api_endpoint = "http://localhost:3000/docs/swagger/json"

# Local spec file path (takes priority over api_endpoint if set)
# spec_file = "./openapi.json"

# Polling interval in milliseconds for watch mode
poll_interval_ms = 10000

[output]
# Folder where all generated files are written
folder = "app/services/api"

[instance]
# Environment variable name for base URL
base_url_env = "VITE_API_URL"

# localStorage key for auth token
token_key = "auth-token"

# Whether to include credentials (cookies) in requests
with_credentials = true

# Request timeout in milliseconds
timeout = 30000

[fetch]
# Headers to include when fetching the OpenAPI spec
# Values can use $ENV or ${ENV} for environment variable interpolation
# headers = { Authorization = "Bearer $API_TOKEN" }

[watch]
# Enable debug logging in watch mode (shows cycle-by-cycle logs)
debug = false

Configuration Options

Root Options

OptionTypeDefaultDescription
api_endpointstring"http://localhost:3000/docs/swagger/json"Remote OpenAPI spec endpoint URL
spec_filestring-Local spec file path (overrides api_endpoint)
poll_interval_msnumber10000Watch mode polling interval (ms)

Output Section

OptionTypeDefaultDescription
folderstring"app/services/api"Output folder for generated files

Instance Section

These options configure the generated Axios instance:

OptionTypeDefaultDescription
base_url_envstring"VITE_API_URL"Environment variable name for base URL
token_keystring"auth-token"localStorage key for auth token
with_credentialsbooleantrueInclude credentials (cookies) in requests
timeoutnumber30000Request timeout in milliseconds

Fetch Section

OptionTypeDefaultDescription
headersobject-Headers to include when fetching the spec

Watch Section

OptionTypeDefaultDescription
debugbooleanfalseEnable verbose cycle-by-cycle logging

Environment Variable Interpolation

Header values support environment variable interpolation:

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

Both $VAR_NAME and ${VAR_NAME} syntax are supported:

[fetch]
headers = { 
  Authorization = "Bearer ${API_TOKEN}",
  X-API-Key = "$MY_API_KEY"
}

If an environment variable is not set, the CLI will throw an error with a helpful message.

Framework-Specific Examples

Vite / React

api.config.toml
api_endpoint = "http://localhost:3000/api-docs/json"

[output]
folder = "src/api"

[instance]
base_url_env = "VITE_API_URL"

Next.js

api.config.toml
api_endpoint = "http://localhost:3000/api-docs/json"

[output]
folder = "lib/api"

[instance]
base_url_env = "NEXT_PUBLIC_API_URL"

Vue / Nuxt

api.config.toml
api_endpoint = "http://localhost:3000/api-docs/json"

[output]
folder = "src/services/api"

[instance]
base_url_env = "VITE_API_BASE_URL"

Using a Local Spec File

Instead of fetching from a remote endpoint, you can use a local OpenAPI file:

api.config.toml
# Comment out or remove api_endpoint
# api_endpoint = "http://localhost:3000/docs/swagger/json"

# Use local file instead
spec_file = "./openapi.json"

[output]
folder = "app/services/api"

The CLI will use this file for all generation operations.

Multiple Configurations

If you need different configurations (e.g., for different API services), you can:

  1. Create multiple config files:

    • api.config.toml (default)
    • api.config.auth.toml
    • api.config.payments.toml
  2. Specify which config to use:

chowbea-axios fetch --config api.config.auth.toml

Next Steps

On this page