···11+---
22+'@hey-api/openapi-ts': patch
33+---
44+55+fix(tanstack-query): add name builder options for all generated artifacts
+5
.changeset/unlucky-kiwis-smile.md
···11+---
22+'@hey-api/openapi-ts': patch
33+---
44+55+fix(parser): set correct subscription context for plugins
+17
docs/openapi-ts/configuration.md
···493493};
494494```
495495496496+## Pagination
497497+498498+Paginated operations are detected by having a pagination keyword in its parameters or request body. By default, we consider the following to be pagination keywords: `after`, `before`, `cursor`, `offset`, `page`, and `start`. You can override these keywords by providing your own keywords array using `input.pagination.keywords`.
499499+500500+```js
501501+export default {
502502+ input: {
503503+ pagination: {
504504+ keywords: ['custom', 'pagination', 'keywords'], // [!code ++]
505505+ },
506506+ path: 'https://get.heyapi.dev/hey-api/backend',
507507+ },
508508+ output: 'src/client',
509509+ plugins: ['@hey-api/client-fetch'],
510510+};
511511+```
512512+496513## Patch
497514498515There are times when you need to modify your input before it's processed further. A common use case is fixing an invalid specification or adding a missing field. You can apply custom patches with `input.patch`.
+11-12
docs/openapi-ts/plugins/tanstack-query.md
···114114115115## Queries
116116117117-Queries are generated from GET and POST endpoints. The generated functions follow the naming convention of SDK functions and append `Options`, e.g. `getPetByIdOptions()`.
117117+Queries are generated from GET and POST endpoints. The generated query functions follow the naming convention of SDK functions and by default append `Options`, e.g. `getPetByIdOptions()`.
118118119119```ts
120120const { data, error } = useQuery({
···126126});
127127```
128128129129+You can customize query function names using `queryOptionsNameBuilder`.
130130+129131## Infinite Queries
130132131131-Infinite queries are generated from GET and POST endpoints if we detect a pagination parameter. The generated functions follow the naming convention of SDK functions and append `InfiniteOptions`, e.g. `getFooInfiniteOptions()`.
133133+Infinite queries are generated from GET and POST endpoints if we detect a [pagination](/openapi-ts/configuration#pagination) parameter. The generated infinite query functions follow the naming convention of SDK functions and by default append `InfiniteOptions`, e.g. `getFooInfiniteOptions()`.
132134133135```ts
134136const { data, error } = useInfiniteQuery({
···142144});
143145```
144146145145-Infinite queries are recognized by having one of these keywords in the endpoint's parameters:
146146-147147-- after
148148-- before
149149-- cursor
150150-- offset
151151-- page
152152-- start
147147+You can customize infinite query function names using `infiniteQueryOptionsNameBuilder`.
153148154149## Mutations
155150156156-Mutations are generated from DELETE, PATCH, POST, and PUT endpoints. The generated functions follow the naming convention of SDK functions and append `Mutation`, e.g. `addPetMutation()`.
151151+Mutations are generated from DELETE, PATCH, POST, and PUT endpoints. The generated mutation functions follow the naming convention of SDK functions and by default append `Mutation`, e.g. `addPetMutation()`.
157152158153```ts
159154const addPet = useMutation({
···170165});
171166```
172167168168+You can customize mutation function names using `mutationOptionsNameBuilder`.
169169+173170## Query Keys
174171175172Query keys are generated for both queries and infinite queries. If you have access to the result of query or infinite query options function, you can get the query key from the `queryKey` field.
···182179});
183180```
184181185185-Alternatively, you can access the same query key by calling `QueryKey` or `InfiniteQueryKey` function.
182182+Alternatively, you can access the same query key by calling query key functions. The generated query key functions follow the naming convention of SDK functions and by default append `QueryKey` or `InfiniteQueryKey`, e.g. `getPetByIdQueryKey()` or `getPetByIdInfiniteQueryKey()`.
186183187184```ts
188185const queryKey = getPetByIdQueryKey({
···191188 },
192189});
193190```
191191+192192+You can customize query key function names using `queryKeyNameBuilder` and `infiniteQueryKeyNameBuilder`.
194193195194<!--@include: ../../examples.md-->
196195<!--@include: ../../sponsors.md-->
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11-// This file is auto-generated by @hey-api/openapi-ts
22-33-import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
44-import type { PostFooData, PostFooResponses } from './types.gen';
55-import { client as _heyApiClient } from './client.gen';
66-77-export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
88- /**
99- * You can provide a client instance returned by `createClient()` instead of
1010- * individual options. This might be also useful if you want to implement a
1111- * custom client.
1212- */
1313- client?: Client;
1414- /**
1515- * You can pass arbitrary values through the `meta` object. This can be
1616- * used to access values that aren't defined as part of the SDK function.
1717- */
1818- meta?: Record<string, unknown>;
1919-};
2020-2121-export const postFoo = <ThrowOnError extends boolean = false>(options: Options<PostFooData, ThrowOnError>) => {
2222- return (options.client ?? _heyApiClient).post<PostFooResponses, unknown, ThrowOnError>({
2323- url: '/foo',
2424- ...options,
2525- headers: {
2626- 'Content-Type': 'application/json',
2727- ...options?.headers
2828- }
2929- });
3030-};
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());