Skip to main content

Overview

kweri-gen takes an OpenAPI 3.x specification and generates a single client.ts file into your own source tree, containing:
  • TypeBox schemas for every component and endpoint (method, path, parameters, responses)
  • EndpointByMethod — the unified map used by createReactPathHooks and createVuePathHooks
  • createClient — a typed client whose every method runs through the kweri runtime (cache, request dedup, stale-while-revalidate)
The output is plain TypeScript that your own build compiles. Commit it like any other source file.

Usage

External and internal $ref pointers are resolved automatically — there is no separate bundling flag.

Examples

package.json
Run kweri-gen as an explicit gen script and commit the output — not as a postinstall hook. Writing into your own tree means the generated client survives reinstalls and works under npm, pnpm, and Yarn PnP.

Output

The generated file is written to <out>/client.ts (default src/api/kweri/client.ts), relative to the current working directory.

File structure

Using the generated client

Because the client routes through kweri, every call is cached and deduplicated:

Using with path-based hooks

The generated EndpointByMethod works directly with createReactPathHooks and createVuePathHooks. Import it from your generated file:

How endpoint resolution works

When you call useGet('/users', {}), the path hook:
  1. Lowercases the method: 'get'
  2. Looks up EndpointByMethod['get']['/users'] → the TypeBox schema (for types)
  3. Extracts the responses.200 (or responses.201) schema as the response type
  4. Constructs a temporary Endpoint with params: Type.Any() (skips runtime param validation)
  5. Delegates to the underlying useQuery
If the path isn’t found in the map, the hook throws:

Regenerating

Re-run kweri-gen whenever your API spec changes. The output file is completely regenerated each time — don’t edit client.ts by hand, your changes will be overwritten. Commit the regenerated file so builds are deterministic and don’t depend on the API being reachable at build time.