Skip to content

Commit d09d655

Browse files
committed
Merge branch 'main' of https://github.com/hey-api/openapi-ts into feat/tanstack-query-custom-query-key
2 parents 44fa131 + f017284 commit d09d655

File tree

50 files changed

+1807
-4524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1807
-4524
lines changed

.changeset/many-mangos-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: use relative path to custom config file if provided when resolving relative paths

packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ export const createQueryKeyFunction = ({
7070
type: compiler.typeReferenceNode({ typeName: 'boolean' }),
7171
},
7272
],
73-
returnType,
73+
returnType: compiler.typeTupleNode({
74+
types: [returnType],
75+
}),
7476
statements: [
7577
compiler.constVariable({
7678
assertion: returnType,
@@ -200,8 +202,10 @@ export const createQueryKeyFunction = ({
200202
],
201203
}),
202204
}),
203-
compiler.returnVariable({
204-
expression: 'params',
205+
compiler.returnStatement({
206+
expression: compiler.arrayLiteralExpression({
207+
elements: [compiler.identifier({ text: 'params' })],
208+
}),
205209
}),
206210
],
207211
types: [

packages/openapi-ts/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts

Lines changed: 30 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack
55
import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen';
66
import { client as _heyApiClient } from '../client.gen';
77

8-
type QueryKey<TOptions extends Options> = [
8+
export type QueryKey<TOptions extends Options> = [
99
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
1010
_id: string;
1111
_infinite?: boolean;
1212
}
1313
];
1414

15-
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
15+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): [
16+
QueryKey<TOptions>[0]
17+
] => {
1618
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey<TOptions>[0];
1719
if (infinite) {
1820
params._infinite = infinite;
@@ -29,12 +31,12 @@ const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions
2931
if (options?.query) {
3032
params.query = options.query;
3133
}
32-
return params;
34+
return [
35+
params
36+
];
3337
};
3438

35-
export const serviceWithEmptyTagQueryKey = (options?: Options<ServiceWithEmptyTagData>) => [
36-
createQueryKey('serviceWithEmptyTag', options)
37-
];
39+
export const serviceWithEmptyTagQueryKey = (options?: Options<ServiceWithEmptyTagData>) => createQueryKey('serviceWithEmptyTag', options);
3840

3941
export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTagData>) => {
4042
return queryOptions({
@@ -93,9 +95,7 @@ export const deleteCallWithoutParametersAndResponseMutation = (options?: Partial
9395
return mutationOptions;
9496
};
9597

96-
export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => [
97-
createQueryKey('getCallWithoutParametersAndResponse', options)
98-
];
98+
export const getCallWithoutParametersAndResponseQueryKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => createQueryKey('getCallWithoutParametersAndResponse', options);
9999

100100
export const getCallWithoutParametersAndResponseOptions = (options?: Options<GetCallWithoutParametersAndResponseData>) => {
101101
return queryOptions({
@@ -126,9 +126,7 @@ export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<
126126
return mutationOptions;
127127
};
128128

129-
export const postCallWithoutParametersAndResponseQueryKey = (options?: Options<PostCallWithoutParametersAndResponseData>) => [
130-
createQueryKey('postCallWithoutParametersAndResponse', options)
131-
];
129+
export const postCallWithoutParametersAndResponseQueryKey = (options?: Options<PostCallWithoutParametersAndResponseData>) => createQueryKey('postCallWithoutParametersAndResponse', options);
132130

133131
export const postCallWithoutParametersAndResponseOptions = (options?: Options<PostCallWithoutParametersAndResponseData>) => {
134132
return queryOptions({
@@ -173,9 +171,7 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial<Op
173171
return mutationOptions;
174172
};
175173

176-
export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [
177-
createQueryKey('callWithDescriptions', options)
178-
];
174+
export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => createQueryKey('callWithDescriptions', options);
179175

180176
export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => {
181177
return queryOptions({
@@ -206,9 +202,7 @@ export const callWithDescriptionsMutation = (options?: Partial<Options<CallWithD
206202
return mutationOptions;
207203
};
208204

209-
export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [
210-
createQueryKey('callWithParameters', options)
211-
];
205+
export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => createQueryKey('callWithParameters', options);
212206

213207
export const callWithParametersOptions = (options: Options<CallWithParametersData>) => {
214208
return queryOptions({
@@ -239,9 +233,7 @@ export const callWithParametersMutation = (options?: Partial<Options<CallWithPar
239233
return mutationOptions;
240234
};
241235

242-
export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [
243-
createQueryKey('callWithWeirdParameterNames', options)
244-
];
236+
export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => createQueryKey('callWithWeirdParameterNames', options);
245237

246238
export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => {
247239
return queryOptions({
@@ -272,9 +264,7 @@ export const callWithWeirdParameterNamesMutation = (options?: Partial<Options<Ca
272264
return mutationOptions;
273265
};
274266

275-
export const callWithDefaultParametersQueryKey = (options: Options<CallWithDefaultParametersData>) => [
276-
createQueryKey('callWithDefaultParameters', options)
277-
];
267+
export const callWithDefaultParametersQueryKey = (options: Options<CallWithDefaultParametersData>) => createQueryKey('callWithDefaultParameters', options);
278268

279269
export const callWithDefaultParametersOptions = (options: Options<CallWithDefaultParametersData>) => {
280270
return queryOptions({
@@ -291,9 +281,7 @@ export const callWithDefaultParametersOptions = (options: Options<CallWithDefaul
291281
});
292282
};
293283

294-
export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [
295-
createQueryKey('callWithDefaultOptionalParameters', options)
296-
];
284+
export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => createQueryKey('callWithDefaultOptionalParameters', options);
297285

298286
export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => {
299287
return queryOptions({
@@ -352,9 +340,7 @@ export const duplicateNameMutation = (options?: Partial<Options<DuplicateNameDat
352340
return mutationOptions;
353341
};
354342

355-
export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => [
356-
createQueryKey('duplicateName2', options)
357-
];
343+
export const duplicateName2QueryKey = (options?: Options<DuplicateName2Data>) => createQueryKey('duplicateName2', options);
358344

359345
export const duplicateName2Options = (options?: Options<DuplicateName2Data>) => {
360346
return queryOptions({
@@ -371,9 +357,7 @@ export const duplicateName2Options = (options?: Options<DuplicateName2Data>) =>
371357
});
372358
};
373359

374-
export const duplicateName3QueryKey = (options?: Options<DuplicateName3Data>) => [
375-
createQueryKey('duplicateName3', options)
376-
];
360+
export const duplicateName3QueryKey = (options?: Options<DuplicateName3Data>) => createQueryKey('duplicateName3', options);
377361

378362
export const duplicateName3Options = (options?: Options<DuplicateName3Data>) => {
379363
return queryOptions({
@@ -418,9 +402,7 @@ export const duplicateName4Mutation = (options?: Partial<Options<DuplicateName4D
418402
return mutationOptions;
419403
};
420404

421-
export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => [
422-
createQueryKey('callWithNoContentResponse', options)
423-
];
405+
export const callWithNoContentResponseQueryKey = (options?: Options<CallWithNoContentResponseData>) => createQueryKey('callWithNoContentResponse', options);
424406

425407
export const callWithNoContentResponseOptions = (options?: Options<CallWithNoContentResponseData>) => {
426408
return queryOptions({
@@ -437,9 +419,7 @@ export const callWithNoContentResponseOptions = (options?: Options<CallWithNoCon
437419
});
438420
};
439421

440-
export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => [
441-
createQueryKey('callWithResponseAndNoContentResponse', options)
442-
];
422+
export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options);
443423

444424
export const callWithResponseAndNoContentResponseOptions = (options?: Options<CallWithResponseAndNoContentResponseData>) => {
445425
return queryOptions({
@@ -456,9 +436,7 @@ export const callWithResponseAndNoContentResponseOptions = (options?: Options<Ca
456436
});
457437
};
458438

459-
export const dummyAQueryKey = (options?: Options<DummyAData>) => [
460-
createQueryKey('dummyA', options)
461-
];
439+
export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options);
462440

463441
export const dummyAOptions = (options?: Options<DummyAData>) => {
464442
return queryOptions({
@@ -475,9 +453,7 @@ export const dummyAOptions = (options?: Options<DummyAData>) => {
475453
});
476454
};
477455

478-
export const dummyBQueryKey = (options?: Options<DummyBData>) => [
479-
createQueryKey('dummyB', options)
480-
];
456+
export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options);
481457

482458
export const dummyBOptions = (options?: Options<DummyBData>) => {
483459
return queryOptions({
@@ -494,9 +470,7 @@ export const dummyBOptions = (options?: Options<DummyBData>) => {
494470
});
495471
};
496472

497-
export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => [
498-
createQueryKey('callWithResponse', options)
499-
];
473+
export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options);
500474

501475
export const callWithResponseOptions = (options?: Options<CallWithResponseData>) => {
502476
return queryOptions({
@@ -513,9 +487,7 @@ export const callWithResponseOptions = (options?: Options<CallWithResponseData>)
513487
});
514488
};
515489

516-
export const callWithDuplicateResponsesQueryKey = (options?: Options<CallWithDuplicateResponsesData>) => [
517-
createQueryKey('callWithDuplicateResponses', options)
518-
];
490+
export const callWithDuplicateResponsesQueryKey = (options?: Options<CallWithDuplicateResponsesData>) => createQueryKey('callWithDuplicateResponses', options);
519491

520492
export const callWithDuplicateResponsesOptions = (options?: Options<CallWithDuplicateResponsesData>) => {
521493
return queryOptions({
@@ -560,9 +532,7 @@ export const callWithResponsesMutation = (options?: Partial<Options<CallWithResp
560532
return mutationOptions;
561533
};
562534

563-
export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [
564-
createQueryKey('collectionFormat', options)
565-
];
535+
export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => createQueryKey('collectionFormat', options);
566536

567537
export const collectionFormatOptions = (options: Options<CollectionFormatData>) => {
568538
return queryOptions({
@@ -579,9 +549,7 @@ export const collectionFormatOptions = (options: Options<CollectionFormatData>)
579549
});
580550
};
581551

582-
export const typesQueryKey = (options: Options<TypesData>) => [
583-
createQueryKey('types', options)
584-
];
552+
export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options);
585553

586554
export const typesOptions = (options: Options<TypesData>) => {
587555
return queryOptions({
@@ -598,9 +566,7 @@ export const typesOptions = (options: Options<TypesData>) => {
598566
});
599567
};
600568

601-
export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [
602-
createQueryKey('complexTypes', options)
603-
];
569+
export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options);
604570

605571
export const complexTypesOptions = (options: Options<ComplexTypesData>) => {
606572
return queryOptions({
@@ -617,9 +583,7 @@ export const complexTypesOptions = (options: Options<ComplexTypesData>) => {
617583
});
618584
};
619585

620-
export const callWithResultFromHeaderQueryKey = (options?: Options<CallWithResultFromHeaderData>) => [
621-
createQueryKey('callWithResultFromHeader', options)
622-
];
586+
export const callWithResultFromHeaderQueryKey = (options?: Options<CallWithResultFromHeaderData>) => createQueryKey('callWithResultFromHeader', options);
623587

624588
export const callWithResultFromHeaderOptions = (options?: Options<CallWithResultFromHeaderData>) => {
625589
return queryOptions({
@@ -650,9 +614,7 @@ export const callWithResultFromHeaderMutation = (options?: Partial<Options<CallW
650614
return mutationOptions;
651615
};
652616

653-
export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [
654-
createQueryKey('testErrorCode', options)
655-
];
617+
export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => createQueryKey('testErrorCode', options);
656618

657619
export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => {
658620
return queryOptions({
@@ -683,9 +645,7 @@ export const testErrorCodeMutation = (options?: Partial<Options<TestErrorCodeDat
683645
return mutationOptions;
684646
};
685647

686-
export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [
687-
createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options)
688-
];
648+
export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options);
689649

690650
export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => {
691651
return queryOptions({
@@ -716,9 +676,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options?: Partial<
716676
return mutationOptions;
717677
};
718678

719-
export const postApiVbyApiVersionBodyQueryKey = (options: Options<PostApiVbyApiVersionBodyData>) => [
720-
createQueryKey('postApiVbyApiVersionBody', options)
721-
];
679+
export const postApiVbyApiVersionBodyQueryKey = (options: Options<PostApiVbyApiVersionBodyData>) => createQueryKey('postApiVbyApiVersionBody', options);
722680

723681
export const postApiVbyApiVersionBodyOptions = (options: Options<PostApiVbyApiVersionBodyData>) => {
724682
return queryOptions({

0 commit comments

Comments
 (0)