What is generated
src/api/generated/├── models.ts every schema as a type├── pets.ts one module per tag: endpoints, keys, types, request functions, hooks├── owners.ts├── schemas.ts Zod validators (zod: true)├── services.ts API_SERVICE_BASE_URLS (per-service base URLs)├── index.ts re-exports everything├── client.ts ┐ the built-in runtime, written once, yours to edit├── hooks.ts │ (client.ts only for api-client and axios;└── types.ts ┘ fetch and Angular's HttpClient need none)A module (trimmed) looks like this:
export const petsEndpoints = { listPets: "/pets", getPet: "/pets/{pet_id}",} as const;
export const petsKeys = { all: ["Pets"] as const, lists: () => [...petsKeys.all, "list"] as const, details: () => [...petsKeys.all, "detail"] as const, listPets: (params: ListPetsQuery) => [...petsKeys.lists(), petsEndpoints.listPets, params] as const, getPet: (petId: string) => [...petsKeys.details(), petsEndpoints.getPet, petId] as const,} as const;
export type ListPetsQuery = { start?: number; kind?: "cat" | "dog"; ids?: string[] };
/** List the pets — `GET /pets` */export function listPets(config?: RequestConfig<ApiListData<Pet>>) { … } // api-client: the query is `params` in its own configlistPets({ params: { kind: "cat" } });getPet({ addTemplateToUrl: { pet_id: "7" } }); // the path values are in the config too; getPet() does not compile
export function useListPetsQuery(params: ListPetsQuery = {}, options?: ApiQueryOptions<…>) { … }export function useGetPetQuery(petId: string | undefined, options?: ApiQueryOptions<…>) { … }export function useCreatePetMutation(options?: ApiMutationOptions<Pet, CreatePetVariables>) { … }- A write takes one variables object (
{ petId, params, headers, body }— only the parts it has), named<Operation>Variables. - Query and header parameters get
<Operation>Query/<Operation>Headerstypes. The query is calledparams, as every built-in client calls it (runtime.requestKeys.querynames it for a custom transport). With@mrzr/api-clienta request function takes only its body and the client’s ownconfig: the query isparamsand the path values areaddTemplateToUrlin that config (listPets({ params: { kind: "cat" } }),getPet({ addTemplateToUrl: { pet_id: "7" } })), and it goes to the client as it is. axios does the same for the query. The hooks keep everything typed (useListPetsQuery({ kind: "cat" }),useGetPetQuery("7")).fetchand Angular’s service take the path values andparamsas arguments, since neither has a config to carry them; path arguments keep the document’s names. - An operation with no tag goes to the
defaultmodule.