Features
Generated code
- Models — one
typeper schema: inline objects get names,allOf/oneOf/anyOf,nullable, enums, tuples (prefixItems), records (additionalProperties),Blobfor uploads, circular references. - Routes —
<tag>Endpoints, the one place each URL is written; the request functions read their route from it, so a path changes in a single line. - Request functions — one per operation, with typed path, query, header and body arguments, a
configargument forsignal,baseUrland the like, and a JSDoc block (summary, description,METHOD /route,@deprecated). - Query-key factories —
<tag>Keyswithall, its two halveslists()anddetails()(a read with a path id is a detail, any other a list) and one key per read: the half, the operation’s route (read from<tag>Endpoints) and the arguments its answer depends on (["Pets", "detail", "/pets/{pet_id}", "7"]), so invalidating a tag, all its lists or all its details is one line and a path still changes in one place. - Hooks for React Query, Vue Query, Svelte Query, Solid Query, Angular Query or SWR: a query hook per read, a mutation hook per write (or only plain request functions with
target: "requests"). - Reactive arguments — in Vue, Svelte, Solid and Angular a hook argument may be a ref, a getter or a signal, and the query follows it.
- Zod validators (
zod: true) —schemas.ts, one validator per model, typedz.ZodType<Model>so the two cannot drift apart. - Infinite-list hooks (
infinite: true) for paged reads. - Shared types — query and variable types with the same shape are written once (aliased, or
Omit<…> & { … }when close); an inline object that repeats a named model reuses it.
Transport
- Four built-in HTTP clients —
@mrzr/api-client(default),fetch, axios and Angular’sHttpClient. Each one is called as itself, in its own way —apiClient.get(…),http.get(…)on an axios instance,fetch(…), an injectable Angular service overHttpClient: the answer, the errors and the interceptors are the client’s own, and the generator only gives it the request the document describes. - Or your own —
client: "custom"imports your transport; every name and module path is configurable. - The request the document describes — the route, the query, header parameters,
multipart/form-data,application/x-www-form-urlencoded, text and binary bodies, bodies onDELETE, and how a non-JSON answer should be read (textorblob). What a client cannot write is listed, not sent differently in silence. - Types that match the client — the type of an answer is what the chosen client returns.
@mrzr/api-clientis called straight and answers with its ownIRes<T>, whosedatais the payload (it takes thedataof a{ data }answer itself, so a{ result, data }envelope is typed as itsdata); axios answers anAxiosResponse<T>,fetchaResponse, Angular anObservable<T>.{ count, list }becomesApiListData<T>. - Cancellation — queries, mutations and infinite lists pass an
AbortSignalto the request (SWR cannot cancel, see below); what an aborted call does is the client’s own.
Input
- Swagger 2.0, OpenAPI 3.0 and 3.1, as JSON or YAML, from a file, a folder of files or a URL.
- Request headers for protected URLs;
--insecureand--cafor private / self-signed certificates. - Several backend services in one layer — merged, with conflicts decided once and committed to
openapi-forge.decisions.json; per-service base URLs. - An incomplete document never breaks the output: gaps are typed
unknownand listed with the operation and the part to fix.
Workflow
generate,pull,diff,doctor,initcommands;--watch;--check.- Change reports — what a new spec breaks, in terms of your code (operation, hook, schema, property): breaking / risky / safe, as text, Markdown or JSON, with
--fail-onfor CI. - Hooks into naming — rename operations, query parameters and files, or drop an operation, with the
transformoption. - Tag filters, an
apiPrefixstripped from every route, a custom banner (generatorName). - Strict TypeScript, ships its own
.d.ts, Node ≥ 20, one runtime dependency (yaml).