fork of hey-api/openapi-ts because I need some additional things

Merge pull request #894 from hey-api/chore/tanstack-query-wip-6

chore: progress on TanStack Query plugin

authored by

Lubos and committed by
GitHub
c44508fa c1b76029

+1499 -342
+40 -12
packages/openapi-ts/src/compiler/index.ts
··· 30 30 31 31 export class TypeScriptFile { 32 32 private _headers: Array<string> = []; 33 - private _imports: Array<ts.Node> = []; 33 + private _imports = new Map< 34 + string, 35 + Map<string, utils.ImportExportItemObject> 36 + >(); 34 37 private _items: Array<ts.Node | string> = []; 35 38 private _name: string; 36 39 private _path: PathLike; ··· 59 62 this._items = [...this._items, ...nodes]; 60 63 } 61 64 62 - public addImport( 63 - ...params: Parameters<typeof compiler.namedImportDeclarations> 64 - ) { 65 - this._imports = [ 66 - ...this._imports, 67 - compiler.namedImportDeclarations(...params), 68 - ]; 65 + /** 66 + * Adds an import to the provided module. Handles duplication, returns added import. 67 + */ 68 + public import({ 69 + module, 70 + ...importedItem 71 + }: utils.ImportExportItemObject & { 72 + module: string; 73 + }): utils.ImportExportItemObject { 74 + let moduleMap = this._imports.get(module); 75 + 76 + if (!moduleMap) { 77 + moduleMap = new Map<string, utils.ImportExportItemObject>(); 78 + this._imports.set(module, moduleMap); 79 + } 80 + 81 + const match = moduleMap.get(importedItem.name); 82 + if (match) { 83 + return match; 84 + } 85 + 86 + moduleMap.set(importedItem.name, importedItem); 87 + return importedItem; 69 88 } 70 89 71 90 public getName(withExtension = true) { ··· 106 125 if (this._headers.length) { 107 126 output = [...output, this._headers.join('\n')]; 108 127 } 109 - if (this._imports.length) { 110 - output = [ 111 - ...output, 112 - this._imports.map((node) => utils.tsNodeToString({ node })).join('\n'), 128 + let importsStringArray: string[] = []; 129 + for (const [_module, moduleMap] of this._imports.entries()) { 130 + const imports = Array.from(moduleMap.values()); 131 + const node = compiler.namedImportDeclarations({ 132 + imports, 133 + module: _module, 134 + }); 135 + importsStringArray = [ 136 + ...importsStringArray, 137 + utils.tsNodeToString({ node }), 113 138 ]; 139 + } 140 + if (importsStringArray.length) { 141 + output = [...output, importsStringArray.join('\n')]; 114 142 } 115 143 output = [ 116 144 ...output,
+154 -206
packages/openapi-ts/src/generate/plugins.ts
··· 4 4 5 5 import { compiler, Property, TypeScriptFile } from '../compiler'; 6 6 import type { ImportExportItem } from '../compiler/module'; 7 - import type { ImportExportItemObject } from '../compiler/utils'; 7 + import { ImportExportItemObject } from '../compiler/utils'; 8 8 import type { Operation } from '../openApi'; 9 9 import type { 10 10 Method, ··· 15 15 import type { Client } from '../types/client'; 16 16 import type { Files } from '../types/utils'; 17 17 import { getConfig, isStandaloneClient } from '../utils/config'; 18 - import { unique } from '../utils/unique'; 19 18 import { clientModulePath, clientOptionsTypeName } from './client'; 20 19 import { 21 20 generateImport, ··· 61 60 dir: outputDir, 62 61 name: `${outputParts[outputParts.length - 1]}.ts`, 63 62 }); 63 + const file = files[plugin.name]; 64 64 65 65 if (plugin.name === '@tanstack/react-query') { 66 66 const paginationWordsRegExp = /^(cursor|offset|page|start)/; 67 67 68 - files[plugin.name].addImport({ 69 - imports: [ 70 - { 71 - asType: true, 72 - name: clientOptionsTypeName(), 73 - }, 74 - ], 68 + if (!files.services) { 69 + // TODO: throw 70 + } 71 + if (!files.types) { 72 + // TODO: throw 73 + } 74 + 75 + file.import({ 76 + asType: true, 75 77 module: clientModulePath(), 78 + name: clientOptionsTypeName(), 76 79 }); 77 80 78 - let imports: string[] = []; 79 - let importsServices: ImportExportItem[] = []; 81 + const relativePath = 82 + new Array(outputParts.length).fill('').join('../') || './'; 83 + const servicesModulePath = relativePath + files.services.getName(false); 84 + const typesModulePath = relativePath + files.types.getName(false); 80 85 81 86 const createQueryKeyParamsFn = 'createQueryKeyParams'; 82 87 const infiniteQueryOptionsFn = 'infiniteQueryOptions'; 83 88 const mutationsType = 'UseMutationOptions'; 84 - const optionsType = 'Options'; 85 89 const queryKeyName = 'QueryKey'; 86 90 const queryOptionsFn = 'queryOptions'; 87 91 const TOptionsType = 'TOptions'; 88 92 89 - // TODO: `addTanStackQueryImport()` should be a method of file class to create 90 - // unique imports. It could be made more performant too 91 - let importsTanStackQuery: ImportExportItemObject[] = []; 92 - const addTanStackQueryImport = ( 93 - imported: ImportExportItem, 94 - ): ImportExportItemObject => { 95 - const importedItem: ImportExportItemObject = 96 - typeof imported === 'string' 97 - ? { 98 - name: imported, 99 - } 100 - : imported; 101 - const match = importsTanStackQuery.find( 102 - (item) => item.name === importedItem.name, 103 - ); 104 - if (match) { 105 - return match; 106 - } 107 - 108 - importsTanStackQuery = [...importsTanStackQuery, importedItem]; 109 - return importedItem; 110 - }; 111 - 112 93 const getPaginationIn = (parameter: OperationParameter) => { 113 94 switch (parameter.in) { 114 95 case 'formData': ··· 260 241 types: [ 261 242 { 262 243 extends: compiler.typeReferenceNode({ 263 - typeName: compiler.identifier({ text: optionsType }), 244 + typeName: compiler.identifier({ 245 + text: clientOptionsTypeName(), 246 + }), 264 247 }), 265 248 name: TOptionsType, 266 249 }, ··· 268 251 }), 269 252 name: createQueryKeyParamsFn, 270 253 }); 271 - files[plugin.name].add(queryKeyParamsFunction); 254 + file.add(queryKeyParamsFunction); 272 255 }; 273 256 274 257 const createQueryKeyLiteral = ({ ··· 347 330 typeParameters: [ 348 331 { 349 332 extends: compiler.typeReferenceNode({ 350 - typeName: compiler.identifier({ text: optionsType }), 333 + typeName: compiler.identifier({ 334 + text: clientOptionsTypeName(), 335 + }), 351 336 }), 352 337 name: TOptionsType, 353 338 }, 354 339 ], 355 340 }); 356 - files[plugin.name].add(queryKeyType); 341 + file.add(queryKeyType); 342 + }; 343 + 344 + const createTypeData = ({ operation }: { operation: Operation }) => { 345 + const { name: nameTypeData } = generateImport({ 346 + client, 347 + meta: operation.parameters.length 348 + ? { 349 + // TODO: this should be exact ref to operation for consistency, 350 + // but name should work too as operation ID is unique 351 + $ref: operation.name, 352 + name: operation.name, 353 + } 354 + : undefined, 355 + nameTransformer: operationDataTypeName, 356 + onImport: (name) => { 357 + file.import({ 358 + asType: true, 359 + module: typesModulePath, 360 + name, 361 + }); 362 + }, 363 + }); 364 + 365 + const typeData = operationOptionsType(nameTypeData); 366 + 367 + return { typeData }; 368 + }; 369 + 370 + const createTypeError = ({ operation }: { operation: Operation }) => { 371 + const { name: nameTypeError } = generateImport({ 372 + client, 373 + meta: { 374 + // TODO: this should be exact ref to operation for consistency, 375 + // but name should work too as operation ID is unique 376 + $ref: operation.name, 377 + name: operation.name, 378 + }, 379 + nameTransformer: operationErrorTypeName, 380 + onImport: (name) => { 381 + file.import({ 382 + asType: true, 383 + module: typesModulePath, 384 + name, 385 + }); 386 + }, 387 + }); 388 + 389 + let typeError: ImportExportItemObject = { 390 + asType: true, 391 + name: nameTypeError, 392 + }; 393 + if (!typeError.name) { 394 + typeError = file.import({ 395 + asType: true, 396 + module: plugin.name, 397 + name: 'DefaultError', 398 + }); 399 + } 400 + 401 + if (config.client.name === '@hey-api/client-axios') { 402 + const axiosError = file.import({ 403 + asType: true, 404 + module: 'axios', 405 + name: 'AxiosError', 406 + }); 407 + typeError = { 408 + ...axiosError, 409 + name: `${axiosError.name}<${typeError.name}>`, 410 + }; 411 + } 412 + 413 + return { typeError }; 414 + }; 415 + 416 + const createTypeResponse = ({ operation }: { operation: Operation }) => { 417 + const { name: nameTypeResponse } = generateImport({ 418 + client, 419 + meta: { 420 + // TODO: this should be exact ref to operation for consistency, 421 + // but name should work too as operation ID is unique 422 + $ref: operation.name, 423 + name: operation.name, 424 + }, 425 + nameTransformer: operationResponseTypeName, 426 + onImport: (imported) => { 427 + file.import({ 428 + asType: true, 429 + module: typesModulePath, 430 + name: imported, 431 + }); 432 + }, 433 + }); 434 + 435 + const typeResponse = nameTypeResponse || 'void'; 436 + 437 + return { typeResponse }; 357 438 }; 358 439 359 440 let typeInfiniteData!: ImportExportItem; ··· 381 462 createQueryKeyParamsFunction(); 382 463 } 383 464 384 - addTanStackQueryImport(queryOptionsFn); 465 + file.import({ 466 + module: plugin.name, 467 + name: queryOptionsFn, 468 + }); 385 469 } 386 470 387 471 hasUsedQueryFn = true; 388 472 389 - const { name: nameTypeData } = generateImport({ 390 - client, 391 - meta: operation.parameters.length 392 - ? { 393 - // TODO: this should be exact ref to operation for consistency, 394 - // but name should work too as operation ID is unique 395 - $ref: operation.name, 396 - name: operation.name, 397 - } 398 - : undefined, 399 - nameTransformer: operationDataTypeName, 400 - onImport: (imported) => { 401 - imports = [...imports, imported]; 402 - }, 403 - }); 473 + const { typeData } = createTypeData({ operation }); 404 474 405 475 const isRequired = isOperationParameterRequired( 406 476 operation.parameters, ··· 411 481 { 412 482 isRequired, 413 483 name: 'options', 414 - type: operationOptionsType(nameTypeData), 484 + type: typeData, 415 485 }, 416 486 ], 417 487 statements: [ ··· 485 555 exportConst: true, 486 556 expression, 487 557 name: toQueryOptionsName(operation), 558 + // TODO: add type error 559 + // TODO: AxiosError<PutSubmissionMetaError> 488 560 }); 489 - files[plugin.name].add(statement); 561 + file.add(statement); 490 562 } 491 563 492 564 // infinite queries ··· 541 613 createQueryKeyParamsFunction(); 542 614 } 543 615 544 - addTanStackQueryImport(infiniteQueryOptionsFn); 616 + file.import({ 617 + module: plugin.name, 618 + name: infiniteQueryOptionsFn, 619 + }); 545 620 546 - typeInfiniteData = addTanStackQueryImport({ 621 + typeInfiniteData = file.import({ 547 622 asType: true, 623 + module: plugin.name, 548 624 name: 'InfiniteData', 549 625 }); 550 626 } 551 627 552 628 hasUsedQueryFn = true; 553 629 554 - const { name: nameTypeError } = generateImport({ 555 - client, 556 - meta: { 557 - // TODO: this should be exact ref to operation for consistency, 558 - // but name should work too as operation ID is unique 559 - $ref: operation.name, 560 - name: operation.name, 561 - }, 562 - nameTransformer: operationErrorTypeName, 563 - onImport: (imported) => { 564 - imports = [...imports, imported]; 565 - }, 566 - }); 567 - 568 - let typeError: ImportExportItem = nameTypeError; 569 - if (!typeError) { 570 - typeError = addTanStackQueryImport({ 571 - asType: true, 572 - name: 'DefaultError', 573 - }); 574 - } 575 - 576 - const { name: nameTypeData } = generateImport({ 577 - client, 578 - meta: operation.parameters.length 579 - ? { 580 - // TODO: this should be exact ref to operation for consistency, 581 - // but name should work too as operation ID is unique 582 - $ref: operation.name, 583 - name: operation.name, 584 - } 585 - : undefined, 586 - nameTransformer: operationDataTypeName, 587 - onImport: (imported) => { 588 - imports = [...imports, imported]; 589 - }, 590 - }); 591 - 592 - const { name: nameTypeResponse } = generateImport({ 593 - client, 594 - meta: { 595 - // TODO: this should be exact ref to operation for consistency, 596 - // but name should work too as operation ID is unique 597 - $ref: operation.name, 598 - name: operation.name, 599 - }, 600 - nameTransformer: operationResponseTypeName, 601 - onImport: (imported) => { 602 - imports = [...imports, imported]; 603 - }, 604 - }); 605 - 606 - const typeResponse = nameTypeResponse || 'void'; 630 + const { typeData } = createTypeData({ operation }); 631 + const { typeError } = createTypeError({ operation }); 632 + const { typeResponse } = createTypeResponse({ operation }); 607 633 608 634 const isRequired = isOperationParameterRequired( 609 635 operation.parameters, 610 636 ); 611 637 612 - const typeQueryKey = `${queryKeyName}<${optionsType}<${nameTypeData}>>`; 638 + const typeQueryKey = `${queryKeyName}<${typeData}>`; 613 639 const typePageObjectParam = `${typeQueryKey}[0]['params']`; 614 640 const typePageParam = `${paginationField.base} | ${typePageObjectParam}`; 615 641 ··· 618 644 { 619 645 isRequired, 620 646 name: 'options', 621 - type: operationOptionsType(nameTypeData), 647 + type: typeData, 622 648 }, 623 649 ], 624 650 statements: [ ··· 800 826 // TODO: better types syntax 801 827 types: [ 802 828 typeResponse, 803 - typeof typeError === 'string' 804 - ? typeError 805 - : typeError.name, 829 + typeError.name, 806 830 `${typeof typeInfiniteData === 'string' ? typeInfiniteData : typeInfiniteData.name}<${typeResponse}>`, 807 831 typeQueryKey, 808 832 typePageParam, ··· 817 841 expression, 818 842 name: toInfiniteQueryOptionsName(operation), 819 843 }); 820 - files[plugin.name].add(statement); 844 + file.add(statement); 821 845 } 822 846 } 823 847 ··· 831 855 if (!hasMutations) { 832 856 hasMutations = true; 833 857 834 - addTanStackQueryImport({ 858 + file.import({ 835 859 asType: true, 860 + module: plugin.name, 836 861 name: mutationsType, 837 862 }); 838 863 } 839 864 840 865 hasUsedQueryFn = true; 841 866 842 - const { name: nameTypeError } = generateImport({ 843 - client, 844 - meta: { 845 - // TODO: this should be exact ref to operation for consistency, 846 - // but name should work too as operation ID is unique 847 - $ref: operation.name, 848 - name: operation.name, 849 - }, 850 - nameTransformer: operationErrorTypeName, 851 - onImport: (imported) => { 852 - imports = [...imports, imported]; 853 - }, 854 - }); 855 - 856 - let typeError: ImportExportItem = nameTypeError; 857 - if (!typeError) { 858 - typeError = addTanStackQueryImport({ 859 - asType: true, 860 - name: 'DefaultError', 861 - }); 862 - } 863 - 864 - const { name: nameTypeData } = generateImport({ 865 - client, 866 - meta: operation.parameters.length 867 - ? { 868 - // TODO: this should be exact ref to operation for consistency, 869 - // but name should work too as operation ID is unique 870 - $ref: operation.name, 871 - name: operation.name, 872 - } 873 - : undefined, 874 - nameTransformer: operationDataTypeName, 875 - onImport: (imported) => { 876 - imports = [...imports, imported]; 877 - }, 878 - }); 879 - 880 - const { name: nameTypeResponse } = generateImport({ 881 - client, 882 - meta: { 883 - // TODO: this should be exact ref to operation for consistency, 884 - // but name should work too as operation ID is unique 885 - $ref: operation.name, 886 - name: operation.name, 887 - }, 888 - nameTransformer: operationResponseTypeName, 889 - onImport: (imported) => { 890 - imports = [...imports, imported]; 891 - }, 892 - }); 893 - 894 - const typeResponse = nameTypeResponse || 'void'; 867 + const { typeData } = createTypeData({ operation }); 868 + const { typeError } = createTypeError({ operation }); 869 + const { typeResponse } = createTypeResponse({ operation }); 895 870 896 871 const statement = compiler.constVariable({ 897 872 // TODO: describe options, same as the actual function call ··· 943 918 }), 944 919 name: toMutationOptionsName(operation), 945 920 // TODO: better types syntax 946 - typeName: `${mutationsType}<${typeResponse}, ${typeof typeError === 'string' ? typeError : typeError.name}, ${operationOptionsType(nameTypeData)}>`, 921 + typeName: `${mutationsType}<${typeResponse}, ${typeError.name}, ${typeData}>`, 947 922 }); 948 - files[plugin.name].add(statement); 923 + file.add(statement); 949 924 } 950 925 951 - if (hasUsedQueryFn && !importsServices.includes(queryFn)) { 952 - importsServices = [...importsServices, queryFn]; 926 + if (hasUsedQueryFn) { 927 + file.import({ 928 + module: servicesModulePath, 929 + name: queryFn, 930 + }); 953 931 } 954 - } 955 - } 956 - 957 - if (importsTanStackQuery.length) { 958 - files[plugin.name].addImport({ 959 - imports: importsTanStackQuery, 960 - module: '@tanstack/react-query', 961 - }); 962 - } 963 - 964 - const relativePath = 965 - new Array(outputParts.length).fill('').join('../') || './'; 966 - 967 - if (importsServices.length && files.services) { 968 - files[plugin.name].addImport({ 969 - imports: importsServices, 970 - module: relativePath + files.services.getName(false), 971 - }); 972 - } 973 - 974 - if (files.types && !files.types.isEmpty()) { 975 - const importedTypes = imports.filter(unique).map((name) => ({ 976 - asType: true, 977 - name, 978 - })); 979 - if (importedTypes.length) { 980 - files[plugin.name].addImport({ 981 - imports: importedTypes, 982 - module: relativePath + files.types.getName(false), 983 - }); 984 932 } 985 933 } 986 934 }
+74 -77
packages/openapi-ts/src/generate/services.ts
··· 706 706 return; 707 707 } 708 708 709 + if (!files.types) { 710 + // TODO: throw 711 + } 712 + 709 713 const isStandalone = isStandaloneClient(config); 710 714 711 715 files.services = new TypeScriptFile({ ··· 713 717 name: 'services.ts', 714 718 }); 715 719 716 - // define client first 720 + // Import required packages and core files. 717 721 if (isStandalone) { 718 - const statement = compiler.constVariable({ 719 - exportConst: true, 720 - expression: compiler.callExpression({ 721 - functionName: 'createClient', 722 - parameters: [ 723 - compiler.callExpression({ 724 - functionName: 'createConfig', 725 - }), 726 - ], 727 - }), 728 - name: 'client', 722 + files.services.import({ 723 + module: clientModulePath(), 724 + name: 'createClient', 729 725 }); 730 - files.services.add(statement); 731 - } 732 - 733 - let imports: string[] = []; 734 - let clientImports: string[] = []; 735 - 736 - for (const service of client.services) { 737 - processService({ 738 - client, 739 - onClientImport: (imported) => { 740 - clientImports = [...clientImports, imported]; 741 - }, 742 - onImport: (imported) => { 743 - imports = [...imports, imported]; 744 - }, 745 - onNode: (node) => { 746 - files.services.add(node); 747 - }, 748 - service, 726 + files.services.import({ 727 + module: clientModulePath(), 728 + name: 'createConfig', 749 729 }); 750 - } 751 - 752 - // Import required packages and core files. 753 - if (isStandalone) { 754 - files.services.addImport({ 755 - imports: [ 756 - 'createClient', 757 - 'createConfig', 758 - { 759 - asType: true, 760 - name: clientOptionsTypeName(), 761 - }, 762 - ...clientImports.filter(unique), 763 - ], 730 + files.services.import({ 731 + asType: true, 764 732 module: clientModulePath(), 733 + name: clientOptionsTypeName(), 765 734 }); 766 735 } else { 767 736 if (config.client.name === 'angular') { 768 - files.services.addImport({ 769 - imports: 'Injectable', 737 + files.services.import({ 770 738 module: '@angular/core', 739 + name: 'Injectable', 771 740 }); 772 741 773 742 if (!config.name) { 774 - files.services.addImport({ 775 - imports: 'HttpClient', 743 + files.services.import({ 776 744 module: '@angular/common/http', 745 + name: 'HttpClient', 777 746 }); 778 747 } 779 748 780 - files.services.addImport({ 781 - imports: { asType: true, name: 'Observable' }, 749 + files.services.import({ 750 + asType: true, 782 751 module: 'rxjs', 752 + name: 'Observable', 783 753 }); 784 754 } else { 785 - files.services.addImport({ 786 - imports: { asType: true, name: 'CancelablePromise' }, 755 + files.services.import({ 756 + asType: true, 787 757 module: './core/CancelablePromise', 758 + name: 'CancelablePromise', 788 759 }); 789 760 } 790 761 791 762 if (config.services.response === 'response') { 792 - files.services.addImport({ 793 - imports: { asType: true, name: 'ApiResult' }, 763 + files.services.import({ 764 + asType: true, 794 765 module: './core/ApiResult', 766 + name: 'ApiResult', 795 767 }); 796 768 } 797 769 798 770 if (config.name) { 799 - files.services.addImport({ 800 - imports: { 801 - asType: config.client.name !== 'angular', 802 - name: 'BaseHttpRequest', 803 - }, 771 + files.services.import({ 772 + asType: config.client.name !== 'angular', 804 773 module: './core/BaseHttpRequest', 774 + name: 'BaseHttpRequest', 805 775 }); 806 776 } else { 807 - files.services.addImport({ 808 - imports: 'OpenAPI', 777 + files.services.import({ 809 778 module: './core/OpenAPI', 779 + name: 'OpenAPI', 810 780 }); 811 - files.services.addImport({ 812 - imports: { alias: '__request', name: 'request' }, 781 + files.services.import({ 782 + alias: '__request', 813 783 module: './core/request', 784 + name: 'request', 814 785 }); 815 786 } 816 787 } 817 788 818 - // Import all models required by the services. 819 - if (files.types && !files.types.isEmpty()) { 820 - const importedTypes = imports.filter(unique).map((name) => ({ 821 - // this detection could be done safer, but it shouldn't cause any issues 822 - asType: !name.endsWith('Transformer'), 823 - name, 824 - })); 825 - if (importedTypes.length) { 826 - files.services.addImport({ 827 - imports: importedTypes, 828 - module: `./${files.types.getName(false)}`, 829 - }); 830 - } 789 + // define client first 790 + if (isStandalone) { 791 + const statement = compiler.constVariable({ 792 + exportConst: true, 793 + expression: compiler.callExpression({ 794 + functionName: 'createClient', 795 + parameters: [ 796 + compiler.callExpression({ 797 + functionName: 'createConfig', 798 + }), 799 + ], 800 + }), 801 + name: 'client', 802 + }); 803 + files.services.add(statement); 804 + } 805 + 806 + for (const service of client.services) { 807 + processService({ 808 + client, 809 + onClientImport: (imported) => { 810 + files.services.import({ 811 + module: clientModulePath(), 812 + name: imported, 813 + }); 814 + }, 815 + onImport: (imported) => { 816 + files.services.import({ 817 + // this detection could be done safer, but it shouldn't cause any issues 818 + asType: !imported.endsWith('Transformer'), 819 + module: `./${files.types.getName(false)}`, 820 + name: imported, 821 + }); 822 + }, 823 + onNode: (node) => { 824 + files.services.add(node); 825 + }, 826 + service, 827 + }); 831 828 } 832 829 };
+1 -1
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
··· 31 31 infiniteQueryOptions: true, 32 32 mutationOptions: true, 33 33 name: '@tanstack/react-query', 34 - output: '@tanstack/query', 34 + output: '@tanstack/react-query', 35 35 queryOptions: true, 36 36 };
+32 -31
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/query.gen.ts.snap packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap
··· 3 3 import type { Options } from '@hey-api/client-axios'; 4 4 import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; 5 5 import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 - import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsError, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 6 + import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 + import type { AxiosError } from 'axios'; 7 8 8 9 type QueryKey<TOptions extends Options> = [ 9 10 { ··· 64 65 ] 65 66 }); }; 66 67 67 - export const importMutation: UseMutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 68 + export const importMutation: UseMutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 68 69 mutationFn: async (options) => { 69 70 const { data } = await import_({ 70 71 ...options, ··· 108 109 ] 109 110 }); }; 110 111 111 - export const putCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 112 + export const putCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 112 113 mutationFn: async (options) => { 113 114 const { data } = await putCallWithoutParametersAndResponse({ 114 115 ...options, ··· 135 136 ] 136 137 }); }; 137 138 138 - export const postCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 139 + export const postCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 139 140 mutationFn: async (options) => { 140 141 const { data } = await postCallWithoutParametersAndResponse({ 141 142 ...options, ··· 145 146 } 146 147 }; 147 148 148 - export const deleteCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 149 + export const deleteCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 149 150 mutationFn: async (options) => { 150 151 const { data } = await deleteCallWithoutParametersAndResponse({ 151 152 ...options, ··· 155 156 } 156 157 }; 157 158 158 - export const patchCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 159 + export const patchCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 159 160 mutationFn: async (options) => { 160 161 const { data } = await patchCallWithoutParametersAndResponse({ 161 162 ...options, ··· 165 166 } 166 167 }; 167 168 168 - export const deleteFooMutation: UseMutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 169 + export const deleteFooMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 169 170 mutationFn: async (options) => { 170 171 const { data } = await deleteFoo({ 171 172 ...options, ··· 192 193 ] 193 194 }); }; 194 195 195 - export const callWithDescriptionsMutation: UseMutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 196 + export const callWithDescriptionsMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 196 197 mutationFn: async (options) => { 197 198 const { data } = await callWithDescriptions({ 198 199 ...options, ··· 219 220 ] 220 221 }); }; 221 222 222 - export const deprecatedCallMutation: UseMutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 223 + export const deprecatedCallMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 223 224 mutationFn: async (options) => { 224 225 const { data } = await deprecatedCall({ 225 226 ...options, ··· 246 247 ] 247 248 }); }; 248 249 249 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 250 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 250 251 // @ts-ignore 251 252 { 252 253 queryFn: async ({ pageParam, queryKey }) => { ··· 287 288 ] 288 289 }); }; 289 290 290 - export const callWithParametersMutation: UseMutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 291 + export const callWithParametersMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 291 292 mutationFn: async (options) => { 292 293 const { data } = await callWithParameters({ 293 294 ...options, ··· 314 315 ] 315 316 }); }; 316 317 317 - export const callWithWeirdParameterNamesMutation: UseMutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 318 + export const callWithWeirdParameterNamesMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 318 319 mutationFn: async (options) => { 319 320 const { data } = await callWithWeirdParameterNames({ 320 321 ...options, ··· 341 342 ] 342 343 }); }; 343 344 344 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 345 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 345 346 // @ts-ignore 346 347 { 347 348 queryFn: async ({ pageParam, queryKey }) => { ··· 399 400 ] 400 401 }); }; 401 402 402 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 403 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 403 404 // @ts-ignore 404 405 { 405 406 queryFn: async ({ pageParam, queryKey }) => { ··· 440 441 ] 441 442 }); }; 442 443 443 - export const postCallWithOptionalParamMutation: UseMutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 444 + export const postCallWithOptionalParamMutation: UseMutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 444 445 mutationFn: async (options) => { 445 446 const { data } = await postCallWithOptionalParam({ 446 447 ...options, ··· 467 468 ] 468 469 }); }; 469 470 470 - export const postApiVbyApiVersionRequestBodyMutation: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 471 + export const postApiVbyApiVersionRequestBodyMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 471 472 mutationFn: async (options) => { 472 473 const { data } = await postApiVbyApiVersionRequestBody({ 473 474 ...options, ··· 494 495 ] 495 496 }); }; 496 497 497 - export const postApiVbyApiVersionFormDataMutation: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 498 + export const postApiVbyApiVersionFormDataMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 498 499 mutationFn: async (options) => { 499 500 const { data } = await postApiVbyApiVersionFormData({ 500 501 ...options, ··· 538 539 ] 539 540 }); }; 540 541 541 - export const callWithDefaultOptionalParametersMutation: UseMutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 542 + export const callWithDefaultOptionalParametersMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 542 543 mutationFn: async (options) => { 543 544 const { data } = await callWithDefaultOptionalParameters({ 544 545 ...options, ··· 548 549 } 549 550 }; 550 551 551 - export const callToTestOrderOfParamsMutation: UseMutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 552 + export const callToTestOrderOfParamsMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 552 553 mutationFn: async (options) => { 553 554 const { data } = await callToTestOrderOfParams({ 554 555 ...options, ··· 592 593 ] 593 594 }); }; 594 595 595 - export const duplicateName1Mutation: UseMutationOptions<void, DefaultError, Options> = { 596 + export const duplicateName1Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 596 597 mutationFn: async (options) => { 597 598 const { data } = await duplicateName1({ 598 599 ...options, ··· 602 603 } 603 604 }; 604 605 605 - export const duplicateName2Mutation: UseMutationOptions<void, DefaultError, Options> = { 606 + export const duplicateName2Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 606 607 mutationFn: async (options) => { 607 608 const { data } = await duplicateName2({ 608 609 ...options, ··· 612 613 } 613 614 }; 614 615 615 - export const duplicateName3Mutation: UseMutationOptions<void, DefaultError, Options> = { 616 + export const duplicateName3Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 616 617 mutationFn: async (options) => { 617 618 const { data } = await duplicateName3({ 618 619 ...options, ··· 724 725 ] 725 726 }); }; 726 727 727 - export const callWithDuplicateResponsesMutation: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 728 + export const callWithDuplicateResponsesMutation: UseMutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 728 729 mutationFn: async (options) => { 729 730 const { data } = await callWithDuplicateResponses({ 730 731 ...options, ··· 734 735 } 735 736 }; 736 737 737 - export const callWithResponsesMutation: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 738 + export const callWithResponsesMutation: UseMutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 738 739 mutationFn: async (options) => { 739 740 const { data } = await callWithResponses({ 740 741 ...options, ··· 795 796 ] 796 797 }); }; 797 798 798 - export const uploadFileMutation: UseMutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 799 + export const uploadFileMutation: UseMutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 799 800 mutationFn: async (options) => { 800 801 const { data } = await uploadFile({ 801 802 ...options, ··· 856 857 ] 857 858 }); }; 858 859 859 - export const multipartRequestMutation: UseMutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 860 + export const multipartRequestMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 860 861 mutationFn: async (options) => { 861 862 const { data } = await multipartRequest({ 862 863 ...options, ··· 883 884 ] 884 885 }); }; 885 886 886 - export const complexParamsMutation: UseMutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 887 + export const complexParamsMutation: UseMutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 887 888 mutationFn: async (options) => { 888 889 const { data } = await complexParams({ 889 890 ...options, ··· 910 911 ] 911 912 }); }; 912 913 913 - export const callWithResultFromHeaderMutation: UseMutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 914 + export const callWithResultFromHeaderMutation: UseMutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 914 915 mutationFn: async (options) => { 915 916 const { data } = await callWithResultFromHeader({ 916 917 ...options, ··· 937 938 ] 938 939 }); }; 939 940 940 - export const testErrorCodeMutation: UseMutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 941 + export const testErrorCodeMutation: UseMutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 941 942 mutationFn: async (options) => { 942 943 const { data } = await testErrorCode({ 943 944 ...options, ··· 964 965 ] 965 966 }); }; 966 967 967 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 968 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 968 969 mutationFn: async (options) => { 969 970 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 970 971 ...options, ··· 974 975 } 975 976 }; 976 977 977 - export const putWithFormUrlEncodedMutation: UseMutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 978 + export const putWithFormUrlEncodedMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 978 979 mutationFn: async (options) => { 979 980 const { data } = await putWithFormUrlEncoded({ 980 981 ...options,
+8 -7
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query_transform/@tanstack/query.gen.ts.snap packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query_transform/@tanstack/react-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-axios'; 4 4 import { queryOptions, type UseMutationOptions } from '@tanstack/react-query'; 5 + import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 + import type { AxiosError } from 'axios'; 5 7 import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 6 - import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 7 8 8 9 type QueryKey<TOptions extends Options> = [ 9 10 { ··· 47 48 ] 48 49 }); }; 49 50 50 - export const parentModelWithDatesMutation: UseMutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 51 + export const parentModelWithDatesMutation: UseMutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 51 52 mutationFn: async (options) => { 52 53 const { data } = await parentModelWithDates({ 53 54 ...options, ··· 57 58 } 58 59 }; 59 60 60 - export const modelWithDatesMutation: UseMutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 61 + export const modelWithDatesMutation: UseMutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 61 62 mutationFn: async (options) => { 62 63 const { data } = await modelWithDates({ 63 64 ...options, ··· 67 68 } 68 69 }; 69 70 70 - export const modelWithDatesArrayMutation: UseMutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 71 + export const modelWithDatesArrayMutation: UseMutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 71 72 mutationFn: async (options) => { 72 73 const { data } = await modelWithDatesArray({ 73 74 ...options, ··· 77 78 } 78 79 }; 79 80 80 - export const arrayOfDatesMutation: UseMutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 81 + export const arrayOfDatesMutation: UseMutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 81 82 mutationFn: async (options) => { 82 83 const { data } = await arrayOfDates({ 83 84 ...options, ··· 87 88 } 88 89 }; 89 90 90 - export const dateMutation: UseMutationOptions<DateResponse, DateError, Options> = { 91 + export const dateMutation: UseMutationOptions<DateResponse, AxiosError<DateError>, Options> = { 91 92 mutationFn: async (options) => { 92 93 const { data } = await date({ 93 94 ...options, ··· 97 98 } 98 99 }; 99 100 100 - export const multipleResponsesMutation: UseMutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 101 + export const multipleResponsesMutation: UseMutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 101 102 mutationFn: async (options) => { 102 103 const { data } = await multipleResponses({ 103 104 ...options,
+1 -1
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/query.gen.ts.snap packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap
··· 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; 5 5 import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 - import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsError, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 6 + import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 9 {
+1 -1
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query_transform/@tanstack/query.gen.ts.snap packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query_transform/@tanstack/react-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type UseMutationOptions } from '@tanstack/react-query'; 5 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 6 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 + import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 9 {
+2 -1
packages/openapi-ts/test/__snapshots__/test/generated/v3_services_name/index.ts.snap
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 - export * from './services.gen'; 2 + export * from './services.gen'; 3 + export * from './types.gen';
+1
packages/openapi-ts/test/__snapshots__/test/generated/v3_services_name/services.gen.ts.snap
··· 3 3 import type { CancelablePromise } from './core/CancelablePromise'; 4 4 import { OpenAPI } from './core/OpenAPI'; 5 5 import { request as __request } from './core/request'; 6 + import type { ApiVversionOdataControllerCountResponse, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse } from './types.gen'; 6 7 7 8 export class myAwesomeSimpleApi { 8 9 /**
+1181
packages/openapi-ts/test/__snapshots__/test/generated/v3_services_name/types.gen.ts.snap
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + /** 4 + * Model with number-only name 5 + */ 6 + export type _400 = string; 7 + 8 + /** 9 + * Testing multiline comments in string: First line 10 + * Second line 11 + * 12 + * Fourth line 13 + */ 14 + export type camelCaseCommentWithBreaks = number; 15 + 16 + /** 17 + * Testing multiline comments in string: First line 18 + * Second line 19 + * 20 + * Fourth line 21 + */ 22 + export type CommentWithBreaks = number; 23 + 24 + /** 25 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 26 + */ 27 + export type CommentWithBackticks = number; 28 + 29 + /** 30 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 31 + */ 32 + export type CommentWithBackticksAndQuotes = number; 33 + 34 + /** 35 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 36 + */ 37 + export type CommentWithSlashes = number; 38 + 39 + /** 40 + * Testing expression placeholders in string: ${expression} should work 41 + */ 42 + export type CommentWithExpressionPlaceholders = number; 43 + 44 + /** 45 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 46 + */ 47 + export type CommentWithQuotes = number; 48 + 49 + /** 50 + * Testing reserved characters in string: * inline * and ** inline ** should work 51 + */ 52 + export type CommentWithReservedCharacters = number; 53 + 54 + /** 55 + * This is a simple number 56 + */ 57 + export type SimpleInteger = number; 58 + 59 + /** 60 + * This is a simple boolean 61 + */ 62 + export type SimpleBoolean = boolean; 63 + 64 + /** 65 + * This is a simple string 66 + */ 67 + export type SimpleString = string; 68 + 69 + /** 70 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 71 + */ 72 + export type NonAsciiStringæøåÆØÅöôêÊ字符串 = string; 73 + 74 + /** 75 + * This is a simple file 76 + */ 77 + export type SimpleFile = (Blob | File); 78 + 79 + /** 80 + * This is a simple reference 81 + */ 82 + export type SimpleReference = ModelWithString; 83 + 84 + /** 85 + * This is a simple string 86 + */ 87 + export type SimpleStringWithPattern = string | null; 88 + 89 + /** 90 + * This is a simple enum with strings 91 + */ 92 + export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 93 + 94 + /** 95 + * This is a simple enum with strings 96 + */ 97 + export const EnumWithStrings = { 98 + SUCCESS: 'Success', 99 + WARNING: 'Warning', 100 + ERROR: 'Error', 101 + _SINGLE_QUOTE_: "'Single Quote'", 102 + _DOUBLE_QUOTES_: '"Double Quotes"', 103 + NON_ASCII__ØÆÅÔÖ_ØÆÅÔÖ字符串: 'Non-ascii: øæåôöØÆÅÔÖ字符串' 104 + } as const; 105 + 106 + export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 107 + 108 + export const EnumWithReplacedCharacters = { 109 + _SINGLE_QUOTE_: "'Single Quote'", 110 + _DOUBLE_QUOTES_: '"Double Quotes"', 111 + ØÆÅÔÖ_ØÆÅÔÖ字符串: 'øæåôöØÆÅÔÖ字符串', 112 + '_3.1': 3.1, 113 + EMPTY_STRING: '' 114 + } as const; 115 + 116 + /** 117 + * This is a simple enum with numbers 118 + */ 119 + export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 120 + 121 + /** 122 + * This is a simple enum with numbers 123 + */ 124 + export const EnumWithNumbers = { 125 + '_1': 1, 126 + '_2': 2, 127 + '_3': 3, 128 + '_1.1': 1.1, 129 + '_1.2': 1.2, 130 + '_1.3': 1.3, 131 + '_100': 100, 132 + '_200': 200, 133 + '_300': 300, 134 + '_-100': -100, 135 + '_-200': -200, 136 + '_-300': -300, 137 + '_-1.1': -1.1, 138 + '_-1.2': -1.2, 139 + '_-1.3': -1.3 140 + } as const; 141 + 142 + /** 143 + * Success=1,Warning=2,Error=3 144 + */ 145 + export type EnumFromDescription = number; 146 + 147 + /** 148 + * This is a simple enum with numbers 149 + */ 150 + export type EnumWithExtensions = 200 | 400 | 500; 151 + 152 + /** 153 + * This is a simple enum with numbers 154 + */ 155 + export const EnumWithExtensions = { 156 + /** 157 + * Used when the status of something is successful 158 + */ 159 + CUSTOM_SUCCESS: 200, 160 + /** 161 + * Used when the status of something has a warning 162 + */ 163 + CUSTOM_WARNING: 400, 164 + /** 165 + * Used when the status of something has an error 166 + */ 167 + CUSTOM_ERROR: 500 168 + } as const; 169 + 170 + export type EnumWithXEnumNames = 0 | 1 | 2; 171 + 172 + export const EnumWithXEnumNames = { 173 + zero: 0, 174 + one: 1, 175 + two: 2 176 + } as const; 177 + 178 + /** 179 + * This is a simple array with numbers 180 + */ 181 + export type ArrayWithNumbers = Array<(number)>; 182 + 183 + /** 184 + * This is a simple array with booleans 185 + */ 186 + export type ArrayWithBooleans = Array<(boolean)>; 187 + 188 + /** 189 + * This is a simple array with strings 190 + */ 191 + export type ArrayWithStrings = Array<(string)>; 192 + 193 + /** 194 + * This is a simple array with references 195 + */ 196 + export type ArrayWithReferences = Array<ModelWithString>; 197 + 198 + /** 199 + * This is a simple array containing an array 200 + */ 201 + export type ArrayWithArray = Array<Array<ModelWithString>>; 202 + 203 + /** 204 + * This is a simple array with properties 205 + */ 206 + export type ArrayWithProperties = Array<{ 207 + '16x16'?: camelCaseCommentWithBreaks; 208 + bar?: string; 209 + }>; 210 + 211 + /** 212 + * This is a simple array with any of properties 213 + */ 214 + export type ArrayWithAnyOfProperties = Array<({ 215 + foo?: string; 216 + } | { 217 + bar?: string; 218 + })>; 219 + 220 + export type AnyOfAnyAndNull = { 221 + data?: unknown | null; 222 + }; 223 + 224 + /** 225 + * This is a simple array with any of properties 226 + */ 227 + export type AnyOfArrays = { 228 + results?: Array<({ 229 + foo?: string; 230 + } | { 231 + bar?: string; 232 + })>; 233 + }; 234 + 235 + /** 236 + * This is a string dictionary 237 + */ 238 + export type DictionaryWithString = { 239 + [key: string]: (string); 240 + }; 241 + 242 + export type DictionaryWithPropertiesAndAdditionalProperties = { 243 + foo?: number; 244 + bar?: boolean; 245 + [key: string]: (string | number | boolean) | undefined; 246 + }; 247 + 248 + /** 249 + * This is a string reference 250 + */ 251 + export type DictionaryWithReference = { 252 + [key: string]: ModelWithString; 253 + }; 254 + 255 + /** 256 + * This is a complex dictionary 257 + */ 258 + export type DictionaryWithArray = { 259 + [key: string]: Array<ModelWithString>; 260 + }; 261 + 262 + /** 263 + * This is a string dictionary 264 + */ 265 + export type DictionaryWithDictionary = { 266 + [key: string]: { 267 + [key: string]: (string); 268 + }; 269 + }; 270 + 271 + /** 272 + * This is a complex dictionary 273 + */ 274 + export type DictionaryWithProperties = { 275 + [key: string]: { 276 + foo?: string; 277 + bar?: string; 278 + }; 279 + }; 280 + 281 + /** 282 + * This is a model with one number property 283 + */ 284 + export type ModelWithInteger = { 285 + /** 286 + * This is a simple number property 287 + */ 288 + prop?: number; 289 + }; 290 + 291 + /** 292 + * This is a model with one boolean property 293 + */ 294 + export type ModelWithBoolean = { 295 + /** 296 + * This is a simple boolean property 297 + */ 298 + prop?: boolean; 299 + }; 300 + 301 + /** 302 + * This is a model with one string property 303 + */ 304 + export type ModelWithString = { 305 + /** 306 + * This is a simple string property 307 + */ 308 + prop?: string; 309 + }; 310 + 311 + /** 312 + * This is a model with one string property 313 + */ 314 + export type ModelWithStringError = { 315 + /** 316 + * This is a simple string property 317 + */ 318 + prop?: string; 319 + }; 320 + 321 + /** 322 + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) 323 + */ 324 + export type Model_From_Zendesk = string; 325 + 326 + /** 327 + * This is a model with one string property 328 + */ 329 + export type ModelWithNullableString = { 330 + /** 331 + * This is a simple string property 332 + */ 333 + nullableProp1?: string | null; 334 + /** 335 + * This is a simple string property 336 + */ 337 + nullableRequiredProp1: string | null; 338 + /** 339 + * This is a simple string property 340 + */ 341 + nullableProp2?: string | null; 342 + /** 343 + * This is a simple string property 344 + */ 345 + nullableRequiredProp2: string | null; 346 + /** 347 + * This is a simple enum with strings 348 + */ 349 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 350 + }; 351 + 352 + /** 353 + * This is a simple enum with strings 354 + */ 355 + export type foo_bar_enum = 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 356 + 357 + /** 358 + * This is a simple enum with strings 359 + */ 360 + export const foo_bar_enum = { 361 + SUCCESS: 'Success', 362 + WARNING: 'Warning', 363 + ERROR: 'Error', 364 + ØÆÅ字符串: 'ØÆÅ字符串' 365 + } as const; 366 + 367 + /** 368 + * This is a model with one enum 369 + */ 370 + export type ModelWithEnum = { 371 + /** 372 + * This is a simple enum with strings 373 + */ 374 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 375 + /** 376 + * These are the HTTP error code enums 377 + */ 378 + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 379 + /** 380 + * Simple boolean enum 381 + */ 382 + bool?: boolean; 383 + }; 384 + 385 + /** 386 + * These are the HTTP error code enums 387 + */ 388 + export type statusCode = '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 389 + 390 + /** 391 + * These are the HTTP error code enums 392 + */ 393 + export const statusCode = { 394 + _100: '100', 395 + _200_FOO: '200 FOO', 396 + _300_FOO_BAR: '300 FOO_BAR', 397 + _400_FOO_BAR: '400 foo-bar', 398 + _500_FOO_BAR: '500 foo.bar', 399 + _600_FOO_BAR: '600 foo&bar' 400 + } as const; 401 + 402 + /** 403 + * This is a model with one enum with escaped name 404 + */ 405 + export type ModelWithEnumWithHyphen = { 406 + 'foo-bar-baz-qux'?: '3.0'; 407 + }; 408 + 409 + export type foo_bar_baz_qux = '3.0'; 410 + 411 + export const foo_bar_baz_qux = { 412 + _3_0: '3.0' 413 + } as const; 414 + 415 + /** 416 + * This is a model with one enum 417 + */ 418 + export type ModelWithEnumFromDescription = { 419 + /** 420 + * Success=1,Warning=2,Error=3 421 + */ 422 + test?: number; 423 + }; 424 + 425 + /** 426 + * This is a model with nested enums 427 + */ 428 + export type ModelWithNestedEnums = { 429 + dictionaryWithEnum?: { 430 + [key: string]: ('Success' | 'Warning' | 'Error'); 431 + }; 432 + dictionaryWithEnumFromDescription?: { 433 + [key: string]: (number); 434 + }; 435 + arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; 436 + arrayWithDescription?: Array<(number)>; 437 + /** 438 + * This is a simple enum with strings 439 + */ 440 + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 441 + }; 442 + 443 + /** 444 + * This is a model with one property containing a reference 445 + */ 446 + export type ModelWithReference = { 447 + prop?: ModelWithProperties; 448 + }; 449 + 450 + /** 451 + * This is a model with one property containing an array 452 + */ 453 + export type ModelWithArrayReadOnlyAndWriteOnly = { 454 + prop?: Array<ModelWithReadOnlyAndWriteOnly>; 455 + propWithFile?: Array<((Blob | File))>; 456 + propWithNumber?: Array<(number)>; 457 + }; 458 + 459 + /** 460 + * This is a model with one property containing an array 461 + */ 462 + export type ModelWithArray = { 463 + prop?: Array<ModelWithString>; 464 + propWithFile?: Array<((Blob | File))>; 465 + propWithNumber?: Array<(number)>; 466 + }; 467 + 468 + /** 469 + * This is a model with one property containing a dictionary 470 + */ 471 + export type ModelWithDictionary = { 472 + prop?: { 473 + [key: string]: (string); 474 + }; 475 + }; 476 + 477 + /** 478 + * This is a deprecated model with a deprecated property 479 + * @deprecated 480 + */ 481 + export type DeprecatedModel = { 482 + /** 483 + * This is a deprecated property 484 + * @deprecated 485 + */ 486 + prop?: string; 487 + }; 488 + 489 + /** 490 + * This is a model with one property containing a circular reference 491 + */ 492 + export type ModelWithCircularReference = { 493 + prop?: ModelWithCircularReference; 494 + }; 495 + 496 + /** 497 + * This is a model with one property with a 'one of' relationship 498 + */ 499 + export type CompositionWithOneOf = { 500 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 501 + }; 502 + 503 + /** 504 + * This is a model with one property with a 'one of' relationship where the options are not $ref 505 + */ 506 + export type CompositionWithOneOfAnonymous = { 507 + propA?: { 508 + propA?: string; 509 + } | string | number; 510 + }; 511 + 512 + /** 513 + * Circle 514 + */ 515 + export type ModelCircle = { 516 + kind: 'circle'; 517 + radius?: number; 518 + }; 519 + 520 + /** 521 + * Square 522 + */ 523 + export type ModelSquare = { 524 + kind: 'square'; 525 + sideLength?: number; 526 + }; 527 + 528 + /** 529 + * This is a model with one property with a 'one of' relationship where the options are not $ref 530 + */ 531 + export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; 532 + 533 + /** 534 + * This is a model with one property with a 'any of' relationship 535 + */ 536 + export type CompositionWithAnyOf = { 537 + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 538 + }; 539 + 540 + /** 541 + * This is a model with one property with a 'any of' relationship where the options are not $ref 542 + */ 543 + export type CompositionWithAnyOfAnonymous = { 544 + propA?: { 545 + propA?: string; 546 + } | string | number; 547 + }; 548 + 549 + /** 550 + * This is a model with nested 'any of' property with a type null 551 + */ 552 + export type CompositionWithNestedAnyAndTypeNull = { 553 + propA?: Array<(ModelWithDictionary | null)> | Array<(ModelWithArray | null)>; 554 + }; 555 + 556 + export type _3e_num_1Период = 'Bird' | 'Dog'; 557 + 558 + export const _3e_num_1Период = { 559 + BIRD: 'Bird', 560 + DOG: 'Dog' 561 + } as const; 562 + 563 + export type ConstValue = "ConstValue"; 564 + 565 + /** 566 + * This is a model with one property with a 'any of' relationship where the options are not $ref 567 + */ 568 + export type CompositionWithNestedAnyOfAndNull = { 569 + propA?: Array<(_3e_num_1Период | ConstValue)> | null; 570 + }; 571 + 572 + /** 573 + * This is a model with one property with a 'one of' relationship 574 + */ 575 + export type CompositionWithOneOfAndNullable = { 576 + propA?: { 577 + boolean?: boolean; 578 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 579 + }; 580 + 581 + /** 582 + * This is a model that contains a simple dictionary within composition 583 + */ 584 + export type CompositionWithOneOfAndSimpleDictionary = { 585 + propA?: boolean | { 586 + [key: string]: (number); 587 + }; 588 + }; 589 + 590 + /** 591 + * This is a model that contains a dictionary of simple arrays within composition 592 + */ 593 + export type CompositionWithOneOfAndSimpleArrayDictionary = { 594 + propA?: boolean | { 595 + [key: string]: Array<(boolean)>; 596 + }; 597 + }; 598 + 599 + /** 600 + * This is a model that contains a dictionary of complex arrays (composited) within composition 601 + */ 602 + export type CompositionWithOneOfAndComplexArrayDictionary = { 603 + propA?: boolean | { 604 + [key: string]: Array<(number | string)>; 605 + }; 606 + }; 607 + 608 + /** 609 + * This is a model with one property with a 'all of' relationship 610 + */ 611 + export type CompositionWithAllOfAndNullable = { 612 + propA?: ({ 613 + boolean?: boolean; 614 + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 615 + }; 616 + 617 + /** 618 + * This is a model with one property with a 'any of' relationship 619 + */ 620 + export type CompositionWithAnyOfAndNullable = { 621 + propA?: { 622 + boolean?: boolean; 623 + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 624 + }; 625 + 626 + /** 627 + * This is a base model with two simple optional properties 628 + */ 629 + export type CompositionBaseModel = { 630 + firstName?: string; 631 + lastname?: string; 632 + }; 633 + 634 + /** 635 + * This is a model that extends the base model 636 + */ 637 + export type CompositionExtendedModel = CompositionBaseModel & { 638 + firstName: string; 639 + lastname: string; 640 + age: number; 641 + }; 642 + 643 + /** 644 + * This is a model with one nested property 645 + */ 646 + export type ModelWithProperties = { 647 + required: string; 648 + readonly requiredAndReadOnly: string; 649 + requiredAndNullable: string | null; 650 + string?: string; 651 + number?: number; 652 + boolean?: boolean; 653 + reference?: ModelWithString; 654 + 'property with space'?: string; 655 + default?: string; 656 + try?: string; 657 + readonly '@namespace.string'?: string; 658 + readonly '@namespace.integer'?: number; 659 + }; 660 + 661 + /** 662 + * This is a model with one nested property 663 + */ 664 + export type ModelWithNestedProperties = { 665 + readonly first: { 666 + readonly second: { 667 + readonly third: string | null; 668 + } | null; 669 + } | null; 670 + }; 671 + 672 + /** 673 + * This is a model with duplicated properties 674 + */ 675 + export type ModelWithDuplicateProperties = { 676 + prop?: ModelWithString; 677 + }; 678 + 679 + /** 680 + * This is a model with ordered properties 681 + */ 682 + export type ModelWithOrderedProperties = { 683 + zebra?: string; 684 + apple?: string; 685 + hawaii?: string; 686 + }; 687 + 688 + /** 689 + * This is a model with duplicated imports 690 + */ 691 + export type ModelWithDuplicateImports = { 692 + propA?: ModelWithString; 693 + propB?: ModelWithString; 694 + propC?: ModelWithString; 695 + }; 696 + 697 + /** 698 + * This is a model that extends another model 699 + */ 700 + export type ModelThatExtends = ModelWithString & { 701 + propExtendsA?: string; 702 + propExtendsB?: ModelWithString; 703 + }; 704 + 705 + /** 706 + * This is a model that extends another model 707 + */ 708 + export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 709 + propExtendsC?: string; 710 + propExtendsD?: ModelWithString; 711 + }; 712 + 713 + /** 714 + * This is a model that contains a some patterns 715 + */ 716 + export type ModelWithPattern = { 717 + key: string; 718 + name: string; 719 + readonly enabled?: boolean; 720 + readonly modified?: string; 721 + id?: string; 722 + text?: string; 723 + patternWithSingleQuotes?: string; 724 + patternWithNewline?: string; 725 + patternWithBacktick?: string; 726 + }; 727 + 728 + export type File = { 729 + readonly id?: string; 730 + readonly updated_at?: string; 731 + readonly created_at?: string; 732 + mime: string; 733 + readonly file?: string; 734 + }; 735 + 736 + export type _default = { 737 + name?: string; 738 + }; 739 + 740 + export type Pageable = { 741 + page?: number; 742 + size?: number; 743 + sort?: Array<(string)>; 744 + }; 745 + 746 + /** 747 + * This is a free-form object without additionalProperties. 748 + */ 749 + export type FreeFormObjectWithoutAdditionalProperties = { 750 + [key: string]: unknown; 751 + }; 752 + 753 + /** 754 + * This is a free-form object with additionalProperties: true. 755 + */ 756 + export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 757 + [key: string]: unknown; 758 + }; 759 + 760 + /** 761 + * This is a free-form object with additionalProperties: {}. 762 + */ 763 + export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 764 + [key: string]: unknown; 765 + }; 766 + 767 + export type ModelWithConst = { 768 + String?: "String"; 769 + number?: 0; 770 + null?: null; 771 + withType?: "Some string"; 772 + }; 773 + 774 + /** 775 + * This is a model with one property and additionalProperties: true 776 + */ 777 + export type ModelWithAdditionalPropertiesEqTrue = { 778 + /** 779 + * This is a simple string property 780 + */ 781 + prop?: string; 782 + [key: string]: unknown | string; 783 + }; 784 + 785 + export type NestedAnyOfArraysNullable = { 786 + nullableArray?: Array<(string | boolean)> | null; 787 + }; 788 + 789 + export type CompositionWithOneOfAndProperties = { 790 + foo: ParameterSimpleParameter; 791 + } | { 792 + bar: NonAsciiStringæøåÆØÅöôêÊ字符串; 793 + } & { 794 + baz: number | null; 795 + qux: number; 796 + }; 797 + 798 + /** 799 + * An object that can be null 800 + */ 801 + export type NullableObject = { 802 + foo?: string; 803 + } | null; 804 + 805 + /** 806 + * Some % character 807 + */ 808 + export type CharactersInDescription = string; 809 + 810 + export type ModelWithNullableObject = { 811 + data?: NullableObject; 812 + }; 813 + 814 + export type ModelWithOneOfEnum = { 815 + foo: 'Bar'; 816 + } | { 817 + foo: 'Baz'; 818 + } | { 819 + foo: 'Qux'; 820 + } | { 821 + content: string; 822 + foo: 'Quux'; 823 + } | { 824 + content: [ 825 + string, 826 + string 827 + ]; 828 + foo: 'Corge'; 829 + }; 830 + 831 + export type foo = 'Bar'; 832 + 833 + export const foo = { 834 + BAR: 'Bar' 835 + } as const; 836 + 837 + export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 838 + 839 + export const ModelWithNestedArrayEnumsDataFoo = { 840 + FOO: 'foo', 841 + BAR: 'bar' 842 + } as const; 843 + 844 + export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 845 + 846 + export const ModelWithNestedArrayEnumsDataBar = { 847 + BAZ: 'baz', 848 + QUX: 'qux' 849 + } as const; 850 + 851 + export type ModelWithNestedArrayEnumsData = { 852 + foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 853 + bar?: Array<ModelWithNestedArrayEnumsDataBar>; 854 + }; 855 + 856 + export type ModelWithNestedArrayEnums = { 857 + array_strings?: Array<(string)>; 858 + data?: ModelWithNestedArrayEnumsData; 859 + }; 860 + 861 + export type ModelWithNestedCompositionEnums = { 862 + foo?: ModelWithNestedArrayEnumsDataFoo; 863 + }; 864 + 865 + export type ModelWithReadOnlyAndWriteOnly = { 866 + foo: string; 867 + readonly bar: string; 868 + baz: string; 869 + }; 870 + 871 + export type ModelWithConstantSizeArray = [ 872 + number, 873 + number 874 + ]; 875 + 876 + export type ModelWithAnyOfConstantSizeArray = [ 877 + number | string, 878 + number | string, 879 + number | string 880 + ]; 881 + 882 + export type ModelWithPrefixItemsConstantSizeArray = [ 883 + ModelWithInteger, 884 + number | string, 885 + string 886 + ]; 887 + 888 + export type ModelWithAnyOfConstantSizeArrayNullable = [ 889 + number | null | string, 890 + number | null | string, 891 + number | null | string 892 + ]; 893 + 894 + export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 895 + number | _import, 896 + number | _import 897 + ]; 898 + 899 + export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 900 + number & string, 901 + number & string 902 + ]; 903 + 904 + export type ModelWithNumericEnumUnion = { 905 + /** 906 + * Период 907 + */ 908 + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 909 + }; 910 + 911 + /** 912 + * Период 913 + */ 914 + export type value = -10 | -1 | 0 | 1 | 3 | 6 | 12; 915 + 916 + /** 917 + * Период 918 + */ 919 + export const value = { 920 + '_-10': -10, 921 + '_-1': -1, 922 + '_0': 0, 923 + '_1': 1, 924 + '_3': 3, 925 + '_6': 6, 926 + '_12': 12 927 + } as const; 928 + 929 + /** 930 + * Some description with `back ticks` 931 + */ 932 + export type ModelWithBackticksInDescription = { 933 + /** 934 + * The template `that` should be used for parsing and importing the contents of the CSV file. 935 + * 936 + * <br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p> 937 + * <pre> 938 + * [ 939 + * { 940 + * "resourceType": "Asset", 941 + * "identifier": { 942 + * "name": "${1}", 943 + * "domain": { 944 + * "name": "${2}", 945 + * "community": { 946 + * "name": "Some Community" 947 + * } 948 + * } 949 + * }, 950 + * "attributes" : { 951 + * "00000000-0000-0000-0000-000000003115" : [ { 952 + * "value" : "${3}" 953 + * } ], 954 + * "00000000-0000-0000-0000-000000000222" : [ { 955 + * "value" : "${4}" 956 + * } ] 957 + * } 958 + * } 959 + * ] 960 + * </pre> 961 + */ 962 + template?: string; 963 + }; 964 + 965 + export type ModelWithOneOfAndProperties = ParameterSimpleParameter | NonAsciiStringæøåÆØÅöôêÊ字符串 & { 966 + baz: number | null; 967 + qux: number; 968 + }; 969 + 970 + /** 971 + * Model used to test deduplication strategy (unused) 972 + */ 973 + export type ParameterSimpleParameterUnused = string; 974 + 975 + /** 976 + * Model used to test deduplication strategy 977 + */ 978 + export type PostServiceWithEmptyTagResponse = string; 979 + 980 + /** 981 + * Model used to test deduplication strategy 982 + */ 983 + export type PostServiceWithEmptyTagResponse2 = string; 984 + 985 + /** 986 + * Model used to test deduplication strategy 987 + */ 988 + export type DeleteFooData = string; 989 + 990 + /** 991 + * Model used to test deduplication strategy 992 + */ 993 + export type DeleteFooData2 = string; 994 + 995 + /** 996 + * Model with restricted keyword name 997 + */ 998 + export type _import = string; 999 + 1000 + export type SchemaWithFormRestrictedKeys = { 1001 + description?: string; 1002 + 'x-enum-descriptions'?: string; 1003 + 'x-enum-varnames'?: string; 1004 + 'x-enumNames'?: string; 1005 + title?: string; 1006 + object?: { 1007 + description?: string; 1008 + 'x-enum-descriptions'?: string; 1009 + 'x-enum-varnames'?: string; 1010 + 'x-enumNames'?: string; 1011 + title?: string; 1012 + }; 1013 + array?: Array<({ 1014 + description?: string; 1015 + 'x-enum-descriptions'?: string; 1016 + 'x-enum-varnames'?: string; 1017 + 'x-enumNames'?: string; 1018 + title?: string; 1019 + })>; 1020 + }; 1021 + 1022 + /** 1023 + * This is a reusable parameter 1024 + */ 1025 + export type ParameterSimpleParameter = string; 1026 + 1027 + /** 1028 + * Parameter with illegal characters 1029 + */ 1030 + export type Parameterx_Foo_Bar = ModelWithString; 1031 + 1032 + export type ApiVversionOdataControllerCountResponse = Model_From_Zendesk; 1033 + 1034 + export type DeleteFooData3 = { 1035 + /** 1036 + * bar in method 1037 + */ 1038 + barParam: string; 1039 + /** 1040 + * foo in method 1041 + */ 1042 + fooParam: string; 1043 + /** 1044 + * Parameter with illegal characters 1045 + */ 1046 + xFooBar: ModelWithString; 1047 + }; 1048 + 1049 + export type CallWithParametersData = { 1050 + /** 1051 + * This is the parameter that goes into the query params 1052 + */ 1053 + cursor: string | null; 1054 + fooAllOfEnum: ModelWithNestedArrayEnumsDataFoo; 1055 + fooRefEnum?: ModelWithNestedArrayEnumsDataFoo; 1056 + /** 1057 + * This is the parameter that goes into the cookie 1058 + */ 1059 + parameterCookie: string | null; 1060 + /** 1061 + * This is the parameter that goes into the header 1062 + */ 1063 + parameterHeader: string | null; 1064 + /** 1065 + * This is the parameter that goes into the path 1066 + */ 1067 + parameterPath: string | null; 1068 + /** 1069 + * This is the parameter that goes into the body 1070 + */ 1071 + requestBody: { 1072 + [key: string]: unknown; 1073 + } | null; 1074 + }; 1075 + 1076 + export type CallWithWeirdParameterNamesData = { 1077 + /** 1078 + * This is the parameter with a reserved keyword 1079 + */ 1080 + _default?: string; 1081 + /** 1082 + * This is the parameter that goes into the cookie 1083 + */ 1084 + parameterCookie: string | null; 1085 + /** 1086 + * This is the parameter that goes into the request header 1087 + */ 1088 + parameterHeader: string | null; 1089 + /** 1090 + * This is the parameter that goes into the path 1091 + */ 1092 + parameterPath1?: string; 1093 + /** 1094 + * This is the parameter that goes into the path 1095 + */ 1096 + parameterPath2?: string; 1097 + /** 1098 + * This is the parameter that goes into the path 1099 + */ 1100 + parameterPath3?: string; 1101 + /** 1102 + * This is the parameter that goes into the request query params 1103 + */ 1104 + parameterQuery: string | null; 1105 + /** 1106 + * This is the parameter that goes into the body 1107 + */ 1108 + requestBody: ModelWithString | null; 1109 + }; 1110 + 1111 + export type GetCallWithOptionalParamData = { 1112 + /** 1113 + * This is an optional parameter 1114 + */ 1115 + page?: number; 1116 + /** 1117 + * This is a required parameter 1118 + */ 1119 + requestBody: ModelWithOneOfEnum; 1120 + }; 1121 + 1122 + export type PostCallWithOptionalParamData = { 1123 + /** 1124 + * This is a required parameter 1125 + */ 1126 + parameter: Pageable; 1127 + /** 1128 + * This is an optional parameter 1129 + */ 1130 + requestBody?: { 1131 + offset?: number | null; 1132 + }; 1133 + }; 1134 + 1135 + export type PostCallWithOptionalParamResponse = number | void; 1136 + 1137 + export type $OpenApiTs = { 1138 + '/api/v{api-version}/simple/$count': { 1139 + get: { 1140 + res: { 1141 + /** 1142 + * Success 1143 + */ 1144 + 200: Model_From_Zendesk; 1145 + }; 1146 + }; 1147 + }; 1148 + '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}': { 1149 + delete: { 1150 + req: DeleteFooData3; 1151 + }; 1152 + }; 1153 + '/api/v{api-version}/parameters/{parameterPath}': { 1154 + post: { 1155 + req: CallWithParametersData; 1156 + }; 1157 + }; 1158 + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { 1159 + post: { 1160 + req: CallWithWeirdParameterNamesData; 1161 + }; 1162 + }; 1163 + '/api/v{api-version}/parameters/': { 1164 + get: { 1165 + req: GetCallWithOptionalParamData; 1166 + }; 1167 + post: { 1168 + req: PostCallWithOptionalParamData; 1169 + res: { 1170 + /** 1171 + * Response is a simple number 1172 + */ 1173 + 200: number; 1174 + /** 1175 + * Success 1176 + */ 1177 + 204: void; 1178 + }; 1179 + }; 1180 + }; 1181 + };
-1
packages/openapi-ts/test/index.spec.ts
··· 312 312 include: '^(Simple|Parameters)', 313 313 name: 'myAwesome{{name}}Api', 314 314 }, 315 - types: false, 316 315 }), 317 316 description: 'generate services with custom name', 318 317 name: 'v3_services_name',
+4 -4
packages/openapi-ts/test/sample.cjs
··· 5 5 const config = { 6 6 client: { 7 7 // bundle: true, 8 - // name: '@hey-api/client-axios', 9 - name: '@hey-api/client-fetch', 8 + name: '@hey-api/client-axios', 9 + // name: '@hey-api/client-fetch', 10 10 }, 11 11 debug: true, 12 12 // input: './test/spec/v3-transforms.json', ··· 20 20 plugins: [ 21 21 { 22 22 // infiniteQueryOptions: false, 23 - mutationOptions: false, 23 + // mutationOptions: false, 24 24 name: '@tanstack/react-query', 25 - queryOptions: false, 25 + // queryOptions: false, 26 26 }, 27 27 ], 28 28 schemas: {