Skip to main content
Mount any HTTP server with an OpenAPI specification as typed CLI commands. incur automatically generates subcommands with arguments, options, and descriptions extracted from your spec.

Basic Usage

Pass an OpenAPI spec alongside the fetch property to generate typed subcommands:

Generated Command Structure

incur parses your OpenAPI spec and generates commands with:
  • Operation ID as command nameoperationId becomes the command name
  • Path parameters as arguments — path params like {id} become positional arguments
  • Query parameters as options — query params become --flag options
  • Request body as options — JSON body properties become --flag options
  • Descriptions from specsummary and description fields flow through to help text

Example Commands

Without OpenAPI

You can also mount a fetch handler without a spec. All argv tokens are interpreted as path segments and curl-style flags:

Curl-style Flags

When using fetch without OpenAPI, incur supports:
FlagDescription
-X, --method <METHOD>HTTP method (default: GET, POST if body present)
-H, --header "Key: Val"Set a request header (repeatable)
-d, --data <json>Request body (implies POST)
--body <json>Request body (implies POST)
--<key> <value>Query string parameter

Mounting as Commands

You can mount fetch handlers onto specific commands instead of the root:

Base Path

Use basePath to prefix all requests:

Framework Compatibility

incur works with any framework that exposes a Web Fetch API handler:

Type Safety

incur resolves all $ref pointers in your OpenAPI spec and converts JSON Schema types to Zod schemas with automatic coercion for path and query parameters (which arrive as strings from argv).

Error Handling

HTTP errors are automatically converted to incur error envelopes:
If the response body contains a message field, it’s used as the error message. Otherwise, the entire body or a generic HTTP {status} message is shown.