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 bycreateReactPathHooksandcreateVuePathHookscreateClient— a typed client whose every method runs through the kweri runtime (cache, request dedup, stale-while-revalidate)
Usage
$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 generatedEndpointByMethod works directly with createReactPathHooks and
createVuePathHooks. Import it from your generated file:
- React
- Vue
How endpoint resolution works
When you calluseGet('/users', {}), the path hook:
- Lowercases the method:
'get' - Looks up
EndpointByMethod['get']['/users']→ the TypeBox schema (for types) - Extracts the
responses.200(orresponses.201) schema as the response type - Constructs a temporary
Endpointwithparams: Type.Any()(skips runtime param validation) - Delegates to the underlying
useQuery
Regenerating
Re-runkweri-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.