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

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #3544 from hey-api/test/valibot-plugin

test: move valibot tests into separate package

authored by

Lubos and committed by
GitHub
2f981d90 2bfc2d07

+433 -15982
-1
packages/openapi-ts-tests/main/package.json
··· 42 42 "rxjs": "7.8.2", 43 43 "tslib": "2.8.1", 44 44 "typescript": "5.9.3", 45 - "valibot": "1.2.0", 46 45 "vue": "3.5.25", 47 46 "zod": "4.3.6" 48 47 },
-15
packages/openapi-ts-tests/main/test/3.0.x.test.ts
··· 81 81 config: createConfig({ 82 82 input: 'array-items-one-of-length-1.yaml', 83 83 output: 'array-items-one-of-length-1', 84 - plugins: ['@hey-api/typescript', 'valibot'], 85 84 }), 86 85 description: 'generates correct array when items are oneOf array with single item', 87 86 }, ··· 248 247 enums: 'root', 249 248 }, 250 249 }, 251 - plugins: ['@hey-api/typescript'], 252 250 }), 253 251 description: 'exports inline enums', 254 252 }, ··· 535 533 config: createConfig({ 536 534 input: 'enum-null.json', 537 535 output: 'enum-null', 538 - plugins: ['@hey-api/typescript', 'valibot'], 539 536 }), 540 537 description: 'handles null enums', 541 538 }, ··· 586 583 config: createConfig({ 587 584 input: 'ref-deep.yaml', 588 585 output: 'ref-deep', 589 - plugins: ['@hey-api/typescript'], 590 586 }), 591 587 description: 'handles deep references', 592 588 }, ··· 616 612 }, 617 613 }, 618 614 }, 619 - plugins: ['@hey-api/typescript'], 620 615 }), 621 616 description: 'handles schema name transforms', 622 617 }, ··· 632 627 name.replace(/_v\d+_User$/, ''), 633 628 }, 634 629 }, 635 - plugins: ['@hey-api/typescript'], 636 630 }), 637 631 description: 'handles schema name collision prevention', 638 632 }, ··· 763 757 propertiesRequiredByDefault: true, 764 758 }, 765 759 }, 766 - plugins: ['@hey-api/typescript'], 767 760 }), 768 761 description: 'makes all object properties required by default', 769 762 }, ··· 773 766 output: 'type-invalid', 774 767 }), 775 768 description: 'gracefully handles invalid type', 776 - }, 777 - { 778 - config: createConfig({ 779 - input: 'validators.json', 780 - output: 'validators', 781 - plugins: ['valibot'], 782 - }), 783 - description: 'generates validator schemas', 784 769 }, 785 770 ]; 786 771
+2 -107
packages/openapi-ts-tests/main/test/3.1.x.test.ts
··· 101 101 config: createConfig({ 102 102 input: 'array-items-one-of-length-1.yaml', 103 103 output: 'array-items-one-of-length-1', 104 - plugins: ['@hey-api/typescript', 'valibot'], 105 104 }), 106 105 description: 'generates correct array when items are oneOf array with single item', 107 106 }, ··· 288 287 enums: 'root', 289 288 }, 290 289 }, 291 - plugins: ['@hey-api/typescript'], 292 290 }), 293 291 description: 'exports inline enums', 294 292 }, ··· 575 573 config: createConfig({ 576 574 input: 'union-types.json', 577 575 output: 'union-types', 578 - plugins: ['@hey-api/typescript'], 579 576 }), 580 577 description: 'handles union of primitive types', 581 578 }, ··· 583 580 config: createConfig({ 584 581 input: 'enum-null.json', 585 582 output: 'enum-null', 586 - plugins: ['@hey-api/typescript', 'valibot'], 587 583 }), 588 584 description: 'handles null enums', 589 585 }, ··· 695 691 config: createConfig({ 696 692 input: 'ref-deep.yaml', 697 693 output: 'ref-deep', 698 - plugins: ['@hey-api/typescript'], 699 694 }), 700 695 description: 'handles deep references', 701 696 }, ··· 725 720 }, 726 721 }, 727 722 }, 728 - plugins: ['@hey-api/typescript'], 729 723 }), 730 724 description: 'handles schema name transforms', 731 725 }, ··· 733 727 config: createConfig({ 734 728 input: 'transforms-read-write-nested.yaml', 735 729 output: 'transforms-read-write-nested', 736 - plugins: ['@hey-api/typescript'], 737 730 }), 738 731 description: 'handles write-only types in nested schemas', 739 732 }, ··· 741 734 config: createConfig({ 742 735 input: 'transforms-read-write-response.yaml', 743 736 output: 'transforms-read-write-response', 744 - plugins: ['@hey-api/typescript'], 745 737 }), 746 738 description: 'handles read-only types in nested response schemas', 747 739 }, ··· 749 741 config: createConfig({ 750 742 input: 'transforms-read-write-unevaluated.yaml', 751 743 output: 'transforms-read-write-unevaluated', 752 - plugins: ['@hey-api/typescript'], 753 744 }), 754 745 description: 'preserves unevaluatedProperties in schemas with readOnly fields', 755 746 }, ··· 785 776 config: createConfig({ 786 777 input: 'schema-const.yaml', 787 778 output: 'schema-const', 788 - plugins: ['@hey-api/typescript', 'valibot'], 789 779 }), 790 780 description: 'handles various constants', 791 781 }, ··· 924 914 }, 925 915 { 926 916 config: createConfig({ 927 - input: 'validators.yaml', 928 - output: 'validators', 929 - plugins: ['valibot'], 930 - }), 931 - description: 'generates validator schemas', 932 - }, 933 - { 934 - config: createConfig({ 935 - input: 'validators.yaml', 936 - output: 'validators-metadata', 937 - plugins: [ 938 - { 939 - metadata: true, 940 - name: 'valibot', 941 - }, 942 - ], 943 - }), 944 - description: 'generates validator schemas with metadata', 945 - }, 946 - { 947 - config: createConfig({ 948 - input: 'validators.yaml', 949 - output: 'validators-metadata-fn', 950 - plugins: [ 951 - { 952 - metadata: ({ $, node, schema }) => { 953 - node 954 - .prop('custom', $.literal('value')) 955 - .prop('title', $.literal(schema.description ?? schema.type ?? '')); 956 - }, 957 - name: 'valibot', 958 - }, 959 - ], 960 - }), 961 - description: 'generates validator schemas with metadata function', 962 - }, 963 - { 964 - config: createConfig({ 965 - input: 'validators.yaml', 966 - output: 'validators-types', 967 - plugins: ['valibot'], 968 - }), 969 - description: 'generates validator schemas with types', 970 - }, 971 - { 972 - config: createConfig({ 973 - input: 'validators-bigint-min-max.json', 974 - output: 'validators-bigint-min-max', 975 - plugins: ['valibot'], 976 - }), 977 - description: 'validator schemas with BigInt and min/max constraints', 978 - }, 979 - { 980 - config: createConfig({ 981 - input: 'validators-circular-ref.json', 982 - output: 'validators-circular-ref', 983 - plugins: ['valibot'], 984 - }), 985 - description: 'validator schemas with circular reference', 986 - }, 987 - { 988 - config: createConfig({ 989 - input: 'validators-circular-ref-2.yaml', 990 - output: 'validators-circular-ref-2', 991 - plugins: ['valibot'], 992 - }), 993 - description: 'validator schemas with circular reference 2', 994 - }, 995 - { 996 - config: createConfig({ 997 - input: 'validators-union-merge.json', 998 - output: 'validators-union-merge', 999 - plugins: ['valibot'], 1000 - }), 1001 - description: "validator schemas with merged unions (can't use .merge())", 1002 - }, 1003 - { 1004 - config: createConfig({ 1005 - input: 'integer-formats.yaml', 1006 - output: 'integer-formats', 1007 - plugins: ['valibot'], 1008 - }), 1009 - description: 1010 - 'generates validator schemas for all integer format combinations (number/integer/string types with int8, int16, int32, int64, uint8, uint16, uint32, uint64 formats)', 1011 - }, 1012 - { 1013 - config: createConfig({ 1014 917 input: 'opencode.yaml', 1015 918 output: 'sse-angular', 1016 919 parser: { ··· 1111 1014 config: createConfig({ 1112 1015 input: 'zoom-video-sdk.json', 1113 1016 output: 'webhooks', 1114 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 1017 + plugins: ['@hey-api/typescript', 'zod'], 1115 1018 }), 1116 1019 description: 'webhook types and validator schemas', 1117 1020 }, ··· 1119 1022 config: createConfig({ 1120 1023 input: 'string-with-format.yaml', 1121 1024 output: 'string-with-format', 1122 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 1025 + plugins: ['@hey-api/typescript', 'zod'], 1123 1026 }), 1124 1027 description: 'anyOf string and binary string', 1125 - }, 1126 - { 1127 - config: createConfig({ 1128 - input: 'time-format.yaml', 1129 - output: 'time-format', 1130 - plugins: ['valibot'], 1131 - }), 1132 - description: 'generates correct valibot schema for time format', 1133 1028 }, 1134 1029 ]; 1135 1030
-425
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type HttpRequest, httpResource } from '@angular/common/http'; 4 - 5 - import { client } from '../client.gen'; 6 - import type { Options } from '../sdk.gen'; 7 - import type { CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithResponsesData, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexTypesData, ComplexTypesResponse, DeleteCallWithoutParametersAndResponseData, DummyAData, DummyBData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, FooWowData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, ServiceWithEmptyTagData, TestErrorCodeData, TypesData, TypesResponse } from '../types.gen'; 8 - 9 - export const serviceWithEmptyTagRequest = <ThrowOnError extends boolean = false>(options?: Options<ServiceWithEmptyTagData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 10 - responseStyle: 'data', 11 - method: 'GET', 12 - url: '/api/v{api-version}/no+tag', 13 - ...options 14 - }); 15 - 16 - export const patchApiVbyApiVersionNoTagRequest = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 17 - responseStyle: 'data', 18 - method: 'PATCH', 19 - url: '/api/v{api-version}/no+tag', 20 - ...options 21 - }); 22 - 23 - export const fooWowRequest = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 24 - responseStyle: 'data', 25 - method: 'PUT', 26 - url: '/api/v{api-version}/no+tag', 27 - ...options 28 - }); 29 - 30 - export const deleteCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 31 - responseStyle: 'data', 32 - method: 'DELETE', 33 - url: '/api/v{api-version}/simple', 34 - ...options 35 - }); 36 - 37 - export const getCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 38 - responseStyle: 'data', 39 - method: 'GET', 40 - url: '/api/v{api-version}/simple', 41 - ...options 42 - }); 43 - 44 - export const headCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 45 - responseStyle: 'data', 46 - method: 'HEAD', 47 - url: '/api/v{api-version}/simple', 48 - ...options 49 - }); 50 - 51 - export const optionsCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 52 - responseStyle: 'data', 53 - method: 'OPTIONS', 54 - url: '/api/v{api-version}/simple', 55 - ...options 56 - }); 57 - 58 - export const patchCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 59 - responseStyle: 'data', 60 - method: 'PATCH', 61 - url: '/api/v{api-version}/simple', 62 - ...options 63 - }); 64 - 65 - export const postCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 66 - responseStyle: 'data', 67 - method: 'POST', 68 - url: '/api/v{api-version}/simple', 69 - ...options 70 - }); 71 - 72 - export const putCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 73 - responseStyle: 'data', 74 - method: 'PUT', 75 - url: '/api/v{api-version}/simple', 76 - ...options 77 - }); 78 - 79 - export const callWithDescriptionsRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 80 - responseStyle: 'data', 81 - method: 'POST', 82 - url: '/api/v{api-version}/descriptions/', 83 - ...options 84 - }); 85 - 86 - export const callWithParametersRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 87 - responseStyle: 'data', 88 - method: 'POST', 89 - url: '/api/v{api-version}/parameters/{parameterPath}', 90 - ...options 91 - }); 92 - 93 - export const callWithWeirdParameterNamesRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 94 - responseStyle: 'data', 95 - method: 'POST', 96 - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 97 - ...options 98 - }); 99 - 100 - export const callWithDefaultParametersRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithDefaultParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 101 - responseStyle: 'data', 102 - method: 'GET', 103 - url: '/api/v{api-version}/defaults', 104 - ...options 105 - }); 106 - 107 - export const callWithDefaultOptionalParametersRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 108 - responseStyle: 'data', 109 - method: 'POST', 110 - url: '/api/v{api-version}/defaults', 111 - ...options 112 - }); 113 - 114 - export const callToTestOrderOfParamsRequest = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 115 - responseStyle: 'data', 116 - method: 'PUT', 117 - url: '/api/v{api-version}/defaults', 118 - ...options 119 - }); 120 - 121 - export const duplicateNameRequest = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 122 - responseStyle: 'data', 123 - method: 'DELETE', 124 - url: '/api/v{api-version}/duplicate', 125 - ...options 126 - }); 127 - 128 - export const duplicateName2Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 129 - responseStyle: 'data', 130 - method: 'GET', 131 - url: '/api/v{api-version}/duplicate', 132 - ...options 133 - }); 134 - 135 - export const duplicateName3Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 136 - responseStyle: 'data', 137 - method: 'POST', 138 - url: '/api/v{api-version}/duplicate', 139 - ...options 140 - }); 141 - 142 - export const duplicateName4Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 143 - responseStyle: 'data', 144 - method: 'PUT', 145 - url: '/api/v{api-version}/duplicate', 146 - ...options 147 - }); 148 - 149 - export const callWithNoContentResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 150 - responseStyle: 'data', 151 - method: 'GET', 152 - url: '/api/v{api-version}/no-content', 153 - ...options 154 - }); 155 - 156 - export const callWithResponseAndNoContentResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 157 - responseStyle: 'data', 158 - method: 'GET', 159 - url: '/api/v{api-version}/multiple-tags/response-and-no-content', 160 - ...options 161 - }); 162 - 163 - export const dummyARequest = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 164 - responseStyle: 'data', 165 - method: 'GET', 166 - url: '/api/v{api-version}/multiple-tags/a', 167 - ...options 168 - }); 169 - 170 - export const dummyBRequest = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 171 - responseStyle: 'data', 172 - method: 'GET', 173 - url: '/api/v{api-version}/multiple-tags/b', 174 - ...options 175 - }); 176 - 177 - export const callWithResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 178 - responseStyle: 'data', 179 - method: 'GET', 180 - url: '/api/v{api-version}/response', 181 - ...options 182 - }); 183 - 184 - export const callWithDuplicateResponsesRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 185 - responseStyle: 'data', 186 - method: 'POST', 187 - url: '/api/v{api-version}/response', 188 - ...options 189 - }); 190 - 191 - export const callWithResponsesRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 192 - responseStyle: 'data', 193 - method: 'PUT', 194 - url: '/api/v{api-version}/response', 195 - ...options 196 - }); 197 - 198 - export const collectionFormatRequest = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 199 - responseStyle: 'data', 200 - method: 'GET', 201 - url: '/api/v{api-version}/collectionFormat', 202 - ...options 203 - }); 204 - 205 - export const typesRequest = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 206 - responseStyle: 'data', 207 - method: 'GET', 208 - url: '/api/v{api-version}/types', 209 - ...options 210 - }); 211 - 212 - export const complexTypesRequest = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 213 - responseStyle: 'data', 214 - method: 'GET', 215 - url: '/api/v{api-version}/complex', 216 - ...options 217 - }); 218 - 219 - export const callWithResultFromHeaderRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 220 - responseStyle: 'data', 221 - method: 'POST', 222 - url: '/api/v{api-version}/header', 223 - ...options 224 - }); 225 - 226 - export const testErrorCodeRequest = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 227 - responseStyle: 'data', 228 - method: 'POST', 229 - url: '/api/v{api-version}/error', 230 - ...options 231 - }); 232 - 233 - export const nonAsciiæøåÆøÅöôêÊ字符串Request = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 234 - responseStyle: 'data', 235 - method: 'POST', 236 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 237 - ...options 238 - }); 239 - 240 - /** 241 - * Body should not be unknown 242 - * 243 - * Body should not be unknown 244 - */ 245 - export const postApiVbyApiVersionBodyRequest = <ThrowOnError extends boolean = false>(options: Options<PostApiVbyApiVersionBodyData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 246 - responseStyle: 'data', 247 - method: 'POST', 248 - url: '/api/v{api-version}/body', 249 - ...options 250 - }); 251 - 252 - export const serviceWithEmptyTagResource = <ThrowOnError extends boolean = false>(options?: () => Options<ServiceWithEmptyTagData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 253 - const opts = options ? options() : undefined; 254 - return opts ? serviceWithEmptyTagRequest(opts) : undefined; 255 - }); 256 - 257 - export const patchApiVbyApiVersionNoTagResource = <ThrowOnError extends boolean = false>(options?: () => Options<PatchApiVbyApiVersionNoTagData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 258 - const opts = options ? options() : undefined; 259 - return opts ? patchApiVbyApiVersionNoTagRequest(opts) : undefined; 260 - }); 261 - 262 - export const fooWowResource = <ThrowOnError extends boolean = false>(options?: () => Options<FooWowData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 263 - const opts = options ? options() : undefined; 264 - return opts ? fooWowRequest(opts) : undefined; 265 - }); 266 - 267 - export const deleteCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 268 - const opts = options ? options() : undefined; 269 - return opts ? deleteCallWithoutParametersAndResponseRequest(opts) : undefined; 270 - }); 271 - 272 - export const getCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<GetCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 273 - const opts = options ? options() : undefined; 274 - return opts ? getCallWithoutParametersAndResponseRequest(opts) : undefined; 275 - }); 276 - 277 - export const headCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<HeadCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 278 - const opts = options ? options() : undefined; 279 - return opts ? headCallWithoutParametersAndResponseRequest(opts) : undefined; 280 - }); 281 - 282 - export const optionsCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 283 - const opts = options ? options() : undefined; 284 - return opts ? optionsCallWithoutParametersAndResponseRequest(opts) : undefined; 285 - }); 286 - 287 - export const patchCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PatchCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 288 - const opts = options ? options() : undefined; 289 - return opts ? patchCallWithoutParametersAndResponseRequest(opts) : undefined; 290 - }); 291 - 292 - export const postCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 293 - const opts = options ? options() : undefined; 294 - return opts ? postCallWithoutParametersAndResponseRequest(opts) : undefined; 295 - }); 296 - 297 - export const putCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PutCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 298 - const opts = options ? options() : undefined; 299 - return opts ? putCallWithoutParametersAndResponseRequest(opts) : undefined; 300 - }); 301 - 302 - export const callWithDescriptionsResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDescriptionsData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 303 - const opts = options ? options() : undefined; 304 - return opts ? callWithDescriptionsRequest(opts) : undefined; 305 - }); 306 - 307 - export const callWithParametersResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 308 - const opts = options ? options() : undefined; 309 - return opts ? callWithParametersRequest(opts) : undefined; 310 - }); 311 - 312 - export const callWithWeirdParameterNamesResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithWeirdParameterNamesData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 313 - const opts = options ? options() : undefined; 314 - return opts ? callWithWeirdParameterNamesRequest(opts) : undefined; 315 - }); 316 - 317 - export const callWithDefaultParametersResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithDefaultParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 318 - const opts = options ? options() : undefined; 319 - return opts ? callWithDefaultParametersRequest(opts) : undefined; 320 - }); 321 - 322 - export const callWithDefaultOptionalParametersResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDefaultOptionalParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 323 - const opts = options ? options() : undefined; 324 - return opts ? callWithDefaultOptionalParametersRequest(opts) : undefined; 325 - }); 326 - 327 - export const callToTestOrderOfParamsResource = <ThrowOnError extends boolean = false>(options: () => Options<CallToTestOrderOfParamsData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 328 - const opts = options ? options() : undefined; 329 - return opts ? callToTestOrderOfParamsRequest(opts) : undefined; 330 - }); 331 - 332 - export const duplicateNameResource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateNameData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 333 - const opts = options ? options() : undefined; 334 - return opts ? duplicateNameRequest(opts) : undefined; 335 - }); 336 - 337 - export const duplicateName2Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName2Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 338 - const opts = options ? options() : undefined; 339 - return opts ? duplicateName2Request(opts) : undefined; 340 - }); 341 - 342 - export const duplicateName3Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName3Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 343 - const opts = options ? options() : undefined; 344 - return opts ? duplicateName3Request(opts) : undefined; 345 - }); 346 - 347 - export const duplicateName4Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName4Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 348 - const opts = options ? options() : undefined; 349 - return opts ? duplicateName4Request(opts) : undefined; 350 - }); 351 - 352 - export const callWithNoContentResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithNoContentResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 353 - const opts = options ? options() : undefined; 354 - return opts ? callWithNoContentResponseRequest(opts) : undefined; 355 - }); 356 - 357 - export const callWithResponseAndNoContentResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponseAndNoContentResponseData, ThrowOnError> | undefined) => httpResource<CallWithResponseAndNoContentResponseResponse>(() => { 358 - const opts = options ? options() : undefined; 359 - return opts ? callWithResponseAndNoContentResponseRequest(opts) : undefined; 360 - }); 361 - 362 - export const dummyAResource = <ThrowOnError extends boolean = false>(options?: () => Options<DummyAData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 363 - const opts = options ? options() : undefined; 364 - return opts ? dummyARequest(opts) : undefined; 365 - }); 366 - 367 - export const dummyBResource = <ThrowOnError extends boolean = false>(options?: () => Options<DummyBData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 368 - const opts = options ? options() : undefined; 369 - return opts ? dummyBRequest(opts) : undefined; 370 - }); 371 - 372 - export const callWithResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponseData, ThrowOnError> | undefined) => httpResource<CallWithResponseResponse>(() => { 373 - const opts = options ? options() : undefined; 374 - return opts ? callWithResponseRequest(opts) : undefined; 375 - }); 376 - 377 - export const callWithDuplicateResponsesResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDuplicateResponsesData, ThrowOnError> | undefined) => httpResource<CallWithDuplicateResponsesResponse>(() => { 378 - const opts = options ? options() : undefined; 379 - return opts ? callWithDuplicateResponsesRequest(opts) : undefined; 380 - }); 381 - 382 - export const callWithResponsesResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponsesData, ThrowOnError> | undefined) => httpResource<CallWithResponsesResponse>(() => { 383 - const opts = options ? options() : undefined; 384 - return opts ? callWithResponsesRequest(opts) : undefined; 385 - }); 386 - 387 - export const collectionFormatResource = <ThrowOnError extends boolean = false>(options: () => Options<CollectionFormatData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 388 - const opts = options ? options() : undefined; 389 - return opts ? collectionFormatRequest(opts) : undefined; 390 - }); 391 - 392 - export const typesResource = <ThrowOnError extends boolean = false>(options: () => Options<TypesData, ThrowOnError> | undefined) => httpResource<TypesResponse>(() => { 393 - const opts = options ? options() : undefined; 394 - return opts ? typesRequest(opts) : undefined; 395 - }); 396 - 397 - export const complexTypesResource = <ThrowOnError extends boolean = false>(options: () => Options<ComplexTypesData, ThrowOnError> | undefined) => httpResource<ComplexTypesResponse>(() => { 398 - const opts = options ? options() : undefined; 399 - return opts ? complexTypesRequest(opts) : undefined; 400 - }); 401 - 402 - export const callWithResultFromHeaderResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResultFromHeaderData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 403 - const opts = options ? options() : undefined; 404 - return opts ? callWithResultFromHeaderRequest(opts) : undefined; 405 - }); 406 - 407 - export const testErrorCodeResource = <ThrowOnError extends boolean = false>(options: () => Options<TestErrorCodeData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 408 - const opts = options ? options() : undefined; 409 - return opts ? testErrorCodeRequest(opts) : undefined; 410 - }); 411 - 412 - export const nonAsciiæøåÆøÅöôêÊ字符串Resource = <ThrowOnError extends boolean = false>(options: () => Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError> | undefined) => httpResource<NonAsciiæøåÆøÅöôêÊ字符串Response>(() => { 413 - const opts = options ? options() : undefined; 414 - return opts ? nonAsciiæøåÆøÅöôêÊ字符串Request(opts) : undefined; 415 - }); 416 - 417 - /** 418 - * Body should not be unknown 419 - * 420 - * Body should not be unknown 421 - */ 422 - export const postApiVbyApiVersionBodyResource = <ThrowOnError extends boolean = false>(options: () => Options<PostApiVbyApiVersionBodyData, ThrowOnError> | undefined) => httpResource<PostApiVbyApiVersionBodyResponse>(() => { 423 - const opts = options ? options() : undefined; 424 - return opts ? postApiVbyApiVersionBodyRequest(opts) : undefined; 425 - });
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/client.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/client/client.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/index.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/client/index.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/client/types.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/client/utils.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/auth.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/bodySerializer.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/params.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/pathSerializer.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/queryKeySerializer.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/queryKeySerializer.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/serverSentEvents.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/types.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/core/utils.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/index.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/sdk.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/transformers.gen.ts
-36
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type ClientOptions = { 4 - baseUrl: string; 5 - }; 6 - 7 - export type TypeID<T extends string> = `${T}_${string}`; 8 - 9 - export type UserId = TypeID<'user'>; 10 - 11 - export type Foo = { 12 - bar?: number; 13 - foo: bigint; 14 - id: UserId; 15 - }; 16 - 17 - export type Bar = { 18 - foo: number; 19 - [key: string]: number; 20 - }; 21 - 22 - export type PostFooData = { 23 - body?: never; 24 - path?: never; 25 - query?: never; 26 - url: '/foo'; 27 - }; 28 - 29 - export type PostFooResponses = { 30 - /** 31 - * OK 32 - */ 33 - 200: Foo; 34 - }; 35 - 36 - export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/valibot.gen.ts
-775
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - /** 6 - * Testing multiline comments in string: First line 7 - * Second line 8 - * 9 - * Fourth line 10 - */ 11 - export const vCommentWithBreaks = v.pipe(v.number(), v.integer()); 12 - 13 - /** 14 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 15 - */ 16 - export const vCommentWithBackticks = v.pipe(v.number(), v.integer()); 17 - 18 - /** 19 - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 20 - */ 21 - export const vCommentWithBackticksAndQuotes = v.pipe(v.number(), v.integer()); 22 - 23 - /** 24 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 25 - */ 26 - export const vCommentWithSlashes = v.pipe(v.number(), v.integer()); 27 - 28 - /** 29 - * Testing expression placeholders in string: ${expression} should work 30 - */ 31 - export const vCommentWithExpressionPlaceholders = v.pipe(v.number(), v.integer()); 32 - 33 - /** 34 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 35 - */ 36 - export const vCommentWithQuotes = v.pipe(v.number(), v.integer()); 37 - 38 - /** 39 - * Testing reserved characters in string: * inline * and ** inline ** should work 40 - */ 41 - export const vCommentWithReservedCharacters = v.pipe(v.number(), v.integer()); 42 - 43 - /** 44 - * This is a simple number 45 - */ 46 - export const vSimpleInteger = v.pipe(v.number(), v.integer()); 47 - 48 - /** 49 - * This is a simple boolean 50 - */ 51 - export const vSimpleBoolean = v.boolean(); 52 - 53 - /** 54 - * This is a simple string 55 - */ 56 - export const vSimpleString = v.string(); 57 - 58 - /** 59 - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 60 - */ 61 - export const vNonAsciiStringæøåÆøÅöôêÊ字符串 = v.string(); 62 - 63 - /** 64 - * This is a simple file 65 - */ 66 - export const vSimpleFile = v.string(); 67 - 68 - /** 69 - * This is a simple string 70 - */ 71 - export const vSimpleStringWithPattern = v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)); 72 - 73 - /** 74 - * This is a simple enum with strings 75 - */ 76 - export const vEnumWithStrings = v.picklist([ 77 - 'Success', 78 - 'Warning', 79 - 'Error', 80 - '\'Single Quote\'', 81 - '"Double Quotes"', 82 - 'Non-ascii: øæåôöØÆÅÔÖ字符串' 83 - ]); 84 - 85 - /** 86 - * This is a simple enum with numbers 87 - */ 88 - export const vEnumWithNumbers = v.unknown(); 89 - 90 - /** 91 - * Success=1,Warning=2,Error=3 92 - */ 93 - export const vEnumFromDescription = v.number(); 94 - 95 - /** 96 - * This is a simple enum with numbers 97 - */ 98 - export const vEnumWithExtensions = v.unknown(); 99 - 100 - /** 101 - * This is a simple array with numbers 102 - */ 103 - export const vArrayWithNumbers = v.array(v.pipe(v.number(), v.integer())); 104 - 105 - /** 106 - * This is a simple array with booleans 107 - */ 108 - export const vArrayWithBooleans = v.array(v.boolean()); 109 - 110 - /** 111 - * This is a simple array with strings 112 - */ 113 - export const vArrayWithStrings = v.array(v.string()); 114 - 115 - /** 116 - * This is a simple array with properties 117 - */ 118 - export const vArrayWithProperties = v.array(v.object({ 119 - foo: v.optional(v.string()), 120 - bar: v.optional(v.string()) 121 - })); 122 - 123 - /** 124 - * This is a string dictionary 125 - */ 126 - export const vDictionaryWithString = v.record(v.string(), v.string()); 127 - 128 - /** 129 - * This is a string dictionary 130 - */ 131 - export const vDictionaryWithDictionary = v.record(v.string(), v.record(v.string(), v.string())); 132 - 133 - /** 134 - * This is a complex dictionary 135 - */ 136 - export const vDictionaryWithProperties = v.record(v.string(), v.object({ 137 - foo: v.optional(v.string()), 138 - bar: v.optional(v.string()) 139 - })); 140 - 141 - /** 142 - * This is a type-only model that defines Date as a string 143 - */ 144 - export const vDate = v.string(); 145 - 146 - /** 147 - * This is a model with one number property 148 - */ 149 - export const vModelWithInteger = v.object({ 150 - prop: v.optional(v.pipe(v.number(), v.integer())) 151 - }); 152 - 153 - /** 154 - * This is a model with one boolean property 155 - */ 156 - export const vModelWithBoolean = v.object({ 157 - prop: v.optional(v.boolean()) 158 - }); 159 - 160 - /** 161 - * This is a model with one string property 162 - */ 163 - export const vModelWithString = v.object({ 164 - prop: v.optional(v.string()) 165 - }); 166 - 167 - export const vSimpleReference = vModelWithString; 168 - 169 - /** 170 - * This is a simple array with references 171 - */ 172 - export const vArrayWithReferences = v.array(vModelWithString); 173 - 174 - /** 175 - * This is a simple array containing an array 176 - */ 177 - export const vArrayWithArray = v.array(v.array(vModelWithString)); 178 - 179 - /** 180 - * This is a string reference 181 - */ 182 - export const vDictionaryWithReference = v.object({}); 183 - 184 - /** 185 - * This is a complex dictionary 186 - */ 187 - export const vDictionaryWithArray = v.record(v.string(), v.array(vModelWithString)); 188 - 189 - /** 190 - * This is a model with one string property 191 - */ 192 - export const vModelWithStringError = v.object({ 193 - prop: v.optional(v.string()) 194 - }); 195 - 196 - /** 197 - * This is a model with one string property 198 - */ 199 - export const vModelWithNullableString = v.object({ 200 - nullableProp: v.nullish(v.string()), 201 - nullableRequiredProp: v.nullable(v.string()) 202 - }); 203 - 204 - /** 205 - * This is a model with one enum 206 - */ 207 - export const vModelWithEnum = v.object({ 208 - test: v.optional(v.picklist([ 209 - 'Success', 210 - 'Warning', 211 - 'Error', 212 - 'ØÆÅ字符串' 213 - ])), 214 - statusCode: v.optional(v.picklist([ 215 - '100', 216 - '200 FOO', 217 - '300 FOO_BAR', 218 - '400 foo-bar', 219 - '500 foo.bar', 220 - '600 foo&bar' 221 - ])), 222 - bool: v.optional(v.unknown()) 223 - }); 224 - 225 - /** 226 - * This is a model with one enum 227 - */ 228 - export const vModelWithEnumFromDescription = v.object({ 229 - test: v.optional(v.pipe(v.number(), v.integer())) 230 - }); 231 - 232 - /** 233 - * This is a model with nested enums 234 - */ 235 - export const vModelWithNestedEnums = v.object({ 236 - dictionaryWithEnum: v.optional(v.record(v.string(), v.picklist([ 237 - 'Success', 238 - 'Warning', 239 - 'Error' 240 - ]))), 241 - dictionaryWithEnumFromDescription: v.optional(v.record(v.string(), v.pipe(v.number(), v.integer()))), 242 - arrayWithEnum: v.optional(v.array(v.picklist([ 243 - 'Success', 244 - 'Warning', 245 - 'Error' 246 - ]))), 247 - arrayWithDescription: v.optional(v.array(v.pipe(v.number(), v.integer()))) 248 - }); 249 - 250 - /** 251 - * This is a model with one property containing an array 252 - */ 253 - export const vModelWithArray = v.object({ 254 - prop: v.optional(v.array(vModelWithString)), 255 - propWithFile: v.optional(v.array(v.string())), 256 - propWithNumber: v.optional(v.array(v.number())) 257 - }); 258 - 259 - /** 260 - * This is a model with one property containing a dictionary 261 - */ 262 - export const vModelWithDictionary = v.object({ 263 - prop: v.optional(v.record(v.string(), v.string())) 264 - }); 265 - 266 - /** 267 - * This is a model with one property containing a circular reference 268 - */ 269 - export const vModelWithCircularReference: v.GenericSchema = v.object({ 270 - prop: v.optional(v.lazy(() => vModelWithCircularReference)) 271 - }); 272 - 273 - /** 274 - * This is a model with one nested property 275 - */ 276 - export const vModelWithProperties = v.object({ 277 - required: v.string(), 278 - requiredAndReadOnly: v.pipe(v.string(), v.readonly()), 279 - string: v.optional(v.string()), 280 - number: v.optional(v.number()), 281 - boolean: v.optional(v.boolean()), 282 - reference: v.optional(vModelWithString), 283 - 'property with space': v.optional(v.string()), 284 - default: v.optional(v.string()), 285 - try: v.optional(v.string()), 286 - '@namespace.string': v.optional(v.pipe(v.string(), v.readonly())), 287 - '@namespace.integer': v.optional(v.pipe(v.pipe(v.number(), v.integer()), v.readonly())) 288 - }); 289 - 290 - /** 291 - * This is a model with one property containing a reference 292 - */ 293 - export const vModelWithReference = v.object({ 294 - prop: v.optional(vModelWithProperties) 295 - }); 296 - 297 - /** 298 - * This is a model with one nested property 299 - */ 300 - export const vModelWithNestedProperties = v.object({ 301 - first: v.pipe(v.object({ 302 - second: v.pipe(v.object({ 303 - third: v.pipe(v.string(), v.readonly()) 304 - }), v.readonly()) 305 - }), v.readonly()) 306 - }); 307 - 308 - /** 309 - * This is a model with duplicated properties 310 - */ 311 - export const vModelWithDuplicateProperties = v.object({ 312 - prop: v.optional(vModelWithString) 313 - }); 314 - 315 - /** 316 - * This is a model with ordered properties 317 - */ 318 - export const vModelWithOrderedProperties = v.object({ 319 - zebra: v.optional(v.string()), 320 - apple: v.optional(v.string()), 321 - hawaii: v.optional(v.string()) 322 - }); 323 - 324 - /** 325 - * This is a model with duplicated imports 326 - */ 327 - export const vModelWithDuplicateImports = v.object({ 328 - propA: v.optional(vModelWithString), 329 - propB: v.optional(vModelWithString), 330 - propC: v.optional(vModelWithString) 331 - }); 332 - 333 - /** 334 - * This is a model that extends another model 335 - */ 336 - export const vModelThatExtends = v.intersect([vModelWithString, v.object({ 337 - propExtendsA: v.optional(v.string()), 338 - propExtendsB: v.optional(vModelWithString) 339 - })]); 340 - 341 - /** 342 - * This is a model that extends another model 343 - */ 344 - export const vModelThatExtendsExtends = v.intersect([ 345 - vModelWithString, 346 - vModelThatExtends, 347 - v.object({ 348 - propExtendsC: v.optional(v.string()), 349 - propExtendsD: v.optional(vModelWithString) 350 - }) 351 - ]); 352 - 353 - export const vDefault = v.object({ 354 - name: v.optional(v.string()) 355 - }); 356 - 357 - /** 358 - * This is a model that contains a some patterns 359 - */ 360 - export const vModelWithPattern = v.object({ 361 - key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), 362 - name: v.pipe(v.string(), v.maxLength(255)), 363 - enabled: v.optional(v.pipe(v.boolean(), v.readonly())), 364 - modified: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 365 - id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), 366 - text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), 367 - patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), 368 - patternWithNewline: v.optional(v.pipe(v.string(), v.regex(/aaa\nbbb/))), 369 - patternWithBacktick: v.optional(v.pipe(v.string(), v.regex(/aaa`bbb/))), 370 - patternWithUnicode: v.optional(v.pipe(v.string(), v.regex(/^\p{L}+$/u))) 371 - }); 372 - 373 - export const vParameterActivityParams = v.object({ 374 - description: v.optional(v.string()), 375 - graduate_id: v.optional(v.pipe(v.number(), v.integer())), 376 - organization_id: v.optional(v.pipe(v.number(), v.integer())), 377 - parent_activity: v.optional(v.pipe(v.number(), v.integer())), 378 - post_id: v.optional(v.pipe(v.number(), v.integer())) 379 - }); 380 - 381 - export const vResponsePostActivityResponse = v.object({ 382 - description: v.optional(v.string()), 383 - graduate_id: v.optional(v.pipe(v.number(), v.integer())), 384 - organization_id: v.optional(v.pipe(v.number(), v.integer())), 385 - parent_activity_id: v.optional(v.pipe(v.number(), v.integer())), 386 - post_id: v.optional(v.pipe(v.number(), v.integer())) 387 - }); 388 - 389 - export const vFailureFailure = v.object({ 390 - error: v.optional(v.string()), 391 - message: v.optional(v.string()), 392 - reference_code: v.optional(v.string()) 393 - }); 394 - 395 - export const vExternalSharedModel = v.object({ 396 - id: v.string(), 397 - name: v.optional(v.string()) 398 - }); 399 - 400 - export const vExternalRefA = vExternalSharedModel; 401 - 402 - export const vExternalRefB = vExternalSharedModel; 403 - 404 - /** 405 - * This is a model with one nested property 406 - */ 407 - export const vModelWithPropertiesWritable = v.object({ 408 - required: v.string(), 409 - string: v.optional(v.string()), 410 - number: v.optional(v.number()), 411 - boolean: v.optional(v.boolean()), 412 - reference: v.optional(vModelWithString), 413 - 'property with space': v.optional(v.string()), 414 - default: v.optional(v.string()), 415 - try: v.optional(v.string()) 416 - }); 417 - 418 - /** 419 - * This is a model with one property containing a reference 420 - */ 421 - export const vModelWithReferenceWritable = v.object({ 422 - prop: v.optional(vModelWithPropertiesWritable) 423 - }); 424 - 425 - /** 426 - * This is a model that contains a some patterns 427 - */ 428 - export const vModelWithPatternWritable = v.object({ 429 - key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), 430 - name: v.pipe(v.string(), v.maxLength(255)), 431 - id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), 432 - text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), 433 - patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), 434 - patternWithNewline: v.optional(v.pipe(v.string(), v.regex(/aaa\nbbb/))), 435 - patternWithBacktick: v.optional(v.pipe(v.string(), v.regex(/aaa`bbb/))), 436 - patternWithUnicode: v.optional(v.pipe(v.string(), v.regex(/^\p{L}+$/u))) 437 - }); 438 - 439 - export const vServiceWithEmptyTagData = v.object({ 440 - body: v.optional(v.never()), 441 - path: v.optional(v.never()), 442 - query: v.optional(v.never()) 443 - }); 444 - 445 - export const vPatchApiVbyApiVersionNoTagData = v.object({ 446 - body: v.optional(v.never()), 447 - path: v.optional(v.never()), 448 - query: v.optional(v.never()) 449 - }); 450 - 451 - export const vFooWowData = v.object({ 452 - body: v.optional(v.never()), 453 - path: v.optional(v.never()), 454 - query: v.optional(v.never()) 455 - }); 456 - 457 - export const vDeleteCallWithoutParametersAndResponseData = v.object({ 458 - body: v.optional(v.never()), 459 - path: v.optional(v.never()), 460 - query: v.optional(v.never()) 461 - }); 462 - 463 - export const vGetCallWithoutParametersAndResponseData = v.object({ 464 - body: v.optional(v.never()), 465 - path: v.optional(v.never()), 466 - query: v.optional(v.never()) 467 - }); 468 - 469 - export const vHeadCallWithoutParametersAndResponseData = v.object({ 470 - body: v.optional(v.never()), 471 - path: v.optional(v.never()), 472 - query: v.optional(v.never()) 473 - }); 474 - 475 - export const vOptionsCallWithoutParametersAndResponseData = v.object({ 476 - body: v.optional(v.never()), 477 - path: v.optional(v.never()), 478 - query: v.optional(v.never()) 479 - }); 480 - 481 - export const vPatchCallWithoutParametersAndResponseData = v.object({ 482 - body: v.optional(v.never()), 483 - path: v.optional(v.never()), 484 - query: v.optional(v.never()) 485 - }); 486 - 487 - export const vPostCallWithoutParametersAndResponseData = v.object({ 488 - body: v.optional(v.never()), 489 - path: v.optional(v.never()), 490 - query: v.optional(v.never()) 491 - }); 492 - 493 - export const vPutCallWithoutParametersAndResponseData = v.object({ 494 - body: v.optional(v.never()), 495 - path: v.optional(v.never()), 496 - query: v.optional(v.never()) 497 - }); 498 - 499 - export const vCallWithDescriptionsData = v.object({ 500 - body: v.optional(v.never()), 501 - path: v.optional(v.never()), 502 - query: v.optional(v.object({ 503 - parameterWithBreaks: v.optional(v.string()), 504 - parameterWithBackticks: v.optional(v.string()), 505 - parameterWithSlashes: v.optional(v.string()), 506 - parameterWithExpressionPlaceholders: v.optional(v.string()), 507 - parameterWithQuotes: v.optional(v.string()), 508 - parameterWithReservedCharacters: v.optional(v.string()) 509 - })) 510 - }); 511 - 512 - export const vCallWithParametersData = v.object({ 513 - body: v.optional(v.never()), 514 - path: v.object({ 515 - parameterPath: v.string(), 516 - 'api-version': v.string() 517 - }), 518 - query: v.object({ 519 - parameterQuery: v.string() 520 - }), 521 - headers: v.object({ 522 - parameterHeader: v.string() 523 - }) 524 - }); 525 - 526 - export const vCallWithWeirdParameterNamesData = v.object({ 527 - body: v.string(), 528 - path: v.object({ 529 - 'parameter.path.1': v.optional(v.string()), 530 - 'parameter-path-2': v.optional(v.string()), 531 - 'PARAMETER-PATH-3': v.optional(v.string()), 532 - 'api-version': v.string() 533 - }), 534 - query: v.object({ 535 - default: v.optional(v.string()), 536 - 'parameter-query': v.string() 537 - }), 538 - headers: v.object({ 539 - 'parameter.header': v.string() 540 - }) 541 - }); 542 - 543 - export const vCallWithDefaultParametersData = v.object({ 544 - body: v.optional(v.never()), 545 - path: v.optional(v.never()), 546 - query: v.object({ 547 - parameterString: v.optional(v.string(), 'Hello World!'), 548 - parameterNumber: v.optional(v.number(), 123), 549 - parameterBoolean: v.optional(v.boolean(), true), 550 - parameterEnum: v.picklist([ 551 - 'Success', 552 - 'Warning', 553 - 'Error' 554 - ]), 555 - parameterModel: v.optional(v.object({ 556 - prop: v.optional(v.string()) 557 - }), { prop: 'Hello World!' }) 558 - }) 559 - }); 560 - 561 - export const vCallWithDefaultOptionalParametersData = v.object({ 562 - body: v.optional(v.never()), 563 - path: v.optional(v.never()), 564 - query: v.optional(v.object({ 565 - parameterString: v.optional(v.string(), 'Hello World!'), 566 - parameterNumber: v.optional(v.number(), 123), 567 - parameterBoolean: v.optional(v.boolean(), true), 568 - parameterEnum: v.optional(v.picklist([ 569 - 'Success', 570 - 'Warning', 571 - 'Error' 572 - ])) 573 - })) 574 - }); 575 - 576 - export const vCallToTestOrderOfParamsData = v.object({ 577 - body: v.optional(v.never()), 578 - path: v.optional(v.never()), 579 - query: v.object({ 580 - parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), 581 - parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ''), 582 - parameterOptionalStringWithNoDefault: v.optional(v.string()), 583 - parameterStringWithDefault: v.optional(v.string(), 'Hello World!'), 584 - parameterStringWithEmptyDefault: v.optional(v.string(), ''), 585 - parameterStringWithNoDefault: v.string(), 586 - parameterStringNullableWithNoDefault: v.nullish(v.string()), 587 - parameterStringNullableWithDefault: v.nullish(v.string(), null) 588 - }) 589 - }); 590 - 591 - export const vDuplicateNameData = v.object({ 592 - body: v.optional(v.never()), 593 - path: v.optional(v.never()), 594 - query: v.optional(v.never()) 595 - }); 596 - 597 - export const vDuplicateName2Data = v.object({ 598 - body: v.optional(v.never()), 599 - path: v.optional(v.never()), 600 - query: v.optional(v.never()) 601 - }); 602 - 603 - export const vDuplicateName3Data = v.object({ 604 - body: v.optional(v.never()), 605 - path: v.optional(v.never()), 606 - query: v.optional(v.never()) 607 - }); 608 - 609 - export const vDuplicateName4Data = v.object({ 610 - body: v.optional(v.never()), 611 - path: v.optional(v.never()), 612 - query: v.optional(v.never()) 613 - }); 614 - 615 - export const vCallWithNoContentResponseData = v.object({ 616 - body: v.optional(v.never()), 617 - path: v.optional(v.never()), 618 - query: v.optional(v.never()) 619 - }); 620 - 621 - export const vCallWithResponseAndNoContentResponseData = v.object({ 622 - body: v.optional(v.never()), 623 - path: v.optional(v.never()), 624 - query: v.optional(v.never()) 625 - }); 626 - 627 - export const vCallWithResponseAndNoContentResponseResponse = v.union([v.number(), v.unknown()]); 628 - 629 - export const vDummyAData = v.object({ 630 - body: v.optional(v.never()), 631 - path: v.optional(v.never()), 632 - query: v.optional(v.never()) 633 - }); 634 - 635 - export const vDummyBData = v.object({ 636 - body: v.optional(v.never()), 637 - path: v.optional(v.never()), 638 - query: v.optional(v.never()) 639 - }); 640 - 641 - export const vCallWithResponseData = v.object({ 642 - body: v.optional(v.never()), 643 - path: v.optional(v.never()), 644 - query: v.optional(v.never()) 645 - }); 646 - 647 - /** 648 - * Message for default response 649 - */ 650 - export const vCallWithResponseResponse = vModelWithString; 651 - 652 - export const vCallWithDuplicateResponsesData = v.object({ 653 - body: v.optional(v.never()), 654 - path: v.optional(v.never()), 655 - query: v.optional(v.never()) 656 - }); 657 - 658 - /** 659 - * Message for 201 response 660 - */ 661 - export const vCallWithDuplicateResponsesResponse = vModelWithString; 662 - 663 - export const vCallWithResponsesData = v.object({ 664 - body: v.optional(v.never()), 665 - path: v.optional(v.never()), 666 - query: v.optional(v.never()) 667 - }); 668 - 669 - export const vCallWithResponsesResponse = v.union([ 670 - v.object({ 671 - '@namespace.string': v.optional(v.pipe(v.string(), v.readonly())), 672 - '@namespace.integer': v.optional(v.pipe(v.pipe(v.number(), v.integer()), v.readonly())), 673 - value: v.optional(v.pipe(v.array(vModelWithString), v.readonly())) 674 - }), 675 - vModelThatExtends, 676 - vModelThatExtendsExtends 677 - ]); 678 - 679 - export const vCollectionFormatData = v.object({ 680 - body: v.optional(v.never()), 681 - path: v.optional(v.never()), 682 - query: v.object({ 683 - parameterArrayCSV: v.array(v.string()), 684 - parameterArraySSV: v.array(v.string()), 685 - parameterArrayTSV: v.array(v.string()), 686 - parameterArrayPipes: v.array(v.string()), 687 - parameterArrayMulti: v.array(v.string()) 688 - }) 689 - }); 690 - 691 - export const vTypesData = v.object({ 692 - body: v.optional(v.never()), 693 - path: v.optional(v.object({ 694 - id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))) 695 - })), 696 - query: v.object({ 697 - parameterNumber: v.optional(v.number(), 123), 698 - parameterString: v.optional(v.string(), 'default'), 699 - parameterBoolean: v.optional(v.boolean(), true), 700 - parameterArray: v.array(v.string()), 701 - parameterDictionary: v.record(v.string(), v.unknown()), 702 - parameterEnum: v.picklist([ 703 - 'Success', 704 - 'Warning', 705 - 'Error' 706 - ]) 707 - }) 708 - }); 709 - 710 - export const vTypesResponse = v.union([ 711 - v.number(), 712 - v.string(), 713 - v.boolean(), 714 - v.record(v.string(), v.unknown()) 715 - ]); 716 - 717 - export const vComplexTypesData = v.object({ 718 - body: v.optional(v.never()), 719 - path: v.optional(v.never()), 720 - query: v.object({ 721 - parameterObject: v.object({ 722 - first: v.optional(v.object({ 723 - second: v.optional(v.object({ 724 - third: v.optional(v.string()) 725 - })) 726 - })) 727 - }), 728 - parameterReference: v.object({ 729 - prop: v.optional(v.string()) 730 - }) 731 - }) 732 - }); 733 - 734 - /** 735 - * Successful response 736 - */ 737 - export const vComplexTypesResponse = v.array(vModelWithString); 738 - 739 - export const vCallWithResultFromHeaderData = v.object({ 740 - body: v.optional(v.never()), 741 - path: v.optional(v.never()), 742 - query: v.optional(v.never()) 743 - }); 744 - 745 - export const vTestErrorCodeData = v.object({ 746 - body: v.optional(v.never()), 747 - path: v.optional(v.never()), 748 - query: v.object({ 749 - status: v.string() 750 - }) 751 - }); 752 - 753 - export const vNonAsciiæøåÆøÅöôêÊ字符串Data = v.object({ 754 - body: v.optional(v.never()), 755 - path: v.optional(v.never()), 756 - query: v.object({ 757 - nonAsciiParamæøåÆØÅöôêÊ: v.pipe(v.number(), v.integer()) 758 - }) 759 - }); 760 - 761 - /** 762 - * Successful response 763 - */ 764 - export const vNonAsciiæøåÆøÅöôêÊ字符串Response = vNonAsciiStringæøåÆøÅöôêÊ字符串; 765 - 766 - export const vPostApiVbyApiVersionBodyData = v.object({ 767 - body: vParameterActivityParams, 768 - path: v.optional(v.never()), 769 - query: v.optional(v.never()) 770 - }); 771 - 772 - /** 773 - * OK 774 - */ 775 - export const vPostApiVbyApiVersionBodyResponse = vResponsePostActivityResponse;
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.0.x/array-items-one-of-length-1/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.0.x/enum-null/valibot.gen.ts
-3
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export { type ClientOptions, type Foo, TypeEnum } from './types.gen';
-595
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type HttpRequest, httpResource } from '@angular/common/http'; 4 - 5 - import { client } from '../client.gen'; 6 - import type { Options } from '../sdk.gen'; 7 - import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithResponsesData, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponse, ComplexTypesData, ComplexTypesResponse, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponse, DummyBData, DummyBResponse, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponse, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, ImportData, ImportResponse, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TypesData, TypesResponse, UploadFileData, UploadFileResponse } from '../types.gen'; 8 - 9 - export const exportRequest = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 10 - responseStyle: 'data', 11 - method: 'GET', 12 - url: '/api/v{api-version}/no+tag', 13 - ...options 14 - }); 15 - 16 - export const patchApiVbyApiVersionNoTagRequest = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 17 - responseStyle: 'data', 18 - method: 'PATCH', 19 - url: '/api/v{api-version}/no+tag', 20 - ...options 21 - }); 22 - 23 - export const importRequest = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 24 - responseStyle: 'data', 25 - method: 'POST', 26 - url: '/api/v{api-version}/no+tag', 27 - ...options 28 - }); 29 - 30 - export const fooWowRequest = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 31 - responseStyle: 'data', 32 - method: 'PUT', 33 - url: '/api/v{api-version}/no+tag', 34 - ...options 35 - }); 36 - 37 - export const apiVVersionODataControllerCountRequest = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 38 - responseStyle: 'data', 39 - method: 'GET', 40 - url: '/api/v{api-version}/simple/$count', 41 - ...options 42 - }); 43 - 44 - export const getApiVbyApiVersionSimpleOperationRequest = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 45 - responseStyle: 'data', 46 - method: 'GET', 47 - url: '/api/v{api-version}/simple:operation', 48 - ...options 49 - }); 50 - 51 - export const deleteCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 52 - responseStyle: 'data', 53 - method: 'DELETE', 54 - url: '/api/v{api-version}/simple', 55 - ...options 56 - }); 57 - 58 - export const getCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 59 - responseStyle: 'data', 60 - method: 'GET', 61 - url: '/api/v{api-version}/simple', 62 - ...options 63 - }); 64 - 65 - export const headCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 66 - responseStyle: 'data', 67 - method: 'HEAD', 68 - url: '/api/v{api-version}/simple', 69 - ...options 70 - }); 71 - 72 - export const optionsCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 73 - responseStyle: 'data', 74 - method: 'OPTIONS', 75 - url: '/api/v{api-version}/simple', 76 - ...options 77 - }); 78 - 79 - export const patchCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 80 - responseStyle: 'data', 81 - method: 'PATCH', 82 - url: '/api/v{api-version}/simple', 83 - ...options 84 - }); 85 - 86 - export const postCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 87 - responseStyle: 'data', 88 - method: 'POST', 89 - url: '/api/v{api-version}/simple', 90 - ...options 91 - }); 92 - 93 - export const putCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 94 - responseStyle: 'data', 95 - method: 'PUT', 96 - url: '/api/v{api-version}/simple', 97 - ...options 98 - }); 99 - 100 - export const deleteFooRequest = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 101 - responseStyle: 'data', 102 - method: 'DELETE', 103 - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 104 - ...options 105 - }); 106 - 107 - export const callWithDescriptionsRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 108 - responseStyle: 'data', 109 - method: 'POST', 110 - url: '/api/v{api-version}/descriptions', 111 - ...options 112 - }); 113 - 114 - /** 115 - * @deprecated 116 - */ 117 - export const deprecatedCallRequest = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 118 - responseStyle: 'data', 119 - method: 'POST', 120 - url: '/api/v{api-version}/parameters/deprecated', 121 - ...options 122 - }); 123 - 124 - export const callWithParametersRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 125 - responseStyle: 'data', 126 - method: 'POST', 127 - url: '/api/v{api-version}/parameters/{parameterPath}', 128 - ...options 129 - }); 130 - 131 - export const callWithWeirdParameterNamesRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 132 - responseStyle: 'data', 133 - method: 'POST', 134 - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 135 - ...options 136 - }); 137 - 138 - export const getCallWithOptionalParamRequest = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 139 - responseStyle: 'data', 140 - method: 'GET', 141 - url: '/api/v{api-version}/parameters', 142 - ...options 143 - }); 144 - 145 - export const postCallWithOptionalParamRequest = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 146 - responseStyle: 'data', 147 - method: 'POST', 148 - url: '/api/v{api-version}/parameters', 149 - ...options 150 - }); 151 - 152 - export const postApiVbyApiVersionRequestBodyRequest = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 153 - responseStyle: 'data', 154 - method: 'POST', 155 - url: '/api/v{api-version}/requestBody', 156 - ...options 157 - }); 158 - 159 - export const postApiVbyApiVersionFormDataRequest = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 160 - responseStyle: 'data', 161 - method: 'POST', 162 - url: '/api/v{api-version}/formData', 163 - ...options 164 - }); 165 - 166 - export const callWithDefaultParametersRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 167 - responseStyle: 'data', 168 - method: 'GET', 169 - url: '/api/v{api-version}/defaults', 170 - ...options 171 - }); 172 - 173 - export const callWithDefaultOptionalParametersRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 174 - responseStyle: 'data', 175 - method: 'POST', 176 - url: '/api/v{api-version}/defaults', 177 - ...options 178 - }); 179 - 180 - export const callToTestOrderOfParamsRequest = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 181 - responseStyle: 'data', 182 - method: 'PUT', 183 - url: '/api/v{api-version}/defaults', 184 - ...options 185 - }); 186 - 187 - export const duplicateNameRequest = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 188 - responseStyle: 'data', 189 - method: 'DELETE', 190 - url: '/api/v{api-version}/duplicate', 191 - ...options 192 - }); 193 - 194 - export const duplicateName2Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 195 - responseStyle: 'data', 196 - method: 'GET', 197 - url: '/api/v{api-version}/duplicate', 198 - ...options 199 - }); 200 - 201 - export const duplicateName3Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 202 - responseStyle: 'data', 203 - method: 'POST', 204 - url: '/api/v{api-version}/duplicate', 205 - ...options 206 - }); 207 - 208 - export const duplicateName4Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 209 - responseStyle: 'data', 210 - method: 'PUT', 211 - url: '/api/v{api-version}/duplicate', 212 - ...options 213 - }); 214 - 215 - export const callWithNoContentResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 216 - responseStyle: 'data', 217 - method: 'GET', 218 - url: '/api/v{api-version}/no-content', 219 - ...options 220 - }); 221 - 222 - export const callWithResponseAndNoContentResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 223 - responseStyle: 'data', 224 - method: 'GET', 225 - url: '/api/v{api-version}/multiple-tags/response-and-no-content', 226 - ...options 227 - }); 228 - 229 - export const dummyARequest = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 230 - responseStyle: 'data', 231 - method: 'GET', 232 - url: '/api/v{api-version}/multiple-tags/a', 233 - ...options 234 - }); 235 - 236 - export const dummyBRequest = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 237 - responseStyle: 'data', 238 - method: 'GET', 239 - url: '/api/v{api-version}/multiple-tags/b', 240 - ...options 241 - }); 242 - 243 - export const callWithResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 244 - responseStyle: 'data', 245 - method: 'GET', 246 - url: '/api/v{api-version}/response', 247 - ...options 248 - }); 249 - 250 - export const callWithDuplicateResponsesRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 251 - responseStyle: 'data', 252 - method: 'POST', 253 - url: '/api/v{api-version}/response', 254 - ...options 255 - }); 256 - 257 - export const callWithResponsesRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 258 - responseStyle: 'data', 259 - method: 'PUT', 260 - url: '/api/v{api-version}/response', 261 - ...options 262 - }); 263 - 264 - export const collectionFormatRequest = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 265 - responseStyle: 'data', 266 - method: 'GET', 267 - url: '/api/v{api-version}/collectionFormat', 268 - ...options 269 - }); 270 - 271 - export const typesRequest = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 272 - responseStyle: 'data', 273 - method: 'GET', 274 - url: '/api/v{api-version}/types', 275 - ...options 276 - }); 277 - 278 - export const uploadFileRequest = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 279 - responseStyle: 'data', 280 - method: 'POST', 281 - url: '/api/v{api-version}/upload', 282 - ...options 283 - }); 284 - 285 - export const fileResponseRequest = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 286 - responseStyle: 'data', 287 - method: 'GET', 288 - url: '/api/v{api-version}/file/{id}', 289 - ...options 290 - }); 291 - 292 - export const complexTypesRequest = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 293 - responseStyle: 'data', 294 - method: 'GET', 295 - url: '/api/v{api-version}/complex', 296 - ...options 297 - }); 298 - 299 - export const multipartResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 300 - responseStyle: 'data', 301 - method: 'GET', 302 - url: '/api/v{api-version}/multipart', 303 - ...options 304 - }); 305 - 306 - export const multipartRequestRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 307 - responseStyle: 'data', 308 - method: 'POST', 309 - url: '/api/v{api-version}/multipart', 310 - ...options 311 - }); 312 - 313 - export const complexParamsRequest = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 314 - responseStyle: 'data', 315 - method: 'PUT', 316 - url: '/api/v{api-version}/complex/{id}', 317 - ...options 318 - }); 319 - 320 - export const callWithResultFromHeaderRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 321 - responseStyle: 'data', 322 - method: 'POST', 323 - url: '/api/v{api-version}/header', 324 - ...options 325 - }); 326 - 327 - export const testErrorCodeRequest = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 328 - responseStyle: 'data', 329 - method: 'POST', 330 - url: '/api/v{api-version}/error', 331 - ...options 332 - }); 333 - 334 - export const nonAsciiæøåÆøÅöôêÊ字符串Request = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 335 - responseStyle: 'data', 336 - method: 'POST', 337 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 338 - ...options 339 - }); 340 - 341 - /** 342 - * Login User 343 - */ 344 - export const putWithFormUrlEncodedRequest = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 345 - responseStyle: 'data', 346 - method: 'PUT', 347 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 348 - ...options 349 - }); 350 - 351 - export const exportResource = <ThrowOnError extends boolean = false>(options?: () => Options<ExportData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 352 - const opts = options ? options() : undefined; 353 - return opts ? exportRequest(opts) : undefined; 354 - }); 355 - 356 - export const patchApiVbyApiVersionNoTagResource = <ThrowOnError extends boolean = false>(options?: () => Options<PatchApiVbyApiVersionNoTagData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 357 - const opts = options ? options() : undefined; 358 - return opts ? patchApiVbyApiVersionNoTagRequest(opts) : undefined; 359 - }); 360 - 361 - export const importResource = <ThrowOnError extends boolean = false>(options: () => Options<ImportData, ThrowOnError> | undefined) => httpResource<ImportResponse>(() => { 362 - const opts = options ? options() : undefined; 363 - return opts ? importRequest(opts) : undefined; 364 - }); 365 - 366 - export const fooWowResource = <ThrowOnError extends boolean = false>(options?: () => Options<FooWowData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 367 - const opts = options ? options() : undefined; 368 - return opts ? fooWowRequest(opts) : undefined; 369 - }); 370 - 371 - export const apiVVersionODataControllerCountResource = <ThrowOnError extends boolean = false>(options?: () => Options<ApiVVersionODataControllerCountData, ThrowOnError> | undefined) => httpResource<ApiVVersionODataControllerCountResponse>(() => { 372 - const opts = options ? options() : undefined; 373 - return opts ? apiVVersionODataControllerCountRequest(opts) : undefined; 374 - }); 375 - 376 - export const getApiVbyApiVersionSimpleOperationResource = <ThrowOnError extends boolean = false>(options: () => Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError> | undefined) => httpResource<GetApiVbyApiVersionSimpleOperationResponse>(() => { 377 - const opts = options ? options() : undefined; 378 - return opts ? getApiVbyApiVersionSimpleOperationRequest(opts) : undefined; 379 - }); 380 - 381 - export const deleteCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 382 - const opts = options ? options() : undefined; 383 - return opts ? deleteCallWithoutParametersAndResponseRequest(opts) : undefined; 384 - }); 385 - 386 - export const getCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<GetCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 387 - const opts = options ? options() : undefined; 388 - return opts ? getCallWithoutParametersAndResponseRequest(opts) : undefined; 389 - }); 390 - 391 - export const headCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<HeadCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 392 - const opts = options ? options() : undefined; 393 - return opts ? headCallWithoutParametersAndResponseRequest(opts) : undefined; 394 - }); 395 - 396 - export const optionsCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 397 - const opts = options ? options() : undefined; 398 - return opts ? optionsCallWithoutParametersAndResponseRequest(opts) : undefined; 399 - }); 400 - 401 - export const patchCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PatchCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 402 - const opts = options ? options() : undefined; 403 - return opts ? patchCallWithoutParametersAndResponseRequest(opts) : undefined; 404 - }); 405 - 406 - export const postCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 407 - const opts = options ? options() : undefined; 408 - return opts ? postCallWithoutParametersAndResponseRequest(opts) : undefined; 409 - }); 410 - 411 - export const putCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PutCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 412 - const opts = options ? options() : undefined; 413 - return opts ? putCallWithoutParametersAndResponseRequest(opts) : undefined; 414 - }); 415 - 416 - export const deleteFooResource = <ThrowOnError extends boolean = false>(options: () => Options<DeleteFooData3, ThrowOnError> | undefined) => httpResource<unknown>(() => { 417 - const opts = options ? options() : undefined; 418 - return opts ? deleteFooRequest(opts) : undefined; 419 - }); 420 - 421 - export const callWithDescriptionsResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDescriptionsData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 422 - const opts = options ? options() : undefined; 423 - return opts ? callWithDescriptionsRequest(opts) : undefined; 424 - }); 425 - 426 - /** 427 - * @deprecated 428 - */ 429 - export const deprecatedCallResource = <ThrowOnError extends boolean = false>(options: () => Options<DeprecatedCallData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 430 - const opts = options ? options() : undefined; 431 - return opts ? deprecatedCallRequest(opts) : undefined; 432 - }); 433 - 434 - export const callWithParametersResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 435 - const opts = options ? options() : undefined; 436 - return opts ? callWithParametersRequest(opts) : undefined; 437 - }); 438 - 439 - export const callWithWeirdParameterNamesResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithWeirdParameterNamesData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 440 - const opts = options ? options() : undefined; 441 - return opts ? callWithWeirdParameterNamesRequest(opts) : undefined; 442 - }); 443 - 444 - export const getCallWithOptionalParamResource = <ThrowOnError extends boolean = false>(options: () => Options<GetCallWithOptionalParamData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 445 - const opts = options ? options() : undefined; 446 - return opts ? getCallWithOptionalParamRequest(opts) : undefined; 447 - }); 448 - 449 - export const postCallWithOptionalParamResource = <ThrowOnError extends boolean = false>(options: () => Options<PostCallWithOptionalParamData, ThrowOnError> | undefined) => httpResource<PostCallWithOptionalParamResponse>(() => { 450 - const opts = options ? options() : undefined; 451 - return opts ? postCallWithOptionalParamRequest(opts) : undefined; 452 - }); 453 - 454 - export const postApiVbyApiVersionRequestBodyResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 455 - const opts = options ? options() : undefined; 456 - return opts ? postApiVbyApiVersionRequestBodyRequest(opts) : undefined; 457 - }); 458 - 459 - export const postApiVbyApiVersionFormDataResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostApiVbyApiVersionFormDataData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 460 - const opts = options ? options() : undefined; 461 - return opts ? postApiVbyApiVersionFormDataRequest(opts) : undefined; 462 - }); 463 - 464 - export const callWithDefaultParametersResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDefaultParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 465 - const opts = options ? options() : undefined; 466 - return opts ? callWithDefaultParametersRequest(opts) : undefined; 467 - }); 468 - 469 - export const callWithDefaultOptionalParametersResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDefaultOptionalParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 470 - const opts = options ? options() : undefined; 471 - return opts ? callWithDefaultOptionalParametersRequest(opts) : undefined; 472 - }); 473 - 474 - export const callToTestOrderOfParamsResource = <ThrowOnError extends boolean = false>(options: () => Options<CallToTestOrderOfParamsData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 475 - const opts = options ? options() : undefined; 476 - return opts ? callToTestOrderOfParamsRequest(opts) : undefined; 477 - }); 478 - 479 - export const duplicateNameResource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateNameData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 480 - const opts = options ? options() : undefined; 481 - return opts ? duplicateNameRequest(opts) : undefined; 482 - }); 483 - 484 - export const duplicateName2Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName2Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 485 - const opts = options ? options() : undefined; 486 - return opts ? duplicateName2Request(opts) : undefined; 487 - }); 488 - 489 - export const duplicateName3Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName3Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 490 - const opts = options ? options() : undefined; 491 - return opts ? duplicateName3Request(opts) : undefined; 492 - }); 493 - 494 - export const duplicateName4Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName4Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 495 - const opts = options ? options() : undefined; 496 - return opts ? duplicateName4Request(opts) : undefined; 497 - }); 498 - 499 - export const callWithNoContentResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithNoContentResponseData, ThrowOnError> | undefined) => httpResource<CallWithNoContentResponseResponse>(() => { 500 - const opts = options ? options() : undefined; 501 - return opts ? callWithNoContentResponseRequest(opts) : undefined; 502 - }); 503 - 504 - export const callWithResponseAndNoContentResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponseAndNoContentResponseData, ThrowOnError> | undefined) => httpResource<CallWithResponseAndNoContentResponseResponse>(() => { 505 - const opts = options ? options() : undefined; 506 - return opts ? callWithResponseAndNoContentResponseRequest(opts) : undefined; 507 - }); 508 - 509 - export const dummyAResource = <ThrowOnError extends boolean = false>(options?: () => Options<DummyAData, ThrowOnError> | undefined) => httpResource<DummyAResponse>(() => { 510 - const opts = options ? options() : undefined; 511 - return opts ? dummyARequest(opts) : undefined; 512 - }); 513 - 514 - export const dummyBResource = <ThrowOnError extends boolean = false>(options?: () => Options<DummyBData, ThrowOnError> | undefined) => httpResource<DummyBResponse>(() => { 515 - const opts = options ? options() : undefined; 516 - return opts ? dummyBRequest(opts) : undefined; 517 - }); 518 - 519 - export const callWithResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponseData, ThrowOnError> | undefined) => httpResource<CallWithResponseResponse>(() => { 520 - const opts = options ? options() : undefined; 521 - return opts ? callWithResponseRequest(opts) : undefined; 522 - }); 523 - 524 - export const callWithDuplicateResponsesResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDuplicateResponsesData, ThrowOnError> | undefined) => httpResource<CallWithDuplicateResponsesResponse>(() => { 525 - const opts = options ? options() : undefined; 526 - return opts ? callWithDuplicateResponsesRequest(opts) : undefined; 527 - }); 528 - 529 - export const callWithResponsesResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponsesData, ThrowOnError> | undefined) => httpResource<CallWithResponsesResponse>(() => { 530 - const opts = options ? options() : undefined; 531 - return opts ? callWithResponsesRequest(opts) : undefined; 532 - }); 533 - 534 - export const collectionFormatResource = <ThrowOnError extends boolean = false>(options: () => Options<CollectionFormatData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 535 - const opts = options ? options() : undefined; 536 - return opts ? collectionFormatRequest(opts) : undefined; 537 - }); 538 - 539 - export const typesResource = <ThrowOnError extends boolean = false>(options: () => Options<TypesData, ThrowOnError> | undefined) => httpResource<TypesResponse>(() => { 540 - const opts = options ? options() : undefined; 541 - return opts ? typesRequest(opts) : undefined; 542 - }); 543 - 544 - export const uploadFileResource = <ThrowOnError extends boolean = false>(options: () => Options<UploadFileData, ThrowOnError> | undefined) => httpResource<UploadFileResponse>(() => { 545 - const opts = options ? options() : undefined; 546 - return opts ? uploadFileRequest(opts) : undefined; 547 - }); 548 - 549 - export const fileResponseResource = <ThrowOnError extends boolean = false>(options: () => Options<FileResponseData, ThrowOnError> | undefined) => httpResource<FileResponseResponse>(() => { 550 - const opts = options ? options() : undefined; 551 - return opts ? fileResponseRequest(opts) : undefined; 552 - }); 553 - 554 - export const complexTypesResource = <ThrowOnError extends boolean = false>(options: () => Options<ComplexTypesData, ThrowOnError> | undefined) => httpResource<ComplexTypesResponse>(() => { 555 - const opts = options ? options() : undefined; 556 - return opts ? complexTypesRequest(opts) : undefined; 557 - }); 558 - 559 - export const multipartResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<MultipartResponseData, ThrowOnError> | undefined) => httpResource<MultipartResponseResponse>(() => { 560 - const opts = options ? options() : undefined; 561 - return opts ? multipartResponseRequest(opts) : undefined; 562 - }); 563 - 564 - export const multipartRequestResource = <ThrowOnError extends boolean = false>(options?: () => Options<MultipartRequestData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 565 - const opts = options ? options() : undefined; 566 - return opts ? multipartRequestRequest(opts) : undefined; 567 - }); 568 - 569 - export const complexParamsResource = <ThrowOnError extends boolean = false>(options: () => Options<ComplexParamsData, ThrowOnError> | undefined) => httpResource<ComplexParamsResponse>(() => { 570 - const opts = options ? options() : undefined; 571 - return opts ? complexParamsRequest(opts) : undefined; 572 - }); 573 - 574 - export const callWithResultFromHeaderResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResultFromHeaderData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 575 - const opts = options ? options() : undefined; 576 - return opts ? callWithResultFromHeaderRequest(opts) : undefined; 577 - }); 578 - 579 - export const testErrorCodeResource = <ThrowOnError extends boolean = false>(options: () => Options<TestErrorCodeData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 580 - const opts = options ? options() : undefined; 581 - return opts ? testErrorCodeRequest(opts) : undefined; 582 - }); 583 - 584 - export const nonAsciiæøåÆøÅöôêÊ字符串Resource = <ThrowOnError extends boolean = false>(options: () => Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError> | undefined) => httpResource<NonAsciiæøåÆøÅöôêÊ字符串Response>(() => { 585 - const opts = options ? options() : undefined; 586 - return opts ? nonAsciiæøåÆøÅöôêÊ字符串Request(opts) : undefined; 587 - }); 588 - 589 - /** 590 - * Login User 591 - */ 592 - export const putWithFormUrlEncodedResource = <ThrowOnError extends boolean = false>(options: () => Options<PutWithFormUrlEncodedData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 593 - const opts = options ? options() : undefined; 594 - return opts ? putWithFormUrlEncodedRequest(opts) : undefined; 595 - });
-16
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 - import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 - 6 - /** 7 - * The `createClientConfig()` function will be called on client initialization 8 - * and the returned object will become the client's initial configuration. 9 - * 10 - * You may want to initialize your client this way instead of calling 11 - * `setConfig()`. This is useful for example if you're using Next.js 12 - * to ensure your client always has the correct values. 13 - */ 14 - export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 - 16 - export const client = createClient(createConfig<ClientOptions2>());
-290
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { createSseClient } from '../core/serverSentEvents.gen'; 4 - import type { HttpMethod } from '../core/types.gen'; 5 - import { getValidRequestBody } from '../core/utils.gen'; 6 - import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen'; 7 - import { 8 - buildUrl, 9 - createConfig, 10 - createInterceptors, 11 - getParseAs, 12 - mergeConfigs, 13 - mergeHeaders, 14 - setAuthParams, 15 - } from './utils.gen'; 16 - 17 - type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 18 - body?: any; 19 - headers: ReturnType<typeof mergeHeaders>; 20 - }; 21 - 22 - export const createClient = (config: Config = {}): Client => { 23 - let _config = mergeConfigs(createConfig(), config); 24 - 25 - const getConfig = (): Config => ({ ..._config }); 26 - 27 - const setConfig = (config: Config): Config => { 28 - _config = mergeConfigs(_config, config); 29 - return getConfig(); 30 - }; 31 - 32 - const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 33 - 34 - const beforeRequest = async (options: RequestOptions) => { 35 - const opts = { 36 - ..._config, 37 - ...options, 38 - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 39 - headers: mergeHeaders(_config.headers, options.headers), 40 - serializedBody: undefined as string | undefined, 41 - }; 42 - 43 - if (opts.security) { 44 - await setAuthParams({ 45 - ...opts, 46 - security: opts.security, 47 - }); 48 - } 49 - 50 - if (opts.requestValidator) { 51 - await opts.requestValidator(opts); 52 - } 53 - 54 - if (opts.body !== undefined && opts.bodySerializer) { 55 - opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined; 56 - } 57 - 58 - // remove Content-Type header if body is empty to avoid sending invalid requests 59 - if (opts.body === undefined || opts.serializedBody === '') { 60 - opts.headers.delete('Content-Type'); 61 - } 62 - 63 - const url = buildUrl(opts); 64 - 65 - return { opts, url }; 66 - }; 67 - 68 - const request: Client['request'] = async (options) => { 69 - // @ts-expect-error 70 - const { opts, url } = await beforeRequest(options); 71 - const requestInit: ReqInit = { 72 - redirect: 'follow', 73 - ...opts, 74 - body: getValidRequestBody(opts), 75 - }; 76 - 77 - let request = new Request(url, requestInit); 78 - 79 - for (const fn of interceptors.request.fns) { 80 - if (fn) { 81 - request = await fn(request, opts); 82 - } 83 - } 84 - 85 - // fetch must be assigned here, otherwise it would throw the error: 86 - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 - const _fetch = opts.fetch!; 88 - let response: Response; 89 - 90 - try { 91 - response = await _fetch(request); 92 - } catch (error) { 93 - // Handle fetch exceptions (AbortError, network errors, etc.) 94 - let finalError = error; 95 - 96 - for (const fn of interceptors.error.fns) { 97 - if (fn) { 98 - finalError = (await fn(error, undefined as any, request, opts)) as unknown; 99 - } 100 - } 101 - 102 - finalError = finalError || ({} as unknown); 103 - 104 - if (opts.throwOnError) { 105 - throw finalError; 106 - } 107 - 108 - // Return error response 109 - return opts.responseStyle === 'data' 110 - ? undefined 111 - : { 112 - error: finalError, 113 - request, 114 - response: undefined as any, 115 - }; 116 - } 117 - 118 - for (const fn of interceptors.response.fns) { 119 - if (fn) { 120 - response = await fn(response, request, opts); 121 - } 122 - } 123 - 124 - const result = { 125 - request, 126 - response, 127 - }; 128 - 129 - if (response.ok) { 130 - const parseAs = 131 - (opts.parseAs === 'auto' 132 - ? getParseAs(response.headers.get('Content-Type')) 133 - : opts.parseAs) ?? 'json'; 134 - 135 - if (response.status === 204 || response.headers.get('Content-Length') === '0') { 136 - let emptyData: any; 137 - switch (parseAs) { 138 - case 'arrayBuffer': 139 - case 'blob': 140 - case 'text': 141 - emptyData = await response[parseAs](); 142 - break; 143 - case 'formData': 144 - emptyData = new FormData(); 145 - break; 146 - case 'stream': 147 - emptyData = response.body; 148 - break; 149 - case 'json': 150 - default: 151 - emptyData = {}; 152 - break; 153 - } 154 - return opts.responseStyle === 'data' 155 - ? emptyData 156 - : { 157 - data: emptyData, 158 - ...result, 159 - }; 160 - } 161 - 162 - let data: any; 163 - switch (parseAs) { 164 - case 'arrayBuffer': 165 - case 'blob': 166 - case 'formData': 167 - case 'text': 168 - data = await response[parseAs](); 169 - break; 170 - case 'json': { 171 - // Some servers return 200 with no Content-Length and empty body. 172 - // response.json() would throw; read as text and parse if non-empty. 173 - const text = await response.text(); 174 - data = text ? JSON.parse(text) : {}; 175 - break; 176 - } 177 - case 'stream': 178 - return opts.responseStyle === 'data' 179 - ? response.body 180 - : { 181 - data: response.body, 182 - ...result, 183 - }; 184 - } 185 - 186 - if (parseAs === 'json') { 187 - if (opts.responseValidator) { 188 - await opts.responseValidator(data); 189 - } 190 - 191 - if (opts.responseTransformer) { 192 - data = await opts.responseTransformer(data); 193 - } 194 - } 195 - 196 - return opts.responseStyle === 'data' 197 - ? data 198 - : { 199 - data, 200 - ...result, 201 - }; 202 - } 203 - 204 - const textError = await response.text(); 205 - let jsonError: unknown; 206 - 207 - try { 208 - jsonError = JSON.parse(textError); 209 - } catch { 210 - // noop 211 - } 212 - 213 - const error = jsonError ?? textError; 214 - let finalError = error; 215 - 216 - for (const fn of interceptors.error.fns) { 217 - if (fn) { 218 - finalError = (await fn(error, response, request, opts)) as string; 219 - } 220 - } 221 - 222 - finalError = finalError || ({} as string); 223 - 224 - if (opts.throwOnError) { 225 - throw finalError; 226 - } 227 - 228 - // TODO: we probably want to return error and improve types 229 - return opts.responseStyle === 'data' 230 - ? undefined 231 - : { 232 - error: finalError, 233 - ...result, 234 - }; 235 - }; 236 - 237 - const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 238 - request({ ...options, method }); 239 - 240 - const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 241 - const { opts, url } = await beforeRequest(options); 242 - return createSseClient({ 243 - ...opts, 244 - body: opts.body as BodyInit | null | undefined, 245 - headers: opts.headers as unknown as Record<string, string>, 246 - method, 247 - onRequest: async (url, init) => { 248 - let request = new Request(url, init); 249 - for (const fn of interceptors.request.fns) { 250 - if (fn) { 251 - request = await fn(request, opts); 252 - } 253 - } 254 - return request; 255 - }, 256 - serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined, 257 - url, 258 - }); 259 - }; 260 - 261 - const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options }); 262 - 263 - return { 264 - buildUrl: _buildUrl, 265 - connect: makeMethodFn('CONNECT'), 266 - delete: makeMethodFn('DELETE'), 267 - get: makeMethodFn('GET'), 268 - getConfig, 269 - head: makeMethodFn('HEAD'), 270 - interceptors, 271 - options: makeMethodFn('OPTIONS'), 272 - patch: makeMethodFn('PATCH'), 273 - post: makeMethodFn('POST'), 274 - put: makeMethodFn('PUT'), 275 - request, 276 - setConfig, 277 - sse: { 278 - connect: makeSseFn('CONNECT'), 279 - delete: makeSseFn('DELETE'), 280 - get: makeSseFn('GET'), 281 - head: makeSseFn('HEAD'), 282 - options: makeSseFn('OPTIONS'), 283 - patch: makeSseFn('PATCH'), 284 - post: makeSseFn('POST'), 285 - put: makeSseFn('PUT'), 286 - trace: makeSseFn('TRACE'), 287 - }, 288 - trace: makeMethodFn('TRACE'), 289 - } as Client; 290 - };
-25
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type { Auth } from '../core/auth.gen'; 4 - export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 - export { 6 - formDataBodySerializer, 7 - jsonBodySerializer, 8 - urlSearchParamsBodySerializer, 9 - } from '../core/bodySerializer.gen'; 10 - export { buildClientParams } from '../core/params.gen'; 11 - export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen'; 12 - export { createClient } from './client.gen'; 13 - export type { 14 - Client, 15 - ClientOptions, 16 - Config, 17 - CreateClientConfig, 18 - Options, 19 - RequestOptions, 20 - RequestResult, 21 - ResolvedRequestOptions, 22 - ResponseStyle, 23 - TDataShape, 24 - } from './types.gen'; 25 - export { createConfig, mergeHeaders } from './utils.gen';
-214
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Auth } from '../core/auth.gen'; 4 - import type { 5 - ServerSentEventsOptions, 6 - ServerSentEventsResult, 7 - } from '../core/serverSentEvents.gen'; 8 - import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen'; 9 - import type { Middleware } from './utils.gen'; 10 - 11 - export type ResponseStyle = 'data' | 'fields'; 12 - 13 - export interface Config<T extends ClientOptions = ClientOptions> 14 - extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig { 15 - /** 16 - * Base URL for all requests made by this client. 17 - */ 18 - baseUrl?: T['baseUrl']; 19 - /** 20 - * Fetch API implementation. You can use this option to provide a custom 21 - * fetch instance. 22 - * 23 - * @default globalThis.fetch 24 - */ 25 - fetch?: typeof fetch; 26 - /** 27 - * Please don't use the Fetch client for Next.js applications. The `next` 28 - * options won't have any effect. 29 - * 30 - * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 31 - */ 32 - next?: never; 33 - /** 34 - * Return the response data parsed in a specified format. By default, `auto` 35 - * will infer the appropriate method from the `Content-Type` response header. 36 - * You can override this behavior with any of the {@link Body} methods. 37 - * Select `stream` if you don't want to parse response data at all. 38 - * 39 - * @default 'auto' 40 - */ 41 - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 42 - /** 43 - * Should we return only data or multiple fields (data, error, response, etc.)? 44 - * 45 - * @default 'fields' 46 - */ 47 - responseStyle?: ResponseStyle; 48 - /** 49 - * Throw an error instead of returning it in the response? 50 - * 51 - * @default false 52 - */ 53 - throwOnError?: T['throwOnError']; 54 - } 55 - 56 - export interface RequestOptions< 57 - TData = unknown, 58 - TResponseStyle extends ResponseStyle = 'fields', 59 - ThrowOnError extends boolean = boolean, 60 - Url extends string = string, 61 - > 62 - extends 63 - Config<{ 64 - responseStyle: TResponseStyle; 65 - throwOnError: ThrowOnError; 66 - }>, 67 - Pick< 68 - ServerSentEventsOptions<TData>, 69 - | 'onRequest' 70 - | 'onSseError' 71 - | 'onSseEvent' 72 - | 'sseDefaultRetryDelay' 73 - | 'sseMaxRetryAttempts' 74 - | 'sseMaxRetryDelay' 75 - > { 76 - /** 77 - * Any body that you want to add to your request. 78 - * 79 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 80 - */ 81 - body?: unknown; 82 - path?: Record<string, unknown>; 83 - query?: Record<string, unknown>; 84 - /** 85 - * Security mechanism(s) to use for the request. 86 - */ 87 - security?: ReadonlyArray<Auth>; 88 - url: Url; 89 - } 90 - 91 - export interface ResolvedRequestOptions< 92 - TResponseStyle extends ResponseStyle = 'fields', 93 - ThrowOnError extends boolean = boolean, 94 - Url extends string = string, 95 - > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 96 - serializedBody?: string; 97 - } 98 - 99 - export type RequestResult< 100 - TData = unknown, 101 - TError = unknown, 102 - ThrowOnError extends boolean = boolean, 103 - TResponseStyle extends ResponseStyle = 'fields', 104 - > = ThrowOnError extends true 105 - ? Promise< 106 - TResponseStyle extends 'data' 107 - ? TData extends Record<string, unknown> 108 - ? TData[keyof TData] 109 - : TData 110 - : { 111 - data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 112 - request: Request; 113 - response: Response; 114 - } 115 - > 116 - : Promise< 117 - TResponseStyle extends 'data' 118 - ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined 119 - : ( 120 - | { 121 - data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 122 - error: undefined; 123 - } 124 - | { 125 - data: undefined; 126 - error: TError extends Record<string, unknown> ? TError[keyof TError] : TError; 127 - } 128 - ) & { 129 - request: Request; 130 - response: Response; 131 - } 132 - >; 133 - 134 - export interface ClientOptions { 135 - baseUrl?: string; 136 - responseStyle?: ResponseStyle; 137 - throwOnError?: boolean; 138 - } 139 - 140 - type MethodFn = < 141 - TData = unknown, 142 - TError = unknown, 143 - ThrowOnError extends boolean = false, 144 - TResponseStyle extends ResponseStyle = 'fields', 145 - >( 146 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 147 - ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 148 - 149 - type SseFn = < 150 - TData = unknown, 151 - TError = unknown, 152 - ThrowOnError extends boolean = false, 153 - TResponseStyle extends ResponseStyle = 'fields', 154 - >( 155 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 156 - ) => Promise<ServerSentEventsResult<TData, TError>>; 157 - 158 - type RequestFn = < 159 - TData = unknown, 160 - TError = unknown, 161 - ThrowOnError extends boolean = false, 162 - TResponseStyle extends ResponseStyle = 'fields', 163 - >( 164 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 165 - Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>, 166 - ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 167 - 168 - type BuildUrlFn = < 169 - TData extends { 170 - body?: unknown; 171 - path?: Record<string, unknown>; 172 - query?: Record<string, unknown>; 173 - url: string; 174 - }, 175 - >( 176 - options: TData & Options<TData>, 177 - ) => string; 178 - 179 - export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & { 180 - interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 181 - }; 182 - 183 - /** 184 - * The `createClientConfig()` function will be called on client initialization 185 - * and the returned object will become the client's initial configuration. 186 - * 187 - * You may want to initialize your client this way instead of calling 188 - * `setConfig()`. This is useful for example if you're using Next.js 189 - * to ensure your client always has the correct values. 190 - */ 191 - export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 192 - override?: Config<ClientOptions & T>, 193 - ) => Config<Required<ClientOptions> & T>; 194 - 195 - export interface TDataShape { 196 - body?: unknown; 197 - headers?: unknown; 198 - path?: unknown; 199 - query?: unknown; 200 - url: string; 201 - } 202 - 203 - type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 204 - 205 - export type Options< 206 - TData extends TDataShape = TDataShape, 207 - ThrowOnError extends boolean = boolean, 208 - TResponse = unknown, 209 - TResponseStyle extends ResponseStyle = 'fields', 210 - > = OmitKeys< 211 - RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 212 - 'body' | 'path' | 'query' | 'url' 213 - > & 214 - ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
-316
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { getAuthToken } from '../core/auth.gen'; 4 - import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 - import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 - import { 7 - serializeArrayParam, 8 - serializeObjectParam, 9 - serializePrimitiveParam, 10 - } from '../core/pathSerializer.gen'; 11 - import { getUrl } from '../core/utils.gen'; 12 - import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 - 14 - export const createQuerySerializer = <T = unknown>({ 15 - parameters = {}, 16 - ...args 17 - }: QuerySerializerOptions = {}) => { 18 - const querySerializer = (queryParams: T) => { 19 - const search: string[] = []; 20 - if (queryParams && typeof queryParams === 'object') { 21 - for (const name in queryParams) { 22 - const value = queryParams[name]; 23 - 24 - if (value === undefined || value === null) { 25 - continue; 26 - } 27 - 28 - const options = parameters[name] || args; 29 - 30 - if (Array.isArray(value)) { 31 - const serializedArray = serializeArrayParam({ 32 - allowReserved: options.allowReserved, 33 - explode: true, 34 - name, 35 - style: 'form', 36 - value, 37 - ...options.array, 38 - }); 39 - if (serializedArray) search.push(serializedArray); 40 - } else if (typeof value === 'object') { 41 - const serializedObject = serializeObjectParam({ 42 - allowReserved: options.allowReserved, 43 - explode: true, 44 - name, 45 - style: 'deepObject', 46 - value: value as Record<string, unknown>, 47 - ...options.object, 48 - }); 49 - if (serializedObject) search.push(serializedObject); 50 - } else { 51 - const serializedPrimitive = serializePrimitiveParam({ 52 - allowReserved: options.allowReserved, 53 - name, 54 - value: value as string, 55 - }); 56 - if (serializedPrimitive) search.push(serializedPrimitive); 57 - } 58 - } 59 - } 60 - return search.join('&'); 61 - }; 62 - return querySerializer; 63 - }; 64 - 65 - /** 66 - * Infers parseAs value from provided Content-Type header. 67 - */ 68 - export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => { 69 - if (!contentType) { 70 - // If no Content-Type header is provided, the best we can do is return the raw response body, 71 - // which is effectively the same as the 'stream' option. 72 - return 'stream'; 73 - } 74 - 75 - const cleanContent = contentType.split(';')[0]?.trim(); 76 - 77 - if (!cleanContent) { 78 - return; 79 - } 80 - 81 - if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) { 82 - return 'json'; 83 - } 84 - 85 - if (cleanContent === 'multipart/form-data') { 86 - return 'formData'; 87 - } 88 - 89 - if ( 90 - ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type)) 91 - ) { 92 - return 'blob'; 93 - } 94 - 95 - if (cleanContent.startsWith('text/')) { 96 - return 'text'; 97 - } 98 - 99 - return; 100 - }; 101 - 102 - const checkForExistence = ( 103 - options: Pick<RequestOptions, 'auth' | 'query'> & { 104 - headers: Headers; 105 - }, 106 - name?: string, 107 - ): boolean => { 108 - if (!name) { 109 - return false; 110 - } 111 - if ( 112 - options.headers.has(name) || 113 - options.query?.[name] || 114 - options.headers.get('Cookie')?.includes(`${name}=`) 115 - ) { 116 - return true; 117 - } 118 - return false; 119 - }; 120 - 121 - export const setAuthParams = async ({ 122 - security, 123 - ...options 124 - }: Pick<Required<RequestOptions>, 'security'> & 125 - Pick<RequestOptions, 'auth' | 'query'> & { 126 - headers: Headers; 127 - }) => { 128 - for (const auth of security) { 129 - if (checkForExistence(options, auth.name)) { 130 - continue; 131 - } 132 - 133 - const token = await getAuthToken(auth, options.auth); 134 - 135 - if (!token) { 136 - continue; 137 - } 138 - 139 - const name = auth.name ?? 'Authorization'; 140 - 141 - switch (auth.in) { 142 - case 'query': 143 - if (!options.query) { 144 - options.query = {}; 145 - } 146 - options.query[name] = token; 147 - break; 148 - case 'cookie': 149 - options.headers.append('Cookie', `${name}=${token}`); 150 - break; 151 - case 'header': 152 - default: 153 - options.headers.set(name, token); 154 - break; 155 - } 156 - } 157 - }; 158 - 159 - export const buildUrl: Client['buildUrl'] = (options) => 160 - getUrl({ 161 - baseUrl: options.baseUrl as string, 162 - path: options.path, 163 - query: options.query, 164 - querySerializer: 165 - typeof options.querySerializer === 'function' 166 - ? options.querySerializer 167 - : createQuerySerializer(options.querySerializer), 168 - url: options.url, 169 - }); 170 - 171 - export const mergeConfigs = (a: Config, b: Config): Config => { 172 - const config = { ...a, ...b }; 173 - if (config.baseUrl?.endsWith('/')) { 174 - config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 175 - } 176 - config.headers = mergeHeaders(a.headers, b.headers); 177 - return config; 178 - }; 179 - 180 - const headersEntries = (headers: Headers): Array<[string, string]> => { 181 - const entries: Array<[string, string]> = []; 182 - headers.forEach((value, key) => { 183 - entries.push([key, value]); 184 - }); 185 - return entries; 186 - }; 187 - 188 - export const mergeHeaders = ( 189 - ...headers: Array<Required<Config>['headers'] | undefined> 190 - ): Headers => { 191 - const mergedHeaders = new Headers(); 192 - for (const header of headers) { 193 - if (!header) { 194 - continue; 195 - } 196 - 197 - const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header); 198 - 199 - for (const [key, value] of iterator) { 200 - if (value === null) { 201 - mergedHeaders.delete(key); 202 - } else if (Array.isArray(value)) { 203 - for (const v of value) { 204 - mergedHeaders.append(key, v as string); 205 - } 206 - } else if (value !== undefined) { 207 - // assume object headers are meant to be JSON stringified, i.e. their 208 - // content value in OpenAPI specification is 'application/json' 209 - mergedHeaders.set( 210 - key, 211 - typeof value === 'object' ? JSON.stringify(value) : (value as string), 212 - ); 213 - } 214 - } 215 - } 216 - return mergedHeaders; 217 - }; 218 - 219 - type ErrInterceptor<Err, Res, Req, Options> = ( 220 - error: Err, 221 - response: Res, 222 - request: Req, 223 - options: Options, 224 - ) => Err | Promise<Err>; 225 - 226 - type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>; 227 - 228 - type ResInterceptor<Res, Req, Options> = ( 229 - response: Res, 230 - request: Req, 231 - options: Options, 232 - ) => Res | Promise<Res>; 233 - 234 - class Interceptors<Interceptor> { 235 - fns: Array<Interceptor | null> = []; 236 - 237 - clear(): void { 238 - this.fns = []; 239 - } 240 - 241 - eject(id: number | Interceptor): void { 242 - const index = this.getInterceptorIndex(id); 243 - if (this.fns[index]) { 244 - this.fns[index] = null; 245 - } 246 - } 247 - 248 - exists(id: number | Interceptor): boolean { 249 - const index = this.getInterceptorIndex(id); 250 - return Boolean(this.fns[index]); 251 - } 252 - 253 - getInterceptorIndex(id: number | Interceptor): number { 254 - if (typeof id === 'number') { 255 - return this.fns[id] ? id : -1; 256 - } 257 - return this.fns.indexOf(id); 258 - } 259 - 260 - update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false { 261 - const index = this.getInterceptorIndex(id); 262 - if (this.fns[index]) { 263 - this.fns[index] = fn; 264 - return id; 265 - } 266 - return false; 267 - } 268 - 269 - use(fn: Interceptor): number { 270 - this.fns.push(fn); 271 - return this.fns.length - 1; 272 - } 273 - } 274 - 275 - export interface Middleware<Req, Res, Err, Options> { 276 - error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; 277 - request: Interceptors<ReqInterceptor<Req, Options>>; 278 - response: Interceptors<ResInterceptor<Res, Req, Options>>; 279 - } 280 - 281 - export const createInterceptors = <Req, Res, Err, Options>(): Middleware< 282 - Req, 283 - Res, 284 - Err, 285 - Options 286 - > => ({ 287 - error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 288 - request: new Interceptors<ReqInterceptor<Req, Options>>(), 289 - response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 290 - }); 291 - 292 - const defaultQuerySerializer = createQuerySerializer({ 293 - allowReserved: false, 294 - array: { 295 - explode: true, 296 - style: 'form', 297 - }, 298 - object: { 299 - explode: true, 300 - style: 'deepObject', 301 - }, 302 - }); 303 - 304 - const defaultHeaders = { 305 - 'Content-Type': 'application/json', 306 - }; 307 - 308 - export const createConfig = <T extends ClientOptions = ClientOptions>( 309 - override: Config<Omit<ClientOptions, keyof T> & T> = {}, 310 - ): Config<Omit<ClientOptions, keyof T> & T> => ({ 311 - ...jsonBodySerializer, 312 - headers: defaultHeaders, 313 - parseAs: 'auto', 314 - querySerializer: defaultQuerySerializer, 315 - ...override, 316 - });
-41
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type AuthToken = string | undefined; 4 - 5 - export interface Auth { 6 - /** 7 - * Which part of the request do we use to send the auth? 8 - * 9 - * @default 'header' 10 - */ 11 - in?: 'header' | 'query' | 'cookie'; 12 - /** 13 - * Header or query parameter name. 14 - * 15 - * @default 'Authorization' 16 - */ 17 - name?: string; 18 - scheme?: 'basic' | 'bearer'; 19 - type: 'apiKey' | 'http'; 20 - } 21 - 22 - export const getAuthToken = async ( 23 - auth: Auth, 24 - callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 - ): Promise<string | undefined> => { 26 - const token = typeof callback === 'function' ? await callback(auth) : callback; 27 - 28 - if (!token) { 29 - return; 30 - } 31 - 32 - if (auth.scheme === 'bearer') { 33 - return `Bearer ${token}`; 34 - } 35 - 36 - if (auth.scheme === 'basic') { 37 - return `Basic ${btoa(token)}`; 38 - } 39 - 40 - return token; 41 - };
-82
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen'; 4 - 5 - export type QuerySerializer = (query: Record<string, unknown>) => string; 6 - 7 - export type BodySerializer = (body: unknown) => unknown; 8 - 9 - type QuerySerializerOptionsObject = { 10 - allowReserved?: boolean; 11 - array?: Partial<SerializerOptions<ArrayStyle>>; 12 - object?: Partial<SerializerOptions<ObjectStyle>>; 13 - }; 14 - 15 - export type QuerySerializerOptions = QuerySerializerOptionsObject & { 16 - /** 17 - * Per-parameter serialization overrides. When provided, these settings 18 - * override the global array/object settings for specific parameter names. 19 - */ 20 - parameters?: Record<string, QuerySerializerOptionsObject>; 21 - }; 22 - 23 - const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { 24 - if (typeof value === 'string' || value instanceof Blob) { 25 - data.append(key, value); 26 - } else if (value instanceof Date) { 27 - data.append(key, value.toISOString()); 28 - } else { 29 - data.append(key, JSON.stringify(value)); 30 - } 31 - }; 32 - 33 - const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => { 34 - if (typeof value === 'string') { 35 - data.append(key, value); 36 - } else { 37 - data.append(key, JSON.stringify(value)); 38 - } 39 - }; 40 - 41 - export const formDataBodySerializer = { 42 - bodySerializer: (body: unknown): FormData => { 43 - const data = new FormData(); 44 - 45 - Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 46 - if (value === undefined || value === null) { 47 - return; 48 - } 49 - if (Array.isArray(value)) { 50 - value.forEach((v) => serializeFormDataPair(data, key, v)); 51 - } else { 52 - serializeFormDataPair(data, key, value); 53 - } 54 - }); 55 - 56 - return data; 57 - }, 58 - }; 59 - 60 - export const jsonBodySerializer = { 61 - bodySerializer: (body: unknown): string => 62 - JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 63 - }; 64 - 65 - export const urlSearchParamsBodySerializer = { 66 - bodySerializer: (body: unknown): string => { 67 - const data = new URLSearchParams(); 68 - 69 - Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 70 - if (value === undefined || value === null) { 71 - return; 72 - } 73 - if (Array.isArray(value)) { 74 - value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 75 - } else { 76 - serializeUrlSearchParamsPair(data, key, value); 77 - } 78 - }); 79 - 80 - return data.toString(); 81 - }, 82 - };
-169
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - type Slot = 'body' | 'headers' | 'path' | 'query'; 4 - 5 - export type Field = 6 - | { 7 - in: Exclude<Slot, 'body'>; 8 - /** 9 - * Field name. This is the name we want the user to see and use. 10 - */ 11 - key: string; 12 - /** 13 - * Field mapped name. This is the name we want to use in the request. 14 - * If omitted, we use the same value as `key`. 15 - */ 16 - map?: string; 17 - } 18 - | { 19 - in: Extract<Slot, 'body'>; 20 - /** 21 - * Key isn't required for bodies. 22 - */ 23 - key?: string; 24 - map?: string; 25 - } 26 - | { 27 - /** 28 - * Field name. This is the name we want the user to see and use. 29 - */ 30 - key: string; 31 - /** 32 - * Field mapped name. This is the name we want to use in the request. 33 - * If `in` is omitted, `map` aliases `key` to the transport layer. 34 - */ 35 - map: Slot; 36 - }; 37 - 38 - export interface Fields { 39 - allowExtra?: Partial<Record<Slot, boolean>>; 40 - args?: ReadonlyArray<Field>; 41 - } 42 - 43 - export type FieldsConfig = ReadonlyArray<Field | Fields>; 44 - 45 - const extraPrefixesMap: Record<string, Slot> = { 46 - $body_: 'body', 47 - $headers_: 'headers', 48 - $path_: 'path', 49 - $query_: 'query', 50 - }; 51 - const extraPrefixes = Object.entries(extraPrefixesMap); 52 - 53 - type KeyMap = Map< 54 - string, 55 - | { 56 - in: Slot; 57 - map?: string; 58 - } 59 - | { 60 - in?: never; 61 - map: Slot; 62 - } 63 - >; 64 - 65 - const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 66 - if (!map) { 67 - map = new Map(); 68 - } 69 - 70 - for (const config of fields) { 71 - if ('in' in config) { 72 - if (config.key) { 73 - map.set(config.key, { 74 - in: config.in, 75 - map: config.map, 76 - }); 77 - } 78 - } else if ('key' in config) { 79 - map.set(config.key, { 80 - map: config.map, 81 - }); 82 - } else if (config.args) { 83 - buildKeyMap(config.args, map); 84 - } 85 - } 86 - 87 - return map; 88 - }; 89 - 90 - interface Params { 91 - body: unknown; 92 - headers: Record<string, unknown>; 93 - path: Record<string, unknown>; 94 - query: Record<string, unknown>; 95 - } 96 - 97 - const stripEmptySlots = (params: Params) => { 98 - for (const [slot, value] of Object.entries(params)) { 99 - if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) { 100 - delete params[slot as Slot]; 101 - } 102 - } 103 - }; 104 - 105 - export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => { 106 - const params: Params = { 107 - body: {}, 108 - headers: {}, 109 - path: {}, 110 - query: {}, 111 - }; 112 - 113 - const map = buildKeyMap(fields); 114 - 115 - let config: FieldsConfig[number] | undefined; 116 - 117 - for (const [index, arg] of args.entries()) { 118 - if (fields[index]) { 119 - config = fields[index]; 120 - } 121 - 122 - if (!config) { 123 - continue; 124 - } 125 - 126 - if ('in' in config) { 127 - if (config.key) { 128 - const field = map.get(config.key)!; 129 - const name = field.map || config.key; 130 - if (field.in) { 131 - (params[field.in] as Record<string, unknown>)[name] = arg; 132 - } 133 - } else { 134 - params.body = arg; 135 - } 136 - } else { 137 - for (const [key, value] of Object.entries(arg ?? {})) { 138 - const field = map.get(key); 139 - 140 - if (field) { 141 - if (field.in) { 142 - const name = field.map || key; 143 - (params[field.in] as Record<string, unknown>)[name] = value; 144 - } else { 145 - params[field.map] = value; 146 - } 147 - } else { 148 - const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)); 149 - 150 - if (extra) { 151 - const [prefix, slot] = extra; 152 - (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value; 153 - } else if ('allowExtra' in config && config.allowExtra) { 154 - for (const [slot, allowed] of Object.entries(config.allowExtra)) { 155 - if (allowed) { 156 - (params[slot as Slot] as Record<string, unknown>)[key] = value; 157 - break; 158 - } 159 - } 160 - } 161 - } 162 - } 163 - } 164 - } 165 - 166 - stripEmptySlots(params); 167 - 168 - return params; 169 - };
-171
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {} 4 - 5 - interface SerializePrimitiveOptions { 6 - allowReserved?: boolean; 7 - name: string; 8 - } 9 - 10 - export interface SerializerOptions<T> { 11 - /** 12 - * @default true 13 - */ 14 - explode: boolean; 15 - style: T; 16 - } 17 - 18 - export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 19 - export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 20 - type MatrixStyle = 'label' | 'matrix' | 'simple'; 21 - export type ObjectStyle = 'form' | 'deepObject'; 22 - type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 23 - 24 - interface SerializePrimitiveParam extends SerializePrimitiveOptions { 25 - value: string; 26 - } 27 - 28 - export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 29 - switch (style) { 30 - case 'label': 31 - return '.'; 32 - case 'matrix': 33 - return ';'; 34 - case 'simple': 35 - return ','; 36 - default: 37 - return '&'; 38 - } 39 - }; 40 - 41 - export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 42 - switch (style) { 43 - case 'form': 44 - return ','; 45 - case 'pipeDelimited': 46 - return '|'; 47 - case 'spaceDelimited': 48 - return '%20'; 49 - default: 50 - return ','; 51 - } 52 - }; 53 - 54 - export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 55 - switch (style) { 56 - case 'label': 57 - return '.'; 58 - case 'matrix': 59 - return ';'; 60 - case 'simple': 61 - return ','; 62 - default: 63 - return '&'; 64 - } 65 - }; 66 - 67 - export const serializeArrayParam = ({ 68 - allowReserved, 69 - explode, 70 - name, 71 - style, 72 - value, 73 - }: SerializeOptions<ArraySeparatorStyle> & { 74 - value: unknown[]; 75 - }) => { 76 - if (!explode) { 77 - const joinedValues = ( 78 - allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 79 - ).join(separatorArrayNoExplode(style)); 80 - switch (style) { 81 - case 'label': 82 - return `.${joinedValues}`; 83 - case 'matrix': 84 - return `;${name}=${joinedValues}`; 85 - case 'simple': 86 - return joinedValues; 87 - default: 88 - return `${name}=${joinedValues}`; 89 - } 90 - } 91 - 92 - const separator = separatorArrayExplode(style); 93 - const joinedValues = value 94 - .map((v) => { 95 - if (style === 'label' || style === 'simple') { 96 - return allowReserved ? v : encodeURIComponent(v as string); 97 - } 98 - 99 - return serializePrimitiveParam({ 100 - allowReserved, 101 - name, 102 - value: v as string, 103 - }); 104 - }) 105 - .join(separator); 106 - return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 107 - }; 108 - 109 - export const serializePrimitiveParam = ({ 110 - allowReserved, 111 - name, 112 - value, 113 - }: SerializePrimitiveParam) => { 114 - if (value === undefined || value === null) { 115 - return ''; 116 - } 117 - 118 - if (typeof value === 'object') { 119 - throw new Error( 120 - 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 121 - ); 122 - } 123 - 124 - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 125 - }; 126 - 127 - export const serializeObjectParam = ({ 128 - allowReserved, 129 - explode, 130 - name, 131 - style, 132 - value, 133 - valueOnly, 134 - }: SerializeOptions<ObjectSeparatorStyle> & { 135 - value: Record<string, unknown> | Date; 136 - valueOnly?: boolean; 137 - }) => { 138 - if (value instanceof Date) { 139 - return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 140 - } 141 - 142 - if (style !== 'deepObject' && !explode) { 143 - let values: string[] = []; 144 - Object.entries(value).forEach(([key, v]) => { 145 - values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]; 146 - }); 147 - const joinedValues = values.join(','); 148 - switch (style) { 149 - case 'form': 150 - return `${name}=${joinedValues}`; 151 - case 'label': 152 - return `.${joinedValues}`; 153 - case 'matrix': 154 - return `;${name}=${joinedValues}`; 155 - default: 156 - return joinedValues; 157 - } 158 - } 159 - 160 - const separator = separatorObjectExplode(style); 161 - const joinedValues = Object.entries(value) 162 - .map(([key, v]) => 163 - serializePrimitiveParam({ 164 - allowReserved, 165 - name: style === 'deepObject' ? `${name}[${key}]` : key, 166 - value: v as string, 167 - }), 168 - ) 169 - .join(separator); 170 - return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 171 - };
-117
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/queryKeySerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - /** 4 - * JSON-friendly union that mirrors what Pinia Colada can hash. 5 - */ 6 - export type JsonValue = 7 - | null 8 - | string 9 - | number 10 - | boolean 11 - | JsonValue[] 12 - | { [key: string]: JsonValue }; 13 - 14 - /** 15 - * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. 16 - */ 17 - export const queryKeyJsonReplacer = (_key: string, value: unknown) => { 18 - if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 19 - return undefined; 20 - } 21 - if (typeof value === 'bigint') { 22 - return value.toString(); 23 - } 24 - if (value instanceof Date) { 25 - return value.toISOString(); 26 - } 27 - return value; 28 - }; 29 - 30 - /** 31 - * Safely stringifies a value and parses it back into a JsonValue. 32 - */ 33 - export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { 34 - try { 35 - const json = JSON.stringify(input, queryKeyJsonReplacer); 36 - if (json === undefined) { 37 - return undefined; 38 - } 39 - return JSON.parse(json) as JsonValue; 40 - } catch { 41 - return undefined; 42 - } 43 - }; 44 - 45 - /** 46 - * Detects plain objects (including objects with a null prototype). 47 - */ 48 - const isPlainObject = (value: unknown): value is Record<string, unknown> => { 49 - if (value === null || typeof value !== 'object') { 50 - return false; 51 - } 52 - const prototype = Object.getPrototypeOf(value as object); 53 - return prototype === Object.prototype || prototype === null; 54 - }; 55 - 56 - /** 57 - * Turns URLSearchParams into a sorted JSON object for deterministic keys. 58 - */ 59 - const serializeSearchParams = (params: URLSearchParams): JsonValue => { 60 - const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b)); 61 - const result: Record<string, JsonValue> = {}; 62 - 63 - for (const [key, value] of entries) { 64 - const existing = result[key]; 65 - if (existing === undefined) { 66 - result[key] = value; 67 - continue; 68 - } 69 - 70 - if (Array.isArray(existing)) { 71 - (existing as string[]).push(value); 72 - } else { 73 - result[key] = [existing, value]; 74 - } 75 - } 76 - 77 - return result; 78 - }; 79 - 80 - /** 81 - * Normalizes any accepted value into a JSON-friendly shape for query keys. 82 - */ 83 - export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => { 84 - if (value === null) { 85 - return null; 86 - } 87 - 88 - if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 89 - return value; 90 - } 91 - 92 - if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 93 - return undefined; 94 - } 95 - 96 - if (typeof value === 'bigint') { 97 - return value.toString(); 98 - } 99 - 100 - if (value instanceof Date) { 101 - return value.toISOString(); 102 - } 103 - 104 - if (Array.isArray(value)) { 105 - return stringifyToJsonValue(value); 106 - } 107 - 108 - if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) { 109 - return serializeSearchParams(value); 110 - } 111 - 112 - if (isPlainObject(value)) { 113 - return stringifyToJsonValue(value); 114 - } 115 - 116 - return undefined; 117 - };
-243
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Config } from './types.gen'; 4 - 5 - export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & 6 - Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 7 - /** 8 - * Fetch API implementation. You can use this option to provide a custom 9 - * fetch instance. 10 - * 11 - * @default globalThis.fetch 12 - */ 13 - fetch?: typeof fetch; 14 - /** 15 - * Implementing clients can call request interceptors inside this hook. 16 - */ 17 - onRequest?: (url: string, init: RequestInit) => Promise<Request>; 18 - /** 19 - * Callback invoked when a network or parsing error occurs during streaming. 20 - * 21 - * This option applies only if the endpoint returns a stream of events. 22 - * 23 - * @param error The error that occurred. 24 - */ 25 - onSseError?: (error: unknown) => void; 26 - /** 27 - * Callback invoked when an event is streamed from the server. 28 - * 29 - * This option applies only if the endpoint returns a stream of events. 30 - * 31 - * @param event Event streamed from the server. 32 - * @returns Nothing (void). 33 - */ 34 - onSseEvent?: (event: StreamEvent<TData>) => void; 35 - serializedBody?: RequestInit['body']; 36 - /** 37 - * Default retry delay in milliseconds. 38 - * 39 - * This option applies only if the endpoint returns a stream of events. 40 - * 41 - * @default 3000 42 - */ 43 - sseDefaultRetryDelay?: number; 44 - /** 45 - * Maximum number of retry attempts before giving up. 46 - */ 47 - sseMaxRetryAttempts?: number; 48 - /** 49 - * Maximum retry delay in milliseconds. 50 - * 51 - * Applies only when exponential backoff is used. 52 - * 53 - * This option applies only if the endpoint returns a stream of events. 54 - * 55 - * @default 30000 56 - */ 57 - sseMaxRetryDelay?: number; 58 - /** 59 - * Optional sleep function for retry backoff. 60 - * 61 - * Defaults to using `setTimeout`. 62 - */ 63 - sseSleepFn?: (ms: number) => Promise<void>; 64 - url: string; 65 - }; 66 - 67 - export interface StreamEvent<TData = unknown> { 68 - data: TData; 69 - event?: string; 70 - id?: string; 71 - retry?: number; 72 - } 73 - 74 - export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = { 75 - stream: AsyncGenerator< 76 - TData extends Record<string, unknown> ? TData[keyof TData] : TData, 77 - TReturn, 78 - TNext 79 - >; 80 - }; 81 - 82 - export const createSseClient = <TData = unknown>({ 83 - onRequest, 84 - onSseError, 85 - onSseEvent, 86 - responseTransformer, 87 - responseValidator, 88 - sseDefaultRetryDelay, 89 - sseMaxRetryAttempts, 90 - sseMaxRetryDelay, 91 - sseSleepFn, 92 - url, 93 - ...options 94 - }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 95 - let lastEventId: string | undefined; 96 - 97 - const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 98 - 99 - const createStream = async function* () { 100 - let retryDelay: number = sseDefaultRetryDelay ?? 3000; 101 - let attempt = 0; 102 - const signal = options.signal ?? new AbortController().signal; 103 - 104 - while (true) { 105 - if (signal.aborted) break; 106 - 107 - attempt++; 108 - 109 - const headers = 110 - options.headers instanceof Headers 111 - ? options.headers 112 - : new Headers(options.headers as Record<string, string> | undefined); 113 - 114 - if (lastEventId !== undefined) { 115 - headers.set('Last-Event-ID', lastEventId); 116 - } 117 - 118 - try { 119 - const requestInit: RequestInit = { 120 - redirect: 'follow', 121 - ...options, 122 - body: options.serializedBody, 123 - headers, 124 - signal, 125 - }; 126 - let request = new Request(url, requestInit); 127 - if (onRequest) { 128 - request = await onRequest(url, requestInit); 129 - } 130 - // fetch must be assigned here, otherwise it would throw the error: 131 - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 132 - const _fetch = options.fetch ?? globalThis.fetch; 133 - const response = await _fetch(request); 134 - 135 - if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`); 136 - 137 - if (!response.body) throw new Error('No body in SSE response'); 138 - 139 - const reader = response.body.pipeThrough(new TextDecoderStream()).getReader(); 140 - 141 - let buffer = ''; 142 - 143 - const abortHandler = () => { 144 - try { 145 - reader.cancel(); 146 - } catch { 147 - // noop 148 - } 149 - }; 150 - 151 - signal.addEventListener('abort', abortHandler); 152 - 153 - try { 154 - while (true) { 155 - const { done, value } = await reader.read(); 156 - if (done) break; 157 - buffer += value; 158 - // Normalize line endings: CRLF -> LF, then CR -> LF 159 - buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); 160 - 161 - const chunks = buffer.split('\n\n'); 162 - buffer = chunks.pop() ?? ''; 163 - 164 - for (const chunk of chunks) { 165 - const lines = chunk.split('\n'); 166 - const dataLines: Array<string> = []; 167 - let eventName: string | undefined; 168 - 169 - for (const line of lines) { 170 - if (line.startsWith('data:')) { 171 - dataLines.push(line.replace(/^data:\s*/, '')); 172 - } else if (line.startsWith('event:')) { 173 - eventName = line.replace(/^event:\s*/, ''); 174 - } else if (line.startsWith('id:')) { 175 - lastEventId = line.replace(/^id:\s*/, ''); 176 - } else if (line.startsWith('retry:')) { 177 - const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10); 178 - if (!Number.isNaN(parsed)) { 179 - retryDelay = parsed; 180 - } 181 - } 182 - } 183 - 184 - let data: unknown; 185 - let parsedJson = false; 186 - 187 - if (dataLines.length) { 188 - const rawData = dataLines.join('\n'); 189 - try { 190 - data = JSON.parse(rawData); 191 - parsedJson = true; 192 - } catch { 193 - data = rawData; 194 - } 195 - } 196 - 197 - if (parsedJson) { 198 - if (responseValidator) { 199 - await responseValidator(data); 200 - } 201 - 202 - if (responseTransformer) { 203 - data = await responseTransformer(data); 204 - } 205 - } 206 - 207 - onSseEvent?.({ 208 - data, 209 - event: eventName, 210 - id: lastEventId, 211 - retry: retryDelay, 212 - }); 213 - 214 - if (dataLines.length) { 215 - yield data as any; 216 - } 217 - } 218 - } 219 - } finally { 220 - signal.removeEventListener('abort', abortHandler); 221 - reader.releaseLock(); 222 - } 223 - 224 - break; // exit loop on normal completion 225 - } catch (error) { 226 - // connection failed or aborted; retry after delay 227 - onSseError?.(error); 228 - 229 - if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) { 230 - break; // stop after firing error 231 - } 232 - 233 - // exponential backoff: double retry each attempt, cap at 30s 234 - const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000); 235 - await sleep(backoff); 236 - } 237 - } 238 - }; 239 - 240 - const stream = createStream(); 241 - 242 - return { stream }; 243 - };
-104
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Auth, AuthToken } from './auth.gen'; 4 - import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen'; 5 - 6 - export type HttpMethod = 7 - | 'connect' 8 - | 'delete' 9 - | 'get' 10 - | 'head' 11 - | 'options' 12 - | 'patch' 13 - | 'post' 14 - | 'put' 15 - | 'trace'; 16 - 17 - export type Client< 18 - RequestFn = never, 19 - Config = unknown, 20 - MethodFn = never, 21 - BuildUrlFn = never, 22 - SseFn = never, 23 - > = { 24 - /** 25 - * Returns the final request URL. 26 - */ 27 - buildUrl: BuildUrlFn; 28 - getConfig: () => Config; 29 - request: RequestFn; 30 - setConfig: (config: Config) => Config; 31 - } & { 32 - [K in HttpMethod]: MethodFn; 33 - } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } }); 34 - 35 - export interface Config { 36 - /** 37 - * Auth token or a function returning auth token. The resolved value will be 38 - * added to the request payload as defined by its `security` array. 39 - */ 40 - auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 41 - /** 42 - * A function for serializing request body parameter. By default, 43 - * {@link JSON.stringify()} will be used. 44 - */ 45 - bodySerializer?: BodySerializer | null; 46 - /** 47 - * An object containing any HTTP headers that you want to pre-populate your 48 - * `Headers` object with. 49 - * 50 - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 51 - */ 52 - headers?: 53 - | RequestInit['headers'] 54 - | Record< 55 - string, 56 - string | number | boolean | (string | number | boolean)[] | null | undefined | unknown 57 - >; 58 - /** 59 - * The request method. 60 - * 61 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 62 - */ 63 - method?: Uppercase<HttpMethod>; 64 - /** 65 - * A function for serializing request query parameters. By default, arrays 66 - * will be exploded in form style, objects will be exploded in deepObject 67 - * style, and reserved characters are percent-encoded. 68 - * 69 - * This method will have no effect if the native `paramsSerializer()` Axios 70 - * API function is used. 71 - * 72 - * {@link https://swagger.io/docs/specification/serialization/#query View examples} 73 - */ 74 - querySerializer?: QuerySerializer | QuerySerializerOptions; 75 - /** 76 - * A function validating request data. This is useful if you want to ensure 77 - * the request conforms to the desired shape, so it can be safely sent to 78 - * the server. 79 - */ 80 - requestValidator?: (data: unknown) => Promise<unknown>; 81 - /** 82 - * A function transforming response data before it's returned. This is useful 83 - * for post-processing data, e.g. converting ISO strings into Date objects. 84 - */ 85 - responseTransformer?: (data: unknown) => Promise<unknown>; 86 - /** 87 - * A function validating response data. This is useful if you want to ensure 88 - * the response conforms to the desired shape, so it can be safely passed to 89 - * the transformers and returned to the user. 90 - */ 91 - responseValidator?: (data: unknown) => Promise<unknown>; 92 - } 93 - 94 - type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 95 - ? true 96 - : [T] extends [never | undefined] 97 - ? [undefined] extends [T] 98 - ? false 99 - : true 100 - : false; 101 - 102 - export type OmitNever<T extends Record<string, unknown>> = { 103 - [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]; 104 - };
-140
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; 4 - import { 5 - type ArraySeparatorStyle, 6 - serializeArrayParam, 7 - serializeObjectParam, 8 - serializePrimitiveParam, 9 - } from './pathSerializer.gen'; 10 - 11 - export interface PathSerializer { 12 - path: Record<string, unknown>; 13 - url: string; 14 - } 15 - 16 - export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 - 18 - export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 - let url = _url; 20 - const matches = _url.match(PATH_PARAM_RE); 21 - if (matches) { 22 - for (const match of matches) { 23 - let explode = false; 24 - let name = match.substring(1, match.length - 1); 25 - let style: ArraySeparatorStyle = 'simple'; 26 - 27 - if (name.endsWith('*')) { 28 - explode = true; 29 - name = name.substring(0, name.length - 1); 30 - } 31 - 32 - if (name.startsWith('.')) { 33 - name = name.substring(1); 34 - style = 'label'; 35 - } else if (name.startsWith(';')) { 36 - name = name.substring(1); 37 - style = 'matrix'; 38 - } 39 - 40 - const value = path[name]; 41 - 42 - if (value === undefined || value === null) { 43 - continue; 44 - } 45 - 46 - if (Array.isArray(value)) { 47 - url = url.replace(match, serializeArrayParam({ explode, name, style, value })); 48 - continue; 49 - } 50 - 51 - if (typeof value === 'object') { 52 - url = url.replace( 53 - match, 54 - serializeObjectParam({ 55 - explode, 56 - name, 57 - style, 58 - value: value as Record<string, unknown>, 59 - valueOnly: true, 60 - }), 61 - ); 62 - continue; 63 - } 64 - 65 - if (style === 'matrix') { 66 - url = url.replace( 67 - match, 68 - `;${serializePrimitiveParam({ 69 - name, 70 - value: value as string, 71 - })}`, 72 - ); 73 - continue; 74 - } 75 - 76 - const replaceValue = encodeURIComponent( 77 - style === 'label' ? `.${value as string}` : (value as string), 78 - ); 79 - url = url.replace(match, replaceValue); 80 - } 81 - } 82 - return url; 83 - }; 84 - 85 - export const getUrl = ({ 86 - baseUrl, 87 - path, 88 - query, 89 - querySerializer, 90 - url: _url, 91 - }: { 92 - baseUrl?: string; 93 - path?: Record<string, unknown>; 94 - query?: Record<string, unknown>; 95 - querySerializer: QuerySerializer; 96 - url: string; 97 - }) => { 98 - const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 99 - let url = (baseUrl ?? '') + pathUrl; 100 - if (path) { 101 - url = defaultPathSerializer({ path, url }); 102 - } 103 - let search = query ? querySerializer(query) : ''; 104 - if (search.startsWith('?')) { 105 - search = search.substring(1); 106 - } 107 - if (search) { 108 - url += `?${search}`; 109 - } 110 - return url; 111 - }; 112 - 113 - export function getValidRequestBody(options: { 114 - body?: unknown; 115 - bodySerializer?: BodySerializer | null; 116 - serializedBody?: unknown; 117 - }) { 118 - const hasBody = options.body !== undefined; 119 - const isSerializedBody = hasBody && options.bodySerializer; 120 - 121 - if (isSerializedBody) { 122 - if ('serializedBody' in options) { 123 - const hasSerializedBody = 124 - options.serializedBody !== undefined && options.serializedBody !== ''; 125 - 126 - return hasSerializedBody ? options.serializedBody : null; 127 - } 128 - 129 - // not all clients implement a serializedBody property (i.e. client-axios) 130 - return options.body !== '' ? options.body : null; 131 - } 132 - 133 - // plain/text body 134 - if (hasBody) { 135 - return options.body; 136 - } 137 - 138 - // no body was provided 139 - return undefined; 140 - }
-4
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export { type Options, postFoo } from './sdk.gen'; 4 - export type { Bar, ClientOptions, Foo, PostFooData, PostFooResponse, PostFooResponses, TypeID, UserId } from './types.gen';
-31
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - import type { Client, Options as Options2, TDataShape } from './client'; 6 - import { client } from './client.gen'; 7 - import { postFooResponseTransformer } from './transformers.gen'; 8 - import type { PostFooData, PostFooResponses } from './types.gen'; 9 - import { vPostFooData, vPostFooResponse } from './valibot.gen'; 10 - 11 - export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 12 - /** 13 - * You can provide a client instance returned by `createClient()` instead of 14 - * individual options. This might be also useful if you want to implement a 15 - * custom client. 16 - */ 17 - client?: Client; 18 - /** 19 - * You can pass arbitrary values through the `meta` object. This can be 20 - * used to access values that aren't defined as part of the SDK function. 21 - */ 22 - meta?: Record<string, unknown>; 23 - }; 24 - 25 - export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => (options?.client ?? client).post<PostFooResponses, unknown, ThrowOnError>({ 26 - requestValidator: async (data) => await v.parseAsync(vPostFooData, data), 27 - responseTransformer: postFooResponseTransformer, 28 - responseValidator: async (data) => await v.parseAsync(vPostFooResponse, data), 29 - url: '/foo', 30 - ...options 31 - });
-13
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { PostFooResponse } from './types.gen'; 4 - 5 - const fooSchemaResponseTransformer = (data: any) => { 6 - data.foo = BigInt(data.foo.toString()); 7 - return data; 8 - }; 9 - 10 - export const postFooResponseTransformer = async (data: any): Promise<PostFooResponse> => { 11 - data = fooSchemaResponseTransformer(data); 12 - return data; 13 - };
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/type-format-valibot/types.gen.ts
-28
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - export const vFoo = v.object({ 6 - bar: v.optional(v.pipe(v.number(), v.integer())), 7 - foo: v.optional(v.pipe(v.union([ 8 - v.number(), 9 - v.string(), 10 - v.bigint() 11 - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')), BigInt(0)), 12 - id: v.string() 13 - }); 14 - 15 - export const vBar = v.objectWithRest({ 16 - foo: v.pipe(v.number(), v.integer()) 17 - }, v.pipe(v.number(), v.integer())); 18 - 19 - export const vPostFooData = v.object({ 20 - body: v.optional(v.never()), 21 - path: v.optional(v.never()), 22 - query: v.optional(v.never()) 23 - }); 24 - 25 - /** 26 - * OK 27 - */ 28 - export const vPostFooResponse = vFoo;
-1487
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - /** 6 - * Model with number-only name 7 - */ 8 - export const v400 = v.string(); 9 - 10 - /** 11 - * Testing multiline comments in string: First line 12 - * Second line 13 - * 14 - * Fourth line 15 - */ 16 - export const vCamelCaseCommentWithBreaks = v.pipe(v.number(), v.integer()); 17 - 18 - /** 19 - * Testing multiline comments in string: First line 20 - * Second line 21 - * 22 - * Fourth line 23 - */ 24 - export const vCommentWithBreaks = v.pipe(v.number(), v.integer()); 25 - 26 - /** 27 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 28 - */ 29 - export const vCommentWithBackticks = v.pipe(v.number(), v.integer()); 30 - 31 - /** 32 - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 33 - */ 34 - export const vCommentWithBackticksAndQuotes = v.pipe(v.number(), v.integer()); 35 - 36 - /** 37 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 38 - */ 39 - export const vCommentWithSlashes = v.pipe(v.number(), v.integer()); 40 - 41 - /** 42 - * Testing expression placeholders in string: ${expression} should work 43 - */ 44 - export const vCommentWithExpressionPlaceholders = v.pipe(v.number(), v.integer()); 45 - 46 - /** 47 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 48 - */ 49 - export const vCommentWithQuotes = v.pipe(v.number(), v.integer()); 50 - 51 - /** 52 - * Testing reserved characters in string: * inline * and ** inline ** should work 53 - */ 54 - export const vCommentWithReservedCharacters = v.pipe(v.number(), v.integer()); 55 - 56 - /** 57 - * This is a simple number 58 - */ 59 - export const vSimpleInteger = v.pipe(v.number(), v.integer()); 60 - 61 - /** 62 - * This is a simple boolean 63 - */ 64 - export const vSimpleBoolean = v.boolean(); 65 - 66 - /** 67 - * This is a simple string 68 - */ 69 - export const vSimpleString = v.string(); 70 - 71 - /** 72 - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 73 - */ 74 - export const vNonAsciiStringæøåÆøÅöôêÊ字符串 = v.string(); 75 - 76 - /** 77 - * This is a simple file 78 - */ 79 - export const vSimpleFile = v.string(); 80 - 81 - /** 82 - * This is a simple string 83 - */ 84 - export const vSimpleStringWithPattern = v.nullable(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/))); 85 - 86 - /** 87 - * This is a simple enum with strings 88 - */ 89 - export const vEnumWithStrings = v.picklist([ 90 - 'Success', 91 - 'Warning', 92 - 'Error', 93 - '\'Single Quote\'', 94 - '"Double Quotes"', 95 - 'Non-ascii: øæåôöØÆÅÔÖ字符串' 96 - ]); 97 - 98 - export const vEnumWithReplacedCharacters = v.picklist([ 99 - '\'Single Quote\'', 100 - '"Double Quotes"', 101 - 'øæåôöØÆÅÔÖ字符串', 102 - '' 103 - ]); 104 - 105 - /** 106 - * This is a simple enum with numbers 107 - */ 108 - export const vEnumWithNumbers = v.unknown(); 109 - 110 - /** 111 - * Success=1,Warning=2,Error=3 112 - */ 113 - export const vEnumFromDescription = v.number(); 114 - 115 - /** 116 - * This is a simple enum with numbers 117 - */ 118 - export const vEnumWithExtensions = v.unknown(); 119 - 120 - export const vEnumWithXEnumNames = v.unknown(); 121 - 122 - /** 123 - * This is a simple array with numbers 124 - */ 125 - export const vArrayWithNumbers = v.array(v.pipe(v.number(), v.integer())); 126 - 127 - /** 128 - * This is a simple array with booleans 129 - */ 130 - export const vArrayWithBooleans = v.array(v.boolean()); 131 - 132 - /** 133 - * This is a simple array with strings 134 - */ 135 - export const vArrayWithStrings = v.optional(v.array(v.string()), ['test']); 136 - 137 - /** 138 - * This is a simple array with properties 139 - */ 140 - export const vArrayWithProperties = v.array(v.object({ 141 - '16x16': v.optional(vCamelCaseCommentWithBreaks), 142 - bar: v.optional(v.string()) 143 - })); 144 - 145 - /** 146 - * This is a simple array with any of properties 147 - */ 148 - export const vArrayWithAnyOfProperties = v.array(v.unknown()); 149 - 150 - export const vAnyOfAnyAndNull = v.object({ 151 - data: v.optional(v.unknown()) 152 - }); 153 - 154 - /** 155 - * This is a simple array with any of properties 156 - */ 157 - export const vAnyOfArrays = v.object({ 158 - results: v.optional(v.array(v.unknown())) 159 - }); 160 - 161 - /** 162 - * This is a string dictionary 163 - */ 164 - export const vDictionaryWithString = v.record(v.string(), v.string()); 165 - 166 - export const vDictionaryWithPropertiesAndAdditionalProperties = v.objectWithRest({ 167 - foo: v.optional(v.number()), 168 - bar: v.optional(v.boolean()) 169 - }, v.string()); 170 - 171 - /** 172 - * This is a string dictionary 173 - */ 174 - export const vDictionaryWithDictionary = v.record(v.string(), v.record(v.string(), v.string())); 175 - 176 - /** 177 - * This is a complex dictionary 178 - */ 179 - export const vDictionaryWithProperties = v.record(v.string(), v.object({ 180 - foo: v.optional(v.string()), 181 - bar: v.optional(v.string()) 182 - })); 183 - 184 - /** 185 - * This is a model with one number property 186 - */ 187 - export const vModelWithInteger = v.object({ 188 - prop: v.optional(v.pipe(v.number(), v.integer())) 189 - }); 190 - 191 - /** 192 - * This is a model with one boolean property 193 - */ 194 - export const vModelWithBoolean = v.object({ 195 - prop: v.optional(v.boolean()) 196 - }); 197 - 198 - /** 199 - * This is a model with one string property 200 - */ 201 - export const vModelWithString = v.object({ 202 - prop: v.optional(v.string()) 203 - }); 204 - 205 - /** 206 - * This is a simple reference 207 - */ 208 - export const vSimpleReference = vModelWithString; 209 - 210 - /** 211 - * This is a simple array with references 212 - */ 213 - export const vArrayWithReferences = v.array(vModelWithString); 214 - 215 - /** 216 - * This is a simple array containing an array 217 - */ 218 - export const vArrayWithArray = v.array(v.array(vModelWithString)); 219 - 220 - /** 221 - * This is a string reference 222 - */ 223 - export const vDictionaryWithReference = v.object({}); 224 - 225 - /** 226 - * This is a complex dictionary 227 - */ 228 - export const vDictionaryWithArray = v.record(v.string(), v.array(vModelWithString)); 229 - 230 - /** 231 - * This is a model with one string property 232 - */ 233 - export const vModelWithStringError = v.object({ 234 - prop: v.optional(v.string()) 235 - }); 236 - 237 - /** 238 - * `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) 239 - */ 240 - export const vModelFromZendesk = v.string(); 241 - 242 - /** 243 - * This is a model with one string property 244 - */ 245 - export const vModelWithNullableString = v.object({ 246 - nullableProp1: v.nullish(v.string()), 247 - nullableRequiredProp1: v.nullable(v.string()), 248 - nullableProp2: v.nullish(v.string()), 249 - nullableRequiredProp2: v.nullable(v.string()), 250 - 'foo_bar-enum': v.optional(v.picklist([ 251 - 'Success', 252 - 'Warning', 253 - 'Error', 254 - 'ØÆÅ字符串' 255 - ])) 256 - }); 257 - 258 - /** 259 - * This is a model with one enum 260 - */ 261 - export const vModelWithEnum = v.object({ 262 - 'foo_bar-enum': v.optional(v.picklist([ 263 - 'Success', 264 - 'Warning', 265 - 'Error', 266 - 'ØÆÅ字符串' 267 - ])), 268 - statusCode: v.optional(v.picklist([ 269 - '100', 270 - '200 FOO', 271 - '300 FOO_BAR', 272 - '400 foo-bar', 273 - '500 foo.bar', 274 - '600 foo&bar' 275 - ])), 276 - bool: v.optional(v.unknown()) 277 - }); 278 - 279 - /** 280 - * This is a model with one enum with escaped name 281 - */ 282 - export const vModelWithEnumWithHyphen = v.object({ 283 - 'foo-bar-baz-qux': v.optional(v.picklist(['3.0'])) 284 - }); 285 - 286 - /** 287 - * This is a model with one enum 288 - */ 289 - export const vModelWithEnumFromDescription = v.object({ 290 - test: v.optional(v.pipe(v.number(), v.integer())) 291 - }); 292 - 293 - /** 294 - * This is a model with nested enums 295 - */ 296 - export const vModelWithNestedEnums = v.object({ 297 - dictionaryWithEnum: v.optional(v.record(v.string(), v.picklist([ 298 - 'Success', 299 - 'Warning', 300 - 'Error' 301 - ]))), 302 - dictionaryWithEnumFromDescription: v.optional(v.record(v.string(), v.pipe(v.number(), v.integer()))), 303 - arrayWithEnum: v.optional(v.array(v.picklist([ 304 - 'Success', 305 - 'Warning', 306 - 'Error' 307 - ]))), 308 - arrayWithDescription: v.optional(v.array(v.pipe(v.number(), v.integer()))), 309 - 'foo_bar-enum': v.optional(v.picklist([ 310 - 'Success', 311 - 'Warning', 312 - 'Error', 313 - 'ØÆÅ字符串' 314 - ])) 315 - }); 316 - 317 - /** 318 - * This is a model with one property containing an array 319 - */ 320 - export const vModelWithArray = v.object({ 321 - prop: v.optional(v.array(vModelWithString)), 322 - propWithFile: v.optional(v.array(v.string())), 323 - propWithNumber: v.optional(v.array(v.number())) 324 - }); 325 - 326 - /** 327 - * This is a model with one property containing a dictionary 328 - */ 329 - export const vModelWithDictionary = v.object({ 330 - prop: v.optional(v.record(v.string(), v.string())) 331 - }); 332 - 333 - /** 334 - * This is a deprecated model with a deprecated property 335 - * 336 - * @deprecated 337 - */ 338 - export const vDeprecatedModel = v.object({ 339 - prop: v.optional(v.string()) 340 - }); 341 - 342 - /** 343 - * This is a model with one property containing a circular reference 344 - */ 345 - export const vModelWithCircularReference: v.GenericSchema = v.object({ 346 - prop: v.optional(v.lazy(() => vModelWithCircularReference)) 347 - }); 348 - 349 - /** 350 - * This is a model with one property with a 'one of' relationship 351 - */ 352 - export const vCompositionWithOneOf = v.object({ 353 - propA: v.optional(v.union([ 354 - vModelWithString, 355 - vModelWithEnum, 356 - vModelWithArray, 357 - vModelWithDictionary 358 - ])) 359 - }); 360 - 361 - /** 362 - * This is a model with one property with a 'one of' relationship where the options are not $ref 363 - */ 364 - export const vCompositionWithOneOfAnonymous = v.object({ 365 - propA: v.optional(v.union([ 366 - v.object({ 367 - propA: v.optional(v.string()) 368 - }), 369 - v.string(), 370 - v.pipe(v.number(), v.integer()) 371 - ])) 372 - }); 373 - 374 - /** 375 - * Circle 376 - */ 377 - export const vModelCircle = v.object({ 378 - kind: v.string(), 379 - radius: v.optional(v.number()) 380 - }); 381 - 382 - /** 383 - * Square 384 - */ 385 - export const vModelSquare = v.object({ 386 - kind: v.string(), 387 - sideLength: v.optional(v.number()) 388 - }); 389 - 390 - /** 391 - * This is a model with one property with a 'one of' relationship where the options are not $ref 392 - */ 393 - export const vCompositionWithOneOfDiscriminator = v.union([v.intersect([v.object({ 394 - kind: v.literal('circle') 395 - }), vModelCircle]), v.intersect([v.object({ 396 - kind: v.literal('square') 397 - }), vModelSquare])]); 398 - 399 - /** 400 - * This is a model with one property with a 'any of' relationship 401 - */ 402 - export const vCompositionWithAnyOf = v.object({ 403 - propA: v.optional(v.union([ 404 - vModelWithString, 405 - vModelWithEnum, 406 - vModelWithArray, 407 - vModelWithDictionary 408 - ])) 409 - }); 410 - 411 - /** 412 - * This is a model with one property with a 'any of' relationship where the options are not $ref 413 - */ 414 - export const vCompositionWithAnyOfAnonymous = v.object({ 415 - propA: v.optional(v.union([ 416 - v.object({ 417 - propA: v.optional(v.string()) 418 - }), 419 - v.string(), 420 - v.pipe(v.number(), v.integer()) 421 - ])) 422 - }); 423 - 424 - /** 425 - * This is a model with nested 'any of' property with a type null 426 - */ 427 - export const vCompositionWithNestedAnyAndTypeNull = v.object({ 428 - propA: v.optional(v.union([v.array(v.nullable(vModelWithDictionary)), v.array(v.nullable(vModelWithArray))])) 429 - }); 430 - 431 - export const v3eNum1Период = v.picklist(['Bird', 'Dog']); 432 - 433 - export const vConstValue = v.picklist(['ConstValue']); 434 - 435 - /** 436 - * This is a model with one property with a 'any of' relationship where the options are not $ref 437 - */ 438 - export const vCompositionWithNestedAnyOfAndNull = v.object({ 439 - propA: v.nullish(v.array(v.unknown())) 440 - }); 441 - 442 - /** 443 - * This is a model with one property with a 'one of' relationship 444 - */ 445 - export const vCompositionWithOneOfAndNullable = v.object({ 446 - propA: v.nullish(v.union([ 447 - v.object({ 448 - boolean: v.optional(v.boolean()) 449 - }), 450 - vModelWithEnum, 451 - vModelWithArray, 452 - vModelWithDictionary 453 - ])) 454 - }); 455 - 456 - /** 457 - * This is a model that contains a simple dictionary within composition 458 - */ 459 - export const vCompositionWithOneOfAndSimpleDictionary = v.object({ 460 - propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.number())])) 461 - }); 462 - 463 - /** 464 - * This is a model that contains a dictionary of simple arrays within composition 465 - */ 466 - export const vCompositionWithOneOfAndSimpleArrayDictionary = v.object({ 467 - propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.boolean()))])) 468 - }); 469 - 470 - /** 471 - * This is a model that contains a dictionary of complex arrays (composited) within composition 472 - */ 473 - export const vCompositionWithOneOfAndComplexArrayDictionary = v.object({ 474 - propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.unknown()))])) 475 - }); 476 - 477 - /** 478 - * This is a model with one property with a 'all of' relationship 479 - */ 480 - export const vCompositionWithAllOfAndNullable = v.object({ 481 - propA: v.nullish(v.intersect([ 482 - v.object({ 483 - boolean: v.optional(v.boolean()) 484 - }), 485 - vModelWithEnum, 486 - vModelWithArray, 487 - vModelWithDictionary 488 - ])) 489 - }); 490 - 491 - /** 492 - * This is a model with one property with a 'any of' relationship 493 - */ 494 - export const vCompositionWithAnyOfAndNullable = v.object({ 495 - propA: v.nullish(v.union([ 496 - v.object({ 497 - boolean: v.optional(v.boolean()) 498 - }), 499 - vModelWithEnum, 500 - vModelWithArray, 501 - vModelWithDictionary 502 - ])) 503 - }); 504 - 505 - /** 506 - * This is a base model with two simple optional properties 507 - */ 508 - export const vCompositionBaseModel = v.object({ 509 - firstName: v.optional(v.string()), 510 - lastname: v.optional(v.string()) 511 - }); 512 - 513 - /** 514 - * This is a model that extends the base model 515 - */ 516 - export const vCompositionExtendedModel = v.intersect([vCompositionBaseModel, v.object({ 517 - age: v.number(), 518 - firstName: v.string(), 519 - lastname: v.string() 520 - })]); 521 - 522 - /** 523 - * This is a model with one nested property 524 - */ 525 - export const vModelWithProperties = v.object({ 526 - required: v.string(), 527 - requiredAndReadOnly: v.pipe(v.string(), v.readonly()), 528 - requiredAndNullable: v.nullable(v.string()), 529 - string: v.optional(v.string()), 530 - number: v.optional(v.number()), 531 - boolean: v.optional(v.boolean()), 532 - reference: v.optional(vModelWithString), 533 - 'property with space': v.optional(v.string()), 534 - default: v.optional(v.string()), 535 - try: v.optional(v.string()), 536 - '@namespace.string': v.optional(v.pipe(v.string(), v.readonly())), 537 - '@namespace.integer': v.optional(v.pipe(v.pipe(v.number(), v.integer()), v.readonly())) 538 - }); 539 - 540 - /** 541 - * This is a model with one property containing a reference 542 - */ 543 - export const vModelWithReference = v.object({ 544 - prop: v.optional(vModelWithProperties) 545 - }); 546 - 547 - /** 548 - * This is a model with one nested property 549 - */ 550 - export const vModelWithNestedProperties = v.object({ 551 - first: v.nullable(v.pipe(v.object({ 552 - second: v.nullable(v.pipe(v.object({ 553 - third: v.nullable(v.pipe(v.string(), v.readonly())) 554 - }), v.readonly())) 555 - }), v.readonly())) 556 - }); 557 - 558 - /** 559 - * This is a model with duplicated properties 560 - */ 561 - export const vModelWithDuplicateProperties = v.object({ 562 - prop: v.optional(vModelWithString) 563 - }); 564 - 565 - /** 566 - * This is a model with ordered properties 567 - */ 568 - export const vModelWithOrderedProperties = v.object({ 569 - zebra: v.optional(v.string()), 570 - apple: v.optional(v.string()), 571 - hawaii: v.optional(v.string()) 572 - }); 573 - 574 - /** 575 - * This is a model with duplicated imports 576 - */ 577 - export const vModelWithDuplicateImports = v.object({ 578 - propA: v.optional(vModelWithString), 579 - propB: v.optional(vModelWithString), 580 - propC: v.optional(vModelWithString) 581 - }); 582 - 583 - /** 584 - * This is a model that extends another model 585 - */ 586 - export const vModelThatExtends = v.intersect([vModelWithString, v.object({ 587 - propExtendsA: v.optional(v.string()), 588 - propExtendsB: v.optional(vModelWithString) 589 - })]); 590 - 591 - /** 592 - * This is a model that extends another model 593 - */ 594 - export const vModelThatExtendsExtends = v.intersect([ 595 - vModelWithString, 596 - vModelThatExtends, 597 - v.object({ 598 - propExtendsC: v.optional(v.string()), 599 - propExtendsD: v.optional(vModelWithString) 600 - }) 601 - ]); 602 - 603 - /** 604 - * This is a model that contains a some patterns 605 - */ 606 - export const vModelWithPattern = v.object({ 607 - key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), 608 - name: v.pipe(v.string(), v.maxLength(255)), 609 - enabled: v.optional(v.pipe(v.boolean(), v.readonly())), 610 - modified: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 611 - id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), 612 - text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), 613 - patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), 614 - patternWithNewline: v.optional(v.pipe(v.string(), v.regex(/aaa\nbbb/))), 615 - patternWithBacktick: v.optional(v.pipe(v.string(), v.regex(/aaa`bbb/))), 616 - patternWithUnicode: v.optional(v.pipe(v.string(), v.regex(/^\p{L}+$/u))) 617 - }); 618 - 619 - export const vFile = v.object({ 620 - id: v.optional(v.pipe(v.pipe(v.string(), v.minLength(1)), v.readonly())), 621 - updated_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 622 - created_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 623 - mime: v.pipe(v.string(), v.minLength(1), v.maxLength(24)), 624 - file: v.optional(v.pipe(v.pipe(v.string(), v.url()), v.readonly())) 625 - }); 626 - 627 - export const vDefault = v.object({ 628 - name: v.optional(v.string()) 629 - }); 630 - 631 - export const vPageable = v.object({ 632 - page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), 0), 633 - size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))), 634 - sort: v.optional(v.array(v.string())) 635 - }); 636 - 637 - /** 638 - * This is a free-form object without additionalProperties. 639 - */ 640 - export const vFreeFormObjectWithoutAdditionalProperties = v.record(v.string(), v.unknown()); 641 - 642 - /** 643 - * This is a free-form object with additionalProperties: true. 644 - */ 645 - export const vFreeFormObjectWithAdditionalPropertiesEqTrue = v.record(v.string(), v.unknown()); 646 - 647 - /** 648 - * This is a free-form object with additionalProperties: {}. 649 - */ 650 - export const vFreeFormObjectWithAdditionalPropertiesEqEmptyObject = v.record(v.string(), v.unknown()); 651 - 652 - export const vModelWithConst = v.object({ 653 - String: v.optional(v.picklist(['String'])), 654 - number: v.optional(v.unknown()), 655 - null: v.optional(v.unknown()), 656 - withType: v.optional(v.picklist(['Some string'])) 657 - }); 658 - 659 - /** 660 - * This is a model with one property and additionalProperties: true 661 - */ 662 - export const vModelWithAdditionalPropertiesEqTrue = v.objectWithRest({ 663 - prop: v.optional(v.string()) 664 - }, v.unknown()); 665 - 666 - export const vNestedAnyOfArraysNullable = v.object({ 667 - nullableArray: v.nullish(v.array(v.unknown())) 668 - }); 669 - 670 - /** 671 - * An object that can be null 672 - */ 673 - export const vNullableObject = v.nullish(v.object({ 674 - foo: v.optional(v.string()) 675 - }), null); 676 - 677 - /** 678 - * Some % character 679 - */ 680 - export const vCharactersInDescription = v.string(); 681 - 682 - export const vModelWithNullableObject = v.object({ 683 - data: v.optional(vNullableObject) 684 - }); 685 - 686 - /** 687 - * An object with additional properties that can be null 688 - */ 689 - export const vModelWithAdditionalPropertiesRef = v.object({}); 690 - 691 - export const vModelWithOneOfEnum = v.union([ 692 - v.object({ 693 - foo: v.picklist(['Bar']) 694 - }), 695 - v.object({ 696 - foo: v.picklist(['Baz']) 697 - }), 698 - v.object({ 699 - foo: v.picklist(['Qux']) 700 - }), 701 - v.object({ 702 - content: v.pipe(v.string(), v.isoTimestamp()), 703 - foo: v.picklist(['Quux']) 704 - }), 705 - v.object({ 706 - content: v.tuple([v.pipe(v.string(), v.isoTimestamp()), v.pipe(v.string(), v.isoTimestamp())]), 707 - foo: v.picklist(['Corge']) 708 - }) 709 - ]); 710 - 711 - export const vModelWithNestedArrayEnumsDataFoo = v.picklist(['foo', 'bar']); 712 - 713 - export const vModelWithNestedArrayEnumsDataBar = v.picklist(['baz', 'qux']); 714 - 715 - export const vModelWithNestedArrayEnumsData = v.object({ 716 - foo: v.optional(v.array(vModelWithNestedArrayEnumsDataFoo)), 717 - bar: v.optional(v.array(vModelWithNestedArrayEnumsDataBar)) 718 - }); 719 - 720 - export const vModelWithNestedArrayEnums = v.object({ 721 - array_strings: v.optional(v.array(v.string())), 722 - data: v.optional(vModelWithNestedArrayEnumsData) 723 - }); 724 - 725 - export const vModelWithNestedCompositionEnums = v.object({ 726 - foo: v.optional(vModelWithNestedArrayEnumsDataFoo) 727 - }); 728 - 729 - export const vModelWithReadOnlyAndWriteOnly = v.object({ 730 - foo: v.string(), 731 - bar: v.pipe(v.string(), v.readonly()) 732 - }); 733 - 734 - /** 735 - * This is a model with one property containing an array 736 - */ 737 - export const vModelWithArrayReadOnlyAndWriteOnly = v.object({ 738 - prop: v.optional(v.array(vModelWithReadOnlyAndWriteOnly)), 739 - propWithFile: v.optional(v.array(v.string())), 740 - propWithNumber: v.optional(v.array(v.number())) 741 - }); 742 - 743 - export const vModelWithConstantSizeArray = v.tuple([v.number(), v.number()]); 744 - 745 - export const vModelWithAnyOfConstantSizeArray = v.tuple([ 746 - v.union([v.number(), v.string()]), 747 - v.union([v.number(), v.string()]), 748 - v.union([v.number(), v.string()]) 749 - ]); 750 - 751 - export const vModelWithPrefixItemsConstantSizeArray = v.array(v.unknown()); 752 - 753 - export const vModelWithAnyOfConstantSizeArrayNullable = v.tuple([ 754 - v.nullable(v.union([v.number(), v.string()])), 755 - v.nullable(v.union([v.number(), v.string()])), 756 - v.nullable(v.union([v.number(), v.string()])) 757 - ]); 758 - 759 - export const vModelWithAnyOfConstantSizeArrayAndIntersect = v.tuple([v.intersect([v.number(), v.string()]), v.intersect([v.number(), v.string()])]); 760 - 761 - export const vModelWithNumericEnumUnion = v.object({ 762 - value: v.optional(v.unknown()) 763 - }); 764 - 765 - /** 766 - * Some description with `back ticks` 767 - */ 768 - export const vModelWithBackticksInDescription = v.object({ 769 - template: v.optional(v.string()) 770 - }); 771 - 772 - /** 773 - * Model used to test deduplication strategy (unused) 774 - */ 775 - export const vParameterSimpleParameterUnused = v.string(); 776 - 777 - /** 778 - * Model used to test deduplication strategy 779 - */ 780 - export const vPostServiceWithEmptyTagResponse = v.string(); 781 - 782 - /** 783 - * Model used to test deduplication strategy 784 - */ 785 - export const vPostServiceWithEmptyTagResponse2 = v.string(); 786 - 787 - /** 788 - * Model used to test deduplication strategy 789 - */ 790 - export const vDeleteFooData = v.string(); 791 - 792 - /** 793 - * Model used to test deduplication strategy 794 - */ 795 - export const vDeleteFooData2 = v.string(); 796 - 797 - /** 798 - * Model with restricted keyword name 799 - */ 800 - export const vImport = v.string(); 801 - 802 - export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); 803 - 804 - export const vSchemaWithFormRestrictedKeys = v.object({ 805 - description: v.optional(v.string()), 806 - 'x-enum-descriptions': v.optional(v.string()), 807 - 'x-enum-varnames': v.optional(v.string()), 808 - 'x-enumNames': v.optional(v.string()), 809 - title: v.optional(v.string()), 810 - object: v.optional(v.object({ 811 - description: v.optional(v.string()), 812 - 'x-enum-descriptions': v.optional(v.string()), 813 - 'x-enum-varnames': v.optional(v.string()), 814 - 'x-enumNames': v.optional(v.string()), 815 - title: v.optional(v.string()) 816 - })), 817 - array: v.optional(v.array(v.object({ 818 - description: v.optional(v.string()), 819 - 'x-enum-descriptions': v.optional(v.string()), 820 - 'x-enum-varnames': v.optional(v.string()), 821 - 'x-enumNames': v.optional(v.string()), 822 - title: v.optional(v.string()) 823 - }))) 824 - }); 825 - 826 - /** 827 - * This schema was giving PascalCase transformations a hard time 828 - */ 829 - export const vIoK8sApimachineryPkgApisMetaV1Preconditions = v.object({ 830 - resourceVersion: v.optional(v.string()), 831 - uid: v.optional(v.string()) 832 - }); 833 - 834 - /** 835 - * This schema was giving PascalCase transformations a hard time 836 - */ 837 - export const vIoK8sApimachineryPkgApisMetaV1DeleteOptions = v.object({ 838 - preconditions: v.optional(vIoK8sApimachineryPkgApisMetaV1Preconditions) 839 - }); 840 - 841 - export const vAdditionalPropertiesUnknownIssue = v.object({}); 842 - 843 - export const vAdditionalPropertiesUnknownIssue2 = v.object({}); 844 - 845 - export const vAdditionalPropertiesUnknownIssue3 = v.intersect([v.string(), v.object({ 846 - entries: v.object({}) 847 - })]); 848 - 849 - export const vAdditionalPropertiesIntegerIssue = v.objectWithRest({ 850 - value: v.pipe(v.number(), v.integer()) 851 - }, v.pipe(v.number(), v.integer())); 852 - 853 - export const vGenericSchemaDuplicateIssue1SystemBoolean = v.strictObject({ 854 - item: v.optional(v.boolean()), 855 - error: v.nullish(v.string()), 856 - hasError: v.optional(v.pipe(v.boolean(), v.readonly())), 857 - data: v.optional(v.strictObject({})) 858 - }); 859 - 860 - export const vGenericSchemaDuplicateIssue1SystemString = v.strictObject({ 861 - item: v.nullish(v.string()), 862 - error: v.nullish(v.string()), 863 - hasError: v.optional(v.pipe(v.boolean(), v.readonly())) 864 - }); 865 - 866 - export const vOneOfAllOfIssue = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); 867 - 868 - export const vExternalSharedModel = v.object({ 869 - id: v.string(), 870 - name: v.optional(v.string()) 871 - }); 872 - 873 - export const vExternalRefA = vExternalSharedModel; 874 - 875 - export const vExternalRefB = vExternalSharedModel; 876 - 877 - /** 878 - * This is a model with one nested property 879 - */ 880 - export const vModelWithPropertiesWritable = v.object({ 881 - required: v.string(), 882 - requiredAndNullable: v.nullable(v.string()), 883 - string: v.optional(v.string()), 884 - number: v.optional(v.number()), 885 - boolean: v.optional(v.boolean()), 886 - reference: v.optional(vModelWithString), 887 - 'property with space': v.optional(v.string()), 888 - default: v.optional(v.string()), 889 - try: v.optional(v.string()) 890 - }); 891 - 892 - /** 893 - * This is a model with one property containing a reference 894 - */ 895 - export const vModelWithReferenceWritable = v.object({ 896 - prop: v.optional(vModelWithPropertiesWritable) 897 - }); 898 - 899 - /** 900 - * This is a model that contains a some patterns 901 - */ 902 - export const vModelWithPatternWritable = v.object({ 903 - key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), 904 - name: v.pipe(v.string(), v.maxLength(255)), 905 - id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), 906 - text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), 907 - patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), 908 - patternWithNewline: v.optional(v.pipe(v.string(), v.regex(/aaa\nbbb/))), 909 - patternWithBacktick: v.optional(v.pipe(v.string(), v.regex(/aaa`bbb/))), 910 - patternWithUnicode: v.optional(v.pipe(v.string(), v.regex(/^\p{L}+$/u))) 911 - }); 912 - 913 - export const vFileWritable = v.object({ 914 - mime: v.pipe(v.string(), v.minLength(1), v.maxLength(24)) 915 - }); 916 - 917 - export const vModelWithReadOnlyAndWriteOnlyWritable = v.object({ 918 - foo: v.string(), 919 - baz: v.string() 920 - }); 921 - 922 - /** 923 - * This is a model with one property containing an array 924 - */ 925 - export const vModelWithArrayReadOnlyAndWriteOnlyWritable = v.object({ 926 - prop: v.optional(v.array(vModelWithReadOnlyAndWriteOnlyWritable)), 927 - propWithFile: v.optional(v.array(v.string())), 928 - propWithNumber: v.optional(v.array(v.number())) 929 - }); 930 - 931 - export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); 932 - 933 - export const vAdditionalPropertiesUnknownIssueWritable = v.object({}); 934 - 935 - export const vOneOfAllOfIssueWritable = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); 936 - 937 - export const vGenericSchemaDuplicateIssue1SystemBooleanWritable = v.strictObject({ 938 - item: v.optional(v.boolean()), 939 - error: v.nullish(v.string()), 940 - data: v.optional(v.strictObject({})) 941 - }); 942 - 943 - export const vGenericSchemaDuplicateIssue1SystemStringWritable = v.strictObject({ 944 - item: v.nullish(v.string()), 945 - error: v.nullish(v.string()) 946 - }); 947 - 948 - /** 949 - * This is a reusable parameter 950 - */ 951 - export const vSimpleParameter = v.string(); 952 - 953 - export const vCompositionWithOneOfAndProperties = v.intersect([v.union([v.strictObject({ 954 - foo: vSimpleParameter 955 - }), v.strictObject({ 956 - bar: vNonAsciiStringæøåÆøÅöôêÊ字符串 957 - })]), v.object({ 958 - baz: v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'))), 959 - qux: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255')) 960 - })]); 961 - 962 - export const vModelWithOneOfAndProperties = v.intersect([v.union([vSimpleParameter, vNonAsciiStringæøåÆøÅöôêÊ字符串]), v.object({ 963 - baz: v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'))), 964 - qux: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255')) 965 - })]); 966 - 967 - /** 968 - * Parameter with illegal characters 969 - */ 970 - export const vXFooBar = vModelWithString; 971 - 972 - export const vSimpleRequestBody = vModelWithString; 973 - 974 - export const vSimpleFormData = vModelWithString; 975 - 976 - export const vExportData = v.object({ 977 - body: v.optional(v.never()), 978 - path: v.optional(v.never()), 979 - query: v.optional(v.never()) 980 - }); 981 - 982 - export const vPatchApiVbyApiVersionNoTagData = v.object({ 983 - body: v.optional(v.never()), 984 - path: v.optional(v.never()), 985 - query: v.optional(v.never()) 986 - }); 987 - 988 - export const vImportData = v.object({ 989 - body: v.union([vModelWithReadOnlyAndWriteOnlyWritable, vModelWithArrayReadOnlyAndWriteOnlyWritable]), 990 - path: v.optional(v.never()), 991 - query: v.optional(v.never()) 992 - }); 993 - 994 - export const vImportResponse = v.union([vModelFromZendesk, vModelWithReadOnlyAndWriteOnly]); 995 - 996 - export const vFooWowData = v.object({ 997 - body: v.optional(v.never()), 998 - path: v.optional(v.never()), 999 - query: v.optional(v.never()) 1000 - }); 1001 - 1002 - export const vApiVVersionODataControllerCountData = v.object({ 1003 - body: v.optional(v.never()), 1004 - path: v.optional(v.never()), 1005 - query: v.optional(v.never()) 1006 - }); 1007 - 1008 - /** 1009 - * Success 1010 - */ 1011 - export const vApiVVersionODataControllerCountResponse = vModelFromZendesk; 1012 - 1013 - export const vGetApiVbyApiVersionSimpleOperationData = v.object({ 1014 - body: v.optional(v.never()), 1015 - path: v.object({ 1016 - foo_param: v.string() 1017 - }), 1018 - query: v.optional(v.never()) 1019 - }); 1020 - 1021 - /** 1022 - * Response is a simple number 1023 - */ 1024 - export const vGetApiVbyApiVersionSimpleOperationResponse = v.number(); 1025 - 1026 - export const vDeleteCallWithoutParametersAndResponseData = v.object({ 1027 - body: v.optional(v.never()), 1028 - path: v.optional(v.never()), 1029 - query: v.optional(v.never()) 1030 - }); 1031 - 1032 - export const vGetCallWithoutParametersAndResponseData = v.object({ 1033 - body: v.optional(v.never()), 1034 - path: v.optional(v.never()), 1035 - query: v.optional(v.never()) 1036 - }); 1037 - 1038 - export const vHeadCallWithoutParametersAndResponseData = v.object({ 1039 - body: v.optional(v.never()), 1040 - path: v.optional(v.never()), 1041 - query: v.optional(v.never()) 1042 - }); 1043 - 1044 - export const vOptionsCallWithoutParametersAndResponseData = v.object({ 1045 - body: v.optional(v.never()), 1046 - path: v.optional(v.never()), 1047 - query: v.optional(v.never()) 1048 - }); 1049 - 1050 - export const vPatchCallWithoutParametersAndResponseData = v.object({ 1051 - body: v.optional(v.never()), 1052 - path: v.optional(v.never()), 1053 - query: v.optional(v.never()) 1054 - }); 1055 - 1056 - export const vPostCallWithoutParametersAndResponseData = v.object({ 1057 - body: v.optional(v.never()), 1058 - path: v.optional(v.never()), 1059 - query: v.optional(v.never()) 1060 - }); 1061 - 1062 - export const vPutCallWithoutParametersAndResponseData = v.object({ 1063 - body: v.optional(v.never()), 1064 - path: v.optional(v.never()), 1065 - query: v.optional(v.never()) 1066 - }); 1067 - 1068 - export const vDeleteFooData3 = v.object({ 1069 - body: v.optional(v.never()), 1070 - path: v.object({ 1071 - foo_param: v.string(), 1072 - BarParam: v.string() 1073 - }), 1074 - query: v.optional(v.never()), 1075 - headers: v.object({ 1076 - 'x-Foo-Bar': vModelWithString 1077 - }) 1078 - }); 1079 - 1080 - export const vCallWithDescriptionsData = v.object({ 1081 - body: v.optional(v.never()), 1082 - path: v.optional(v.never()), 1083 - query: v.optional(v.object({ 1084 - parameterWithBreaks: v.optional(v.string()), 1085 - parameterWithBackticks: v.optional(v.string()), 1086 - parameterWithSlashes: v.optional(v.string()), 1087 - parameterWithExpressionPlaceholders: v.optional(v.string()), 1088 - parameterWithQuotes: v.optional(v.string()), 1089 - parameterWithReservedCharacters: v.optional(v.string()) 1090 - })) 1091 - }); 1092 - 1093 - export const vDeprecatedCallData = v.object({ 1094 - body: v.optional(v.never()), 1095 - path: v.optional(v.never()), 1096 - query: v.optional(v.never()), 1097 - headers: v.object({ 1098 - parameter: v.nullable(vDeprecatedModel) 1099 - }) 1100 - }); 1101 - 1102 - export const vCallWithParametersData = v.object({ 1103 - body: v.nullable(v.record(v.string(), v.unknown())), 1104 - path: v.object({ 1105 - parameterPath: v.nullable(v.string()), 1106 - 'api-version': v.nullable(v.string()) 1107 - }), 1108 - query: v.object({ 1109 - foo_ref_enum: v.optional(vModelWithNestedArrayEnumsDataFoo), 1110 - foo_all_of_enum: vModelWithNestedArrayEnumsDataFoo, 1111 - cursor: v.nullable(v.string()) 1112 - }), 1113 - headers: v.object({ 1114 - parameterHeader: v.nullable(v.string()) 1115 - }) 1116 - }); 1117 - 1118 - export const vCallWithWeirdParameterNamesData = v.object({ 1119 - body: v.nullable(vModelWithString), 1120 - path: v.object({ 1121 - 'parameter.path.1': v.optional(v.string()), 1122 - 'parameter-path-2': v.optional(v.string()), 1123 - 'PARAMETER-PATH-3': v.optional(v.string()), 1124 - 'api-version': v.nullable(v.string()) 1125 - }), 1126 - query: v.object({ 1127 - default: v.optional(v.string()), 1128 - 'parameter-query': v.nullable(v.string()) 1129 - }), 1130 - headers: v.object({ 1131 - 'parameter.header': v.nullable(v.string()) 1132 - }) 1133 - }); 1134 - 1135 - export const vGetCallWithOptionalParamData = v.object({ 1136 - body: vModelWithOneOfEnum, 1137 - path: v.optional(v.never()), 1138 - query: v.optional(v.object({ 1139 - page: v.optional(v.number()) 1140 - })) 1141 - }); 1142 - 1143 - export const vPostCallWithOptionalParamData = v.object({ 1144 - body: v.optional(v.object({ 1145 - offset: v.nullish(v.number()) 1146 - })), 1147 - path: v.optional(v.never()), 1148 - query: v.object({ 1149 - parameter: vPageable 1150 - }) 1151 - }); 1152 - 1153 - export const vPostCallWithOptionalParamResponse = v.union([v.number(), v.void()]); 1154 - 1155 - export const vPostApiVbyApiVersionRequestBodyData = v.object({ 1156 - body: v.optional(vSimpleRequestBody), 1157 - path: v.optional(v.never()), 1158 - query: v.optional(v.object({ 1159 - parameter: v.optional(v.string()) 1160 - })) 1161 - }); 1162 - 1163 - export const vPostApiVbyApiVersionFormDataData = v.object({ 1164 - body: v.optional(vSimpleFormData), 1165 - path: v.optional(v.never()), 1166 - query: v.optional(v.object({ 1167 - parameter: v.optional(v.string()) 1168 - })) 1169 - }); 1170 - 1171 - export const vCallWithDefaultParametersData = v.object({ 1172 - body: v.optional(v.never()), 1173 - path: v.optional(v.never()), 1174 - query: v.optional(v.object({ 1175 - parameterString: v.nullish(v.string(), 'Hello World!'), 1176 - parameterNumber: v.nullish(v.number(), 123), 1177 - parameterBoolean: v.nullish(v.boolean(), true), 1178 - parameterEnum: v.optional(v.picklist([ 1179 - 'Success', 1180 - 'Warning', 1181 - 'Error' 1182 - ])), 1183 - parameterModel: v.nullish(vModelWithString) 1184 - })) 1185 - }); 1186 - 1187 - export const vCallWithDefaultOptionalParametersData = v.object({ 1188 - body: v.optional(v.never()), 1189 - path: v.optional(v.never()), 1190 - query: v.optional(v.object({ 1191 - parameterString: v.optional(v.string(), 'Hello World!'), 1192 - parameterNumber: v.optional(v.number(), 123), 1193 - parameterBoolean: v.optional(v.boolean(), true), 1194 - parameterEnum: v.optional(v.picklist([ 1195 - 'Success', 1196 - 'Warning', 1197 - 'Error' 1198 - ])), 1199 - parameterModel: v.optional(vModelWithString) 1200 - })) 1201 - }); 1202 - 1203 - export const vCallToTestOrderOfParamsData = v.object({ 1204 - body: v.optional(v.never()), 1205 - path: v.optional(v.never()), 1206 - query: v.object({ 1207 - parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), 1208 - parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ''), 1209 - parameterOptionalStringWithNoDefault: v.optional(v.string()), 1210 - parameterStringWithDefault: v.optional(v.string(), 'Hello World!'), 1211 - parameterStringWithEmptyDefault: v.optional(v.string(), ''), 1212 - parameterStringWithNoDefault: v.string(), 1213 - parameterStringNullableWithNoDefault: v.nullish(v.string()), 1214 - parameterStringNullableWithDefault: v.nullish(v.string(), null) 1215 - }) 1216 - }); 1217 - 1218 - export const vDuplicateNameData = v.object({ 1219 - body: v.optional(v.never()), 1220 - path: v.optional(v.never()), 1221 - query: v.optional(v.never()) 1222 - }); 1223 - 1224 - export const vDuplicateName2Data = v.object({ 1225 - body: v.optional(v.never()), 1226 - path: v.optional(v.never()), 1227 - query: v.optional(v.never()) 1228 - }); 1229 - 1230 - export const vDuplicateName3Data = v.object({ 1231 - body: v.optional(v.never()), 1232 - path: v.optional(v.never()), 1233 - query: v.optional(v.never()) 1234 - }); 1235 - 1236 - export const vDuplicateName4Data = v.object({ 1237 - body: v.optional(v.never()), 1238 - path: v.optional(v.never()), 1239 - query: v.optional(v.never()) 1240 - }); 1241 - 1242 - export const vCallWithNoContentResponseData = v.object({ 1243 - body: v.optional(v.never()), 1244 - path: v.optional(v.never()), 1245 - query: v.optional(v.never()) 1246 - }); 1247 - 1248 - /** 1249 - * Success 1250 - */ 1251 - export const vCallWithNoContentResponseResponse = v.void(); 1252 - 1253 - export const vCallWithResponseAndNoContentResponseData = v.object({ 1254 - body: v.optional(v.never()), 1255 - path: v.optional(v.never()), 1256 - query: v.optional(v.never()) 1257 - }); 1258 - 1259 - export const vCallWithResponseAndNoContentResponseResponse = v.union([v.number(), v.void()]); 1260 - 1261 - export const vDummyAData = v.object({ 1262 - body: v.optional(v.never()), 1263 - path: v.optional(v.never()), 1264 - query: v.optional(v.never()) 1265 - }); 1266 - 1267 - export const vDummyAResponse = v400; 1268 - 1269 - export const vDummyBData = v.object({ 1270 - body: v.optional(v.never()), 1271 - path: v.optional(v.never()), 1272 - query: v.optional(v.never()) 1273 - }); 1274 - 1275 - /** 1276 - * Success 1277 - */ 1278 - export const vDummyBResponse = v.void(); 1279 - 1280 - export const vCallWithResponseData = v.object({ 1281 - body: v.optional(v.never()), 1282 - path: v.optional(v.never()), 1283 - query: v.optional(v.never()) 1284 - }); 1285 - 1286 - export const vCallWithResponseResponse = vImport; 1287 - 1288 - export const vCallWithDuplicateResponsesData = v.object({ 1289 - body: v.optional(v.never()), 1290 - path: v.optional(v.never()), 1291 - query: v.optional(v.never()) 1292 - }); 1293 - 1294 - export const vCallWithDuplicateResponsesResponse = v.union([v.intersect([vModelWithBoolean, vModelWithInteger]), vModelWithString]); 1295 - 1296 - export const vCallWithResponsesData = v.object({ 1297 - body: v.optional(v.never()), 1298 - path: v.optional(v.never()), 1299 - query: v.optional(v.never()) 1300 - }); 1301 - 1302 - export const vCallWithResponsesResponse = v.union([ 1303 - v.object({ 1304 - '@namespace.string': v.optional(v.pipe(v.string(), v.readonly())), 1305 - '@namespace.integer': v.optional(v.pipe(v.pipe(v.number(), v.integer()), v.readonly())), 1306 - value: v.optional(v.pipe(v.array(vModelWithString), v.readonly())) 1307 - }), 1308 - vModelThatExtends, 1309 - vModelThatExtendsExtends 1310 - ]); 1311 - 1312 - export const vCollectionFormatData = v.object({ 1313 - body: v.optional(v.never()), 1314 - path: v.optional(v.never()), 1315 - query: v.object({ 1316 - parameterArrayCSV: v.nullable(v.array(v.string())), 1317 - parameterArraySSV: v.nullable(v.array(v.string())), 1318 - parameterArrayTSV: v.nullable(v.array(v.string())), 1319 - parameterArrayPipes: v.nullable(v.array(v.string())), 1320 - parameterArrayMulti: v.nullable(v.array(v.string())) 1321 - }) 1322 - }); 1323 - 1324 - export const vTypesData = v.object({ 1325 - body: v.optional(v.never()), 1326 - path: v.optional(v.object({ 1327 - id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))) 1328 - })), 1329 - query: v.object({ 1330 - parameterNumber: v.optional(v.number(), 123), 1331 - parameterString: v.nullish(v.string(), 'default'), 1332 - parameterBoolean: v.nullish(v.boolean(), true), 1333 - parameterObject: v.nullish(v.record(v.string(), v.unknown()), null), 1334 - parameterArray: v.nullable(v.array(v.string())), 1335 - parameterDictionary: v.nullable(v.record(v.string(), v.unknown())), 1336 - parameterEnum: v.picklist([ 1337 - 'Success', 1338 - 'Warning', 1339 - 'Error' 1340 - ]) 1341 - }) 1342 - }); 1343 - 1344 - export const vTypesResponse = v.union([ 1345 - v.number(), 1346 - v.string(), 1347 - v.boolean(), 1348 - v.record(v.string(), v.unknown()) 1349 - ]); 1350 - 1351 - export const vUploadFileData = v.object({ 1352 - body: v.string(), 1353 - path: v.object({ 1354 - 'api-version': v.nullable(v.string()) 1355 - }), 1356 - query: v.optional(v.never()) 1357 - }); 1358 - 1359 - export const vUploadFileResponse = v.boolean(); 1360 - 1361 - export const vFileResponseData = v.object({ 1362 - body: v.optional(v.never()), 1363 - path: v.object({ 1364 - id: v.string(), 1365 - 'api-version': v.string() 1366 - }), 1367 - query: v.optional(v.never()) 1368 - }); 1369 - 1370 - /** 1371 - * Success 1372 - */ 1373 - export const vFileResponseResponse = v.string(); 1374 - 1375 - export const vComplexTypesData = v.object({ 1376 - body: v.optional(v.never()), 1377 - path: v.optional(v.never()), 1378 - query: v.object({ 1379 - parameterObject: v.object({ 1380 - first: v.optional(v.object({ 1381 - second: v.optional(v.object({ 1382 - third: v.optional(v.string()) 1383 - })) 1384 - })) 1385 - }), 1386 - parameterReference: vModelWithString 1387 - }) 1388 - }); 1389 - 1390 - /** 1391 - * Successful response 1392 - */ 1393 - export const vComplexTypesResponse = v.array(vModelWithString); 1394 - 1395 - export const vMultipartResponseData = v.object({ 1396 - body: v.optional(v.never()), 1397 - path: v.optional(v.never()), 1398 - query: v.optional(v.never()) 1399 - }); 1400 - 1401 - /** 1402 - * OK 1403 - */ 1404 - export const vMultipartResponseResponse = v.object({ 1405 - file: v.optional(v.string()), 1406 - metadata: v.optional(v.object({ 1407 - foo: v.optional(v.string()), 1408 - bar: v.optional(v.string()) 1409 - })) 1410 - }); 1411 - 1412 - export const vMultipartRequestData = v.object({ 1413 - body: v.optional(v.object({ 1414 - content: v.optional(v.string()), 1415 - data: v.nullish(vModelWithString) 1416 - })), 1417 - path: v.optional(v.never()), 1418 - query: v.optional(v.never()) 1419 - }); 1420 - 1421 - export const vComplexParamsData = v.object({ 1422 - body: v.optional(v.object({ 1423 - key: v.nullable(v.pipe(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.readonly())), 1424 - name: v.nullable(v.pipe(v.string(), v.maxLength(255))), 1425 - enabled: v.optional(v.boolean(), true), 1426 - type: v.picklist([ 1427 - 'Monkey', 1428 - 'Horse', 1429 - 'Bird' 1430 - ]), 1431 - listOfModels: v.nullish(v.array(vModelWithString)), 1432 - listOfStrings: v.nullish(v.array(v.string())), 1433 - parameters: v.union([ 1434 - vModelWithString, 1435 - vModelWithEnum, 1436 - vModelWithArray, 1437 - vModelWithDictionary 1438 - ]), 1439 - user: v.optional(v.pipe(v.object({ 1440 - id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), v.readonly())), 1441 - name: v.nullish(v.pipe(v.string(), v.readonly())) 1442 - }), v.readonly())) 1443 - })), 1444 - path: v.object({ 1445 - id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), 1446 - 'api-version': v.string() 1447 - }), 1448 - query: v.optional(v.never()) 1449 - }); 1450 - 1451 - /** 1452 - * Success 1453 - */ 1454 - export const vComplexParamsResponse = vModelWithString; 1455 - 1456 - export const vCallWithResultFromHeaderData = v.object({ 1457 - body: v.optional(v.never()), 1458 - path: v.optional(v.never()), 1459 - query: v.optional(v.never()) 1460 - }); 1461 - 1462 - export const vTestErrorCodeData = v.object({ 1463 - body: v.optional(v.never()), 1464 - path: v.optional(v.never()), 1465 - query: v.object({ 1466 - status: v.pipe(v.number(), v.integer()) 1467 - }) 1468 - }); 1469 - 1470 - export const vNonAsciiæøåÆøÅöôêÊ字符串Data = v.object({ 1471 - body: v.optional(v.never()), 1472 - path: v.optional(v.never()), 1473 - query: v.object({ 1474 - nonAsciiParamæøåÆØÅöôêÊ: v.pipe(v.number(), v.integer()) 1475 - }) 1476 - }); 1477 - 1478 - /** 1479 - * Successful response 1480 - */ 1481 - export const vNonAsciiæøåÆøÅöôêÊ字符串Response = v.array(vNonAsciiStringæøåÆøÅöôêÊ字符串); 1482 - 1483 - export const vPutWithFormUrlEncodedData = v.object({ 1484 - body: vArrayWithStrings, 1485 - path: v.optional(v.never()), 1486 - query: v.optional(v.never()) 1487 - });
-19
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type ClientOptions = { 4 - baseUrl: `${string}://${string}` | (string & {}); 5 - }; 6 - 7 - export type Foo = { 8 - type?: TypeEnum; 9 - }; 10 - 11 - export const TypeEnum = { 12 - FOO: 'foo', 13 - BAR: 'bar', 14 - FOO_BAR: 'FooBar', 15 - FOO_BAR2: 'fooBar', 16 - FOO_BAR3: 'foo bar' 17 - } as const; 18 - 19 - export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum];
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.0.x/validators/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/array-items-one-of-length-1/valibot.gen.ts
-548
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs
··· 1 - 2 - //#region src/core/auth.ts 3 - const getAuthToken = async (auth, callback) => { 4 - const token = typeof callback === "function" ? await callback(auth) : callback; 5 - if (!token) return; 6 - if (auth.scheme === "bearer") return `Bearer ${token}`; 7 - if (auth.scheme === "basic") return `Basic ${btoa(token)}`; 8 - return token; 9 - }; 10 - 11 - //#endregion 12 - //#region src/core/bodySerializer.ts 13 - const serializeFormDataPair = (data, key, value) => { 14 - if (typeof value === "string" || value instanceof Blob) data.append(key, value); 15 - else data.append(key, JSON.stringify(value)); 16 - }; 17 - const serializeUrlSearchParamsPair = (data, key, value) => { 18 - if (typeof value === "string") data.append(key, value); 19 - else data.append(key, JSON.stringify(value)); 20 - }; 21 - const formDataBodySerializer = { bodySerializer: (body) => { 22 - const data = new FormData(); 23 - Object.entries(body).forEach(([key, value]) => { 24 - if (value === void 0 || value === null) return; 25 - if (Array.isArray(value)) value.forEach((v) => serializeFormDataPair(data, key, v)); 26 - else serializeFormDataPair(data, key, value); 27 - }); 28 - return data; 29 - } }; 30 - const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) }; 31 - const urlSearchParamsBodySerializer = { bodySerializer: (body) => { 32 - const data = new URLSearchParams(); 33 - Object.entries(body).forEach(([key, value]) => { 34 - if (value === void 0 || value === null) return; 35 - if (Array.isArray(value)) value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 36 - else serializeUrlSearchParamsPair(data, key, value); 37 - }); 38 - return data.toString(); 39 - } }; 40 - 41 - //#endregion 42 - //#region src/core/pathSerializer.ts 43 - const separatorArrayExplode = (style) => { 44 - switch (style) { 45 - case "label": return "."; 46 - case "matrix": return ";"; 47 - case "simple": return ","; 48 - default: return "&"; 49 - } 50 - }; 51 - const separatorArrayNoExplode = (style) => { 52 - switch (style) { 53 - case "form": return ","; 54 - case "pipeDelimited": return "|"; 55 - case "spaceDelimited": return "%20"; 56 - default: return ","; 57 - } 58 - }; 59 - const separatorObjectExplode = (style) => { 60 - switch (style) { 61 - case "label": return "."; 62 - case "matrix": return ";"; 63 - case "simple": return ","; 64 - default: return "&"; 65 - } 66 - }; 67 - const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => { 68 - if (!explode) { 69 - const joinedValues$1 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style)); 70 - switch (style) { 71 - case "label": return `.${joinedValues$1}`; 72 - case "matrix": return `;${name}=${joinedValues$1}`; 73 - case "simple": return joinedValues$1; 74 - default: return `${name}=${joinedValues$1}`; 75 - } 76 - } 77 - const separator = separatorArrayExplode(style); 78 - const joinedValues = value.map((v) => { 79 - if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v); 80 - return serializePrimitiveParam({ 81 - allowReserved, 82 - name, 83 - value: v 84 - }); 85 - }).join(separator); 86 - return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues; 87 - }; 88 - const serializePrimitiveParam = ({ allowReserved, name, value }) => { 89 - if (value === void 0 || value === null) return ""; 90 - if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these."); 91 - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 92 - }; 93 - const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => { 94 - if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 95 - if (style !== "deepObject" && !explode) { 96 - let values = []; 97 - Object.entries(value).forEach(([key, v]) => { 98 - values = [ 99 - ...values, 100 - key, 101 - allowReserved ? v : encodeURIComponent(v) 102 - ]; 103 - }); 104 - const joinedValues$1 = values.join(","); 105 - switch (style) { 106 - case "form": return `${name}=${joinedValues$1}`; 107 - case "label": return `.${joinedValues$1}`; 108 - case "matrix": return `;${name}=${joinedValues$1}`; 109 - default: return joinedValues$1; 110 - } 111 - } 112 - const separator = separatorObjectExplode(style); 113 - const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({ 114 - allowReserved, 115 - name: style === "deepObject" ? `${name}[${key}]` : key, 116 - value: v 117 - })).join(separator); 118 - return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues; 119 - }; 120 - 121 - //#endregion 122 - //#region src/utils.ts 123 - const PATH_PARAM_RE = /\{[^{}]+\}/g; 124 - const defaultPathSerializer = ({ path, url: _url }) => { 125 - let url = _url; 126 - const matches = _url.match(PATH_PARAM_RE); 127 - if (matches) for (const match of matches) { 128 - let explode = false; 129 - let name = match.substring(1, match.length - 1); 130 - let style = "simple"; 131 - if (name.endsWith("*")) { 132 - explode = true; 133 - name = name.substring(0, name.length - 1); 134 - } 135 - if (name.startsWith(".")) { 136 - name = name.substring(1); 137 - style = "label"; 138 - } else if (name.startsWith(";")) { 139 - name = name.substring(1); 140 - style = "matrix"; 141 - } 142 - const value = path[name]; 143 - if (value === void 0 || value === null) continue; 144 - if (Array.isArray(value)) { 145 - url = url.replace(match, serializeArrayParam({ 146 - explode, 147 - name, 148 - style, 149 - value 150 - })); 151 - continue; 152 - } 153 - if (typeof value === "object") { 154 - url = url.replace(match, serializeObjectParam({ 155 - explode, 156 - name, 157 - style, 158 - value, 159 - valueOnly: true 160 - })); 161 - continue; 162 - } 163 - if (style === "matrix") { 164 - url = url.replace(match, `;${serializePrimitiveParam({ 165 - name, 166 - value 167 - })}`); 168 - continue; 169 - } 170 - const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value); 171 - url = url.replace(match, replaceValue); 172 - } 173 - return url; 174 - }; 175 - const createQuerySerializer = ({ allowReserved, array, object } = {}) => { 176 - const querySerializer = (queryParams) => { 177 - const search = []; 178 - if (queryParams && typeof queryParams === "object") for (const name in queryParams) { 179 - const value = queryParams[name]; 180 - if (value === void 0 || value === null) continue; 181 - if (Array.isArray(value)) { 182 - const serializedArray = serializeArrayParam({ 183 - allowReserved, 184 - explode: true, 185 - name, 186 - style: "form", 187 - value, 188 - ...array 189 - }); 190 - if (serializedArray) search.push(serializedArray); 191 - } else if (typeof value === "object") { 192 - const serializedObject = serializeObjectParam({ 193 - allowReserved, 194 - explode: true, 195 - name, 196 - style: "deepObject", 197 - value, 198 - ...object 199 - }); 200 - if (serializedObject) search.push(serializedObject); 201 - } else { 202 - const serializedPrimitive = serializePrimitiveParam({ 203 - allowReserved, 204 - name, 205 - value 206 - }); 207 - if (serializedPrimitive) search.push(serializedPrimitive); 208 - } 209 - } 210 - return search.join("&"); 211 - }; 212 - return querySerializer; 213 - }; 214 - /** 215 - * Infers parseAs value from provided Content-Type header. 216 - */ 217 - const getParseAs = (contentType) => { 218 - if (!contentType) return "stream"; 219 - const cleanContent = contentType.split(";")[0]?.trim(); 220 - if (!cleanContent) return; 221 - if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json"; 222 - if (cleanContent === "multipart/form-data") return "formData"; 223 - if ([ 224 - "application/", 225 - "audio/", 226 - "image/", 227 - "video/" 228 - ].some((type) => cleanContent.startsWith(type))) return "blob"; 229 - if (cleanContent.startsWith("text/")) return "text"; 230 - }; 231 - const checkForExistence = (options, name) => { 232 - if (!name) return false; 233 - if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true; 234 - return false; 235 - }; 236 - const setAuthParams = async ({ security, ...options }) => { 237 - for (const auth of security) { 238 - if (checkForExistence(options, auth.name)) continue; 239 - const token = await getAuthToken(auth, options.auth); 240 - if (!token) continue; 241 - const name = auth.name ?? "Authorization"; 242 - switch (auth.in) { 243 - case "query": 244 - if (!options.query) options.query = {}; 245 - options.query[name] = token; 246 - break; 247 - case "cookie": 248 - options.headers.append("Cookie", `${name}=${token}`); 249 - break; 250 - case "header": 251 - default: 252 - options.headers.set(name, token); 253 - break; 254 - } 255 - } 256 - }; 257 - const buildUrl = (options) => { 258 - return getUrl({ 259 - baseUrl: options.baseUrl, 260 - path: options.path, 261 - query: options.query, 262 - querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer), 263 - url: options.url 264 - }); 265 - }; 266 - const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => { 267 - const pathUrl = _url.startsWith("/") ? _url : `/${_url}`; 268 - let url = (baseUrl ?? "") + pathUrl; 269 - if (path) url = defaultPathSerializer({ 270 - path, 271 - url 272 - }); 273 - let search = query ? querySerializer(query) : ""; 274 - if (search.startsWith("?")) search = search.substring(1); 275 - if (search) url += `?${search}`; 276 - return url; 277 - }; 278 - const mergeConfigs = (a, b) => { 279 - const config = { 280 - ...a, 281 - ...b 282 - }; 283 - if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 284 - config.headers = mergeHeaders(a.headers, b.headers); 285 - return config; 286 - }; 287 - const mergeHeaders = (...headers) => { 288 - const mergedHeaders = new Headers(); 289 - for (const header of headers) { 290 - if (!header || typeof header !== "object") continue; 291 - const iterator = header instanceof Headers ? header.entries() : Object.entries(header); 292 - for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key); 293 - else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v); 294 - else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value); 295 - } 296 - return mergedHeaders; 297 - }; 298 - var Interceptors = class { 299 - fns = []; 300 - clear() { 301 - this.fns = []; 302 - } 303 - eject(id) { 304 - const index = this.getInterceptorIndex(id); 305 - if (this.fns[index]) this.fns[index] = null; 306 - } 307 - exists(id) { 308 - const index = this.getInterceptorIndex(id); 309 - return Boolean(this.fns[index]); 310 - } 311 - getInterceptorIndex(id) { 312 - if (typeof id === "number") return this.fns[id] ? id : -1; 313 - return this.fns.indexOf(id); 314 - } 315 - update(id, fn) { 316 - const index = this.getInterceptorIndex(id); 317 - if (this.fns[index]) { 318 - this.fns[index] = fn; 319 - return id; 320 - } 321 - return false; 322 - } 323 - use(fn) { 324 - this.fns.push(fn); 325 - return this.fns.length - 1; 326 - } 327 - }; 328 - const createInterceptors = () => ({ 329 - error: new Interceptors(), 330 - request: new Interceptors(), 331 - response: new Interceptors() 332 - }); 333 - const defaultQuerySerializer = createQuerySerializer({ 334 - allowReserved: false, 335 - array: { 336 - explode: true, 337 - style: "form" 338 - }, 339 - object: { 340 - explode: true, 341 - style: "deepObject" 342 - } 343 - }); 344 - const defaultHeaders = { "Content-Type": "application/json" }; 345 - const createConfig = (override = {}) => ({ 346 - ...jsonBodySerializer, 347 - headers: defaultHeaders, 348 - parseAs: "auto", 349 - querySerializer: defaultQuerySerializer, 350 - ...override 351 - }); 352 - 353 - //#endregion 354 - //#region src/client.ts 355 - const createClient = (config = {}) => { 356 - let _config = mergeConfigs(createConfig(), config); 357 - const getConfig = () => ({ ..._config }); 358 - const setConfig = (config$1) => { 359 - _config = mergeConfigs(_config, config$1); 360 - return getConfig(); 361 - }; 362 - const interceptors = createInterceptors(); 363 - const request = async (options) => { 364 - const opts = { 365 - ..._config, 366 - ...options, 367 - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 368 - headers: mergeHeaders(_config.headers, options.headers) 369 - }; 370 - if (opts.security) await setAuthParams({ 371 - ...opts, 372 - security: opts.security 373 - }); 374 - if (opts.requestValidator) await opts.requestValidator(opts); 375 - if (opts.body && opts.bodySerializer) opts.body = opts.bodySerializer(opts.body); 376 - if (opts.body === void 0 || opts.body === "") opts.headers.delete("Content-Type"); 377 - const url = buildUrl(opts); 378 - const requestInit = { 379 - redirect: "follow", 380 - ...opts 381 - }; 382 - let request$1 = new Request(url, requestInit); 383 - for (const fn of interceptors.request.fns) if (fn) request$1 = await fn(request$1, opts); 384 - const _fetch = opts.fetch; 385 - let response = await _fetch(request$1); 386 - for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request$1, opts); 387 - const result = { 388 - request: request$1, 389 - response 390 - }; 391 - if (response.ok) { 392 - if (response.status === 204 || response.headers.get("Content-Length") === "0") return { 393 - data: {}, 394 - ...result 395 - }; 396 - const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json"; 397 - let data; 398 - switch (parseAs) { 399 - case "arrayBuffer": 400 - case "blob": 401 - case "formData": 402 - case "text": 403 - data = await response[parseAs](); 404 - break; 405 - case "json": { 406 - const text = await response.text(); 407 - data = text ? JSON.parse(text) : {}; 408 - break; 409 - } 410 - case "stream": return { 411 - data: response.body, 412 - ...result 413 - }; 414 - } 415 - if (parseAs === "json") { 416 - if (opts.responseValidator) await opts.responseValidator(data); 417 - if (opts.responseTransformer) data = await opts.responseTransformer(data); 418 - } 419 - return { 420 - data, 421 - ...result 422 - }; 423 - } 424 - let error = await response.text(); 425 - try { 426 - error = JSON.parse(error); 427 - } catch {} 428 - let finalError = error; 429 - for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request$1, opts); 430 - finalError = finalError || {}; 431 - if (opts.throwOnError) throw finalError; 432 - return { 433 - error: finalError, 434 - ...result 435 - }; 436 - }; 437 - return { 438 - buildUrl, 439 - connect: (options) => request({ 440 - ...options, 441 - method: "CONNECT" 442 - }), 443 - delete: (options) => request({ 444 - ...options, 445 - method: "DELETE" 446 - }), 447 - get: (options) => request({ 448 - ...options, 449 - method: "GET" 450 - }), 451 - getConfig, 452 - head: (options) => request({ 453 - ...options, 454 - method: "HEAD" 455 - }), 456 - interceptors, 457 - options: (options) => request({ 458 - ...options, 459 - method: "OPTIONS" 460 - }), 461 - patch: (options) => request({ 462 - ...options, 463 - method: "PATCH" 464 - }), 465 - post: (options) => request({ 466 - ...options, 467 - method: "POST" 468 - }), 469 - put: (options) => request({ 470 - ...options, 471 - method: "PUT" 472 - }), 473 - request, 474 - setConfig, 475 - trace: (options) => request({ 476 - ...options, 477 - method: "TRACE" 478 - }) 479 - }; 480 - }; 481 - 482 - //#endregion 483 - //#region src/core/params.ts 484 - const extraPrefixes = Object.entries({ 485 - $body_: "body", 486 - $headers_: "headers", 487 - $path_: "path", 488 - $query_: "query" 489 - }); 490 - const buildKeyMap = (fields, map) => { 491 - if (!map) map = /* @__PURE__ */ new Map(); 492 - for (const config of fields) if ("in" in config) { 493 - if (config.key) map.set(config.key, { 494 - in: config.in, 495 - map: config.map 496 - }); 497 - } else if (config.args) buildKeyMap(config.args, map); 498 - return map; 499 - }; 500 - const stripEmptySlots = (params) => { 501 - for (const [slot, value] of Object.entries(params)) if (value && typeof value === "object" && !Object.keys(value).length) delete params[slot]; 502 - }; 503 - const buildClientParams = (args, fields) => { 504 - const params = { 505 - body: {}, 506 - headers: {}, 507 - path: {}, 508 - query: {} 509 - }; 510 - const map = buildKeyMap(fields); 511 - let config; 512 - for (const [index, arg] of args.entries()) { 513 - if (fields[index]) config = fields[index]; 514 - if (!config) continue; 515 - if ("in" in config) if (config.key) { 516 - const field = map.get(config.key); 517 - const name = field.map || config.key; 518 - params[field.in][name] = arg; 519 - } else params.body = arg; 520 - else for (const [key, value] of Object.entries(arg ?? {})) { 521 - const field = map.get(key); 522 - if (field) { 523 - const name = field.map || key; 524 - params[field.in][name] = value; 525 - } else { 526 - const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)); 527 - if (extra) { 528 - const [prefix, slot] = extra; 529 - params[slot][key.slice(prefix.length)] = value; 530 - } else for (const [slot, allowed] of Object.entries(config.allowExtra ?? {})) if (allowed) { 531 - params[slot][key] = value; 532 - break; 533 - } 534 - } 535 - } 536 - } 537 - stripEmptySlots(params); 538 - return params; 539 - }; 540 - 541 - //#endregion 542 - exports.buildClientParams = buildClientParams; 543 - exports.createClient = createClient; 544 - exports.createConfig = createConfig; 545 - exports.formDataBodySerializer = formDataBodySerializer; 546 - exports.jsonBodySerializer = jsonBodySerializer; 547 - exports.urlSearchParamsBodySerializer = urlSearchParamsBodySerializer; 548 - //# sourceMappingURL=index.cjs.map
-271
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts
··· 1 - //#region src/core/auth.d.ts 2 - type AuthToken = string | undefined; 3 - interface Auth { 4 - /** 5 - * Which part of the request do we use to send the auth? 6 - * 7 - * @default 'header' 8 - */ 9 - in?: 'header' | 'query' | 'cookie'; 10 - /** 11 - * Header or query parameter name. 12 - * 13 - * @default 'Authorization' 14 - */ 15 - name?: string; 16 - scheme?: 'basic' | 'bearer'; 17 - type: 'apiKey' | 'http'; 18 - } 19 - //#endregion 20 - //#region src/core/pathSerializer.d.ts 21 - interface SerializerOptions<T> { 22 - /** 23 - * @default true 24 - */ 25 - explode: boolean; 26 - style: T; 27 - } 28 - type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 29 - type ObjectStyle = 'form' | 'deepObject'; 30 - //#endregion 31 - //#region src/core/bodySerializer.d.ts 32 - type QuerySerializer = (query: Record<string, unknown>) => string; 33 - type BodySerializer = (body: unknown) => unknown; 34 - type QuerySerializerOptionsObject = { 35 - allowReserved?: boolean; 36 - array?: Partial<SerializerOptions<ArrayStyle>>; 37 - object?: Partial<SerializerOptions<ObjectStyle>>; 38 - }; 39 - type QuerySerializerOptions = QuerySerializerOptionsObject & { 40 - /** 41 - * Per-parameter serialization overrides. When provided, these settings 42 - * override the global array/object settings for specific parameter names. 43 - */ 44 - parameters?: Record<string, QuerySerializerOptionsObject>; 45 - }; 46 - declare const formDataBodySerializer: { 47 - bodySerializer: (body: unknown) => FormData; 48 - }; 49 - declare const jsonBodySerializer: { 50 - bodySerializer: (body: unknown) => string; 51 - }; 52 - declare const urlSearchParamsBodySerializer: { 53 - bodySerializer: (body: unknown) => string; 54 - }; 55 - //#endregion 56 - //#region src/core/types.d.ts 57 - interface Client$1<RequestFn$1 = never, Config$2 = unknown, MethodFn$1 = never, BuildUrlFn$1 = never> { 58 - /** 59 - * Returns the final request URL. 60 - */ 61 - buildUrl: BuildUrlFn$1; 62 - connect: MethodFn$1; 63 - delete: MethodFn$1; 64 - get: MethodFn$1; 65 - getConfig: () => Config$2; 66 - head: MethodFn$1; 67 - options: MethodFn$1; 68 - patch: MethodFn$1; 69 - post: MethodFn$1; 70 - put: MethodFn$1; 71 - request: RequestFn$1; 72 - setConfig: (config: Config$2) => Config$2; 73 - trace: MethodFn$1; 74 - } 75 - interface Config$1 { 76 - /** 77 - * Auth token or a function returning auth token. The resolved value will be 78 - * added to the request payload as defined by its `security` array. 79 - */ 80 - auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 81 - /** 82 - * A function for serializing request body parameter. By default, 83 - * {@link JSON.stringify()} will be used. 84 - */ 85 - bodySerializer?: BodySerializer | null; 86 - /** 87 - * An object containing any HTTP headers that you want to pre-populate your 88 - * `Headers` object with. 89 - * 90 - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 91 - */ 92 - headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>; 93 - /** 94 - * The request method. 95 - * 96 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 97 - */ 98 - method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE'; 99 - /** 100 - * A function for serializing request query parameters. By default, arrays 101 - * will be exploded in form style, objects will be exploded in deepObject 102 - * style, and reserved characters are percent-encoded. 103 - * 104 - * This method will have no effect if the native `paramsSerializer()` Axios 105 - * API function is used. 106 - * 107 - * {@link https://swagger.io/docs/specification/serialization/#query View examples} 108 - */ 109 - querySerializer?: QuerySerializer | QuerySerializerOptions; 110 - /** 111 - * A function validating request data. This is useful if you want to ensure 112 - * the request conforms to the desired shape, so it can be safely sent to 113 - * the server. 114 - */ 115 - requestValidator?: (data: unknown) => Promise<unknown>; 116 - /** 117 - * A function transforming response data before it's returned. This is useful 118 - * for post-processing data, e.g. converting ISO strings into Date objects. 119 - */ 120 - responseTransformer?: (data: unknown) => Promise<unknown>; 121 - /** 122 - * A function validating response data. This is useful if you want to ensure 123 - * the response conforms to the desired shape, so it can be safely passed to 124 - * the transformers and returned to the user. 125 - */ 126 - responseValidator?: (data: unknown) => Promise<unknown>; 127 - } 128 - //#endregion 129 - //#region src/utils.d.ts 130 - type ErrInterceptor<Err, Res, Req, Options$1> = (error: Err, response: Res, request: Req, options: Options$1) => Err | Promise<Err>; 131 - type ReqInterceptor<Req, Options$1> = (request: Req, options: Options$1) => Req | Promise<Req>; 132 - type ResInterceptor<Res, Req, Options$1> = (response: Res, request: Req, options: Options$1) => Res | Promise<Res>; 133 - declare class Interceptors<Interceptor> { 134 - fns: Array<Interceptor | null>; 135 - clear(): void; 136 - eject(id: number | Interceptor): void; 137 - exists(id: number | Interceptor): boolean; 138 - getInterceptorIndex(id: number | Interceptor): number; 139 - update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; 140 - use(fn: Interceptor): number; 141 - } 142 - interface Middleware<Req, Res, Err, Options$1> { 143 - error: Interceptors<ErrInterceptor<Err, Res, Req, Options$1>>; 144 - request: Interceptors<ReqInterceptor<Req, Options$1>>; 145 - response: Interceptors<ResInterceptor<Res, Req, Options$1>>; 146 - } 147 - declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>; 148 - //#endregion 149 - //#region src/types.d.ts 150 - interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 { 151 - /** 152 - * Base URL for all requests made by this client. 153 - */ 154 - baseUrl?: T['baseUrl']; 155 - /** 156 - * Fetch API implementation. You can use this option to provide a custom 157 - * fetch instance. 158 - * 159 - * @default globalThis.fetch 160 - */ 161 - fetch?: (request: Request) => ReturnType<typeof fetch>; 162 - /** 163 - * Return the response data parsed in a specified format. By default, `auto` 164 - * will infer the appropriate method from the `Content-Type` response header. 165 - * You can override this behavior with any of the {@link Body} methods. 166 - * Select `stream` if you don't want to parse response data at all. 167 - * 168 - * @default 'auto' 169 - */ 170 - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 171 - /** 172 - * Throw an error instead of returning it in the response? 173 - * 174 - * @default false 175 - */ 176 - throwOnError?: T['throwOnError']; 177 - } 178 - interface RequestOptions<ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{ 179 - throwOnError: ThrowOnError; 180 - }> { 181 - /** 182 - * Any body that you want to add to your request. 183 - * 184 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 185 - */ 186 - body?: unknown; 187 - path?: Record<string, unknown>; 188 - query?: Record<string, unknown>; 189 - /** 190 - * Security mechanism(s) to use for the request. 191 - */ 192 - security?: ReadonlyArray<Auth>; 193 - url: Url; 194 - } 195 - type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<{ 196 - data: TData; 197 - request: Request; 198 - response: Response; 199 - }> : Promise<({ 200 - data: TData; 201 - error: undefined; 202 - } | { 203 - data: undefined; 204 - error: TError; 205 - }) & { 206 - request: Request; 207 - response: Response; 208 - }>; 209 - interface ClientOptions { 210 - baseUrl?: string; 211 - throwOnError?: boolean; 212 - } 213 - type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError>; 214 - type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'> & Pick<Required<RequestOptions<ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError>; 215 - type BuildUrlFn = <TData extends { 216 - body?: unknown; 217 - path?: Record<string, unknown>; 218 - query?: Record<string, unknown>; 219 - url: string; 220 - }>(options: Pick<TData, 'url'> & Options<TData>) => string; 221 - type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn> & { 222 - interceptors: Middleware<Request, Response, unknown, RequestOptions>; 223 - }; 224 - /** 225 - * The `createClientConfig()` function will be called on client initialization 226 - * and the returned object will become the client's initial configuration. 227 - * 228 - * You may want to initialize your client this way instead of calling 229 - * `setConfig()`. This is useful for example if you're using Next.js 230 - * to ensure your client always has the correct values. 231 - */ 232 - type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 233 - interface TDataShape { 234 - body?: unknown; 235 - headers?: unknown; 236 - path?: unknown; 237 - query?: unknown; 238 - url: string; 239 - } 240 - type OmitKeys<T, K$1> = Pick<T, Exclude<keyof T, K$1>>; 241 - type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>; 242 - //#endregion 243 - //#region src/client.d.ts 244 - declare const createClient: (config?: Config) => Client; 245 - //#endregion 246 - //#region src/core/params.d.ts 247 - type Slot = 'body' | 'headers' | 'path' | 'query'; 248 - type Field = { 249 - in: Exclude<Slot, 'body'>; 250 - key: string; 251 - map?: string; 252 - } | { 253 - in: Extract<Slot, 'body'>; 254 - key?: string; 255 - map?: string; 256 - }; 257 - interface Fields { 258 - allowExtra?: Partial<Record<Slot, boolean>>; 259 - args?: ReadonlyArray<Field>; 260 - } 261 - type FieldsConfig = ReadonlyArray<Field | Fields>; 262 - interface Params { 263 - body: unknown; 264 - headers: Record<string, unknown>; 265 - path: Record<string, unknown>; 266 - query: Record<string, unknown>; 267 - } 268 - declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 269 - //# sourceMappingURL=index.d.cts.map 270 - 271 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
-271
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.mts
··· 1 - //#region src/core/auth.d.ts 2 - type AuthToken = string | undefined; 3 - interface Auth { 4 - /** 5 - * Which part of the request do we use to send the auth? 6 - * 7 - * @default 'header' 8 - */ 9 - in?: 'header' | 'query' | 'cookie'; 10 - /** 11 - * Header or query parameter name. 12 - * 13 - * @default 'Authorization' 14 - */ 15 - name?: string; 16 - scheme?: 'basic' | 'bearer'; 17 - type: 'apiKey' | 'http'; 18 - } 19 - //#endregion 20 - //#region src/core/pathSerializer.d.ts 21 - interface SerializerOptions<T> { 22 - /** 23 - * @default true 24 - */ 25 - explode: boolean; 26 - style: T; 27 - } 28 - type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 29 - type ObjectStyle = 'form' | 'deepObject'; 30 - //#endregion 31 - //#region src/core/bodySerializer.d.ts 32 - type QuerySerializer = (query: Record<string, unknown>) => string; 33 - type BodySerializer = (body: unknown) => unknown; 34 - type QuerySerializerOptionsObject = { 35 - allowReserved?: boolean; 36 - array?: Partial<SerializerOptions<ArrayStyle>>; 37 - object?: Partial<SerializerOptions<ObjectStyle>>; 38 - }; 39 - type QuerySerializerOptions = QuerySerializerOptionsObject & { 40 - /** 41 - * Per-parameter serialization overrides. When provided, these settings 42 - * override the global array/object settings for specific parameter names. 43 - */ 44 - parameters?: Record<string, QuerySerializerOptionsObject>; 45 - }; 46 - declare const formDataBodySerializer: { 47 - bodySerializer: (body: unknown) => FormData; 48 - }; 49 - declare const jsonBodySerializer: { 50 - bodySerializer: (body: unknown) => string; 51 - }; 52 - declare const urlSearchParamsBodySerializer: { 53 - bodySerializer: (body: unknown) => string; 54 - }; 55 - //#endregion 56 - //#region src/core/types.d.ts 57 - interface Client$1<RequestFn$1 = never, Config$2 = unknown, MethodFn$1 = never, BuildUrlFn$1 = never> { 58 - /** 59 - * Returns the final request URL. 60 - */ 61 - buildUrl: BuildUrlFn$1; 62 - connect: MethodFn$1; 63 - delete: MethodFn$1; 64 - get: MethodFn$1; 65 - getConfig: () => Config$2; 66 - head: MethodFn$1; 67 - options: MethodFn$1; 68 - patch: MethodFn$1; 69 - post: MethodFn$1; 70 - put: MethodFn$1; 71 - request: RequestFn$1; 72 - setConfig: (config: Config$2) => Config$2; 73 - trace: MethodFn$1; 74 - } 75 - interface Config$1 { 76 - /** 77 - * Auth token or a function returning auth token. The resolved value will be 78 - * added to the request payload as defined by its `security` array. 79 - */ 80 - auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 81 - /** 82 - * A function for serializing request body parameter. By default, 83 - * {@link JSON.stringify()} will be used. 84 - */ 85 - bodySerializer?: BodySerializer | null; 86 - /** 87 - * An object containing any HTTP headers that you want to pre-populate your 88 - * `Headers` object with. 89 - * 90 - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 91 - */ 92 - headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>; 93 - /** 94 - * The request method. 95 - * 96 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 97 - */ 98 - method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE'; 99 - /** 100 - * A function for serializing request query parameters. By default, arrays 101 - * will be exploded in form style, objects will be exploded in deepObject 102 - * style, and reserved characters are percent-encoded. 103 - * 104 - * This method will have no effect if the native `paramsSerializer()` Axios 105 - * API function is used. 106 - * 107 - * {@link https://swagger.io/docs/specification/serialization/#query View examples} 108 - */ 109 - querySerializer?: QuerySerializer | QuerySerializerOptions; 110 - /** 111 - * A function validating request data. This is useful if you want to ensure 112 - * the request conforms to the desired shape, so it can be safely sent to 113 - * the server. 114 - */ 115 - requestValidator?: (data: unknown) => Promise<unknown>; 116 - /** 117 - * A function transforming response data before it's returned. This is useful 118 - * for post-processing data, e.g. converting ISO strings into Date objects. 119 - */ 120 - responseTransformer?: (data: unknown) => Promise<unknown>; 121 - /** 122 - * A function validating response data. This is useful if you want to ensure 123 - * the response conforms to the desired shape, so it can be safely passed to 124 - * the transformers and returned to the user. 125 - */ 126 - responseValidator?: (data: unknown) => Promise<unknown>; 127 - } 128 - //#endregion 129 - //#region src/utils.d.ts 130 - type ErrInterceptor<Err, Res, Req, Options$1> = (error: Err, response: Res, request: Req, options: Options$1) => Err | Promise<Err>; 131 - type ReqInterceptor<Req, Options$1> = (request: Req, options: Options$1) => Req | Promise<Req>; 132 - type ResInterceptor<Res, Req, Options$1> = (response: Res, request: Req, options: Options$1) => Res | Promise<Res>; 133 - declare class Interceptors<Interceptor> { 134 - fns: Array<Interceptor | null>; 135 - clear(): void; 136 - eject(id: number | Interceptor): void; 137 - exists(id: number | Interceptor): boolean; 138 - getInterceptorIndex(id: number | Interceptor): number; 139 - update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; 140 - use(fn: Interceptor): number; 141 - } 142 - interface Middleware<Req, Res, Err, Options$1> { 143 - error: Interceptors<ErrInterceptor<Err, Res, Req, Options$1>>; 144 - request: Interceptors<ReqInterceptor<Req, Options$1>>; 145 - response: Interceptors<ResInterceptor<Res, Req, Options$1>>; 146 - } 147 - declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>; 148 - //#endregion 149 - //#region src/types.d.ts 150 - interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 { 151 - /** 152 - * Base URL for all requests made by this client. 153 - */ 154 - baseUrl?: T['baseUrl']; 155 - /** 156 - * Fetch API implementation. You can use this option to provide a custom 157 - * fetch instance. 158 - * 159 - * @default globalThis.fetch 160 - */ 161 - fetch?: (request: Request) => ReturnType<typeof fetch>; 162 - /** 163 - * Return the response data parsed in a specified format. By default, `auto` 164 - * will infer the appropriate method from the `Content-Type` response header. 165 - * You can override this behavior with any of the {@link Body} methods. 166 - * Select `stream` if you don't want to parse response data at all. 167 - * 168 - * @default 'auto' 169 - */ 170 - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 171 - /** 172 - * Throw an error instead of returning it in the response? 173 - * 174 - * @default false 175 - */ 176 - throwOnError?: T['throwOnError']; 177 - } 178 - interface RequestOptions<ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{ 179 - throwOnError: ThrowOnError; 180 - }> { 181 - /** 182 - * Any body that you want to add to your request. 183 - * 184 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 185 - */ 186 - body?: unknown; 187 - path?: Record<string, unknown>; 188 - query?: Record<string, unknown>; 189 - /** 190 - * Security mechanism(s) to use for the request. 191 - */ 192 - security?: ReadonlyArray<Auth>; 193 - url: Url; 194 - } 195 - type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<{ 196 - data: TData; 197 - request: Request; 198 - response: Response; 199 - }> : Promise<({ 200 - data: TData; 201 - error: undefined; 202 - } | { 203 - data: undefined; 204 - error: TError; 205 - }) & { 206 - request: Request; 207 - response: Response; 208 - }>; 209 - interface ClientOptions { 210 - baseUrl?: string; 211 - throwOnError?: boolean; 212 - } 213 - type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError>; 214 - type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'> & Pick<Required<RequestOptions<ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError>; 215 - type BuildUrlFn = <TData extends { 216 - body?: unknown; 217 - path?: Record<string, unknown>; 218 - query?: Record<string, unknown>; 219 - url: string; 220 - }>(options: Pick<TData, 'url'> & Options<TData>) => string; 221 - type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn> & { 222 - interceptors: Middleware<Request, Response, unknown, RequestOptions>; 223 - }; 224 - /** 225 - * The `createClientConfig()` function will be called on client initialization 226 - * and the returned object will become the client's initial configuration. 227 - * 228 - * You may want to initialize your client this way instead of calling 229 - * `setConfig()`. This is useful for example if you're using Next.js 230 - * to ensure your client always has the correct values. 231 - */ 232 - type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 233 - interface TDataShape { 234 - body?: unknown; 235 - headers?: unknown; 236 - path?: unknown; 237 - query?: unknown; 238 - url: string; 239 - } 240 - type OmitKeys<T, K$1> = Pick<T, Exclude<keyof T, K$1>>; 241 - type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>; 242 - //#endregion 243 - //#region src/client.d.ts 244 - declare const createClient: (config?: Config) => Client; 245 - //#endregion 246 - //#region src/core/params.d.ts 247 - type Slot = 'body' | 'headers' | 'path' | 'query'; 248 - type Field = { 249 - in: Exclude<Slot, 'body'>; 250 - key: string; 251 - map?: string; 252 - } | { 253 - in: Extract<Slot, 'body'>; 254 - key?: string; 255 - map?: string; 256 - }; 257 - interface Fields { 258 - allowExtra?: Partial<Record<Slot, boolean>>; 259 - args?: ReadonlyArray<Field>; 260 - } 261 - type FieldsConfig = ReadonlyArray<Field | Fields>; 262 - interface Params { 263 - body: unknown; 264 - headers: Record<string, unknown>; 265 - path: Record<string, unknown>; 266 - query: Record<string, unknown>; 267 - } 268 - declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 269 - //# sourceMappingURL=index.d.mts.map 270 - 271 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
-271
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts
··· 1 - //#region src/core/auth.d.ts 2 - type AuthToken = string | undefined; 3 - interface Auth { 4 - /** 5 - * Which part of the request do we use to send the auth? 6 - * 7 - * @default 'header' 8 - */ 9 - in?: 'header' | 'query' | 'cookie'; 10 - /** 11 - * Header or query parameter name. 12 - * 13 - * @default 'Authorization' 14 - */ 15 - name?: string; 16 - scheme?: 'basic' | 'bearer'; 17 - type: 'apiKey' | 'http'; 18 - } 19 - //#endregion 20 - //#region src/core/pathSerializer.d.ts 21 - interface SerializerOptions<T> { 22 - /** 23 - * @default true 24 - */ 25 - explode: boolean; 26 - style: T; 27 - } 28 - type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 29 - type ObjectStyle = 'form' | 'deepObject'; 30 - //#endregion 31 - //#region src/core/bodySerializer.d.ts 32 - type QuerySerializer = (query: Record<string, unknown>) => string; 33 - type BodySerializer = (body: unknown) => unknown; 34 - type QuerySerializerOptionsObject = { 35 - allowReserved?: boolean; 36 - array?: Partial<SerializerOptions<ArrayStyle>>; 37 - object?: Partial<SerializerOptions<ObjectStyle>>; 38 - }; 39 - type QuerySerializerOptions = QuerySerializerOptionsObject & { 40 - /** 41 - * Per-parameter serialization overrides. When provided, these settings 42 - * override the global array/object settings for specific parameter names. 43 - */ 44 - parameters?: Record<string, QuerySerializerOptionsObject>; 45 - }; 46 - declare const formDataBodySerializer: { 47 - bodySerializer: (body: unknown) => FormData; 48 - }; 49 - declare const jsonBodySerializer: { 50 - bodySerializer: (body: unknown) => string; 51 - }; 52 - declare const urlSearchParamsBodySerializer: { 53 - bodySerializer: (body: unknown) => string; 54 - }; 55 - //#endregion 56 - //#region src/core/types.d.ts 57 - interface Client$1<RequestFn$1 = never, Config$2 = unknown, MethodFn$1 = never, BuildUrlFn$1 = never> { 58 - /** 59 - * Returns the final request URL. 60 - */ 61 - buildUrl: BuildUrlFn$1; 62 - connect: MethodFn$1; 63 - delete: MethodFn$1; 64 - get: MethodFn$1; 65 - getConfig: () => Config$2; 66 - head: MethodFn$1; 67 - options: MethodFn$1; 68 - patch: MethodFn$1; 69 - post: MethodFn$1; 70 - put: MethodFn$1; 71 - request: RequestFn$1; 72 - setConfig: (config: Config$2) => Config$2; 73 - trace: MethodFn$1; 74 - } 75 - interface Config$1 { 76 - /** 77 - * Auth token or a function returning auth token. The resolved value will be 78 - * added to the request payload as defined by its `security` array. 79 - */ 80 - auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 81 - /** 82 - * A function for serializing request body parameter. By default, 83 - * {@link JSON.stringify()} will be used. 84 - */ 85 - bodySerializer?: BodySerializer | null; 86 - /** 87 - * An object containing any HTTP headers that you want to pre-populate your 88 - * `Headers` object with. 89 - * 90 - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 91 - */ 92 - headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>; 93 - /** 94 - * The request method. 95 - * 96 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 97 - */ 98 - method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE'; 99 - /** 100 - * A function for serializing request query parameters. By default, arrays 101 - * will be exploded in form style, objects will be exploded in deepObject 102 - * style, and reserved characters are percent-encoded. 103 - * 104 - * This method will have no effect if the native `paramsSerializer()` Axios 105 - * API function is used. 106 - * 107 - * {@link https://swagger.io/docs/specification/serialization/#query View examples} 108 - */ 109 - querySerializer?: QuerySerializer | QuerySerializerOptions; 110 - /** 111 - * A function validating request data. This is useful if you want to ensure 112 - * the request conforms to the desired shape, so it can be safely sent to 113 - * the server. 114 - */ 115 - requestValidator?: (data: unknown) => Promise<unknown>; 116 - /** 117 - * A function transforming response data before it's returned. This is useful 118 - * for post-processing data, e.g. converting ISO strings into Date objects. 119 - */ 120 - responseTransformer?: (data: unknown) => Promise<unknown>; 121 - /** 122 - * A function validating response data. This is useful if you want to ensure 123 - * the response conforms to the desired shape, so it can be safely passed to 124 - * the transformers and returned to the user. 125 - */ 126 - responseValidator?: (data: unknown) => Promise<unknown>; 127 - } 128 - //#endregion 129 - //#region src/utils.d.ts 130 - type ErrInterceptor<Err, Res, Req, Options$1> = (error: Err, response: Res, request: Req, options: Options$1) => Err | Promise<Err>; 131 - type ReqInterceptor<Req, Options$1> = (request: Req, options: Options$1) => Req | Promise<Req>; 132 - type ResInterceptor<Res, Req, Options$1> = (response: Res, request: Req, options: Options$1) => Res | Promise<Res>; 133 - declare class Interceptors<Interceptor> { 134 - fns: Array<Interceptor | null>; 135 - clear(): void; 136 - eject(id: number | Interceptor): void; 137 - exists(id: number | Interceptor): boolean; 138 - getInterceptorIndex(id: number | Interceptor): number; 139 - update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; 140 - use(fn: Interceptor): number; 141 - } 142 - interface Middleware<Req, Res, Err, Options$1> { 143 - error: Interceptors<ErrInterceptor<Err, Res, Req, Options$1>>; 144 - request: Interceptors<ReqInterceptor<Req, Options$1>>; 145 - response: Interceptors<ResInterceptor<Res, Req, Options$1>>; 146 - } 147 - declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>; 148 - //#endregion 149 - //#region src/types.d.ts 150 - interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 { 151 - /** 152 - * Base URL for all requests made by this client. 153 - */ 154 - baseUrl?: T['baseUrl']; 155 - /** 156 - * Fetch API implementation. You can use this option to provide a custom 157 - * fetch instance. 158 - * 159 - * @default globalThis.fetch 160 - */ 161 - fetch?: (request: Request) => ReturnType<typeof fetch>; 162 - /** 163 - * Return the response data parsed in a specified format. By default, `auto` 164 - * will infer the appropriate method from the `Content-Type` response header. 165 - * You can override this behavior with any of the {@link Body} methods. 166 - * Select `stream` if you don't want to parse response data at all. 167 - * 168 - * @default 'auto' 169 - */ 170 - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 171 - /** 172 - * Throw an error instead of returning it in the response? 173 - * 174 - * @default false 175 - */ 176 - throwOnError?: T['throwOnError']; 177 - } 178 - interface RequestOptions<ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{ 179 - throwOnError: ThrowOnError; 180 - }> { 181 - /** 182 - * Any body that you want to add to your request. 183 - * 184 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 185 - */ 186 - body?: unknown; 187 - path?: Record<string, unknown>; 188 - query?: Record<string, unknown>; 189 - /** 190 - * Security mechanism(s) to use for the request. 191 - */ 192 - security?: ReadonlyArray<Auth>; 193 - url: Url; 194 - } 195 - type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<{ 196 - data: TData; 197 - request: Request; 198 - response: Response; 199 - }> : Promise<({ 200 - data: TData; 201 - error: undefined; 202 - } | { 203 - data: undefined; 204 - error: TError; 205 - }) & { 206 - request: Request; 207 - response: Response; 208 - }>; 209 - interface ClientOptions { 210 - baseUrl?: string; 211 - throwOnError?: boolean; 212 - } 213 - type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError>; 214 - type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'> & Pick<Required<RequestOptions<ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError>; 215 - type BuildUrlFn = <TData extends { 216 - body?: unknown; 217 - path?: Record<string, unknown>; 218 - query?: Record<string, unknown>; 219 - url: string; 220 - }>(options: Pick<TData, 'url'> & Options<TData>) => string; 221 - type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn> & { 222 - interceptors: Middleware<Request, Response, unknown, RequestOptions>; 223 - }; 224 - /** 225 - * The `createClientConfig()` function will be called on client initialization 226 - * and the returned object will become the client's initial configuration. 227 - * 228 - * You may want to initialize your client this way instead of calling 229 - * `setConfig()`. This is useful for example if you're using Next.js 230 - * to ensure your client always has the correct values. 231 - */ 232 - type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 233 - interface TDataShape { 234 - body?: unknown; 235 - headers?: unknown; 236 - path?: unknown; 237 - query?: unknown; 238 - url: string; 239 - } 240 - type OmitKeys<T, K$1> = Pick<T, Exclude<keyof T, K$1>>; 241 - type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>; 242 - //#endregion 243 - //#region src/client.d.ts 244 - declare const createClient: (config?: Config) => Client; 245 - //#endregion 246 - //#region src/core/params.d.ts 247 - type Slot = 'body' | 'headers' | 'path' | 'query'; 248 - type Field = { 249 - in: Exclude<Slot, 'body'>; 250 - key: string; 251 - map?: string; 252 - } | { 253 - in: Extract<Slot, 'body'>; 254 - key?: string; 255 - map?: string; 256 - }; 257 - interface Fields { 258 - allowExtra?: Partial<Record<Slot, boolean>>; 259 - args?: ReadonlyArray<Field>; 260 - } 261 - type FieldsConfig = ReadonlyArray<Field | Fields>; 262 - interface Params { 263 - body: unknown; 264 - headers: Record<string, unknown>; 265 - path: Record<string, unknown>; 266 - query: Record<string, unknown>; 267 - } 268 - declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params; 269 - //# sourceMappingURL=index.d.ts.map 270 - 271 - export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
-16
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/custom-client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 - import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 - 6 - /** 7 - * The `createClientConfig()` function will be called on client initialization 8 - * and the returned object will become the client's initial configuration. 9 - * 10 - * You may want to initialize your client this way instead of calling 11 - * `setConfig()`. This is useful for example if you're using Next.js 12 - * to ensure your client always has the correct values. 13 - */ 14 - export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 - 16 - export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:3000/base' }));
-4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export { apiVVersionODataControllerCount, callToTestOrderOfParams, callWithDefaultOptionalParameters, callWithDefaultParameters, callWithDescriptions, callWithDuplicateResponses, callWithNoContentResponse, callWithParameters, callWithResponse, callWithResponseAndNoContentResponse, callWithResponses, callWithResultFromHeader, callWithWeirdParameterNames, collectionFormat, complexParams, complexTypes, deleteCallWithoutParametersAndResponse, deleteFoo, deprecatedCall, dummyA, dummyB, duplicateName, duplicateName2, duplicateName3, duplicateName4, export_, fileResponse, fooWow, getApiVbyApiVersionSimpleOperation, getCallWithOptionalParam, getCallWithoutParametersAndResponse, headCallWithoutParametersAndResponse, import_, multipartRequest, multipartResponse, nonAsciiæøåÆøÅöôêÊ字符串, type Options, optionsCallWithoutParametersAndResponse, patchApiVbyApiVersionNoTag, patchCallWithoutParametersAndResponse, postApiVbyApiVersionFormData, postApiVbyApiVersionRequestBody, postCallWithOptionalParam, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, putWithFormUrlEncoded, testErrorCode, types, uploadFile } from './sdk.gen'; 4 - export type { _3eNum1Период, _400, AdditionalPropertiesIntegerIssue, AdditionalPropertiesUnknownIssue, AdditionalPropertiesUnknownIssue2, AdditionalPropertiesUnknownIssue3, AdditionalPropertiesUnknownIssueWritable, AnyOfAnyAndNull, AnyOfArrays, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountResponses, ArrayWithAnyOfProperties, ArrayWithArray, ArrayWithBooleans, ArrayWithNumbers, ArrayWithProperties, ArrayWithReferences, ArrayWithStrings, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponse, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesError, CallWithResponsesErrors, CallWithResponsesResponse, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CamelCaseCommentWithBreaks, CharactersInDescription, ClientOptions, CollectionFormatData, CommentWithBackticks, CommentWithBackticksAndQuotes, CommentWithBreaks, CommentWithExpressionPlaceholders, CommentWithQuotes, CommentWithReservedCharacters, CommentWithSlashes, ComplexParamsData, ComplexParamsResponse, ComplexParamsResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponse, ComplexTypesResponses, CompositionBaseModel, CompositionExtendedModel, CompositionWithAllOfAndNullable, CompositionWithAnyOf, CompositionWithAnyOfAndNullable, CompositionWithAnyOfAnonymous, CompositionWithNestedAnyAndTypeNull, CompositionWithNestedAnyOfAndNull, CompositionWithOneOf, CompositionWithOneOfAndComplexArrayDictionary, CompositionWithOneOfAndNullable, CompositionWithOneOfAndProperties, CompositionWithOneOfAndSimpleArrayDictionary, CompositionWithOneOfAndSimpleDictionary, CompositionWithOneOfAnonymous, CompositionWithOneOfDiscriminator, ConstValue, Default, DeleteCallWithoutParametersAndResponseData, DeleteFooData, DeleteFooData2, DeleteFooData3, DeprecatedCallData, DeprecatedModel, DictionaryWithArray, DictionaryWithDictionary, DictionaryWithProperties, DictionaryWithPropertiesAndAdditionalProperties, DictionaryWithReference, DictionaryWithString, DummyAData, DummyAResponse, DummyAResponses, DummyBData, DummyBResponse, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, EnumFromDescription, EnumWithExtensions, EnumWithNumbers, EnumWithReplacedCharacters, EnumWithStrings, EnumWithXEnumNames, ExportData, ExternalRefA, ExternalRefB, ExternalSharedModel, File, FileResponseData, FileResponseResponse, FileResponseResponses, FileWritable, FooWowData, FooWowResponses, FreeFormObjectWithAdditionalPropertiesEqEmptyObject, FreeFormObjectWithAdditionalPropertiesEqTrue, FreeFormObjectWithoutAdditionalProperties, GenericSchemaDuplicateIssue1SystemBoolean, GenericSchemaDuplicateIssue1SystemBooleanWritable, GenericSchemaDuplicateIssue1SystemString, GenericSchemaDuplicateIssue1SystemStringWritable, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationErrors, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationResponses, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, Import, ImportData, ImportResponse, ImportResponses, IoK8sApimachineryPkgApisMetaV1DeleteOptions, IoK8sApimachineryPkgApisMetaV1Preconditions, ModelCircle, ModelFromZendesk, ModelSquare, ModelThatExtends, ModelThatExtendsExtends, ModelWithAdditionalPropertiesEqTrue, ModelWithAdditionalPropertiesRef, ModelWithAnyOfConstantSizeArray, ModelWithAnyOfConstantSizeArrayAndIntersect, ModelWithAnyOfConstantSizeArrayNullable, ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions, ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable, ModelWithArray, ModelWithArrayReadOnlyAndWriteOnly, ModelWithArrayReadOnlyAndWriteOnlyWritable, ModelWithBackticksInDescription, ModelWithBoolean, ModelWithCircularReference, ModelWithConst, ModelWithConstantSizeArray, ModelWithDictionary, ModelWithDuplicateImports, ModelWithDuplicateProperties, ModelWithEnum, ModelWithEnumFromDescription, ModelWithEnumWithHyphen, ModelWithInteger, ModelWithNestedArrayEnums, ModelWithNestedArrayEnumsData, ModelWithNestedArrayEnumsDataBar, ModelWithNestedArrayEnumsDataFoo, ModelWithNestedCompositionEnums, ModelWithNestedEnums, ModelWithNestedProperties, ModelWithNullableObject, ModelWithNullableString, ModelWithNumericEnumUnion, ModelWithOneOfAndProperties, ModelWithOneOfEnum, ModelWithOrderedProperties, ModelWithPattern, ModelWithPatternWritable, ModelWithPrefixItemsConstantSizeArray, ModelWithProperties, ModelWithPropertiesWritable, ModelWithReadOnlyAndWriteOnly, ModelWithReadOnlyAndWriteOnlyWritable, ModelWithReference, ModelWithReferenceWritable, ModelWithString, ModelWithStringError, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, MultipartResponseResponses, NestedAnyOfArraysNullable, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Responses, NonAsciiStringæøåÆøÅöôêÊ字符串, NullableObject, OneOfAllOfIssue, OneOfAllOfIssueWritable, OptionsCallWithoutParametersAndResponseData, Pageable, ParameterSimpleParameterUnused, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamResponses, PostCallWithoutParametersAndResponseData, PostServiceWithEmptyTagResponse, PostServiceWithEmptyTagResponse2, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, SchemaWithFormRestrictedKeys, SimpleBoolean, SimpleFile, SimpleFormData, SimpleInteger, SimpleParameter, SimpleReference, SimpleRequestBody, SimpleString, SimpleStringWithPattern, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponse, TypesResponses, UploadFileData, UploadFileResponse, UploadFileResponses, XFooBar } from './types.gen';
-206
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/sdk.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type Client, formDataBodySerializer, type Options as Options2, type TDataShape, urlSearchParamsBodySerializer } from './client'; 4 - import { client } from './custom-client.gen'; 5 - import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, CallWithResponseData, CallWithResponseResponses, CallWithResponsesData, CallWithResponsesErrors, CallWithResponsesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponses, DummyBData, DummyBResponses, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponses, FooWowData, FooWowResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationErrors, GetApiVbyApiVersionSimpleOperationResponses, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, ImportData, ImportResponses, MultipartRequestData, MultipartResponseData, MultipartResponseResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, TypesData, TypesResponses, UploadFileData, UploadFileResponses } from './types.gen'; 6 - 7 - export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 8 - /** 9 - * You can provide a client instance returned by `createClient()` instead of 10 - * individual options. This might be also useful if you want to implement a 11 - * custom client. 12 - */ 13 - client?: Client; 14 - /** 15 - * You can pass arbitrary values through the `meta` object. This can be 16 - * used to access values that aren't defined as part of the SDK function. 17 - */ 18 - meta?: Record<string, unknown>; 19 - }; 20 - 21 - export const export_ = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 22 - 23 - export const patchApiVbyApiVersionNoTag = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>) => (options?.client ?? client).patch<PatchApiVbyApiVersionNoTagResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 24 - 25 - export const import_ = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>) => (options.client ?? client).post<ImportResponses, unknown, ThrowOnError>({ 26 - url: '/api/v{api-version}/no+tag', 27 - ...options, 28 - headers: { 29 - 'Content-Type': 'application/json', 30 - ...options.headers 31 - } 32 - }); 33 - 34 - export const fooWow = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>) => (options?.client ?? client).put<FooWowResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no+tag', ...options }); 35 - 36 - export const apiVVersionODataControllerCount = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>) => (options?.client ?? client).get<ApiVVersionODataControllerCountResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple/$count', ...options }); 37 - 38 - export const getApiVbyApiVersionSimpleOperation = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>) => (options.client ?? client).get<GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, ThrowOnError>({ url: '/api/v{api-version}/simple:operation', ...options }); 39 - 40 - export const deleteCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 41 - 42 - export const getCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 43 - 44 - export const headCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).head<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 45 - 46 - export const optionsCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).options<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 47 - 48 - export const patchCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).patch<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 49 - 50 - export const postCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 51 - 52 - export const putCallWithoutParametersAndResponse = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/simple', ...options }); 53 - 54 - export const deleteFoo = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>) => (options.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); 55 - 56 - export const callWithDescriptions = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/descriptions', ...options }); 57 - 58 - /** 59 - * @deprecated 60 - */ 61 - export const deprecatedCall = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/parameters/deprecated', ...options }); 62 - 63 - export const callWithParameters = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 64 - url: '/api/v{api-version}/parameters/{parameterPath}', 65 - ...options, 66 - headers: { 67 - 'Content-Type': 'application/json', 68 - ...options.headers 69 - } 70 - }); 71 - 72 - export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 73 - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 74 - ...options, 75 - headers: { 76 - 'Content-Type': 'application/json', 77 - ...options.headers 78 - } 79 - }); 80 - 81 - export const getCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ 82 - url: '/api/v{api-version}/parameters', 83 - ...options, 84 - headers: { 85 - 'Content-Type': 'application/json', 86 - ...options.headers 87 - } 88 - }); 89 - 90 - export const postCallWithOptionalParam = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>) => (options.client ?? client).post<PostCallWithOptionalParamResponses, unknown, ThrowOnError>({ 91 - url: '/api/v{api-version}/parameters', 92 - ...options, 93 - headers: { 94 - 'Content-Type': 'application/json', 95 - ...options.headers 96 - } 97 - }); 98 - 99 - export const postApiVbyApiVersionRequestBody = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 100 - url: '/api/v{api-version}/requestBody', 101 - ...options, 102 - headers: { 103 - 'Content-Type': 'application/json', 104 - ...options?.headers 105 - } 106 - }); 107 - 108 - export const postApiVbyApiVersionFormData = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 109 - ...formDataBodySerializer, 110 - url: '/api/v{api-version}/formData', 111 - ...options, 112 - headers: { 113 - 'Content-Type': null, 114 - ...options?.headers 115 - } 116 - }); 117 - 118 - export const callWithDefaultParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 119 - 120 - export const callWithDefaultOptionalParameters = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 121 - 122 - export const callToTestOrderOfParams = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/defaults', ...options }); 123 - 124 - export const duplicateName = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>) => (options?.client ?? client).delete<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 125 - 126 - export const duplicateName2 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>) => (options?.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 127 - 128 - export const duplicateName3 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 129 - 130 - export const duplicateName4 = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>) => (options?.client ?? client).put<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/duplicate', ...options }); 131 - 132 - export const callWithNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/no-content', ...options }); 133 - 134 - export const callWithResponseAndNoContentResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseAndNoContentResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); 135 - 136 - export const dummyA = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>) => (options?.client ?? client).get<DummyAResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/a', ...options }); 137 - 138 - export const dummyB = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>) => (options?.client ?? client).get<DummyBResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multiple-tags/b', ...options }); 139 - 140 - export const callWithResponse = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>) => (options?.client ?? client).get<CallWithResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 141 - 142 - export const callWithDuplicateResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>) => (options?.client ?? client).post<CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 143 - 144 - export const callWithResponses = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>) => (options?.client ?? client).put<CallWithResponsesResponses, CallWithResponsesErrors, ThrowOnError>({ url: '/api/v{api-version}/response', ...options }); 145 - 146 - export const collectionFormat = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>) => (options.client ?? client).get<unknown, unknown, ThrowOnError>({ url: '/api/v{api-version}/collectionFormat', ...options }); 147 - 148 - export const types = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>) => (options.client ?? client).get<TypesResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/types', ...options }); 149 - 150 - export const uploadFile = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>) => (options.client ?? client).post<UploadFileResponses, unknown, ThrowOnError>({ 151 - ...urlSearchParamsBodySerializer, 152 - url: '/api/v{api-version}/upload', 153 - ...options, 154 - headers: { 155 - 'Content-Type': 'application/x-www-form-urlencoded', 156 - ...options.headers 157 - } 158 - }); 159 - 160 - export const fileResponse = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>) => (options.client ?? client).get<FileResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/file/{id}', ...options }); 161 - 162 - export const complexTypes = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>) => (options.client ?? client).get<ComplexTypesResponses, ComplexTypesErrors, ThrowOnError>({ 163 - querySerializer: { parameters: { parameterObject: { object: { style: 'form' } } } }, 164 - url: '/api/v{api-version}/complex', 165 - ...options 166 - }); 167 - 168 - export const multipartResponse = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>) => (options?.client ?? client).get<MultipartResponseResponses, unknown, ThrowOnError>({ url: '/api/v{api-version}/multipart', ...options }); 169 - 170 - export const multipartRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>) => (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 171 - ...formDataBodySerializer, 172 - url: '/api/v{api-version}/multipart', 173 - ...options, 174 - headers: { 175 - 'Content-Type': null, 176 - ...options?.headers 177 - } 178 - }); 179 - 180 - export const complexParams = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>) => (options.client ?? client).put<ComplexParamsResponses, unknown, ThrowOnError>({ 181 - url: '/api/v{api-version}/complex/{id}', 182 - ...options, 183 - headers: { 184 - 'Content-Type': 'application/json-patch+json', 185 - ...options.headers 186 - } 187 - }); 188 - 189 - export const callWithResultFromHeader = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>) => (options?.client ?? client).post<CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, ThrowOnError>({ url: '/api/v{api-version}/header', ...options }); 190 - 191 - export const testErrorCode = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>) => (options.client ?? client).post<TestErrorCodeResponses, TestErrorCodeErrors, ThrowOnError>({ url: '/api/v{api-version}/error', ...options }); 192 - 193 - export const nonAsciiæøåÆøÅöôêÊ字符串 = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>) => (options.client ?? client).post<NonAsciiæøåÆøÅöôêÊ字符串Responses, unknown, ThrowOnError>({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); 194 - 195 - /** 196 - * Login User 197 - */ 198 - export const putWithFormUrlEncoded = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>) => (options.client ?? client).put<unknown, unknown, ThrowOnError>({ 199 - ...urlSearchParamsBodySerializer, 200 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 201 - ...options, 202 - headers: { 203 - 'Content-Type': 'application/x-www-form-urlencoded', 204 - ...options.headers 205 - } 206 - });
-2100
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type ClientOptions = { 4 - baseUrl: 'http://localhost:3000/base' | (string & {}); 5 - }; 6 - 7 - /** 8 - * Model with number-only name 9 - */ 10 - export type _400 = string; 11 - 12 - /** 13 - * External ref to shared model (A) 14 - */ 15 - export type ExternalRefA = ExternalSharedModel; 16 - 17 - /** 18 - * External ref to shared model (B) 19 - */ 20 - export type ExternalRefB = ExternalSharedModel; 21 - 22 - /** 23 - * Testing multiline comments in string: First line 24 - * Second line 25 - * 26 - * Fourth line 27 - */ 28 - export type CamelCaseCommentWithBreaks = number; 29 - 30 - /** 31 - * Testing multiline comments in string: First line 32 - * Second line 33 - * 34 - * Fourth line 35 - */ 36 - export type CommentWithBreaks = number; 37 - 38 - /** 39 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 40 - */ 41 - export type CommentWithBackticks = number; 42 - 43 - /** 44 - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 45 - */ 46 - export type CommentWithBackticksAndQuotes = number; 47 - 48 - /** 49 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 50 - */ 51 - export type CommentWithSlashes = number; 52 - 53 - /** 54 - * Testing expression placeholders in string: ${expression} should work 55 - */ 56 - export type CommentWithExpressionPlaceholders = number; 57 - 58 - /** 59 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 60 - */ 61 - export type CommentWithQuotes = number; 62 - 63 - /** 64 - * Testing reserved characters in string: * inline * and ** inline ** should work 65 - */ 66 - export type CommentWithReservedCharacters = number; 67 - 68 - /** 69 - * This is a simple number 70 - */ 71 - export type SimpleInteger = number; 72 - 73 - /** 74 - * This is a simple boolean 75 - */ 76 - export type SimpleBoolean = boolean; 77 - 78 - /** 79 - * This is a simple string 80 - */ 81 - export type SimpleString = string; 82 - 83 - /** 84 - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 85 - */ 86 - export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; 87 - 88 - /** 89 - * This is a simple file 90 - */ 91 - export type SimpleFile = Blob | File; 92 - 93 - /** 94 - * This is a simple reference 95 - */ 96 - export type SimpleReference = ModelWithString; 97 - 98 - /** 99 - * This is a simple string 100 - */ 101 - export type SimpleStringWithPattern = string | null; 102 - 103 - /** 104 - * This is a simple enum with strings 105 - */ 106 - export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | '\'Single Quote\'' | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; 107 - 108 - export type EnumWithReplacedCharacters = '\'Single Quote\'' | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; 109 - 110 - /** 111 - * This is a simple enum with numbers 112 - */ 113 - export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; 114 - 115 - /** 116 - * Success=1,Warning=2,Error=3 117 - */ 118 - export type EnumFromDescription = number; 119 - 120 - /** 121 - * This is a simple enum with numbers 122 - */ 123 - export type EnumWithExtensions = 200 | 400 | 500; 124 - 125 - export type EnumWithXEnumNames = 0 | 1 | 2; 126 - 127 - /** 128 - * This is a simple array with numbers 129 - */ 130 - export type ArrayWithNumbers = Array<number>; 131 - 132 - /** 133 - * This is a simple array with booleans 134 - */ 135 - export type ArrayWithBooleans = Array<boolean>; 136 - 137 - /** 138 - * This is a simple array with strings 139 - */ 140 - export type ArrayWithStrings = Array<string>; 141 - 142 - /** 143 - * This is a simple array with references 144 - */ 145 - export type ArrayWithReferences = Array<ModelWithString>; 146 - 147 - /** 148 - * This is a simple array containing an array 149 - */ 150 - export type ArrayWithArray = Array<Array<ModelWithString>>; 151 - 152 - /** 153 - * This is a simple array with properties 154 - */ 155 - export type ArrayWithProperties = Array<{ 156 - '16x16'?: CamelCaseCommentWithBreaks; 157 - bar?: string; 158 - }>; 159 - 160 - /** 161 - * This is a simple array with any of properties 162 - */ 163 - export type ArrayWithAnyOfProperties = Array<{ 164 - foo?: string; 165 - } | { 166 - bar?: string; 167 - }>; 168 - 169 - export type AnyOfAnyAndNull = { 170 - data?: unknown | null; 171 - }; 172 - 173 - /** 174 - * This is a simple array with any of properties 175 - */ 176 - export type AnyOfArrays = { 177 - results?: Array<{ 178 - foo?: string; 179 - } | { 180 - bar?: string; 181 - }>; 182 - }; 183 - 184 - /** 185 - * This is a string dictionary 186 - */ 187 - export type DictionaryWithString = { 188 - [key: string]: string; 189 - }; 190 - 191 - export type DictionaryWithPropertiesAndAdditionalProperties = { 192 - foo?: number; 193 - bar?: boolean; 194 - [key: string]: string | number | boolean | undefined; 195 - }; 196 - 197 - /** 198 - * This is a string reference 199 - */ 200 - export type DictionaryWithReference = { 201 - [key: string]: ModelWithString; 202 - }; 203 - 204 - /** 205 - * This is a complex dictionary 206 - */ 207 - export type DictionaryWithArray = { 208 - [key: string]: Array<ModelWithString>; 209 - }; 210 - 211 - /** 212 - * This is a string dictionary 213 - */ 214 - export type DictionaryWithDictionary = { 215 - [key: string]: { 216 - [key: string]: string; 217 - }; 218 - }; 219 - 220 - /** 221 - * This is a complex dictionary 222 - */ 223 - export type DictionaryWithProperties = { 224 - [key: string]: { 225 - foo?: string; 226 - bar?: string; 227 - }; 228 - }; 229 - 230 - /** 231 - * This is a model with one number property 232 - */ 233 - export type ModelWithInteger = { 234 - /** 235 - * This is a simple number property 236 - */ 237 - prop?: number; 238 - }; 239 - 240 - /** 241 - * This is a model with one boolean property 242 - */ 243 - export type ModelWithBoolean = { 244 - /** 245 - * This is a simple boolean property 246 - */ 247 - prop?: boolean; 248 - }; 249 - 250 - /** 251 - * This is a model with one string property 252 - */ 253 - export type ModelWithString = { 254 - /** 255 - * This is a simple string property 256 - */ 257 - prop?: string; 258 - }; 259 - 260 - /** 261 - * This is a model with one string property 262 - */ 263 - export type ModelWithStringError = { 264 - /** 265 - * This is a simple string property 266 - */ 267 - prop?: string; 268 - }; 269 - 270 - /** 271 - * `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) 272 - */ 273 - export type ModelFromZendesk = string; 274 - 275 - /** 276 - * This is a model with one string property 277 - */ 278 - export type ModelWithNullableString = { 279 - /** 280 - * This is a simple string property 281 - */ 282 - nullableProp1?: string | null; 283 - /** 284 - * This is a simple string property 285 - */ 286 - nullableRequiredProp1: string | null; 287 - /** 288 - * This is a simple string property 289 - */ 290 - nullableProp2?: string | null; 291 - /** 292 - * This is a simple string property 293 - */ 294 - nullableRequiredProp2: string | null; 295 - /** 296 - * This is a simple enum with strings 297 - */ 298 - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 299 - }; 300 - 301 - /** 302 - * This is a model with one enum 303 - */ 304 - export type ModelWithEnum = { 305 - /** 306 - * This is a simple enum with strings 307 - */ 308 - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 309 - /** 310 - * These are the HTTP error code enums 311 - */ 312 - statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; 313 - /** 314 - * Simple boolean enum 315 - */ 316 - bool?: true; 317 - }; 318 - 319 - /** 320 - * This is a model with one enum with escaped name 321 - */ 322 - export type ModelWithEnumWithHyphen = { 323 - /** 324 - * Foo-Bar-Baz-Qux 325 - */ 326 - 'foo-bar-baz-qux'?: '3.0'; 327 - }; 328 - 329 - /** 330 - * This is a model with one enum 331 - */ 332 - export type ModelWithEnumFromDescription = { 333 - /** 334 - * Success=1,Warning=2,Error=3 335 - */ 336 - test?: number; 337 - }; 338 - 339 - /** 340 - * This is a model with nested enums 341 - */ 342 - export type ModelWithNestedEnums = { 343 - dictionaryWithEnum?: { 344 - [key: string]: 'Success' | 'Warning' | 'Error'; 345 - }; 346 - dictionaryWithEnumFromDescription?: { 347 - [key: string]: number; 348 - }; 349 - arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; 350 - arrayWithDescription?: Array<number>; 351 - /** 352 - * This is a simple enum with strings 353 - */ 354 - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; 355 - }; 356 - 357 - /** 358 - * This is a model with one property containing a reference 359 - */ 360 - export type ModelWithReference = { 361 - prop?: ModelWithProperties; 362 - }; 363 - 364 - /** 365 - * This is a model with one property containing an array 366 - */ 367 - export type ModelWithArrayReadOnlyAndWriteOnly = { 368 - prop?: Array<ModelWithReadOnlyAndWriteOnly>; 369 - propWithFile?: Array<Blob | File>; 370 - propWithNumber?: Array<number>; 371 - }; 372 - 373 - /** 374 - * This is a model with one property containing an array 375 - */ 376 - export type ModelWithArray = { 377 - prop?: Array<ModelWithString>; 378 - propWithFile?: Array<Blob | File>; 379 - propWithNumber?: Array<number>; 380 - }; 381 - 382 - /** 383 - * This is a model with one property containing a dictionary 384 - */ 385 - export type ModelWithDictionary = { 386 - prop?: { 387 - [key: string]: string; 388 - }; 389 - }; 390 - 391 - /** 392 - * This is a deprecated model with a deprecated property 393 - * 394 - * @deprecated 395 - */ 396 - export type DeprecatedModel = { 397 - /** 398 - * This is a deprecated property 399 - * 400 - * @deprecated 401 - */ 402 - prop?: string; 403 - }; 404 - 405 - /** 406 - * This is a model with one property containing a circular reference 407 - */ 408 - export type ModelWithCircularReference = { 409 - prop?: ModelWithCircularReference; 410 - }; 411 - 412 - /** 413 - * This is a model with one property with a 'one of' relationship 414 - */ 415 - export type CompositionWithOneOf = { 416 - propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 417 - }; 418 - 419 - /** 420 - * This is a model with one property with a 'one of' relationship where the options are not $ref 421 - */ 422 - export type CompositionWithOneOfAnonymous = { 423 - propA?: { 424 - propA?: string; 425 - } | string | number; 426 - }; 427 - 428 - /** 429 - * Circle 430 - */ 431 - export type ModelCircle = { 432 - kind: string; 433 - radius?: number; 434 - }; 435 - 436 - /** 437 - * Square 438 - */ 439 - export type ModelSquare = { 440 - kind: string; 441 - sideLength?: number; 442 - }; 443 - 444 - /** 445 - * This is a model with one property with a 'one of' relationship where the options are not $ref 446 - */ 447 - export type CompositionWithOneOfDiscriminator = ({ 448 - kind: 'circle'; 449 - } & ModelCircle) | ({ 450 - kind: 'square'; 451 - } & ModelSquare); 452 - 453 - /** 454 - * This is a model with one property with a 'any of' relationship 455 - */ 456 - export type CompositionWithAnyOf = { 457 - propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 458 - }; 459 - 460 - /** 461 - * This is a model with one property with a 'any of' relationship where the options are not $ref 462 - */ 463 - export type CompositionWithAnyOfAnonymous = { 464 - propA?: { 465 - propA?: string; 466 - } | string | number; 467 - }; 468 - 469 - /** 470 - * This is a model with nested 'any of' property with a type null 471 - */ 472 - export type CompositionWithNestedAnyAndTypeNull = { 473 - propA?: Array<ModelWithDictionary | null> | Array<ModelWithArray | null>; 474 - }; 475 - 476 - export type _3eNum1Период = 'Bird' | 'Dog'; 477 - 478 - export type ConstValue = 'ConstValue'; 479 - 480 - /** 481 - * This is a model with one property with a 'any of' relationship where the options are not $ref 482 - */ 483 - export type CompositionWithNestedAnyOfAndNull = { 484 - /** 485 - * Scopes 486 - */ 487 - propA?: Array<_3eNum1Период | ConstValue> | null; 488 - }; 489 - 490 - /** 491 - * This is a model with one property with a 'one of' relationship 492 - */ 493 - export type CompositionWithOneOfAndNullable = { 494 - propA?: { 495 - boolean?: boolean; 496 - } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 497 - }; 498 - 499 - /** 500 - * This is a model that contains a simple dictionary within composition 501 - */ 502 - export type CompositionWithOneOfAndSimpleDictionary = { 503 - propA?: boolean | { 504 - [key: string]: number; 505 - }; 506 - }; 507 - 508 - /** 509 - * This is a model that contains a dictionary of simple arrays within composition 510 - */ 511 - export type CompositionWithOneOfAndSimpleArrayDictionary = { 512 - propA?: boolean | { 513 - [key: string]: Array<boolean>; 514 - }; 515 - }; 516 - 517 - /** 518 - * This is a model that contains a dictionary of complex arrays (composited) within composition 519 - */ 520 - export type CompositionWithOneOfAndComplexArrayDictionary = { 521 - propA?: boolean | { 522 - [key: string]: Array<number | string>; 523 - }; 524 - }; 525 - 526 - /** 527 - * This is a model with one property with a 'all of' relationship 528 - */ 529 - export type CompositionWithAllOfAndNullable = { 530 - propA?: ({ 531 - boolean?: boolean; 532 - } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; 533 - }; 534 - 535 - /** 536 - * This is a model with one property with a 'any of' relationship 537 - */ 538 - export type CompositionWithAnyOfAndNullable = { 539 - propA?: { 540 - boolean?: boolean; 541 - } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; 542 - }; 543 - 544 - /** 545 - * This is a base model with two simple optional properties 546 - */ 547 - export type CompositionBaseModel = { 548 - firstName?: string; 549 - lastname?: string; 550 - }; 551 - 552 - /** 553 - * This is a model that extends the base model 554 - */ 555 - export type CompositionExtendedModel = CompositionBaseModel & { 556 - age: number; 557 - firstName: string; 558 - lastname: string; 559 - }; 560 - 561 - /** 562 - * This is a model with one nested property 563 - */ 564 - export type ModelWithProperties = { 565 - required: string; 566 - readonly requiredAndReadOnly: string; 567 - requiredAndNullable: string | null; 568 - string?: string; 569 - number?: number; 570 - boolean?: boolean; 571 - reference?: ModelWithString; 572 - 'property with space'?: string; 573 - default?: string; 574 - try?: string; 575 - readonly '@namespace.string'?: string; 576 - readonly '@namespace.integer'?: number; 577 - }; 578 - 579 - /** 580 - * This is a model with one nested property 581 - */ 582 - export type ModelWithNestedProperties = { 583 - readonly first: { 584 - readonly second: { 585 - readonly third: string | null; 586 - } | null; 587 - } | null; 588 - }; 589 - 590 - /** 591 - * This is a model with duplicated properties 592 - */ 593 - export type ModelWithDuplicateProperties = { 594 - prop?: ModelWithString; 595 - }; 596 - 597 - /** 598 - * This is a model with ordered properties 599 - */ 600 - export type ModelWithOrderedProperties = { 601 - zebra?: string; 602 - apple?: string; 603 - hawaii?: string; 604 - }; 605 - 606 - /** 607 - * This is a model with duplicated imports 608 - */ 609 - export type ModelWithDuplicateImports = { 610 - propA?: ModelWithString; 611 - propB?: ModelWithString; 612 - propC?: ModelWithString; 613 - }; 614 - 615 - /** 616 - * This is a model that extends another model 617 - */ 618 - export type ModelThatExtends = ModelWithString & { 619 - propExtendsA?: string; 620 - propExtendsB?: ModelWithString; 621 - }; 622 - 623 - /** 624 - * This is a model that extends another model 625 - */ 626 - export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { 627 - propExtendsC?: string; 628 - propExtendsD?: ModelWithString; 629 - }; 630 - 631 - /** 632 - * This is a model that contains a some patterns 633 - */ 634 - export type ModelWithPattern = { 635 - key: string; 636 - name: string; 637 - readonly enabled?: boolean; 638 - readonly modified?: string; 639 - id?: string; 640 - text?: string; 641 - patternWithSingleQuotes?: string; 642 - patternWithNewline?: string; 643 - patternWithBacktick?: string; 644 - patternWithUnicode?: string; 645 - }; 646 - 647 - export type File = { 648 - /** 649 - * Id 650 - */ 651 - readonly id?: string; 652 - /** 653 - * Updated at 654 - */ 655 - readonly updated_at?: string; 656 - /** 657 - * Created at 658 - */ 659 - readonly created_at?: string; 660 - /** 661 - * Mime 662 - */ 663 - mime: string; 664 - /** 665 - * File 666 - */ 667 - readonly file?: string; 668 - }; 669 - 670 - export type Default = { 671 - name?: string; 672 - }; 673 - 674 - export type Pageable = { 675 - page?: number; 676 - size?: number; 677 - sort?: Array<string>; 678 - }; 679 - 680 - /** 681 - * This is a free-form object without additionalProperties. 682 - */ 683 - export type FreeFormObjectWithoutAdditionalProperties = { 684 - [key: string]: unknown; 685 - }; 686 - 687 - /** 688 - * This is a free-form object with additionalProperties: true. 689 - */ 690 - export type FreeFormObjectWithAdditionalPropertiesEqTrue = { 691 - [key: string]: unknown; 692 - }; 693 - 694 - /** 695 - * This is a free-form object with additionalProperties: {}. 696 - */ 697 - export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { 698 - [key: string]: unknown; 699 - }; 700 - 701 - export type ModelWithConst = { 702 - String?: 'String'; 703 - number?: 0; 704 - null?: null; 705 - withType?: 'Some string'; 706 - }; 707 - 708 - /** 709 - * This is a model with one property and additionalProperties: true 710 - */ 711 - export type ModelWithAdditionalPropertiesEqTrue = { 712 - /** 713 - * This is a simple string property 714 - */ 715 - prop?: string; 716 - [key: string]: unknown; 717 - }; 718 - 719 - export type NestedAnyOfArraysNullable = { 720 - nullableArray?: Array<string | boolean> | null; 721 - }; 722 - 723 - export type CompositionWithOneOfAndProperties = ({ 724 - foo: SimpleParameter; 725 - } | { 726 - bar: NonAsciiStringæøåÆøÅöôêÊ字符串; 727 - }) & { 728 - baz: number | null; 729 - qux: number; 730 - }; 731 - 732 - /** 733 - * An object that can be null 734 - */ 735 - export type NullableObject = { 736 - foo?: string; 737 - } | null; 738 - 739 - /** 740 - * Some % character 741 - */ 742 - export type CharactersInDescription = string; 743 - 744 - export type ModelWithNullableObject = { 745 - data?: NullableObject; 746 - }; 747 - 748 - /** 749 - * An object with additional properties that can be null (anyOf ref + null) 750 - */ 751 - export type ModelWithAdditionalPropertiesRef = { 752 - [key: string]: NullableObject | null; 753 - }; 754 - 755 - export type ModelWithOneOfEnum = { 756 - foo: 'Bar'; 757 - } | { 758 - foo: 'Baz'; 759 - } | { 760 - foo: 'Qux'; 761 - } | { 762 - content: string; 763 - foo: 'Quux'; 764 - } | { 765 - content: [ 766 - string, 767 - string 768 - ]; 769 - foo: 'Corge'; 770 - }; 771 - 772 - export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; 773 - 774 - export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; 775 - 776 - export type ModelWithNestedArrayEnumsData = { 777 - foo?: Array<ModelWithNestedArrayEnumsDataFoo>; 778 - bar?: Array<ModelWithNestedArrayEnumsDataBar>; 779 - }; 780 - 781 - export type ModelWithNestedArrayEnums = { 782 - array_strings?: Array<string>; 783 - data?: ModelWithNestedArrayEnumsData; 784 - }; 785 - 786 - export type ModelWithNestedCompositionEnums = { 787 - foo?: ModelWithNestedArrayEnumsDataFoo; 788 - }; 789 - 790 - export type ModelWithReadOnlyAndWriteOnly = { 791 - foo: string; 792 - readonly bar: string; 793 - }; 794 - 795 - export type ModelWithConstantSizeArray = [ 796 - number, 797 - number 798 - ]; 799 - 800 - export type ModelWithAnyOfConstantSizeArray = [ 801 - number | string, 802 - number | string, 803 - number | string 804 - ]; 805 - 806 - export type ModelWithPrefixItemsConstantSizeArray = [ 807 - ModelWithInteger, 808 - number | string, 809 - string 810 - ]; 811 - 812 - export type ModelWithAnyOfConstantSizeArrayNullable = [ 813 - number | null | string, 814 - number | null | string, 815 - number | null | string 816 - ]; 817 - 818 - export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ 819 - number | Import, 820 - number | Import 821 - ]; 822 - 823 - export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ 824 - number & string, 825 - number & string 826 - ]; 827 - 828 - export type ModelWithNumericEnumUnion = { 829 - /** 830 - * Период 831 - */ 832 - value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; 833 - }; 834 - 835 - /** 836 - * Some description with `back ticks` 837 - */ 838 - export type ModelWithBackticksInDescription = { 839 - /** 840 - * The template `that` should be used for parsing and importing the contents of the CSV file. 841 - * 842 - * <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> 843 - * <pre> 844 - * [ 845 - * { 846 - * "resourceType": "Asset", 847 - * "identifier": { 848 - * "name": "${1}", 849 - * "domain": { 850 - * "name": "${2}", 851 - * "community": { 852 - * "name": "Some Community" 853 - * } 854 - * } 855 - * }, 856 - * "attributes" : { 857 - * "00000000-0000-0000-0000-000000003115" : [ { 858 - * "value" : "${3}" 859 - * } ], 860 - * "00000000-0000-0000-0000-000000000222" : [ { 861 - * "value" : "${4}" 862 - * } ] 863 - * } 864 - * } 865 - * ] 866 - * </pre> 867 - */ 868 - template?: string; 869 - }; 870 - 871 - export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { 872 - baz: number | null; 873 - qux: number; 874 - }; 875 - 876 - /** 877 - * Model used to test deduplication strategy (unused) 878 - */ 879 - export type ParameterSimpleParameterUnused = string; 880 - 881 - /** 882 - * Model used to test deduplication strategy 883 - */ 884 - export type PostServiceWithEmptyTagResponse = string; 885 - 886 - /** 887 - * Model used to test deduplication strategy 888 - */ 889 - export type PostServiceWithEmptyTagResponse2 = string; 890 - 891 - /** 892 - * Model used to test deduplication strategy 893 - */ 894 - export type DeleteFooData = string; 895 - 896 - /** 897 - * Model used to test deduplication strategy 898 - */ 899 - export type DeleteFooData2 = string; 900 - 901 - /** 902 - * Model with restricted keyword name 903 - */ 904 - export type Import = string; 905 - 906 - export type SchemaWithFormRestrictedKeys = { 907 - description?: string; 908 - 'x-enum-descriptions'?: string; 909 - 'x-enum-varnames'?: string; 910 - 'x-enumNames'?: string; 911 - title?: string; 912 - object?: { 913 - description?: string; 914 - 'x-enum-descriptions'?: string; 915 - 'x-enum-varnames'?: string; 916 - 'x-enumNames'?: string; 917 - title?: string; 918 - }; 919 - array?: Array<{ 920 - description?: string; 921 - 'x-enum-descriptions'?: string; 922 - 'x-enum-varnames'?: string; 923 - 'x-enumNames'?: string; 924 - title?: string; 925 - }>; 926 - }; 927 - 928 - /** 929 - * This schema was giving PascalCase transformations a hard time 930 - */ 931 - export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { 932 - /** 933 - * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. 934 - */ 935 - preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; 936 - }; 937 - 938 - /** 939 - * This schema was giving PascalCase transformations a hard time 940 - */ 941 - export type IoK8sApimachineryPkgApisMetaV1Preconditions = { 942 - /** 943 - * Specifies the target ResourceVersion 944 - */ 945 - resourceVersion?: string; 946 - /** 947 - * Specifies the target UID. 948 - */ 949 - uid?: string; 950 - }; 951 - 952 - export type AdditionalPropertiesUnknownIssue = { 953 - [key: string]: string | number; 954 - }; 955 - 956 - export type AdditionalPropertiesUnknownIssue2 = { 957 - [key: string]: string | number; 958 - }; 959 - 960 - export type AdditionalPropertiesUnknownIssue3 = string & { 961 - entries: { 962 - [key: string]: AdditionalPropertiesUnknownIssue; 963 - }; 964 - }; 965 - 966 - export type AdditionalPropertiesIntegerIssue = { 967 - value: number; 968 - [key: string]: number; 969 - }; 970 - 971 - export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 972 - 973 - export type GenericSchemaDuplicateIssue1SystemBoolean = { 974 - item?: boolean; 975 - error?: string | null; 976 - readonly hasError?: boolean; 977 - data?: { 978 - [key: string]: never; 979 - }; 980 - }; 981 - 982 - export type GenericSchemaDuplicateIssue1SystemString = { 983 - item?: string | null; 984 - error?: string | null; 985 - readonly hasError?: boolean; 986 - }; 987 - 988 - export type ExternalSharedModel = { 989 - id: string; 990 - name?: string; 991 - }; 992 - 993 - /** 994 - * This is a model with one property containing a reference 995 - */ 996 - export type ModelWithReferenceWritable = { 997 - prop?: ModelWithPropertiesWritable; 998 - }; 999 - 1000 - /** 1001 - * This is a model with one property containing an array 1002 - */ 1003 - export type ModelWithArrayReadOnlyAndWriteOnlyWritable = { 1004 - prop?: Array<ModelWithReadOnlyAndWriteOnlyWritable>; 1005 - propWithFile?: Array<Blob | File>; 1006 - propWithNumber?: Array<number>; 1007 - }; 1008 - 1009 - /** 1010 - * This is a model with one nested property 1011 - */ 1012 - export type ModelWithPropertiesWritable = { 1013 - required: string; 1014 - requiredAndNullable: string | null; 1015 - string?: string; 1016 - number?: number; 1017 - boolean?: boolean; 1018 - reference?: ModelWithString; 1019 - 'property with space'?: string; 1020 - default?: string; 1021 - try?: string; 1022 - }; 1023 - 1024 - /** 1025 - * This is a model that contains a some patterns 1026 - */ 1027 - export type ModelWithPatternWritable = { 1028 - key: string; 1029 - name: string; 1030 - id?: string; 1031 - text?: string; 1032 - patternWithSingleQuotes?: string; 1033 - patternWithNewline?: string; 1034 - patternWithBacktick?: string; 1035 - patternWithUnicode?: string; 1036 - }; 1037 - 1038 - export type FileWritable = { 1039 - /** 1040 - * Mime 1041 - */ 1042 - mime: string; 1043 - }; 1044 - 1045 - export type ModelWithReadOnlyAndWriteOnlyWritable = { 1046 - foo: string; 1047 - baz: string; 1048 - }; 1049 - 1050 - export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = [ 1051 - number | Import, 1052 - number | Import 1053 - ]; 1054 - 1055 - export type AdditionalPropertiesUnknownIssueWritable = { 1056 - [key: string]: string | number; 1057 - }; 1058 - 1059 - export type OneOfAllOfIssueWritable = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; 1060 - 1061 - export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { 1062 - item?: boolean; 1063 - error?: string | null; 1064 - data?: { 1065 - [key: string]: never; 1066 - }; 1067 - }; 1068 - 1069 - export type GenericSchemaDuplicateIssue1SystemStringWritable = { 1070 - item?: string | null; 1071 - error?: string | null; 1072 - }; 1073 - 1074 - /** 1075 - * This is a reusable parameter 1076 - */ 1077 - export type SimpleParameter = string; 1078 - 1079 - /** 1080 - * Parameter with illegal characters 1081 - */ 1082 - export type XFooBar = ModelWithString; 1083 - 1084 - /** 1085 - * A reusable request body 1086 - */ 1087 - export type SimpleRequestBody = ModelWithString; 1088 - 1089 - /** 1090 - * A reusable request body 1091 - */ 1092 - export type SimpleFormData = ModelWithString; 1093 - 1094 - export type ExportData = { 1095 - body?: never; 1096 - path?: never; 1097 - query?: never; 1098 - url: '/api/v{api-version}/no+tag'; 1099 - }; 1100 - 1101 - export type PatchApiVbyApiVersionNoTagData = { 1102 - body?: never; 1103 - path?: never; 1104 - query?: never; 1105 - url: '/api/v{api-version}/no+tag'; 1106 - }; 1107 - 1108 - export type PatchApiVbyApiVersionNoTagResponses = { 1109 - /** 1110 - * OK 1111 - */ 1112 - default: unknown; 1113 - }; 1114 - 1115 - export type ImportData = { 1116 - body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnlyWritable; 1117 - path?: never; 1118 - query?: never; 1119 - url: '/api/v{api-version}/no+tag'; 1120 - }; 1121 - 1122 - export type ImportResponses = { 1123 - /** 1124 - * Success 1125 - */ 1126 - 200: ModelFromZendesk; 1127 - /** 1128 - * Default success response 1129 - */ 1130 - default: ModelWithReadOnlyAndWriteOnly; 1131 - }; 1132 - 1133 - export type ImportResponse = ImportResponses[keyof ImportResponses]; 1134 - 1135 - export type FooWowData = { 1136 - body?: never; 1137 - path?: never; 1138 - query?: never; 1139 - url: '/api/v{api-version}/no+tag'; 1140 - }; 1141 - 1142 - export type FooWowResponses = { 1143 - /** 1144 - * OK 1145 - */ 1146 - default: unknown; 1147 - }; 1148 - 1149 - export type ApiVVersionODataControllerCountData = { 1150 - body?: never; 1151 - path?: never; 1152 - query?: never; 1153 - url: '/api/v{api-version}/simple/$count'; 1154 - }; 1155 - 1156 - export type ApiVVersionODataControllerCountResponses = { 1157 - /** 1158 - * Success 1159 - */ 1160 - 200: ModelFromZendesk; 1161 - }; 1162 - 1163 - export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; 1164 - 1165 - export type GetApiVbyApiVersionSimpleOperationData = { 1166 - body?: never; 1167 - path: { 1168 - /** 1169 - * foo in method 1170 - */ 1171 - foo_param: string; 1172 - }; 1173 - query?: never; 1174 - url: '/api/v{api-version}/simple:operation'; 1175 - }; 1176 - 1177 - export type GetApiVbyApiVersionSimpleOperationErrors = { 1178 - /** 1179 - * Default error response 1180 - */ 1181 - default: ModelWithBoolean; 1182 - }; 1183 - 1184 - export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; 1185 - 1186 - export type GetApiVbyApiVersionSimpleOperationResponses = { 1187 - /** 1188 - * Response is a simple number 1189 - */ 1190 - 200: number; 1191 - }; 1192 - 1193 - export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; 1194 - 1195 - export type DeleteCallWithoutParametersAndResponseData = { 1196 - body?: never; 1197 - path?: never; 1198 - query?: never; 1199 - url: '/api/v{api-version}/simple'; 1200 - }; 1201 - 1202 - export type GetCallWithoutParametersAndResponseData = { 1203 - body?: never; 1204 - path?: never; 1205 - query?: never; 1206 - url: '/api/v{api-version}/simple'; 1207 - }; 1208 - 1209 - export type HeadCallWithoutParametersAndResponseData = { 1210 - body?: never; 1211 - path?: never; 1212 - query?: never; 1213 - url: '/api/v{api-version}/simple'; 1214 - }; 1215 - 1216 - export type OptionsCallWithoutParametersAndResponseData = { 1217 - body?: never; 1218 - path?: never; 1219 - query?: never; 1220 - url: '/api/v{api-version}/simple'; 1221 - }; 1222 - 1223 - export type PatchCallWithoutParametersAndResponseData = { 1224 - body?: never; 1225 - path?: never; 1226 - query?: never; 1227 - url: '/api/v{api-version}/simple'; 1228 - }; 1229 - 1230 - export type PostCallWithoutParametersAndResponseData = { 1231 - body?: never; 1232 - path?: never; 1233 - query?: never; 1234 - url: '/api/v{api-version}/simple'; 1235 - }; 1236 - 1237 - export type PutCallWithoutParametersAndResponseData = { 1238 - body?: never; 1239 - path?: never; 1240 - query?: never; 1241 - url: '/api/v{api-version}/simple'; 1242 - }; 1243 - 1244 - export type DeleteFooData3 = { 1245 - body?: never; 1246 - headers: { 1247 - /** 1248 - * Parameter with illegal characters 1249 - */ 1250 - 'x-Foo-Bar': ModelWithString; 1251 - }; 1252 - path: { 1253 - /** 1254 - * foo in method 1255 - */ 1256 - foo_param: string; 1257 - /** 1258 - * bar in method 1259 - */ 1260 - BarParam: string; 1261 - }; 1262 - query?: never; 1263 - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; 1264 - }; 1265 - 1266 - export type CallWithDescriptionsData = { 1267 - body?: never; 1268 - path?: never; 1269 - query?: { 1270 - /** 1271 - * Testing multiline comments in string: First line 1272 - * Second line 1273 - * 1274 - * Fourth line 1275 - */ 1276 - parameterWithBreaks?: string; 1277 - /** 1278 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1279 - */ 1280 - parameterWithBackticks?: string; 1281 - /** 1282 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 1283 - */ 1284 - parameterWithSlashes?: string; 1285 - /** 1286 - * Testing expression placeholders in string: ${expression} should work 1287 - */ 1288 - parameterWithExpressionPlaceholders?: string; 1289 - /** 1290 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 1291 - */ 1292 - parameterWithQuotes?: string; 1293 - /** 1294 - * Testing reserved characters in string: * inline * and ** inline ** should work 1295 - */ 1296 - parameterWithReservedCharacters?: string; 1297 - }; 1298 - url: '/api/v{api-version}/descriptions'; 1299 - }; 1300 - 1301 - export type DeprecatedCallData = { 1302 - body?: never; 1303 - headers: { 1304 - /** 1305 - * This parameter is deprecated 1306 - * 1307 - * @deprecated 1308 - */ 1309 - parameter: DeprecatedModel | null; 1310 - }; 1311 - path?: never; 1312 - query?: never; 1313 - url: '/api/v{api-version}/parameters/deprecated'; 1314 - }; 1315 - 1316 - export type CallWithParametersData = { 1317 - /** 1318 - * This is the parameter that goes into the body 1319 - */ 1320 - body: { 1321 - [key: string]: unknown; 1322 - } | null; 1323 - headers: { 1324 - /** 1325 - * This is the parameter that goes into the header 1326 - */ 1327 - parameterHeader: string | null; 1328 - }; 1329 - path: { 1330 - /** 1331 - * This is the parameter that goes into the path 1332 - */ 1333 - parameterPath: string | null; 1334 - /** 1335 - * api-version should be required in standalone clients 1336 - */ 1337 - 'api-version': string | null; 1338 - }; 1339 - query: { 1340 - foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; 1341 - foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; 1342 - /** 1343 - * This is the parameter that goes into the query params 1344 - */ 1345 - cursor: string | null; 1346 - }; 1347 - url: '/api/v{api-version}/parameters/{parameterPath}'; 1348 - }; 1349 - 1350 - export type CallWithWeirdParameterNamesData = { 1351 - /** 1352 - * This is the parameter that goes into the body 1353 - */ 1354 - body: ModelWithString | null; 1355 - headers: { 1356 - /** 1357 - * This is the parameter that goes into the request header 1358 - */ 1359 - 'parameter.header': string | null; 1360 - }; 1361 - path: { 1362 - /** 1363 - * This is the parameter that goes into the path 1364 - */ 1365 - 'parameter.path.1'?: string; 1366 - /** 1367 - * This is the parameter that goes into the path 1368 - */ 1369 - 'parameter-path-2'?: string; 1370 - /** 1371 - * This is the parameter that goes into the path 1372 - */ 1373 - 'PARAMETER-PATH-3'?: string; 1374 - /** 1375 - * api-version should be required in standalone clients 1376 - */ 1377 - 'api-version': string | null; 1378 - }; 1379 - query: { 1380 - /** 1381 - * This is the parameter with a reserved keyword 1382 - */ 1383 - default?: string; 1384 - /** 1385 - * This is the parameter that goes into the request query params 1386 - */ 1387 - 'parameter-query': string | null; 1388 - }; 1389 - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; 1390 - }; 1391 - 1392 - export type GetCallWithOptionalParamData = { 1393 - /** 1394 - * This is a required parameter 1395 - */ 1396 - body: ModelWithOneOfEnum; 1397 - path?: never; 1398 - query?: { 1399 - /** 1400 - * This is an optional parameter 1401 - */ 1402 - page?: number; 1403 - }; 1404 - url: '/api/v{api-version}/parameters'; 1405 - }; 1406 - 1407 - export type PostCallWithOptionalParamData = { 1408 - /** 1409 - * This is an optional parameter 1410 - */ 1411 - body?: { 1412 - offset?: number | null; 1413 - }; 1414 - path?: never; 1415 - query: { 1416 - /** 1417 - * This is a required parameter 1418 - */ 1419 - parameter: Pageable; 1420 - }; 1421 - url: '/api/v{api-version}/parameters'; 1422 - }; 1423 - 1424 - export type PostCallWithOptionalParamResponses = { 1425 - /** 1426 - * Response is a simple number 1427 - */ 1428 - 200: number; 1429 - /** 1430 - * Success 1431 - */ 1432 - 204: void; 1433 - }; 1434 - 1435 - export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; 1436 - 1437 - export type PostApiVbyApiVersionRequestBodyData = { 1438 - /** 1439 - * A reusable request body 1440 - */ 1441 - body?: SimpleRequestBody; 1442 - path?: never; 1443 - query?: { 1444 - /** 1445 - * This is a reusable parameter 1446 - */ 1447 - parameter?: string; 1448 - }; 1449 - url: '/api/v{api-version}/requestBody'; 1450 - }; 1451 - 1452 - export type PostApiVbyApiVersionFormDataData = { 1453 - /** 1454 - * A reusable request body 1455 - */ 1456 - body?: SimpleFormData; 1457 - path?: never; 1458 - query?: { 1459 - /** 1460 - * This is a reusable parameter 1461 - */ 1462 - parameter?: string; 1463 - }; 1464 - url: '/api/v{api-version}/formData'; 1465 - }; 1466 - 1467 - export type CallWithDefaultParametersData = { 1468 - body?: never; 1469 - path?: never; 1470 - query?: { 1471 - /** 1472 - * This is a simple string with default value 1473 - */ 1474 - parameterString?: string | null; 1475 - /** 1476 - * This is a simple number with default value 1477 - */ 1478 - parameterNumber?: number | null; 1479 - /** 1480 - * This is a simple boolean with default value 1481 - */ 1482 - parameterBoolean?: boolean | null; 1483 - /** 1484 - * This is a simple enum with default value 1485 - */ 1486 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1487 - /** 1488 - * This is a simple model with default value 1489 - */ 1490 - parameterModel?: ModelWithString | null; 1491 - }; 1492 - url: '/api/v{api-version}/defaults'; 1493 - }; 1494 - 1495 - export type CallWithDefaultOptionalParametersData = { 1496 - body?: never; 1497 - path?: never; 1498 - query?: { 1499 - /** 1500 - * This is a simple string that is optional with default value 1501 - */ 1502 - parameterString?: string; 1503 - /** 1504 - * This is a simple number that is optional with default value 1505 - */ 1506 - parameterNumber?: number; 1507 - /** 1508 - * This is a simple boolean that is optional with default value 1509 - */ 1510 - parameterBoolean?: boolean; 1511 - /** 1512 - * This is a simple enum that is optional with default value 1513 - */ 1514 - parameterEnum?: 'Success' | 'Warning' | 'Error'; 1515 - /** 1516 - * This is a simple model that is optional with default value 1517 - */ 1518 - parameterModel?: ModelWithString; 1519 - }; 1520 - url: '/api/v{api-version}/defaults'; 1521 - }; 1522 - 1523 - export type CallToTestOrderOfParamsData = { 1524 - body?: never; 1525 - path?: never; 1526 - query: { 1527 - /** 1528 - * This is a optional string with default 1529 - */ 1530 - parameterOptionalStringWithDefault?: string; 1531 - /** 1532 - * This is a optional string with empty default 1533 - */ 1534 - parameterOptionalStringWithEmptyDefault?: string; 1535 - /** 1536 - * This is a optional string with no default 1537 - */ 1538 - parameterOptionalStringWithNoDefault?: string; 1539 - /** 1540 - * This is a string with default 1541 - */ 1542 - parameterStringWithDefault: string; 1543 - /** 1544 - * This is a string with empty default 1545 - */ 1546 - parameterStringWithEmptyDefault: string; 1547 - /** 1548 - * This is a string with no default 1549 - */ 1550 - parameterStringWithNoDefault: string; 1551 - /** 1552 - * This is a string that can be null with no default 1553 - */ 1554 - parameterStringNullableWithNoDefault?: string | null; 1555 - /** 1556 - * This is a string that can be null with default 1557 - */ 1558 - parameterStringNullableWithDefault?: string | null; 1559 - }; 1560 - url: '/api/v{api-version}/defaults'; 1561 - }; 1562 - 1563 - export type DuplicateNameData = { 1564 - body?: never; 1565 - path?: never; 1566 - query?: never; 1567 - url: '/api/v{api-version}/duplicate'; 1568 - }; 1569 - 1570 - export type DuplicateName2Data = { 1571 - body?: never; 1572 - path?: never; 1573 - query?: never; 1574 - url: '/api/v{api-version}/duplicate'; 1575 - }; 1576 - 1577 - export type DuplicateName3Data = { 1578 - body?: never; 1579 - path?: never; 1580 - query?: never; 1581 - url: '/api/v{api-version}/duplicate'; 1582 - }; 1583 - 1584 - export type DuplicateName4Data = { 1585 - body?: never; 1586 - path?: never; 1587 - query?: never; 1588 - url: '/api/v{api-version}/duplicate'; 1589 - }; 1590 - 1591 - export type CallWithNoContentResponseData = { 1592 - body?: never; 1593 - path?: never; 1594 - query?: never; 1595 - url: '/api/v{api-version}/no-content'; 1596 - }; 1597 - 1598 - export type CallWithNoContentResponseResponses = { 1599 - /** 1600 - * Success 1601 - */ 1602 - 204: void; 1603 - }; 1604 - 1605 - export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; 1606 - 1607 - export type CallWithResponseAndNoContentResponseData = { 1608 - body?: never; 1609 - path?: never; 1610 - query?: never; 1611 - url: '/api/v{api-version}/multiple-tags/response-and-no-content'; 1612 - }; 1613 - 1614 - export type CallWithResponseAndNoContentResponseResponses = { 1615 - /** 1616 - * Response is a simple number 1617 - */ 1618 - 200: number; 1619 - /** 1620 - * Success 1621 - */ 1622 - 204: void; 1623 - }; 1624 - 1625 - export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; 1626 - 1627 - export type DummyAData = { 1628 - body?: never; 1629 - path?: never; 1630 - query?: never; 1631 - url: '/api/v{api-version}/multiple-tags/a'; 1632 - }; 1633 - 1634 - export type DummyAResponses = { 1635 - 200: _400; 1636 - }; 1637 - 1638 - export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; 1639 - 1640 - export type DummyBData = { 1641 - body?: never; 1642 - path?: never; 1643 - query?: never; 1644 - url: '/api/v{api-version}/multiple-tags/b'; 1645 - }; 1646 - 1647 - export type DummyBResponses = { 1648 - /** 1649 - * Success 1650 - */ 1651 - 204: void; 1652 - }; 1653 - 1654 - export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; 1655 - 1656 - export type CallWithResponseData = { 1657 - body?: never; 1658 - path?: never; 1659 - query?: never; 1660 - url: '/api/v{api-version}/response'; 1661 - }; 1662 - 1663 - export type CallWithResponseResponses = { 1664 - default: Import; 1665 - }; 1666 - 1667 - export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; 1668 - 1669 - export type CallWithDuplicateResponsesData = { 1670 - body?: never; 1671 - path?: never; 1672 - query?: never; 1673 - url: '/api/v{api-version}/response'; 1674 - }; 1675 - 1676 - export type CallWithDuplicateResponsesErrors = { 1677 - /** 1678 - * Message for 500 error 1679 - */ 1680 - 500: ModelWithStringError; 1681 - /** 1682 - * Message for 501 error 1683 - */ 1684 - 501: ModelWithStringError; 1685 - /** 1686 - * Message for 502 error 1687 - */ 1688 - 502: ModelWithStringError; 1689 - /** 1690 - * Message for 4XX errors 1691 - */ 1692 - '4XX': DictionaryWithArray; 1693 - /** 1694 - * Default error response 1695 - */ 1696 - default: ModelWithBoolean; 1697 - }; 1698 - 1699 - export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; 1700 - 1701 - export type CallWithDuplicateResponsesResponses = { 1702 - /** 1703 - * Message for 200 response 1704 - */ 1705 - 200: ModelWithBoolean & ModelWithInteger; 1706 - /** 1707 - * Message for 201 response 1708 - */ 1709 - 201: ModelWithString; 1710 - /** 1711 - * Message for 202 response 1712 - */ 1713 - 202: ModelWithString; 1714 - }; 1715 - 1716 - export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; 1717 - 1718 - export type CallWithResponsesData = { 1719 - body?: never; 1720 - path?: never; 1721 - query?: never; 1722 - url: '/api/v{api-version}/response'; 1723 - }; 1724 - 1725 - export type CallWithResponsesErrors = { 1726 - /** 1727 - * Message for 500 error 1728 - */ 1729 - 500: ModelWithStringError; 1730 - /** 1731 - * Message for 501 error 1732 - */ 1733 - 501: ModelWithStringError; 1734 - /** 1735 - * Message for 502 error 1736 - */ 1737 - 502: ModelWithStringError; 1738 - /** 1739 - * Message for default response 1740 - */ 1741 - default: ModelWithStringError; 1742 - }; 1743 - 1744 - export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; 1745 - 1746 - export type CallWithResponsesResponses = { 1747 - /** 1748 - * Message for 200 response 1749 - */ 1750 - 200: { 1751 - readonly '@namespace.string'?: string; 1752 - readonly '@namespace.integer'?: number; 1753 - readonly value?: Array<ModelWithString>; 1754 - }; 1755 - /** 1756 - * Message for 201 response 1757 - */ 1758 - 201: ModelThatExtends; 1759 - /** 1760 - * Message for 202 response 1761 - */ 1762 - 202: ModelThatExtendsExtends; 1763 - }; 1764 - 1765 - export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; 1766 - 1767 - export type CollectionFormatData = { 1768 - body?: never; 1769 - path?: never; 1770 - query: { 1771 - /** 1772 - * This is an array parameter that is sent as csv format (comma-separated values) 1773 - */ 1774 - parameterArrayCSV: Array<string> | null; 1775 - /** 1776 - * This is an array parameter that is sent as ssv format (space-separated values) 1777 - */ 1778 - parameterArraySSV: Array<string> | null; 1779 - /** 1780 - * This is an array parameter that is sent as tsv format (tab-separated values) 1781 - */ 1782 - parameterArrayTSV: Array<string> | null; 1783 - /** 1784 - * This is an array parameter that is sent as pipes format (pipe-separated values) 1785 - */ 1786 - parameterArrayPipes: Array<string> | null; 1787 - /** 1788 - * This is an array parameter that is sent as multi format (multiple parameter instances) 1789 - */ 1790 - parameterArrayMulti: Array<string> | null; 1791 - }; 1792 - url: '/api/v{api-version}/collectionFormat'; 1793 - }; 1794 - 1795 - export type TypesData = { 1796 - body?: never; 1797 - path?: { 1798 - /** 1799 - * This is a number parameter 1800 - */ 1801 - id?: number; 1802 - }; 1803 - query: { 1804 - /** 1805 - * This is a number parameter 1806 - */ 1807 - parameterNumber: number; 1808 - /** 1809 - * This is a string parameter 1810 - */ 1811 - parameterString: string | null; 1812 - /** 1813 - * This is a boolean parameter 1814 - */ 1815 - parameterBoolean: boolean | null; 1816 - /** 1817 - * This is an object parameter 1818 - */ 1819 - parameterObject: { 1820 - [key: string]: unknown; 1821 - } | null; 1822 - /** 1823 - * This is an array parameter 1824 - */ 1825 - parameterArray: Array<string> | null; 1826 - /** 1827 - * This is a dictionary parameter 1828 - */ 1829 - parameterDictionary: { 1830 - [key: string]: unknown; 1831 - } | null; 1832 - /** 1833 - * This is an enum parameter 1834 - */ 1835 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1836 - }; 1837 - url: '/api/v{api-version}/types'; 1838 - }; 1839 - 1840 - export type TypesResponses = { 1841 - /** 1842 - * Response is a simple number 1843 - */ 1844 - 200: number; 1845 - /** 1846 - * Response is a simple string 1847 - */ 1848 - 201: string; 1849 - /** 1850 - * Response is a simple boolean 1851 - */ 1852 - 202: boolean; 1853 - /** 1854 - * Response is a simple object 1855 - */ 1856 - 203: { 1857 - [key: string]: unknown; 1858 - }; 1859 - }; 1860 - 1861 - export type TypesResponse = TypesResponses[keyof TypesResponses]; 1862 - 1863 - export type UploadFileData = { 1864 - body: Blob | File; 1865 - path: { 1866 - /** 1867 - * api-version should be required in standalone clients 1868 - */ 1869 - 'api-version': string | null; 1870 - }; 1871 - query?: never; 1872 - url: '/api/v{api-version}/upload'; 1873 - }; 1874 - 1875 - export type UploadFileResponses = { 1876 - 200: boolean; 1877 - }; 1878 - 1879 - export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; 1880 - 1881 - export type FileResponseData = { 1882 - body?: never; 1883 - path: { 1884 - id: string; 1885 - /** 1886 - * api-version should be required in standalone clients 1887 - */ 1888 - 'api-version': string; 1889 - }; 1890 - query?: never; 1891 - url: '/api/v{api-version}/file/{id}'; 1892 - }; 1893 - 1894 - export type FileResponseResponses = { 1895 - /** 1896 - * Success 1897 - */ 1898 - 200: Blob | File; 1899 - }; 1900 - 1901 - export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; 1902 - 1903 - export type ComplexTypesData = { 1904 - body?: never; 1905 - path?: never; 1906 - query: { 1907 - /** 1908 - * Parameter containing object 1909 - */ 1910 - parameterObject: { 1911 - first?: { 1912 - second?: { 1913 - third?: string; 1914 - }; 1915 - }; 1916 - }; 1917 - /** 1918 - * Parameter containing reference 1919 - */ 1920 - parameterReference: ModelWithString; 1921 - }; 1922 - url: '/api/v{api-version}/complex'; 1923 - }; 1924 - 1925 - export type ComplexTypesErrors = { 1926 - /** 1927 - * 400 `server` error 1928 - */ 1929 - 400: unknown; 1930 - /** 1931 - * 500 server error 1932 - */ 1933 - 500: unknown; 1934 - }; 1935 - 1936 - export type ComplexTypesResponses = { 1937 - /** 1938 - * Successful response 1939 - */ 1940 - 200: Array<ModelWithString>; 1941 - }; 1942 - 1943 - export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; 1944 - 1945 - export type MultipartResponseData = { 1946 - body?: never; 1947 - path?: never; 1948 - query?: never; 1949 - url: '/api/v{api-version}/multipart'; 1950 - }; 1951 - 1952 - export type MultipartResponseResponses = { 1953 - /** 1954 - * OK 1955 - */ 1956 - 200: { 1957 - file?: Blob | File; 1958 - metadata?: { 1959 - foo?: string; 1960 - bar?: string; 1961 - }; 1962 - }; 1963 - }; 1964 - 1965 - export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; 1966 - 1967 - export type MultipartRequestData = { 1968 - body?: { 1969 - content?: Blob | File; 1970 - data?: ModelWithString | null; 1971 - }; 1972 - path?: never; 1973 - query?: never; 1974 - url: '/api/v{api-version}/multipart'; 1975 - }; 1976 - 1977 - export type ComplexParamsData = { 1978 - body?: { 1979 - readonly key: string | null; 1980 - name: string | null; 1981 - enabled?: boolean; 1982 - type: 'Monkey' | 'Horse' | 'Bird'; 1983 - listOfModels?: Array<ModelWithString> | null; 1984 - listOfStrings?: Array<string> | null; 1985 - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; 1986 - readonly user?: { 1987 - readonly id?: number; 1988 - readonly name?: string | null; 1989 - }; 1990 - }; 1991 - path: { 1992 - id: number; 1993 - /** 1994 - * api-version should be required in standalone clients 1995 - */ 1996 - 'api-version': string; 1997 - }; 1998 - query?: never; 1999 - url: '/api/v{api-version}/complex/{id}'; 2000 - }; 2001 - 2002 - export type ComplexParamsResponses = { 2003 - /** 2004 - * Success 2005 - */ 2006 - 200: ModelWithString; 2007 - }; 2008 - 2009 - export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; 2010 - 2011 - export type CallWithResultFromHeaderData = { 2012 - body?: never; 2013 - path?: never; 2014 - query?: never; 2015 - url: '/api/v{api-version}/header'; 2016 - }; 2017 - 2018 - export type CallWithResultFromHeaderErrors = { 2019 - /** 2020 - * 400 server error 2021 - */ 2022 - 400: unknown; 2023 - /** 2024 - * 500 server error 2025 - */ 2026 - 500: unknown; 2027 - }; 2028 - 2029 - export type CallWithResultFromHeaderResponses = { 2030 - /** 2031 - * Successful response 2032 - */ 2033 - 200: unknown; 2034 - }; 2035 - 2036 - export type TestErrorCodeData = { 2037 - body?: never; 2038 - path?: never; 2039 - query: { 2040 - /** 2041 - * Status code to return 2042 - */ 2043 - status: number; 2044 - }; 2045 - url: '/api/v{api-version}/error'; 2046 - }; 2047 - 2048 - export type TestErrorCodeErrors = { 2049 - /** 2050 - * Custom message: Internal Server Error 2051 - */ 2052 - 500: unknown; 2053 - /** 2054 - * Custom message: Not Implemented 2055 - */ 2056 - 501: unknown; 2057 - /** 2058 - * Custom message: Bad Gateway 2059 - */ 2060 - 502: unknown; 2061 - /** 2062 - * Custom message: Service Unavailable 2063 - */ 2064 - 503: unknown; 2065 - }; 2066 - 2067 - export type TestErrorCodeResponses = { 2068 - /** 2069 - * Custom message: Successful response 2070 - */ 2071 - 200: unknown; 2072 - }; 2073 - 2074 - export type NonAsciiæøåÆøÅöôêÊ字符串Data = { 2075 - body?: never; 2076 - path?: never; 2077 - query: { 2078 - /** 2079 - * Dummy input param 2080 - */ 2081 - nonAsciiParamæøåÆØÅöôêÊ: number; 2082 - }; 2083 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2084 - }; 2085 - 2086 - export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { 2087 - /** 2088 - * Successful response 2089 - */ 2090 - 200: Array<NonAsciiStringæøåÆøÅöôêÊ字符串>; 2091 - }; 2092 - 2093 - export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; 2094 - 2095 - export type PutWithFormUrlEncodedData = { 2096 - body: ArrayWithStrings; 2097 - path?: never; 2098 - query?: never; 2099 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; 2100 - };
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/enum-null/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/integer-formats/valibot.gen.ts
-595
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type HttpRequest, httpResource } from '@angular/common/http'; 4 - 5 - import { client } from '../client.gen'; 6 - import type { Options } from '../sdk.gen'; 7 - import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData, CallWithDefaultParametersData, CallWithDescriptionsData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithParametersData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithResponsesData, CallWithResponsesResponse, CallWithResultFromHeaderData, CallWithWeirdParameterNamesData, CollectionFormatData, ComplexParamsData, ComplexParamsResponse, ComplexTypesData, ComplexTypesResponse, DeleteCallWithoutParametersAndResponseData, DeleteFooData3, DeprecatedCallData, DummyAData, DummyAResponse, DummyBData, DummyBResponse, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, DuplicateNameData, ExportData, FileResponseData, FileResponseResponse, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, GetCallWithOptionalParamData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, ImportData, ImportResponse, MultipartRequestData, MultipartResponseData, MultipartResponseResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, OptionsCallWithoutParametersAndResponseData, PatchApiVbyApiVersionNoTagData, PatchCallWithoutParametersAndResponseData, PostApiVbyApiVersionFormDataData, PostApiVbyApiVersionRequestBodyData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, PutWithFormUrlEncodedData, TestErrorCodeData, TypesData, TypesResponse, UploadFileData, UploadFileResponse } from '../types.gen'; 8 - 9 - export const exportRequest = <ThrowOnError extends boolean = false>(options?: Options<ExportData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 10 - responseStyle: 'data', 11 - method: 'GET', 12 - url: '/api/v{api-version}/no+tag', 13 - ...options 14 - }); 15 - 16 - export const patchApiVbyApiVersionNoTagRequest = <ThrowOnError extends boolean = false>(options?: Options<PatchApiVbyApiVersionNoTagData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 17 - responseStyle: 'data', 18 - method: 'PATCH', 19 - url: '/api/v{api-version}/no+tag', 20 - ...options 21 - }); 22 - 23 - export const importRequest = <ThrowOnError extends boolean = false>(options: Options<ImportData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 24 - responseStyle: 'data', 25 - method: 'POST', 26 - url: '/api/v{api-version}/no+tag', 27 - ...options 28 - }); 29 - 30 - export const fooWowRequest = <ThrowOnError extends boolean = false>(options?: Options<FooWowData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 31 - responseStyle: 'data', 32 - method: 'PUT', 33 - url: '/api/v{api-version}/no+tag', 34 - ...options 35 - }); 36 - 37 - export const apiVVersionODataControllerCountRequest = <ThrowOnError extends boolean = false>(options?: Options<ApiVVersionODataControllerCountData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 38 - responseStyle: 'data', 39 - method: 'GET', 40 - url: '/api/v{api-version}/simple/$count', 41 - ...options 42 - }); 43 - 44 - export const getApiVbyApiVersionSimpleOperationRequest = <ThrowOnError extends boolean = false>(options: Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 45 - responseStyle: 'data', 46 - method: 'GET', 47 - url: '/api/v{api-version}/simple:operation', 48 - ...options 49 - }); 50 - 51 - export const deleteCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 52 - responseStyle: 'data', 53 - method: 'DELETE', 54 - url: '/api/v{api-version}/simple', 55 - ...options 56 - }); 57 - 58 - export const getCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<GetCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 59 - responseStyle: 'data', 60 - method: 'GET', 61 - url: '/api/v{api-version}/simple', 62 - ...options 63 - }); 64 - 65 - export const headCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<HeadCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 66 - responseStyle: 'data', 67 - method: 'HEAD', 68 - url: '/api/v{api-version}/simple', 69 - ...options 70 - }); 71 - 72 - export const optionsCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 73 - responseStyle: 'data', 74 - method: 'OPTIONS', 75 - url: '/api/v{api-version}/simple', 76 - ...options 77 - }); 78 - 79 - export const patchCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PatchCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 80 - responseStyle: 'data', 81 - method: 'PATCH', 82 - url: '/api/v{api-version}/simple', 83 - ...options 84 - }); 85 - 86 - export const postCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PostCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 87 - responseStyle: 'data', 88 - method: 'POST', 89 - url: '/api/v{api-version}/simple', 90 - ...options 91 - }); 92 - 93 - export const putCallWithoutParametersAndResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<PutCallWithoutParametersAndResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 94 - responseStyle: 'data', 95 - method: 'PUT', 96 - url: '/api/v{api-version}/simple', 97 - ...options 98 - }); 99 - 100 - export const deleteFooRequest = <ThrowOnError extends boolean = false>(options: Options<DeleteFooData3, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 101 - responseStyle: 'data', 102 - method: 'DELETE', 103 - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', 104 - ...options 105 - }); 106 - 107 - export const callWithDescriptionsRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDescriptionsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 108 - responseStyle: 'data', 109 - method: 'POST', 110 - url: '/api/v{api-version}/descriptions', 111 - ...options 112 - }); 113 - 114 - /** 115 - * @deprecated 116 - */ 117 - export const deprecatedCallRequest = <ThrowOnError extends boolean = false>(options: Options<DeprecatedCallData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 118 - responseStyle: 'data', 119 - method: 'POST', 120 - url: '/api/v{api-version}/parameters/deprecated', 121 - ...options 122 - }); 123 - 124 - export const callWithParametersRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 125 - responseStyle: 'data', 126 - method: 'POST', 127 - url: '/api/v{api-version}/parameters/{parameterPath}', 128 - ...options 129 - }); 130 - 131 - export const callWithWeirdParameterNamesRequest = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 132 - responseStyle: 'data', 133 - method: 'POST', 134 - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 135 - ...options 136 - }); 137 - 138 - export const getCallWithOptionalParamRequest = <ThrowOnError extends boolean = false>(options: Options<GetCallWithOptionalParamData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 139 - responseStyle: 'data', 140 - method: 'GET', 141 - url: '/api/v{api-version}/parameters', 142 - ...options 143 - }); 144 - 145 - export const postCallWithOptionalParamRequest = <ThrowOnError extends boolean = false>(options: Options<PostCallWithOptionalParamData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 146 - responseStyle: 'data', 147 - method: 'POST', 148 - url: '/api/v{api-version}/parameters', 149 - ...options 150 - }); 151 - 152 - export const postApiVbyApiVersionRequestBodyRequest = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 153 - responseStyle: 'data', 154 - method: 'POST', 155 - url: '/api/v{api-version}/requestBody', 156 - ...options 157 - }); 158 - 159 - export const postApiVbyApiVersionFormDataRequest = <ThrowOnError extends boolean = false>(options?: Options<PostApiVbyApiVersionFormDataData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 160 - responseStyle: 'data', 161 - method: 'POST', 162 - url: '/api/v{api-version}/formData', 163 - ...options 164 - }); 165 - 166 - export const callWithDefaultParametersRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 167 - responseStyle: 'data', 168 - method: 'GET', 169 - url: '/api/v{api-version}/defaults', 170 - ...options 171 - }); 172 - 173 - export const callWithDefaultOptionalParametersRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDefaultOptionalParametersData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 174 - responseStyle: 'data', 175 - method: 'POST', 176 - url: '/api/v{api-version}/defaults', 177 - ...options 178 - }); 179 - 180 - export const callToTestOrderOfParamsRequest = <ThrowOnError extends boolean = false>(options: Options<CallToTestOrderOfParamsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 181 - responseStyle: 'data', 182 - method: 'PUT', 183 - url: '/api/v{api-version}/defaults', 184 - ...options 185 - }); 186 - 187 - export const duplicateNameRequest = <ThrowOnError extends boolean = false>(options?: Options<DuplicateNameData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 188 - responseStyle: 'data', 189 - method: 'DELETE', 190 - url: '/api/v{api-version}/duplicate', 191 - ...options 192 - }); 193 - 194 - export const duplicateName2Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName2Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 195 - responseStyle: 'data', 196 - method: 'GET', 197 - url: '/api/v{api-version}/duplicate', 198 - ...options 199 - }); 200 - 201 - export const duplicateName3Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName3Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 202 - responseStyle: 'data', 203 - method: 'POST', 204 - url: '/api/v{api-version}/duplicate', 205 - ...options 206 - }); 207 - 208 - export const duplicateName4Request = <ThrowOnError extends boolean = false>(options?: Options<DuplicateName4Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 209 - responseStyle: 'data', 210 - method: 'PUT', 211 - url: '/api/v{api-version}/duplicate', 212 - ...options 213 - }); 214 - 215 - export const callWithNoContentResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithNoContentResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 216 - responseStyle: 'data', 217 - method: 'GET', 218 - url: '/api/v{api-version}/no-content', 219 - ...options 220 - }); 221 - 222 - export const callWithResponseAndNoContentResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseAndNoContentResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 223 - responseStyle: 'data', 224 - method: 'GET', 225 - url: '/api/v{api-version}/multiple-tags/response-and-no-content', 226 - ...options 227 - }); 228 - 229 - export const dummyARequest = <ThrowOnError extends boolean = false>(options?: Options<DummyAData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 230 - responseStyle: 'data', 231 - method: 'GET', 232 - url: '/api/v{api-version}/multiple-tags/a', 233 - ...options 234 - }); 235 - 236 - export const dummyBRequest = <ThrowOnError extends boolean = false>(options?: Options<DummyBData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 237 - responseStyle: 'data', 238 - method: 'GET', 239 - url: '/api/v{api-version}/multiple-tags/b', 240 - ...options 241 - }); 242 - 243 - export const callWithResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 244 - responseStyle: 'data', 245 - method: 'GET', 246 - url: '/api/v{api-version}/response', 247 - ...options 248 - }); 249 - 250 - export const callWithDuplicateResponsesRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithDuplicateResponsesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 251 - responseStyle: 'data', 252 - method: 'POST', 253 - url: '/api/v{api-version}/response', 254 - ...options 255 - }); 256 - 257 - export const callWithResponsesRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResponsesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 258 - responseStyle: 'data', 259 - method: 'PUT', 260 - url: '/api/v{api-version}/response', 261 - ...options 262 - }); 263 - 264 - export const collectionFormatRequest = <ThrowOnError extends boolean = false>(options: Options<CollectionFormatData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 265 - responseStyle: 'data', 266 - method: 'GET', 267 - url: '/api/v{api-version}/collectionFormat', 268 - ...options 269 - }); 270 - 271 - export const typesRequest = <ThrowOnError extends boolean = false>(options: Options<TypesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 272 - responseStyle: 'data', 273 - method: 'GET', 274 - url: '/api/v{api-version}/types', 275 - ...options 276 - }); 277 - 278 - export const uploadFileRequest = <ThrowOnError extends boolean = false>(options: Options<UploadFileData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 279 - responseStyle: 'data', 280 - method: 'POST', 281 - url: '/api/v{api-version}/upload', 282 - ...options 283 - }); 284 - 285 - export const fileResponseRequest = <ThrowOnError extends boolean = false>(options: Options<FileResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 286 - responseStyle: 'data', 287 - method: 'GET', 288 - url: '/api/v{api-version}/file/{id}', 289 - ...options 290 - }); 291 - 292 - export const complexTypesRequest = <ThrowOnError extends boolean = false>(options: Options<ComplexTypesData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 293 - responseStyle: 'data', 294 - method: 'GET', 295 - url: '/api/v{api-version}/complex', 296 - ...options 297 - }); 298 - 299 - export const multipartResponseRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartResponseData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 300 - responseStyle: 'data', 301 - method: 'GET', 302 - url: '/api/v{api-version}/multipart', 303 - ...options 304 - }); 305 - 306 - export const multipartRequestRequest = <ThrowOnError extends boolean = false>(options?: Options<MultipartRequestData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 307 - responseStyle: 'data', 308 - method: 'POST', 309 - url: '/api/v{api-version}/multipart', 310 - ...options 311 - }); 312 - 313 - export const complexParamsRequest = <ThrowOnError extends boolean = false>(options: Options<ComplexParamsData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 314 - responseStyle: 'data', 315 - method: 'PUT', 316 - url: '/api/v{api-version}/complex/{id}', 317 - ...options 318 - }); 319 - 320 - export const callWithResultFromHeaderRequest = <ThrowOnError extends boolean = false>(options?: Options<CallWithResultFromHeaderData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 321 - responseStyle: 'data', 322 - method: 'POST', 323 - url: '/api/v{api-version}/header', 324 - ...options 325 - }); 326 - 327 - export const testErrorCodeRequest = <ThrowOnError extends boolean = false>(options: Options<TestErrorCodeData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 328 - responseStyle: 'data', 329 - method: 'POST', 330 - url: '/api/v{api-version}/error', 331 - ...options 332 - }); 333 - 334 - export const nonAsciiæøåÆøÅöôêÊ字符串Request = <ThrowOnError extends boolean = false>(options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 335 - responseStyle: 'data', 336 - method: 'POST', 337 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 338 - ...options 339 - }); 340 - 341 - /** 342 - * Login User 343 - */ 344 - export const putWithFormUrlEncodedRequest = <ThrowOnError extends boolean = false>(options: Options<PutWithFormUrlEncodedData, ThrowOnError>): HttpRequest<unknown> => (options?.client ?? client).requestOptions({ 345 - responseStyle: 'data', 346 - method: 'PUT', 347 - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', 348 - ...options 349 - }); 350 - 351 - export const exportResource = <ThrowOnError extends boolean = false>(options?: () => Options<ExportData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 352 - const opts = options ? options() : undefined; 353 - return opts ? exportRequest(opts) : undefined; 354 - }); 355 - 356 - export const patchApiVbyApiVersionNoTagResource = <ThrowOnError extends boolean = false>(options?: () => Options<PatchApiVbyApiVersionNoTagData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 357 - const opts = options ? options() : undefined; 358 - return opts ? patchApiVbyApiVersionNoTagRequest(opts) : undefined; 359 - }); 360 - 361 - export const importResource = <ThrowOnError extends boolean = false>(options: () => Options<ImportData, ThrowOnError> | undefined) => httpResource<ImportResponse>(() => { 362 - const opts = options ? options() : undefined; 363 - return opts ? importRequest(opts) : undefined; 364 - }); 365 - 366 - export const fooWowResource = <ThrowOnError extends boolean = false>(options?: () => Options<FooWowData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 367 - const opts = options ? options() : undefined; 368 - return opts ? fooWowRequest(opts) : undefined; 369 - }); 370 - 371 - export const apiVVersionODataControllerCountResource = <ThrowOnError extends boolean = false>(options?: () => Options<ApiVVersionODataControllerCountData, ThrowOnError> | undefined) => httpResource<ApiVVersionODataControllerCountResponse>(() => { 372 - const opts = options ? options() : undefined; 373 - return opts ? apiVVersionODataControllerCountRequest(opts) : undefined; 374 - }); 375 - 376 - export const getApiVbyApiVersionSimpleOperationResource = <ThrowOnError extends boolean = false>(options: () => Options<GetApiVbyApiVersionSimpleOperationData, ThrowOnError> | undefined) => httpResource<GetApiVbyApiVersionSimpleOperationResponse>(() => { 377 - const opts = options ? options() : undefined; 378 - return opts ? getApiVbyApiVersionSimpleOperationRequest(opts) : undefined; 379 - }); 380 - 381 - export const deleteCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<DeleteCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 382 - const opts = options ? options() : undefined; 383 - return opts ? deleteCallWithoutParametersAndResponseRequest(opts) : undefined; 384 - }); 385 - 386 - export const getCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<GetCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 387 - const opts = options ? options() : undefined; 388 - return opts ? getCallWithoutParametersAndResponseRequest(opts) : undefined; 389 - }); 390 - 391 - export const headCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<HeadCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 392 - const opts = options ? options() : undefined; 393 - return opts ? headCallWithoutParametersAndResponseRequest(opts) : undefined; 394 - }); 395 - 396 - export const optionsCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<OptionsCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 397 - const opts = options ? options() : undefined; 398 - return opts ? optionsCallWithoutParametersAndResponseRequest(opts) : undefined; 399 - }); 400 - 401 - export const patchCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PatchCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 402 - const opts = options ? options() : undefined; 403 - return opts ? patchCallWithoutParametersAndResponseRequest(opts) : undefined; 404 - }); 405 - 406 - export const postCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 407 - const opts = options ? options() : undefined; 408 - return opts ? postCallWithoutParametersAndResponseRequest(opts) : undefined; 409 - }); 410 - 411 - export const putCallWithoutParametersAndResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<PutCallWithoutParametersAndResponseData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 412 - const opts = options ? options() : undefined; 413 - return opts ? putCallWithoutParametersAndResponseRequest(opts) : undefined; 414 - }); 415 - 416 - export const deleteFooResource = <ThrowOnError extends boolean = false>(options: () => Options<DeleteFooData3, ThrowOnError> | undefined) => httpResource<unknown>(() => { 417 - const opts = options ? options() : undefined; 418 - return opts ? deleteFooRequest(opts) : undefined; 419 - }); 420 - 421 - export const callWithDescriptionsResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDescriptionsData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 422 - const opts = options ? options() : undefined; 423 - return opts ? callWithDescriptionsRequest(opts) : undefined; 424 - }); 425 - 426 - /** 427 - * @deprecated 428 - */ 429 - export const deprecatedCallResource = <ThrowOnError extends boolean = false>(options: () => Options<DeprecatedCallData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 430 - const opts = options ? options() : undefined; 431 - return opts ? deprecatedCallRequest(opts) : undefined; 432 - }); 433 - 434 - export const callWithParametersResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 435 - const opts = options ? options() : undefined; 436 - return opts ? callWithParametersRequest(opts) : undefined; 437 - }); 438 - 439 - export const callWithWeirdParameterNamesResource = <ThrowOnError extends boolean = false>(options: () => Options<CallWithWeirdParameterNamesData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 440 - const opts = options ? options() : undefined; 441 - return opts ? callWithWeirdParameterNamesRequest(opts) : undefined; 442 - }); 443 - 444 - export const getCallWithOptionalParamResource = <ThrowOnError extends boolean = false>(options: () => Options<GetCallWithOptionalParamData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 445 - const opts = options ? options() : undefined; 446 - return opts ? getCallWithOptionalParamRequest(opts) : undefined; 447 - }); 448 - 449 - export const postCallWithOptionalParamResource = <ThrowOnError extends boolean = false>(options: () => Options<PostCallWithOptionalParamData, ThrowOnError> | undefined) => httpResource<PostCallWithOptionalParamResponse>(() => { 450 - const opts = options ? options() : undefined; 451 - return opts ? postCallWithOptionalParamRequest(opts) : undefined; 452 - }); 453 - 454 - export const postApiVbyApiVersionRequestBodyResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostApiVbyApiVersionRequestBodyData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 455 - const opts = options ? options() : undefined; 456 - return opts ? postApiVbyApiVersionRequestBodyRequest(opts) : undefined; 457 - }); 458 - 459 - export const postApiVbyApiVersionFormDataResource = <ThrowOnError extends boolean = false>(options?: () => Options<PostApiVbyApiVersionFormDataData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 460 - const opts = options ? options() : undefined; 461 - return opts ? postApiVbyApiVersionFormDataRequest(opts) : undefined; 462 - }); 463 - 464 - export const callWithDefaultParametersResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDefaultParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 465 - const opts = options ? options() : undefined; 466 - return opts ? callWithDefaultParametersRequest(opts) : undefined; 467 - }); 468 - 469 - export const callWithDefaultOptionalParametersResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDefaultOptionalParametersData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 470 - const opts = options ? options() : undefined; 471 - return opts ? callWithDefaultOptionalParametersRequest(opts) : undefined; 472 - }); 473 - 474 - export const callToTestOrderOfParamsResource = <ThrowOnError extends boolean = false>(options: () => Options<CallToTestOrderOfParamsData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 475 - const opts = options ? options() : undefined; 476 - return opts ? callToTestOrderOfParamsRequest(opts) : undefined; 477 - }); 478 - 479 - export const duplicateNameResource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateNameData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 480 - const opts = options ? options() : undefined; 481 - return opts ? duplicateNameRequest(opts) : undefined; 482 - }); 483 - 484 - export const duplicateName2Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName2Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 485 - const opts = options ? options() : undefined; 486 - return opts ? duplicateName2Request(opts) : undefined; 487 - }); 488 - 489 - export const duplicateName3Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName3Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 490 - const opts = options ? options() : undefined; 491 - return opts ? duplicateName3Request(opts) : undefined; 492 - }); 493 - 494 - export const duplicateName4Resource = <ThrowOnError extends boolean = false>(options?: () => Options<DuplicateName4Data, ThrowOnError> | undefined) => httpResource<unknown>(() => { 495 - const opts = options ? options() : undefined; 496 - return opts ? duplicateName4Request(opts) : undefined; 497 - }); 498 - 499 - export const callWithNoContentResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithNoContentResponseData, ThrowOnError> | undefined) => httpResource<CallWithNoContentResponseResponse>(() => { 500 - const opts = options ? options() : undefined; 501 - return opts ? callWithNoContentResponseRequest(opts) : undefined; 502 - }); 503 - 504 - export const callWithResponseAndNoContentResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponseAndNoContentResponseData, ThrowOnError> | undefined) => httpResource<CallWithResponseAndNoContentResponseResponse>(() => { 505 - const opts = options ? options() : undefined; 506 - return opts ? callWithResponseAndNoContentResponseRequest(opts) : undefined; 507 - }); 508 - 509 - export const dummyAResource = <ThrowOnError extends boolean = false>(options?: () => Options<DummyAData, ThrowOnError> | undefined) => httpResource<DummyAResponse>(() => { 510 - const opts = options ? options() : undefined; 511 - return opts ? dummyARequest(opts) : undefined; 512 - }); 513 - 514 - export const dummyBResource = <ThrowOnError extends boolean = false>(options?: () => Options<DummyBData, ThrowOnError> | undefined) => httpResource<DummyBResponse>(() => { 515 - const opts = options ? options() : undefined; 516 - return opts ? dummyBRequest(opts) : undefined; 517 - }); 518 - 519 - export const callWithResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponseData, ThrowOnError> | undefined) => httpResource<CallWithResponseResponse>(() => { 520 - const opts = options ? options() : undefined; 521 - return opts ? callWithResponseRequest(opts) : undefined; 522 - }); 523 - 524 - export const callWithDuplicateResponsesResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithDuplicateResponsesData, ThrowOnError> | undefined) => httpResource<CallWithDuplicateResponsesResponse>(() => { 525 - const opts = options ? options() : undefined; 526 - return opts ? callWithDuplicateResponsesRequest(opts) : undefined; 527 - }); 528 - 529 - export const callWithResponsesResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResponsesData, ThrowOnError> | undefined) => httpResource<CallWithResponsesResponse>(() => { 530 - const opts = options ? options() : undefined; 531 - return opts ? callWithResponsesRequest(opts) : undefined; 532 - }); 533 - 534 - export const collectionFormatResource = <ThrowOnError extends boolean = false>(options: () => Options<CollectionFormatData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 535 - const opts = options ? options() : undefined; 536 - return opts ? collectionFormatRequest(opts) : undefined; 537 - }); 538 - 539 - export const typesResource = <ThrowOnError extends boolean = false>(options: () => Options<TypesData, ThrowOnError> | undefined) => httpResource<TypesResponse>(() => { 540 - const opts = options ? options() : undefined; 541 - return opts ? typesRequest(opts) : undefined; 542 - }); 543 - 544 - export const uploadFileResource = <ThrowOnError extends boolean = false>(options: () => Options<UploadFileData, ThrowOnError> | undefined) => httpResource<UploadFileResponse>(() => { 545 - const opts = options ? options() : undefined; 546 - return opts ? uploadFileRequest(opts) : undefined; 547 - }); 548 - 549 - export const fileResponseResource = <ThrowOnError extends boolean = false>(options: () => Options<FileResponseData, ThrowOnError> | undefined) => httpResource<FileResponseResponse>(() => { 550 - const opts = options ? options() : undefined; 551 - return opts ? fileResponseRequest(opts) : undefined; 552 - }); 553 - 554 - export const complexTypesResource = <ThrowOnError extends boolean = false>(options: () => Options<ComplexTypesData, ThrowOnError> | undefined) => httpResource<ComplexTypesResponse>(() => { 555 - const opts = options ? options() : undefined; 556 - return opts ? complexTypesRequest(opts) : undefined; 557 - }); 558 - 559 - export const multipartResponseResource = <ThrowOnError extends boolean = false>(options?: () => Options<MultipartResponseData, ThrowOnError> | undefined) => httpResource<MultipartResponseResponse>(() => { 560 - const opts = options ? options() : undefined; 561 - return opts ? multipartResponseRequest(opts) : undefined; 562 - }); 563 - 564 - export const multipartRequestResource = <ThrowOnError extends boolean = false>(options?: () => Options<MultipartRequestData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 565 - const opts = options ? options() : undefined; 566 - return opts ? multipartRequestRequest(opts) : undefined; 567 - }); 568 - 569 - export const complexParamsResource = <ThrowOnError extends boolean = false>(options: () => Options<ComplexParamsData, ThrowOnError> | undefined) => httpResource<ComplexParamsResponse>(() => { 570 - const opts = options ? options() : undefined; 571 - return opts ? complexParamsRequest(opts) : undefined; 572 - }); 573 - 574 - export const callWithResultFromHeaderResource = <ThrowOnError extends boolean = false>(options?: () => Options<CallWithResultFromHeaderData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 575 - const opts = options ? options() : undefined; 576 - return opts ? callWithResultFromHeaderRequest(opts) : undefined; 577 - }); 578 - 579 - export const testErrorCodeResource = <ThrowOnError extends boolean = false>(options: () => Options<TestErrorCodeData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 580 - const opts = options ? options() : undefined; 581 - return opts ? testErrorCodeRequest(opts) : undefined; 582 - }); 583 - 584 - export const nonAsciiæøåÆøÅöôêÊ字符串Resource = <ThrowOnError extends boolean = false>(options: () => Options<NonAsciiæøåÆøÅöôêÊ字符串Data, ThrowOnError> | undefined) => httpResource<NonAsciiæøåÆøÅöôêÊ字符串Response>(() => { 585 - const opts = options ? options() : undefined; 586 - return opts ? nonAsciiæøåÆøÅöôêÊ字符串Request(opts) : undefined; 587 - }); 588 - 589 - /** 590 - * Login User 591 - */ 592 - export const putWithFormUrlEncodedResource = <ThrowOnError extends boolean = false>(options: () => Options<PutWithFormUrlEncodedData, ThrowOnError> | undefined) => httpResource<unknown>(() => { 593 - const opts = options ? options() : undefined; 594 - return opts ? putWithFormUrlEncodedRequest(opts) : undefined; 595 - });
-16
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 - import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 - 6 - /** 7 - * The `createClientConfig()` function will be called on client initialization 8 - * and the returned object will become the client's initial configuration. 9 - * 10 - * You may want to initialize your client this way instead of calling 11 - * `setConfig()`. This is useful for example if you're using Next.js 12 - * to ensure your client always has the correct values. 13 - */ 14 - export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 - 16 - export const client = createClient(createConfig<ClientOptions2>());
-290
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { createSseClient } from '../core/serverSentEvents.gen'; 4 - import type { HttpMethod } from '../core/types.gen'; 5 - import { getValidRequestBody } from '../core/utils.gen'; 6 - import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen'; 7 - import { 8 - buildUrl, 9 - createConfig, 10 - createInterceptors, 11 - getParseAs, 12 - mergeConfigs, 13 - mergeHeaders, 14 - setAuthParams, 15 - } from './utils.gen'; 16 - 17 - type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 18 - body?: any; 19 - headers: ReturnType<typeof mergeHeaders>; 20 - }; 21 - 22 - export const createClient = (config: Config = {}): Client => { 23 - let _config = mergeConfigs(createConfig(), config); 24 - 25 - const getConfig = (): Config => ({ ..._config }); 26 - 27 - const setConfig = (config: Config): Config => { 28 - _config = mergeConfigs(_config, config); 29 - return getConfig(); 30 - }; 31 - 32 - const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>(); 33 - 34 - const beforeRequest = async (options: RequestOptions) => { 35 - const opts = { 36 - ..._config, 37 - ...options, 38 - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 39 - headers: mergeHeaders(_config.headers, options.headers), 40 - serializedBody: undefined as string | undefined, 41 - }; 42 - 43 - if (opts.security) { 44 - await setAuthParams({ 45 - ...opts, 46 - security: opts.security, 47 - }); 48 - } 49 - 50 - if (opts.requestValidator) { 51 - await opts.requestValidator(opts); 52 - } 53 - 54 - if (opts.body !== undefined && opts.bodySerializer) { 55 - opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined; 56 - } 57 - 58 - // remove Content-Type header if body is empty to avoid sending invalid requests 59 - if (opts.body === undefined || opts.serializedBody === '') { 60 - opts.headers.delete('Content-Type'); 61 - } 62 - 63 - const url = buildUrl(opts); 64 - 65 - return { opts, url }; 66 - }; 67 - 68 - const request: Client['request'] = async (options) => { 69 - // @ts-expect-error 70 - const { opts, url } = await beforeRequest(options); 71 - const requestInit: ReqInit = { 72 - redirect: 'follow', 73 - ...opts, 74 - body: getValidRequestBody(opts), 75 - }; 76 - 77 - let request = new Request(url, requestInit); 78 - 79 - for (const fn of interceptors.request.fns) { 80 - if (fn) { 81 - request = await fn(request, opts); 82 - } 83 - } 84 - 85 - // fetch must be assigned here, otherwise it would throw the error: 86 - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 87 - const _fetch = opts.fetch!; 88 - let response: Response; 89 - 90 - try { 91 - response = await _fetch(request); 92 - } catch (error) { 93 - // Handle fetch exceptions (AbortError, network errors, etc.) 94 - let finalError = error; 95 - 96 - for (const fn of interceptors.error.fns) { 97 - if (fn) { 98 - finalError = (await fn(error, undefined as any, request, opts)) as unknown; 99 - } 100 - } 101 - 102 - finalError = finalError || ({} as unknown); 103 - 104 - if (opts.throwOnError) { 105 - throw finalError; 106 - } 107 - 108 - // Return error response 109 - return opts.responseStyle === 'data' 110 - ? undefined 111 - : { 112 - error: finalError, 113 - request, 114 - response: undefined as any, 115 - }; 116 - } 117 - 118 - for (const fn of interceptors.response.fns) { 119 - if (fn) { 120 - response = await fn(response, request, opts); 121 - } 122 - } 123 - 124 - const result = { 125 - request, 126 - response, 127 - }; 128 - 129 - if (response.ok) { 130 - const parseAs = 131 - (opts.parseAs === 'auto' 132 - ? getParseAs(response.headers.get('Content-Type')) 133 - : opts.parseAs) ?? 'json'; 134 - 135 - if (response.status === 204 || response.headers.get('Content-Length') === '0') { 136 - let emptyData: any; 137 - switch (parseAs) { 138 - case 'arrayBuffer': 139 - case 'blob': 140 - case 'text': 141 - emptyData = await response[parseAs](); 142 - break; 143 - case 'formData': 144 - emptyData = new FormData(); 145 - break; 146 - case 'stream': 147 - emptyData = response.body; 148 - break; 149 - case 'json': 150 - default: 151 - emptyData = {}; 152 - break; 153 - } 154 - return opts.responseStyle === 'data' 155 - ? emptyData 156 - : { 157 - data: emptyData, 158 - ...result, 159 - }; 160 - } 161 - 162 - let data: any; 163 - switch (parseAs) { 164 - case 'arrayBuffer': 165 - case 'blob': 166 - case 'formData': 167 - case 'text': 168 - data = await response[parseAs](); 169 - break; 170 - case 'json': { 171 - // Some servers return 200 with no Content-Length and empty body. 172 - // response.json() would throw; read as text and parse if non-empty. 173 - const text = await response.text(); 174 - data = text ? JSON.parse(text) : {}; 175 - break; 176 - } 177 - case 'stream': 178 - return opts.responseStyle === 'data' 179 - ? response.body 180 - : { 181 - data: response.body, 182 - ...result, 183 - }; 184 - } 185 - 186 - if (parseAs === 'json') { 187 - if (opts.responseValidator) { 188 - await opts.responseValidator(data); 189 - } 190 - 191 - if (opts.responseTransformer) { 192 - data = await opts.responseTransformer(data); 193 - } 194 - } 195 - 196 - return opts.responseStyle === 'data' 197 - ? data 198 - : { 199 - data, 200 - ...result, 201 - }; 202 - } 203 - 204 - const textError = await response.text(); 205 - let jsonError: unknown; 206 - 207 - try { 208 - jsonError = JSON.parse(textError); 209 - } catch { 210 - // noop 211 - } 212 - 213 - const error = jsonError ?? textError; 214 - let finalError = error; 215 - 216 - for (const fn of interceptors.error.fns) { 217 - if (fn) { 218 - finalError = (await fn(error, response, request, opts)) as string; 219 - } 220 - } 221 - 222 - finalError = finalError || ({} as string); 223 - 224 - if (opts.throwOnError) { 225 - throw finalError; 226 - } 227 - 228 - // TODO: we probably want to return error and improve types 229 - return opts.responseStyle === 'data' 230 - ? undefined 231 - : { 232 - error: finalError, 233 - ...result, 234 - }; 235 - }; 236 - 237 - const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 238 - request({ ...options, method }); 239 - 240 - const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 241 - const { opts, url } = await beforeRequest(options); 242 - return createSseClient({ 243 - ...opts, 244 - body: opts.body as BodyInit | null | undefined, 245 - headers: opts.headers as unknown as Record<string, string>, 246 - method, 247 - onRequest: async (url, init) => { 248 - let request = new Request(url, init); 249 - for (const fn of interceptors.request.fns) { 250 - if (fn) { 251 - request = await fn(request, opts); 252 - } 253 - } 254 - return request; 255 - }, 256 - serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined, 257 - url, 258 - }); 259 - }; 260 - 261 - const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options }); 262 - 263 - return { 264 - buildUrl: _buildUrl, 265 - connect: makeMethodFn('CONNECT'), 266 - delete: makeMethodFn('DELETE'), 267 - get: makeMethodFn('GET'), 268 - getConfig, 269 - head: makeMethodFn('HEAD'), 270 - interceptors, 271 - options: makeMethodFn('OPTIONS'), 272 - patch: makeMethodFn('PATCH'), 273 - post: makeMethodFn('POST'), 274 - put: makeMethodFn('PUT'), 275 - request, 276 - setConfig, 277 - sse: { 278 - connect: makeSseFn('CONNECT'), 279 - delete: makeSseFn('DELETE'), 280 - get: makeSseFn('GET'), 281 - head: makeSseFn('HEAD'), 282 - options: makeSseFn('OPTIONS'), 283 - patch: makeSseFn('PATCH'), 284 - post: makeSseFn('POST'), 285 - put: makeSseFn('PUT'), 286 - trace: makeSseFn('TRACE'), 287 - }, 288 - trace: makeMethodFn('TRACE'), 289 - } as Client; 290 - };
-25
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type { Auth } from '../core/auth.gen'; 4 - export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 - export { 6 - formDataBodySerializer, 7 - jsonBodySerializer, 8 - urlSearchParamsBodySerializer, 9 - } from '../core/bodySerializer.gen'; 10 - export { buildClientParams } from '../core/params.gen'; 11 - export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen'; 12 - export { createClient } from './client.gen'; 13 - export type { 14 - Client, 15 - ClientOptions, 16 - Config, 17 - CreateClientConfig, 18 - Options, 19 - RequestOptions, 20 - RequestResult, 21 - ResolvedRequestOptions, 22 - ResponseStyle, 23 - TDataShape, 24 - } from './types.gen'; 25 - export { createConfig, mergeHeaders } from './utils.gen';
-214
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Auth } from '../core/auth.gen'; 4 - import type { 5 - ServerSentEventsOptions, 6 - ServerSentEventsResult, 7 - } from '../core/serverSentEvents.gen'; 8 - import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen'; 9 - import type { Middleware } from './utils.gen'; 10 - 11 - export type ResponseStyle = 'data' | 'fields'; 12 - 13 - export interface Config<T extends ClientOptions = ClientOptions> 14 - extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig { 15 - /** 16 - * Base URL for all requests made by this client. 17 - */ 18 - baseUrl?: T['baseUrl']; 19 - /** 20 - * Fetch API implementation. You can use this option to provide a custom 21 - * fetch instance. 22 - * 23 - * @default globalThis.fetch 24 - */ 25 - fetch?: typeof fetch; 26 - /** 27 - * Please don't use the Fetch client for Next.js applications. The `next` 28 - * options won't have any effect. 29 - * 30 - * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 31 - */ 32 - next?: never; 33 - /** 34 - * Return the response data parsed in a specified format. By default, `auto` 35 - * will infer the appropriate method from the `Content-Type` response header. 36 - * You can override this behavior with any of the {@link Body} methods. 37 - * Select `stream` if you don't want to parse response data at all. 38 - * 39 - * @default 'auto' 40 - */ 41 - parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text'; 42 - /** 43 - * Should we return only data or multiple fields (data, error, response, etc.)? 44 - * 45 - * @default 'fields' 46 - */ 47 - responseStyle?: ResponseStyle; 48 - /** 49 - * Throw an error instead of returning it in the response? 50 - * 51 - * @default false 52 - */ 53 - throwOnError?: T['throwOnError']; 54 - } 55 - 56 - export interface RequestOptions< 57 - TData = unknown, 58 - TResponseStyle extends ResponseStyle = 'fields', 59 - ThrowOnError extends boolean = boolean, 60 - Url extends string = string, 61 - > 62 - extends 63 - Config<{ 64 - responseStyle: TResponseStyle; 65 - throwOnError: ThrowOnError; 66 - }>, 67 - Pick< 68 - ServerSentEventsOptions<TData>, 69 - | 'onRequest' 70 - | 'onSseError' 71 - | 'onSseEvent' 72 - | 'sseDefaultRetryDelay' 73 - | 'sseMaxRetryAttempts' 74 - | 'sseMaxRetryDelay' 75 - > { 76 - /** 77 - * Any body that you want to add to your request. 78 - * 79 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 80 - */ 81 - body?: unknown; 82 - path?: Record<string, unknown>; 83 - query?: Record<string, unknown>; 84 - /** 85 - * Security mechanism(s) to use for the request. 86 - */ 87 - security?: ReadonlyArray<Auth>; 88 - url: Url; 89 - } 90 - 91 - export interface ResolvedRequestOptions< 92 - TResponseStyle extends ResponseStyle = 'fields', 93 - ThrowOnError extends boolean = boolean, 94 - Url extends string = string, 95 - > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 96 - serializedBody?: string; 97 - } 98 - 99 - export type RequestResult< 100 - TData = unknown, 101 - TError = unknown, 102 - ThrowOnError extends boolean = boolean, 103 - TResponseStyle extends ResponseStyle = 'fields', 104 - > = ThrowOnError extends true 105 - ? Promise< 106 - TResponseStyle extends 'data' 107 - ? TData extends Record<string, unknown> 108 - ? TData[keyof TData] 109 - : TData 110 - : { 111 - data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 112 - request: Request; 113 - response: Response; 114 - } 115 - > 116 - : Promise< 117 - TResponseStyle extends 'data' 118 - ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined 119 - : ( 120 - | { 121 - data: TData extends Record<string, unknown> ? TData[keyof TData] : TData; 122 - error: undefined; 123 - } 124 - | { 125 - data: undefined; 126 - error: TError extends Record<string, unknown> ? TError[keyof TError] : TError; 127 - } 128 - ) & { 129 - request: Request; 130 - response: Response; 131 - } 132 - >; 133 - 134 - export interface ClientOptions { 135 - baseUrl?: string; 136 - responseStyle?: ResponseStyle; 137 - throwOnError?: boolean; 138 - } 139 - 140 - type MethodFn = < 141 - TData = unknown, 142 - TError = unknown, 143 - ThrowOnError extends boolean = false, 144 - TResponseStyle extends ResponseStyle = 'fields', 145 - >( 146 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 147 - ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 148 - 149 - type SseFn = < 150 - TData = unknown, 151 - TError = unknown, 152 - ThrowOnError extends boolean = false, 153 - TResponseStyle extends ResponseStyle = 'fields', 154 - >( 155 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 156 - ) => Promise<ServerSentEventsResult<TData, TError>>; 157 - 158 - type RequestFn = < 159 - TData = unknown, 160 - TError = unknown, 161 - ThrowOnError extends boolean = false, 162 - TResponseStyle extends ResponseStyle = 'fields', 163 - >( 164 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 165 - Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>, 166 - ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 167 - 168 - type BuildUrlFn = < 169 - TData extends { 170 - body?: unknown; 171 - path?: Record<string, unknown>; 172 - query?: Record<string, unknown>; 173 - url: string; 174 - }, 175 - >( 176 - options: TData & Options<TData>, 177 - ) => string; 178 - 179 - export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & { 180 - interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 181 - }; 182 - 183 - /** 184 - * The `createClientConfig()` function will be called on client initialization 185 - * and the returned object will become the client's initial configuration. 186 - * 187 - * You may want to initialize your client this way instead of calling 188 - * `setConfig()`. This is useful for example if you're using Next.js 189 - * to ensure your client always has the correct values. 190 - */ 191 - export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 192 - override?: Config<ClientOptions & T>, 193 - ) => Config<Required<ClientOptions> & T>; 194 - 195 - export interface TDataShape { 196 - body?: unknown; 197 - headers?: unknown; 198 - path?: unknown; 199 - query?: unknown; 200 - url: string; 201 - } 202 - 203 - type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 204 - 205 - export type Options< 206 - TData extends TDataShape = TDataShape, 207 - ThrowOnError extends boolean = boolean, 208 - TResponse = unknown, 209 - TResponseStyle extends ResponseStyle = 'fields', 210 - > = OmitKeys< 211 - RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 212 - 'body' | 'path' | 'query' | 'url' 213 - > & 214 - ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
-316
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { getAuthToken } from '../core/auth.gen'; 4 - import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 - import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 - import { 7 - serializeArrayParam, 8 - serializeObjectParam, 9 - serializePrimitiveParam, 10 - } from '../core/pathSerializer.gen'; 11 - import { getUrl } from '../core/utils.gen'; 12 - import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 - 14 - export const createQuerySerializer = <T = unknown>({ 15 - parameters = {}, 16 - ...args 17 - }: QuerySerializerOptions = {}) => { 18 - const querySerializer = (queryParams: T) => { 19 - const search: string[] = []; 20 - if (queryParams && typeof queryParams === 'object') { 21 - for (const name in queryParams) { 22 - const value = queryParams[name]; 23 - 24 - if (value === undefined || value === null) { 25 - continue; 26 - } 27 - 28 - const options = parameters[name] || args; 29 - 30 - if (Array.isArray(value)) { 31 - const serializedArray = serializeArrayParam({ 32 - allowReserved: options.allowReserved, 33 - explode: true, 34 - name, 35 - style: 'form', 36 - value, 37 - ...options.array, 38 - }); 39 - if (serializedArray) search.push(serializedArray); 40 - } else if (typeof value === 'object') { 41 - const serializedObject = serializeObjectParam({ 42 - allowReserved: options.allowReserved, 43 - explode: true, 44 - name, 45 - style: 'deepObject', 46 - value: value as Record<string, unknown>, 47 - ...options.object, 48 - }); 49 - if (serializedObject) search.push(serializedObject); 50 - } else { 51 - const serializedPrimitive = serializePrimitiveParam({ 52 - allowReserved: options.allowReserved, 53 - name, 54 - value: value as string, 55 - }); 56 - if (serializedPrimitive) search.push(serializedPrimitive); 57 - } 58 - } 59 - } 60 - return search.join('&'); 61 - }; 62 - return querySerializer; 63 - }; 64 - 65 - /** 66 - * Infers parseAs value from provided Content-Type header. 67 - */ 68 - export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => { 69 - if (!contentType) { 70 - // If no Content-Type header is provided, the best we can do is return the raw response body, 71 - // which is effectively the same as the 'stream' option. 72 - return 'stream'; 73 - } 74 - 75 - const cleanContent = contentType.split(';')[0]?.trim(); 76 - 77 - if (!cleanContent) { 78 - return; 79 - } 80 - 81 - if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) { 82 - return 'json'; 83 - } 84 - 85 - if (cleanContent === 'multipart/form-data') { 86 - return 'formData'; 87 - } 88 - 89 - if ( 90 - ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type)) 91 - ) { 92 - return 'blob'; 93 - } 94 - 95 - if (cleanContent.startsWith('text/')) { 96 - return 'text'; 97 - } 98 - 99 - return; 100 - }; 101 - 102 - const checkForExistence = ( 103 - options: Pick<RequestOptions, 'auth' | 'query'> & { 104 - headers: Headers; 105 - }, 106 - name?: string, 107 - ): boolean => { 108 - if (!name) { 109 - return false; 110 - } 111 - if ( 112 - options.headers.has(name) || 113 - options.query?.[name] || 114 - options.headers.get('Cookie')?.includes(`${name}=`) 115 - ) { 116 - return true; 117 - } 118 - return false; 119 - }; 120 - 121 - export const setAuthParams = async ({ 122 - security, 123 - ...options 124 - }: Pick<Required<RequestOptions>, 'security'> & 125 - Pick<RequestOptions, 'auth' | 'query'> & { 126 - headers: Headers; 127 - }) => { 128 - for (const auth of security) { 129 - if (checkForExistence(options, auth.name)) { 130 - continue; 131 - } 132 - 133 - const token = await getAuthToken(auth, options.auth); 134 - 135 - if (!token) { 136 - continue; 137 - } 138 - 139 - const name = auth.name ?? 'Authorization'; 140 - 141 - switch (auth.in) { 142 - case 'query': 143 - if (!options.query) { 144 - options.query = {}; 145 - } 146 - options.query[name] = token; 147 - break; 148 - case 'cookie': 149 - options.headers.append('Cookie', `${name}=${token}`); 150 - break; 151 - case 'header': 152 - default: 153 - options.headers.set(name, token); 154 - break; 155 - } 156 - } 157 - }; 158 - 159 - export const buildUrl: Client['buildUrl'] = (options) => 160 - getUrl({ 161 - baseUrl: options.baseUrl as string, 162 - path: options.path, 163 - query: options.query, 164 - querySerializer: 165 - typeof options.querySerializer === 'function' 166 - ? options.querySerializer 167 - : createQuerySerializer(options.querySerializer), 168 - url: options.url, 169 - }); 170 - 171 - export const mergeConfigs = (a: Config, b: Config): Config => { 172 - const config = { ...a, ...b }; 173 - if (config.baseUrl?.endsWith('/')) { 174 - config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 175 - } 176 - config.headers = mergeHeaders(a.headers, b.headers); 177 - return config; 178 - }; 179 - 180 - const headersEntries = (headers: Headers): Array<[string, string]> => { 181 - const entries: Array<[string, string]> = []; 182 - headers.forEach((value, key) => { 183 - entries.push([key, value]); 184 - }); 185 - return entries; 186 - }; 187 - 188 - export const mergeHeaders = ( 189 - ...headers: Array<Required<Config>['headers'] | undefined> 190 - ): Headers => { 191 - const mergedHeaders = new Headers(); 192 - for (const header of headers) { 193 - if (!header) { 194 - continue; 195 - } 196 - 197 - const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header); 198 - 199 - for (const [key, value] of iterator) { 200 - if (value === null) { 201 - mergedHeaders.delete(key); 202 - } else if (Array.isArray(value)) { 203 - for (const v of value) { 204 - mergedHeaders.append(key, v as string); 205 - } 206 - } else if (value !== undefined) { 207 - // assume object headers are meant to be JSON stringified, i.e. their 208 - // content value in OpenAPI specification is 'application/json' 209 - mergedHeaders.set( 210 - key, 211 - typeof value === 'object' ? JSON.stringify(value) : (value as string), 212 - ); 213 - } 214 - } 215 - } 216 - return mergedHeaders; 217 - }; 218 - 219 - type ErrInterceptor<Err, Res, Req, Options> = ( 220 - error: Err, 221 - response: Res, 222 - request: Req, 223 - options: Options, 224 - ) => Err | Promise<Err>; 225 - 226 - type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>; 227 - 228 - type ResInterceptor<Res, Req, Options> = ( 229 - response: Res, 230 - request: Req, 231 - options: Options, 232 - ) => Res | Promise<Res>; 233 - 234 - class Interceptors<Interceptor> { 235 - fns: Array<Interceptor | null> = []; 236 - 237 - clear(): void { 238 - this.fns = []; 239 - } 240 - 241 - eject(id: number | Interceptor): void { 242 - const index = this.getInterceptorIndex(id); 243 - if (this.fns[index]) { 244 - this.fns[index] = null; 245 - } 246 - } 247 - 248 - exists(id: number | Interceptor): boolean { 249 - const index = this.getInterceptorIndex(id); 250 - return Boolean(this.fns[index]); 251 - } 252 - 253 - getInterceptorIndex(id: number | Interceptor): number { 254 - if (typeof id === 'number') { 255 - return this.fns[id] ? id : -1; 256 - } 257 - return this.fns.indexOf(id); 258 - } 259 - 260 - update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false { 261 - const index = this.getInterceptorIndex(id); 262 - if (this.fns[index]) { 263 - this.fns[index] = fn; 264 - return id; 265 - } 266 - return false; 267 - } 268 - 269 - use(fn: Interceptor): number { 270 - this.fns.push(fn); 271 - return this.fns.length - 1; 272 - } 273 - } 274 - 275 - export interface Middleware<Req, Res, Err, Options> { 276 - error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; 277 - request: Interceptors<ReqInterceptor<Req, Options>>; 278 - response: Interceptors<ResInterceptor<Res, Req, Options>>; 279 - } 280 - 281 - export const createInterceptors = <Req, Res, Err, Options>(): Middleware< 282 - Req, 283 - Res, 284 - Err, 285 - Options 286 - > => ({ 287 - error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 288 - request: new Interceptors<ReqInterceptor<Req, Options>>(), 289 - response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 290 - }); 291 - 292 - const defaultQuerySerializer = createQuerySerializer({ 293 - allowReserved: false, 294 - array: { 295 - explode: true, 296 - style: 'form', 297 - }, 298 - object: { 299 - explode: true, 300 - style: 'deepObject', 301 - }, 302 - }); 303 - 304 - const defaultHeaders = { 305 - 'Content-Type': 'application/json', 306 - }; 307 - 308 - export const createConfig = <T extends ClientOptions = ClientOptions>( 309 - override: Config<Omit<ClientOptions, keyof T> & T> = {}, 310 - ): Config<Omit<ClientOptions, keyof T> & T> => ({ 311 - ...jsonBodySerializer, 312 - headers: defaultHeaders, 313 - parseAs: 'auto', 314 - querySerializer: defaultQuerySerializer, 315 - ...override, 316 - });
-41
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/auth.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type AuthToken = string | undefined; 4 - 5 - export interface Auth { 6 - /** 7 - * Which part of the request do we use to send the auth? 8 - * 9 - * @default 'header' 10 - */ 11 - in?: 'header' | 'query' | 'cookie'; 12 - /** 13 - * Header or query parameter name. 14 - * 15 - * @default 'Authorization' 16 - */ 17 - name?: string; 18 - scheme?: 'basic' | 'bearer'; 19 - type: 'apiKey' | 'http'; 20 - } 21 - 22 - export const getAuthToken = async ( 23 - auth: Auth, 24 - callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 - ): Promise<string | undefined> => { 26 - const token = typeof callback === 'function' ? await callback(auth) : callback; 27 - 28 - if (!token) { 29 - return; 30 - } 31 - 32 - if (auth.scheme === 'bearer') { 33 - return `Bearer ${token}`; 34 - } 35 - 36 - if (auth.scheme === 'basic') { 37 - return `Basic ${btoa(token)}`; 38 - } 39 - 40 - return token; 41 - };
-82
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/bodySerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen'; 4 - 5 - export type QuerySerializer = (query: Record<string, unknown>) => string; 6 - 7 - export type BodySerializer = (body: unknown) => unknown; 8 - 9 - type QuerySerializerOptionsObject = { 10 - allowReserved?: boolean; 11 - array?: Partial<SerializerOptions<ArrayStyle>>; 12 - object?: Partial<SerializerOptions<ObjectStyle>>; 13 - }; 14 - 15 - export type QuerySerializerOptions = QuerySerializerOptionsObject & { 16 - /** 17 - * Per-parameter serialization overrides. When provided, these settings 18 - * override the global array/object settings for specific parameter names. 19 - */ 20 - parameters?: Record<string, QuerySerializerOptionsObject>; 21 - }; 22 - 23 - const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => { 24 - if (typeof value === 'string' || value instanceof Blob) { 25 - data.append(key, value); 26 - } else if (value instanceof Date) { 27 - data.append(key, value.toISOString()); 28 - } else { 29 - data.append(key, JSON.stringify(value)); 30 - } 31 - }; 32 - 33 - const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => { 34 - if (typeof value === 'string') { 35 - data.append(key, value); 36 - } else { 37 - data.append(key, JSON.stringify(value)); 38 - } 39 - }; 40 - 41 - export const formDataBodySerializer = { 42 - bodySerializer: (body: unknown): FormData => { 43 - const data = new FormData(); 44 - 45 - Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 46 - if (value === undefined || value === null) { 47 - return; 48 - } 49 - if (Array.isArray(value)) { 50 - value.forEach((v) => serializeFormDataPair(data, key, v)); 51 - } else { 52 - serializeFormDataPair(data, key, value); 53 - } 54 - }); 55 - 56 - return data; 57 - }, 58 - }; 59 - 60 - export const jsonBodySerializer = { 61 - bodySerializer: (body: unknown): string => 62 - JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)), 63 - }; 64 - 65 - export const urlSearchParamsBodySerializer = { 66 - bodySerializer: (body: unknown): string => { 67 - const data = new URLSearchParams(); 68 - 69 - Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 70 - if (value === undefined || value === null) { 71 - return; 72 - } 73 - if (Array.isArray(value)) { 74 - value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 75 - } else { 76 - serializeUrlSearchParamsPair(data, key, value); 77 - } 78 - }); 79 - 80 - return data.toString(); 81 - }, 82 - };
-169
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/params.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - type Slot = 'body' | 'headers' | 'path' | 'query'; 4 - 5 - export type Field = 6 - | { 7 - in: Exclude<Slot, 'body'>; 8 - /** 9 - * Field name. This is the name we want the user to see and use. 10 - */ 11 - key: string; 12 - /** 13 - * Field mapped name. This is the name we want to use in the request. 14 - * If omitted, we use the same value as `key`. 15 - */ 16 - map?: string; 17 - } 18 - | { 19 - in: Extract<Slot, 'body'>; 20 - /** 21 - * Key isn't required for bodies. 22 - */ 23 - key?: string; 24 - map?: string; 25 - } 26 - | { 27 - /** 28 - * Field name. This is the name we want the user to see and use. 29 - */ 30 - key: string; 31 - /** 32 - * Field mapped name. This is the name we want to use in the request. 33 - * If `in` is omitted, `map` aliases `key` to the transport layer. 34 - */ 35 - map: Slot; 36 - }; 37 - 38 - export interface Fields { 39 - allowExtra?: Partial<Record<Slot, boolean>>; 40 - args?: ReadonlyArray<Field>; 41 - } 42 - 43 - export type FieldsConfig = ReadonlyArray<Field | Fields>; 44 - 45 - const extraPrefixesMap: Record<string, Slot> = { 46 - $body_: 'body', 47 - $headers_: 'headers', 48 - $path_: 'path', 49 - $query_: 'query', 50 - }; 51 - const extraPrefixes = Object.entries(extraPrefixesMap); 52 - 53 - type KeyMap = Map< 54 - string, 55 - | { 56 - in: Slot; 57 - map?: string; 58 - } 59 - | { 60 - in?: never; 61 - map: Slot; 62 - } 63 - >; 64 - 65 - const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 66 - if (!map) { 67 - map = new Map(); 68 - } 69 - 70 - for (const config of fields) { 71 - if ('in' in config) { 72 - if (config.key) { 73 - map.set(config.key, { 74 - in: config.in, 75 - map: config.map, 76 - }); 77 - } 78 - } else if ('key' in config) { 79 - map.set(config.key, { 80 - map: config.map, 81 - }); 82 - } else if (config.args) { 83 - buildKeyMap(config.args, map); 84 - } 85 - } 86 - 87 - return map; 88 - }; 89 - 90 - interface Params { 91 - body: unknown; 92 - headers: Record<string, unknown>; 93 - path: Record<string, unknown>; 94 - query: Record<string, unknown>; 95 - } 96 - 97 - const stripEmptySlots = (params: Params) => { 98 - for (const [slot, value] of Object.entries(params)) { 99 - if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) { 100 - delete params[slot as Slot]; 101 - } 102 - } 103 - }; 104 - 105 - export const buildClientParams = (args: ReadonlyArray<unknown>, fields: FieldsConfig) => { 106 - const params: Params = { 107 - body: {}, 108 - headers: {}, 109 - path: {}, 110 - query: {}, 111 - }; 112 - 113 - const map = buildKeyMap(fields); 114 - 115 - let config: FieldsConfig[number] | undefined; 116 - 117 - for (const [index, arg] of args.entries()) { 118 - if (fields[index]) { 119 - config = fields[index]; 120 - } 121 - 122 - if (!config) { 123 - continue; 124 - } 125 - 126 - if ('in' in config) { 127 - if (config.key) { 128 - const field = map.get(config.key)!; 129 - const name = field.map || config.key; 130 - if (field.in) { 131 - (params[field.in] as Record<string, unknown>)[name] = arg; 132 - } 133 - } else { 134 - params.body = arg; 135 - } 136 - } else { 137 - for (const [key, value] of Object.entries(arg ?? {})) { 138 - const field = map.get(key); 139 - 140 - if (field) { 141 - if (field.in) { 142 - const name = field.map || key; 143 - (params[field.in] as Record<string, unknown>)[name] = value; 144 - } else { 145 - params[field.map] = value; 146 - } 147 - } else { 148 - const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)); 149 - 150 - if (extra) { 151 - const [prefix, slot] = extra; 152 - (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value; 153 - } else if ('allowExtra' in config && config.allowExtra) { 154 - for (const [slot, allowed] of Object.entries(config.allowExtra)) { 155 - if (allowed) { 156 - (params[slot as Slot] as Record<string, unknown>)[key] = value; 157 - break; 158 - } 159 - } 160 - } 161 - } 162 - } 163 - } 164 - } 165 - 166 - stripEmptySlots(params); 167 - 168 - return params; 169 - };
-171
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/pathSerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {} 4 - 5 - interface SerializePrimitiveOptions { 6 - allowReserved?: boolean; 7 - name: string; 8 - } 9 - 10 - export interface SerializerOptions<T> { 11 - /** 12 - * @default true 13 - */ 14 - explode: boolean; 15 - style: T; 16 - } 17 - 18 - export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 19 - export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 20 - type MatrixStyle = 'label' | 'matrix' | 'simple'; 21 - export type ObjectStyle = 'form' | 'deepObject'; 22 - type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 23 - 24 - interface SerializePrimitiveParam extends SerializePrimitiveOptions { 25 - value: string; 26 - } 27 - 28 - export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 29 - switch (style) { 30 - case 'label': 31 - return '.'; 32 - case 'matrix': 33 - return ';'; 34 - case 'simple': 35 - return ','; 36 - default: 37 - return '&'; 38 - } 39 - }; 40 - 41 - export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 42 - switch (style) { 43 - case 'form': 44 - return ','; 45 - case 'pipeDelimited': 46 - return '|'; 47 - case 'spaceDelimited': 48 - return '%20'; 49 - default: 50 - return ','; 51 - } 52 - }; 53 - 54 - export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 55 - switch (style) { 56 - case 'label': 57 - return '.'; 58 - case 'matrix': 59 - return ';'; 60 - case 'simple': 61 - return ','; 62 - default: 63 - return '&'; 64 - } 65 - }; 66 - 67 - export const serializeArrayParam = ({ 68 - allowReserved, 69 - explode, 70 - name, 71 - style, 72 - value, 73 - }: SerializeOptions<ArraySeparatorStyle> & { 74 - value: unknown[]; 75 - }) => { 76 - if (!explode) { 77 - const joinedValues = ( 78 - allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 79 - ).join(separatorArrayNoExplode(style)); 80 - switch (style) { 81 - case 'label': 82 - return `.${joinedValues}`; 83 - case 'matrix': 84 - return `;${name}=${joinedValues}`; 85 - case 'simple': 86 - return joinedValues; 87 - default: 88 - return `${name}=${joinedValues}`; 89 - } 90 - } 91 - 92 - const separator = separatorArrayExplode(style); 93 - const joinedValues = value 94 - .map((v) => { 95 - if (style === 'label' || style === 'simple') { 96 - return allowReserved ? v : encodeURIComponent(v as string); 97 - } 98 - 99 - return serializePrimitiveParam({ 100 - allowReserved, 101 - name, 102 - value: v as string, 103 - }); 104 - }) 105 - .join(separator); 106 - return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 107 - }; 108 - 109 - export const serializePrimitiveParam = ({ 110 - allowReserved, 111 - name, 112 - value, 113 - }: SerializePrimitiveParam) => { 114 - if (value === undefined || value === null) { 115 - return ''; 116 - } 117 - 118 - if (typeof value === 'object') { 119 - throw new Error( 120 - 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 121 - ); 122 - } 123 - 124 - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 125 - }; 126 - 127 - export const serializeObjectParam = ({ 128 - allowReserved, 129 - explode, 130 - name, 131 - style, 132 - value, 133 - valueOnly, 134 - }: SerializeOptions<ObjectSeparatorStyle> & { 135 - value: Record<string, unknown> | Date; 136 - valueOnly?: boolean; 137 - }) => { 138 - if (value instanceof Date) { 139 - return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 140 - } 141 - 142 - if (style !== 'deepObject' && !explode) { 143 - let values: string[] = []; 144 - Object.entries(value).forEach(([key, v]) => { 145 - values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)]; 146 - }); 147 - const joinedValues = values.join(','); 148 - switch (style) { 149 - case 'form': 150 - return `${name}=${joinedValues}`; 151 - case 'label': 152 - return `.${joinedValues}`; 153 - case 'matrix': 154 - return `;${name}=${joinedValues}`; 155 - default: 156 - return joinedValues; 157 - } 158 - } 159 - 160 - const separator = separatorObjectExplode(style); 161 - const joinedValues = Object.entries(value) 162 - .map(([key, v]) => 163 - serializePrimitiveParam({ 164 - allowReserved, 165 - name: style === 'deepObject' ? `${name}[${key}]` : key, 166 - value: v as string, 167 - }), 168 - ) 169 - .join(separator); 170 - return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; 171 - };
-117
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/queryKeySerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - /** 4 - * JSON-friendly union that mirrors what Pinia Colada can hash. 5 - */ 6 - export type JsonValue = 7 - | null 8 - | string 9 - | number 10 - | boolean 11 - | JsonValue[] 12 - | { [key: string]: JsonValue }; 13 - 14 - /** 15 - * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. 16 - */ 17 - export const queryKeyJsonReplacer = (_key: string, value: unknown) => { 18 - if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 19 - return undefined; 20 - } 21 - if (typeof value === 'bigint') { 22 - return value.toString(); 23 - } 24 - if (value instanceof Date) { 25 - return value.toISOString(); 26 - } 27 - return value; 28 - }; 29 - 30 - /** 31 - * Safely stringifies a value and parses it back into a JsonValue. 32 - */ 33 - export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { 34 - try { 35 - const json = JSON.stringify(input, queryKeyJsonReplacer); 36 - if (json === undefined) { 37 - return undefined; 38 - } 39 - return JSON.parse(json) as JsonValue; 40 - } catch { 41 - return undefined; 42 - } 43 - }; 44 - 45 - /** 46 - * Detects plain objects (including objects with a null prototype). 47 - */ 48 - const isPlainObject = (value: unknown): value is Record<string, unknown> => { 49 - if (value === null || typeof value !== 'object') { 50 - return false; 51 - } 52 - const prototype = Object.getPrototypeOf(value as object); 53 - return prototype === Object.prototype || prototype === null; 54 - }; 55 - 56 - /** 57 - * Turns URLSearchParams into a sorted JSON object for deterministic keys. 58 - */ 59 - const serializeSearchParams = (params: URLSearchParams): JsonValue => { 60 - const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b)); 61 - const result: Record<string, JsonValue> = {}; 62 - 63 - for (const [key, value] of entries) { 64 - const existing = result[key]; 65 - if (existing === undefined) { 66 - result[key] = value; 67 - continue; 68 - } 69 - 70 - if (Array.isArray(existing)) { 71 - (existing as string[]).push(value); 72 - } else { 73 - result[key] = [existing, value]; 74 - } 75 - } 76 - 77 - return result; 78 - }; 79 - 80 - /** 81 - * Normalizes any accepted value into a JSON-friendly shape for query keys. 82 - */ 83 - export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => { 84 - if (value === null) { 85 - return null; 86 - } 87 - 88 - if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 89 - return value; 90 - } 91 - 92 - if (value === undefined || typeof value === 'function' || typeof value === 'symbol') { 93 - return undefined; 94 - } 95 - 96 - if (typeof value === 'bigint') { 97 - return value.toString(); 98 - } 99 - 100 - if (value instanceof Date) { 101 - return value.toISOString(); 102 - } 103 - 104 - if (Array.isArray(value)) { 105 - return stringifyToJsonValue(value); 106 - } 107 - 108 - if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) { 109 - return serializeSearchParams(value); 110 - } 111 - 112 - if (isPlainObject(value)) { 113 - return stringifyToJsonValue(value); 114 - } 115 - 116 - return undefined; 117 - };
-243
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Config } from './types.gen'; 4 - 5 - export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & 6 - Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 7 - /** 8 - * Fetch API implementation. You can use this option to provide a custom 9 - * fetch instance. 10 - * 11 - * @default globalThis.fetch 12 - */ 13 - fetch?: typeof fetch; 14 - /** 15 - * Implementing clients can call request interceptors inside this hook. 16 - */ 17 - onRequest?: (url: string, init: RequestInit) => Promise<Request>; 18 - /** 19 - * Callback invoked when a network or parsing error occurs during streaming. 20 - * 21 - * This option applies only if the endpoint returns a stream of events. 22 - * 23 - * @param error The error that occurred. 24 - */ 25 - onSseError?: (error: unknown) => void; 26 - /** 27 - * Callback invoked when an event is streamed from the server. 28 - * 29 - * This option applies only if the endpoint returns a stream of events. 30 - * 31 - * @param event Event streamed from the server. 32 - * @returns Nothing (void). 33 - */ 34 - onSseEvent?: (event: StreamEvent<TData>) => void; 35 - serializedBody?: RequestInit['body']; 36 - /** 37 - * Default retry delay in milliseconds. 38 - * 39 - * This option applies only if the endpoint returns a stream of events. 40 - * 41 - * @default 3000 42 - */ 43 - sseDefaultRetryDelay?: number; 44 - /** 45 - * Maximum number of retry attempts before giving up. 46 - */ 47 - sseMaxRetryAttempts?: number; 48 - /** 49 - * Maximum retry delay in milliseconds. 50 - * 51 - * Applies only when exponential backoff is used. 52 - * 53 - * This option applies only if the endpoint returns a stream of events. 54 - * 55 - * @default 30000 56 - */ 57 - sseMaxRetryDelay?: number; 58 - /** 59 - * Optional sleep function for retry backoff. 60 - * 61 - * Defaults to using `setTimeout`. 62 - */ 63 - sseSleepFn?: (ms: number) => Promise<void>; 64 - url: string; 65 - }; 66 - 67 - export interface StreamEvent<TData = unknown> { 68 - data: TData; 69 - event?: string; 70 - id?: string; 71 - retry?: number; 72 - } 73 - 74 - export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = { 75 - stream: AsyncGenerator< 76 - TData extends Record<string, unknown> ? TData[keyof TData] : TData, 77 - TReturn, 78 - TNext 79 - >; 80 - }; 81 - 82 - export const createSseClient = <TData = unknown>({ 83 - onRequest, 84 - onSseError, 85 - onSseEvent, 86 - responseTransformer, 87 - responseValidator, 88 - sseDefaultRetryDelay, 89 - sseMaxRetryAttempts, 90 - sseMaxRetryDelay, 91 - sseSleepFn, 92 - url, 93 - ...options 94 - }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 95 - let lastEventId: string | undefined; 96 - 97 - const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 98 - 99 - const createStream = async function* () { 100 - let retryDelay: number = sseDefaultRetryDelay ?? 3000; 101 - let attempt = 0; 102 - const signal = options.signal ?? new AbortController().signal; 103 - 104 - while (true) { 105 - if (signal.aborted) break; 106 - 107 - attempt++; 108 - 109 - const headers = 110 - options.headers instanceof Headers 111 - ? options.headers 112 - : new Headers(options.headers as Record<string, string> | undefined); 113 - 114 - if (lastEventId !== undefined) { 115 - headers.set('Last-Event-ID', lastEventId); 116 - } 117 - 118 - try { 119 - const requestInit: RequestInit = { 120 - redirect: 'follow', 121 - ...options, 122 - body: options.serializedBody, 123 - headers, 124 - signal, 125 - }; 126 - let request = new Request(url, requestInit); 127 - if (onRequest) { 128 - request = await onRequest(url, requestInit); 129 - } 130 - // fetch must be assigned here, otherwise it would throw the error: 131 - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 132 - const _fetch = options.fetch ?? globalThis.fetch; 133 - const response = await _fetch(request); 134 - 135 - if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`); 136 - 137 - if (!response.body) throw new Error('No body in SSE response'); 138 - 139 - const reader = response.body.pipeThrough(new TextDecoderStream()).getReader(); 140 - 141 - let buffer = ''; 142 - 143 - const abortHandler = () => { 144 - try { 145 - reader.cancel(); 146 - } catch { 147 - // noop 148 - } 149 - }; 150 - 151 - signal.addEventListener('abort', abortHandler); 152 - 153 - try { 154 - while (true) { 155 - const { done, value } = await reader.read(); 156 - if (done) break; 157 - buffer += value; 158 - // Normalize line endings: CRLF -> LF, then CR -> LF 159 - buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); 160 - 161 - const chunks = buffer.split('\n\n'); 162 - buffer = chunks.pop() ?? ''; 163 - 164 - for (const chunk of chunks) { 165 - const lines = chunk.split('\n'); 166 - const dataLines: Array<string> = []; 167 - let eventName: string | undefined; 168 - 169 - for (const line of lines) { 170 - if (line.startsWith('data:')) { 171 - dataLines.push(line.replace(/^data:\s*/, '')); 172 - } else if (line.startsWith('event:')) { 173 - eventName = line.replace(/^event:\s*/, ''); 174 - } else if (line.startsWith('id:')) { 175 - lastEventId = line.replace(/^id:\s*/, ''); 176 - } else if (line.startsWith('retry:')) { 177 - const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10); 178 - if (!Number.isNaN(parsed)) { 179 - retryDelay = parsed; 180 - } 181 - } 182 - } 183 - 184 - let data: unknown; 185 - let parsedJson = false; 186 - 187 - if (dataLines.length) { 188 - const rawData = dataLines.join('\n'); 189 - try { 190 - data = JSON.parse(rawData); 191 - parsedJson = true; 192 - } catch { 193 - data = rawData; 194 - } 195 - } 196 - 197 - if (parsedJson) { 198 - if (responseValidator) { 199 - await responseValidator(data); 200 - } 201 - 202 - if (responseTransformer) { 203 - data = await responseTransformer(data); 204 - } 205 - } 206 - 207 - onSseEvent?.({ 208 - data, 209 - event: eventName, 210 - id: lastEventId, 211 - retry: retryDelay, 212 - }); 213 - 214 - if (dataLines.length) { 215 - yield data as any; 216 - } 217 - } 218 - } 219 - } finally { 220 - signal.removeEventListener('abort', abortHandler); 221 - reader.releaseLock(); 222 - } 223 - 224 - break; // exit loop on normal completion 225 - } catch (error) { 226 - // connection failed or aborted; retry after delay 227 - onSseError?.(error); 228 - 229 - if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) { 230 - break; // stop after firing error 231 - } 232 - 233 - // exponential backoff: double retry each attempt, cap at 30s 234 - const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000); 235 - await sleep(backoff); 236 - } 237 - } 238 - }; 239 - 240 - const stream = createStream(); 241 - 242 - return { stream }; 243 - };
-104
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Auth, AuthToken } from './auth.gen'; 4 - import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen'; 5 - 6 - export type HttpMethod = 7 - | 'connect' 8 - | 'delete' 9 - | 'get' 10 - | 'head' 11 - | 'options' 12 - | 'patch' 13 - | 'post' 14 - | 'put' 15 - | 'trace'; 16 - 17 - export type Client< 18 - RequestFn = never, 19 - Config = unknown, 20 - MethodFn = never, 21 - BuildUrlFn = never, 22 - SseFn = never, 23 - > = { 24 - /** 25 - * Returns the final request URL. 26 - */ 27 - buildUrl: BuildUrlFn; 28 - getConfig: () => Config; 29 - request: RequestFn; 30 - setConfig: (config: Config) => Config; 31 - } & { 32 - [K in HttpMethod]: MethodFn; 33 - } & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } }); 34 - 35 - export interface Config { 36 - /** 37 - * Auth token or a function returning auth token. The resolved value will be 38 - * added to the request payload as defined by its `security` array. 39 - */ 40 - auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 41 - /** 42 - * A function for serializing request body parameter. By default, 43 - * {@link JSON.stringify()} will be used. 44 - */ 45 - bodySerializer?: BodySerializer | null; 46 - /** 47 - * An object containing any HTTP headers that you want to pre-populate your 48 - * `Headers` object with. 49 - * 50 - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 51 - */ 52 - headers?: 53 - | RequestInit['headers'] 54 - | Record< 55 - string, 56 - string | number | boolean | (string | number | boolean)[] | null | undefined | unknown 57 - >; 58 - /** 59 - * The request method. 60 - * 61 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 62 - */ 63 - method?: Uppercase<HttpMethod>; 64 - /** 65 - * A function for serializing request query parameters. By default, arrays 66 - * will be exploded in form style, objects will be exploded in deepObject 67 - * style, and reserved characters are percent-encoded. 68 - * 69 - * This method will have no effect if the native `paramsSerializer()` Axios 70 - * API function is used. 71 - * 72 - * {@link https://swagger.io/docs/specification/serialization/#query View examples} 73 - */ 74 - querySerializer?: QuerySerializer | QuerySerializerOptions; 75 - /** 76 - * A function validating request data. This is useful if you want to ensure 77 - * the request conforms to the desired shape, so it can be safely sent to 78 - * the server. 79 - */ 80 - requestValidator?: (data: unknown) => Promise<unknown>; 81 - /** 82 - * A function transforming response data before it's returned. This is useful 83 - * for post-processing data, e.g. converting ISO strings into Date objects. 84 - */ 85 - responseTransformer?: (data: unknown) => Promise<unknown>; 86 - /** 87 - * A function validating response data. This is useful if you want to ensure 88 - * the response conforms to the desired shape, so it can be safely passed to 89 - * the transformers and returned to the user. 90 - */ 91 - responseValidator?: (data: unknown) => Promise<unknown>; 92 - } 93 - 94 - type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 95 - ? true 96 - : [T] extends [never | undefined] 97 - ? [undefined] extends [T] 98 - ? false 99 - : true 100 - : false; 101 - 102 - export type OmitNever<T extends Record<string, unknown>> = { 103 - [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K]; 104 - };
-140
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/utils.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; 4 - import { 5 - type ArraySeparatorStyle, 6 - serializeArrayParam, 7 - serializeObjectParam, 8 - serializePrimitiveParam, 9 - } from './pathSerializer.gen'; 10 - 11 - export interface PathSerializer { 12 - path: Record<string, unknown>; 13 - url: string; 14 - } 15 - 16 - export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 - 18 - export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 - let url = _url; 20 - const matches = _url.match(PATH_PARAM_RE); 21 - if (matches) { 22 - for (const match of matches) { 23 - let explode = false; 24 - let name = match.substring(1, match.length - 1); 25 - let style: ArraySeparatorStyle = 'simple'; 26 - 27 - if (name.endsWith('*')) { 28 - explode = true; 29 - name = name.substring(0, name.length - 1); 30 - } 31 - 32 - if (name.startsWith('.')) { 33 - name = name.substring(1); 34 - style = 'label'; 35 - } else if (name.startsWith(';')) { 36 - name = name.substring(1); 37 - style = 'matrix'; 38 - } 39 - 40 - const value = path[name]; 41 - 42 - if (value === undefined || value === null) { 43 - continue; 44 - } 45 - 46 - if (Array.isArray(value)) { 47 - url = url.replace(match, serializeArrayParam({ explode, name, style, value })); 48 - continue; 49 - } 50 - 51 - if (typeof value === 'object') { 52 - url = url.replace( 53 - match, 54 - serializeObjectParam({ 55 - explode, 56 - name, 57 - style, 58 - value: value as Record<string, unknown>, 59 - valueOnly: true, 60 - }), 61 - ); 62 - continue; 63 - } 64 - 65 - if (style === 'matrix') { 66 - url = url.replace( 67 - match, 68 - `;${serializePrimitiveParam({ 69 - name, 70 - value: value as string, 71 - })}`, 72 - ); 73 - continue; 74 - } 75 - 76 - const replaceValue = encodeURIComponent( 77 - style === 'label' ? `.${value as string}` : (value as string), 78 - ); 79 - url = url.replace(match, replaceValue); 80 - } 81 - } 82 - return url; 83 - }; 84 - 85 - export const getUrl = ({ 86 - baseUrl, 87 - path, 88 - query, 89 - querySerializer, 90 - url: _url, 91 - }: { 92 - baseUrl?: string; 93 - path?: Record<string, unknown>; 94 - query?: Record<string, unknown>; 95 - querySerializer: QuerySerializer; 96 - url: string; 97 - }) => { 98 - const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 99 - let url = (baseUrl ?? '') + pathUrl; 100 - if (path) { 101 - url = defaultPathSerializer({ path, url }); 102 - } 103 - let search = query ? querySerializer(query) : ''; 104 - if (search.startsWith('?')) { 105 - search = search.substring(1); 106 - } 107 - if (search) { 108 - url += `?${search}`; 109 - } 110 - return url; 111 - }; 112 - 113 - export function getValidRequestBody(options: { 114 - body?: unknown; 115 - bodySerializer?: BodySerializer | null; 116 - serializedBody?: unknown; 117 - }) { 118 - const hasBody = options.body !== undefined; 119 - const isSerializedBody = hasBody && options.bodySerializer; 120 - 121 - if (isSerializedBody) { 122 - if ('serializedBody' in options) { 123 - const hasSerializedBody = 124 - options.serializedBody !== undefined && options.serializedBody !== ''; 125 - 126 - return hasSerializedBody ? options.serializedBody : null; 127 - } 128 - 129 - // not all clients implement a serializedBody property (i.e. client-axios) 130 - return options.body !== '' ? options.body : null; 131 - } 132 - 133 - // plain/text body 134 - if (hasBody) { 135 - return options.body; 136 - } 137 - 138 - // no body was provided 139 - return undefined; 140 - }
-4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export { type Options, postFoo } from './sdk.gen'; 4 - export type { Bar, ClientOptions, Foo, PostFooData, PostFooResponse, PostFooResponses, TypeID, UserId } from './types.gen';
-31
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - import type { Client, Options as Options2, TDataShape } from './client'; 6 - import { client } from './client.gen'; 7 - import { postFooResponseTransformer } from './transformers.gen'; 8 - import type { PostFooData, PostFooResponses } from './types.gen'; 9 - import { vPostFooData, vPostFooResponse } from './valibot.gen'; 10 - 11 - export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 12 - /** 13 - * You can provide a client instance returned by `createClient()` instead of 14 - * individual options. This might be also useful if you want to implement a 15 - * custom client. 16 - */ 17 - client?: Client; 18 - /** 19 - * You can pass arbitrary values through the `meta` object. This can be 20 - * used to access values that aren't defined as part of the SDK function. 21 - */ 22 - meta?: Record<string, unknown>; 23 - }; 24 - 25 - export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => (options?.client ?? client).post<PostFooResponses, unknown, ThrowOnError>({ 26 - requestValidator: async (data) => await v.parseAsync(vPostFooData, data), 27 - responseTransformer: postFooResponseTransformer, 28 - responseValidator: async (data) => await v.parseAsync(vPostFooResponse, data), 29 - url: '/foo', 30 - ...options 31 - });
-13
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { PostFooResponse } from './types.gen'; 4 - 5 - const fooSchemaResponseTransformer = (data: any) => { 6 - data.foo = BigInt(data.foo.toString()); 7 - return data; 8 - }; 9 - 10 - export const postFooResponseTransformer = async (data: any): Promise<PostFooResponse> => { 11 - data = fooSchemaResponseTransformer(data); 12 - return data; 13 - };
-36
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type ClientOptions = { 4 - baseUrl: `${string}://${string}` | (string & {}); 5 - }; 6 - 7 - export type TypeID<T extends string> = `${T}_${string}`; 8 - 9 - export type UserId = TypeID<'user'>; 10 - 11 - export type Foo = { 12 - bar?: number; 13 - foo: bigint; 14 - id: UserId; 15 - }; 16 - 17 - export type Bar = { 18 - foo: number; 19 - [key: string]: number; 20 - }; 21 - 22 - export type PostFooData = { 23 - body?: never; 24 - path?: never; 25 - query?: never; 26 - url: '/foo'; 27 - }; 28 - 29 - export type PostFooResponses = { 30 - /** 31 - * OK 32 - */ 33 - 200: Foo; 34 - }; 35 - 36 - export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
-28
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - export const vFoo = v.object({ 6 - bar: v.optional(v.pipe(v.number(), v.integer())), 7 - foo: v.optional(v.pipe(v.union([ 8 - v.number(), 9 - v.string(), 10 - v.bigint() 11 - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -9223372036854775808'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 9223372036854775807')), BigInt(0)), 12 - id: v.string() 13 - }); 14 - 15 - export const vBar = v.objectWithRest({ 16 - foo: v.pipe(v.number(), v.integer()) 17 - }, v.pipe(v.number(), v.integer())); 18 - 19 - export const vPostFooData = v.object({ 20 - body: v.optional(v.never()), 21 - path: v.optional(v.never()), 22 - query: v.optional(v.never()) 23 - }); 24 - 25 - /** 26 - * OK 27 - */ 28 - export const vPostFooResponse = vFoo;
-1503
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as v from 'valibot'; 4 - 5 - /** 6 - * Model with number-only name 7 - */ 8 - export const v400 = v.string(); 9 - 10 - /** 11 - * Testing multiline comments in string: First line 12 - * Second line 13 - * 14 - * Fourth line 15 - */ 16 - export const vCamelCaseCommentWithBreaks = v.pipe(v.number(), v.integer()); 17 - 18 - /** 19 - * Testing multiline comments in string: First line 20 - * Second line 21 - * 22 - * Fourth line 23 - */ 24 - export const vCommentWithBreaks = v.pipe(v.number(), v.integer()); 25 - 26 - /** 27 - * Testing backticks in string: `backticks` and ```multiple backticks``` should work 28 - */ 29 - export const vCommentWithBackticks = v.pipe(v.number(), v.integer()); 30 - 31 - /** 32 - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 33 - */ 34 - export const vCommentWithBackticksAndQuotes = v.pipe(v.number(), v.integer()); 35 - 36 - /** 37 - * Testing slashes in string: \backwards\\\ and /forwards/// should work 38 - */ 39 - export const vCommentWithSlashes = v.pipe(v.number(), v.integer()); 40 - 41 - /** 42 - * Testing expression placeholders in string: ${expression} should work 43 - */ 44 - export const vCommentWithExpressionPlaceholders = v.pipe(v.number(), v.integer()); 45 - 46 - /** 47 - * Testing quotes in string: 'single quote''' and "double quotes""" should work 48 - */ 49 - export const vCommentWithQuotes = v.pipe(v.number(), v.integer()); 50 - 51 - /** 52 - * Testing reserved characters in string: * inline * and ** inline ** should work 53 - */ 54 - export const vCommentWithReservedCharacters = v.pipe(v.number(), v.integer()); 55 - 56 - /** 57 - * This is a simple number 58 - */ 59 - export const vSimpleInteger = v.pipe(v.number(), v.integer()); 60 - 61 - /** 62 - * This is a simple boolean 63 - */ 64 - export const vSimpleBoolean = v.boolean(); 65 - 66 - /** 67 - * This is a simple string 68 - */ 69 - export const vSimpleString = v.string(); 70 - 71 - /** 72 - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 73 - */ 74 - export const vNonAsciiStringæøåÆøÅöôêÊ字符串 = v.string(); 75 - 76 - /** 77 - * This is a simple file 78 - */ 79 - export const vSimpleFile = v.string(); 80 - 81 - /** 82 - * This is a simple string 83 - */ 84 - export const vSimpleStringWithPattern = v.nullable(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/))); 85 - 86 - /** 87 - * This is a simple enum with strings 88 - */ 89 - export const vEnumWithStrings = v.picklist([ 90 - 'Success', 91 - 'Warning', 92 - 'Error', 93 - '\'Single Quote\'', 94 - '"Double Quotes"', 95 - 'Non-ascii: øæåôöØÆÅÔÖ字符串' 96 - ]); 97 - 98 - export const vEnumWithReplacedCharacters = v.picklist([ 99 - '\'Single Quote\'', 100 - '"Double Quotes"', 101 - 'øæåôöØÆÅÔÖ字符串', 102 - '' 103 - ]); 104 - 105 - /** 106 - * This is a simple enum with numbers 107 - */ 108 - export const vEnumWithNumbers = v.unknown(); 109 - 110 - /** 111 - * Success=1,Warning=2,Error=3 112 - */ 113 - export const vEnumFromDescription = v.number(); 114 - 115 - /** 116 - * This is a simple enum with numbers 117 - */ 118 - export const vEnumWithExtensions = v.unknown(); 119 - 120 - export const vEnumWithXEnumNames = v.unknown(); 121 - 122 - /** 123 - * This is a simple array with numbers 124 - */ 125 - export const vArrayWithNumbers = v.array(v.pipe(v.number(), v.integer())); 126 - 127 - /** 128 - * This is a simple array with booleans 129 - */ 130 - export const vArrayWithBooleans = v.array(v.boolean()); 131 - 132 - /** 133 - * This is a simple array with strings 134 - */ 135 - export const vArrayWithStrings = v.optional(v.array(v.string()), ['test']); 136 - 137 - /** 138 - * This is a simple array with properties 139 - */ 140 - export const vArrayWithProperties = v.array(v.object({ 141 - '16x16': v.optional(vCamelCaseCommentWithBreaks), 142 - bar: v.optional(v.string()) 143 - })); 144 - 145 - /** 146 - * This is a simple array with any of properties 147 - */ 148 - export const vArrayWithAnyOfProperties = v.array(v.unknown()); 149 - 150 - export const vAnyOfAnyAndNull = v.object({ 151 - data: v.nullish(v.unknown()) 152 - }); 153 - 154 - /** 155 - * This is a simple array with any of properties 156 - */ 157 - export const vAnyOfArrays = v.object({ 158 - results: v.optional(v.array(v.unknown())) 159 - }); 160 - 161 - /** 162 - * This is a string dictionary 163 - */ 164 - export const vDictionaryWithString = v.record(v.string(), v.string()); 165 - 166 - export const vDictionaryWithPropertiesAndAdditionalProperties = v.objectWithRest({ 167 - foo: v.optional(v.number()), 168 - bar: v.optional(v.boolean()) 169 - }, v.string()); 170 - 171 - /** 172 - * This is a string dictionary 173 - */ 174 - export const vDictionaryWithDictionary = v.record(v.string(), v.record(v.string(), v.string())); 175 - 176 - /** 177 - * This is a complex dictionary 178 - */ 179 - export const vDictionaryWithProperties = v.record(v.string(), v.object({ 180 - foo: v.optional(v.string()), 181 - bar: v.optional(v.string()) 182 - })); 183 - 184 - /** 185 - * This is a model with one number property 186 - */ 187 - export const vModelWithInteger = v.object({ 188 - prop: v.optional(v.pipe(v.number(), v.integer())) 189 - }); 190 - 191 - /** 192 - * This is a model with one boolean property 193 - */ 194 - export const vModelWithBoolean = v.object({ 195 - prop: v.optional(v.boolean()) 196 - }); 197 - 198 - /** 199 - * This is a model with one string property 200 - */ 201 - export const vModelWithString = v.object({ 202 - prop: v.optional(v.string()) 203 - }); 204 - 205 - /** 206 - * This is a simple reference 207 - */ 208 - export const vSimpleReference = vModelWithString; 209 - 210 - /** 211 - * This is a simple array with references 212 - */ 213 - export const vArrayWithReferences = v.array(vModelWithString); 214 - 215 - /** 216 - * This is a simple array containing an array 217 - */ 218 - export const vArrayWithArray = v.array(v.array(vModelWithString)); 219 - 220 - /** 221 - * This is a string reference 222 - */ 223 - export const vDictionaryWithReference = v.object({}); 224 - 225 - /** 226 - * This is a complex dictionary 227 - */ 228 - export const vDictionaryWithArray = v.record(v.string(), v.array(vModelWithString)); 229 - 230 - /** 231 - * This is a model with one string property 232 - */ 233 - export const vModelWithStringError = v.object({ 234 - prop: v.optional(v.string()) 235 - }); 236 - 237 - /** 238 - * `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) 239 - */ 240 - export const vModelFromZendesk = v.string(); 241 - 242 - /** 243 - * This is a model with one string property 244 - */ 245 - export const vModelWithNullableString = v.object({ 246 - nullableProp1: v.nullish(v.string()), 247 - nullableRequiredProp1: v.nullable(v.string()), 248 - nullableProp2: v.nullish(v.string()), 249 - nullableRequiredProp2: v.nullable(v.string()), 250 - 'foo_bar-enum': v.optional(v.picklist([ 251 - 'Success', 252 - 'Warning', 253 - 'Error', 254 - 'ØÆÅ字符串' 255 - ])) 256 - }); 257 - 258 - /** 259 - * This is a model with one enum 260 - */ 261 - export const vModelWithEnum = v.object({ 262 - 'foo_bar-enum': v.optional(v.picklist([ 263 - 'Success', 264 - 'Warning', 265 - 'Error', 266 - 'ØÆÅ字符串' 267 - ])), 268 - statusCode: v.optional(v.picklist([ 269 - '100', 270 - '200 FOO', 271 - '300 FOO_BAR', 272 - '400 foo-bar', 273 - '500 foo.bar', 274 - '600 foo&bar' 275 - ])), 276 - bool: v.optional(v.unknown()) 277 - }); 278 - 279 - /** 280 - * This is a model with one enum with escaped name 281 - */ 282 - export const vModelWithEnumWithHyphen = v.object({ 283 - 'foo-bar-baz-qux': v.optional(v.picklist(['3.0'])) 284 - }); 285 - 286 - /** 287 - * This is a model with one enum 288 - */ 289 - export const vModelWithEnumFromDescription = v.object({ 290 - test: v.optional(v.pipe(v.number(), v.integer())) 291 - }); 292 - 293 - /** 294 - * This is a model with nested enums 295 - */ 296 - export const vModelWithNestedEnums = v.object({ 297 - dictionaryWithEnum: v.optional(v.record(v.string(), v.picklist([ 298 - 'Success', 299 - 'Warning', 300 - 'Error' 301 - ]))), 302 - dictionaryWithEnumFromDescription: v.optional(v.record(v.string(), v.pipe(v.number(), v.integer()))), 303 - arrayWithEnum: v.optional(v.array(v.picklist([ 304 - 'Success', 305 - 'Warning', 306 - 'Error' 307 - ]))), 308 - arrayWithDescription: v.optional(v.array(v.pipe(v.number(), v.integer()))), 309 - 'foo_bar-enum': v.optional(v.picklist([ 310 - 'Success', 311 - 'Warning', 312 - 'Error', 313 - 'ØÆÅ字符串' 314 - ])) 315 - }); 316 - 317 - /** 318 - * This is a model with one property containing an array 319 - */ 320 - export const vModelWithArray = v.object({ 321 - prop: v.optional(v.array(vModelWithString)), 322 - propWithFile: v.optional(v.array(v.string())), 323 - propWithNumber: v.optional(v.array(v.number())) 324 - }); 325 - 326 - /** 327 - * This is a model with one property containing a dictionary 328 - */ 329 - export const vModelWithDictionary = v.object({ 330 - prop: v.optional(v.record(v.string(), v.string())) 331 - }); 332 - 333 - /** 334 - * This is a deprecated model with a deprecated property 335 - * 336 - * @deprecated 337 - */ 338 - export const vDeprecatedModel = v.object({ 339 - prop: v.optional(v.string()) 340 - }); 341 - 342 - /** 343 - * This is a model with one property containing a circular reference 344 - */ 345 - export const vModelWithCircularReference: v.GenericSchema = v.object({ 346 - prop: v.optional(v.lazy(() => vModelWithCircularReference)) 347 - }); 348 - 349 - /** 350 - * This is a model with one property with a 'one of' relationship 351 - */ 352 - export const vCompositionWithOneOf = v.object({ 353 - propA: v.optional(v.union([ 354 - vModelWithString, 355 - vModelWithEnum, 356 - vModelWithArray, 357 - vModelWithDictionary 358 - ])) 359 - }); 360 - 361 - /** 362 - * This is a model with one property with a 'one of' relationship where the options are not $ref 363 - */ 364 - export const vCompositionWithOneOfAnonymous = v.object({ 365 - propA: v.optional(v.union([ 366 - v.object({ 367 - propA: v.optional(v.string()) 368 - }), 369 - v.string(), 370 - v.pipe(v.number(), v.integer()) 371 - ])) 372 - }); 373 - 374 - /** 375 - * Circle 376 - */ 377 - export const vModelCircle = v.object({ 378 - kind: v.string(), 379 - radius: v.optional(v.number()) 380 - }); 381 - 382 - /** 383 - * Square 384 - */ 385 - export const vModelSquare = v.object({ 386 - kind: v.string(), 387 - sideLength: v.optional(v.number()) 388 - }); 389 - 390 - /** 391 - * This is a model with one property with a 'one of' relationship where the options are not $ref 392 - */ 393 - export const vCompositionWithOneOfDiscriminator = v.union([v.intersect([v.object({ 394 - kind: v.literal('circle') 395 - }), vModelCircle]), v.intersect([v.object({ 396 - kind: v.literal('square') 397 - }), vModelSquare])]); 398 - 399 - /** 400 - * This is a model with one property with a 'any of' relationship 401 - */ 402 - export const vCompositionWithAnyOf = v.object({ 403 - propA: v.optional(v.union([ 404 - vModelWithString, 405 - vModelWithEnum, 406 - vModelWithArray, 407 - vModelWithDictionary 408 - ])) 409 - }); 410 - 411 - /** 412 - * This is a model with one property with a 'any of' relationship where the options are not $ref 413 - */ 414 - export const vCompositionWithAnyOfAnonymous = v.object({ 415 - propA: v.optional(v.union([ 416 - v.object({ 417 - propA: v.optional(v.string()) 418 - }), 419 - v.string(), 420 - v.pipe(v.number(), v.integer()) 421 - ])) 422 - }); 423 - 424 - /** 425 - * This is a model with nested 'any of' property with a type null 426 - */ 427 - export const vCompositionWithNestedAnyAndTypeNull = v.object({ 428 - propA: v.optional(v.union([v.array(v.unknown()), v.array(v.unknown())])) 429 - }); 430 - 431 - export const v3eNum1Период = v.picklist(['Bird', 'Dog']); 432 - 433 - export const vConstValue = v.literal('ConstValue'); 434 - 435 - /** 436 - * This is a model with one property with a 'any of' relationship where the options are not $ref 437 - */ 438 - export const vCompositionWithNestedAnyOfAndNull = v.object({ 439 - propA: v.nullish(v.array(v.unknown())) 440 - }); 441 - 442 - /** 443 - * This is a model with one property with a 'one of' relationship 444 - */ 445 - export const vCompositionWithOneOfAndNullable = v.object({ 446 - propA: v.nullish(v.union([ 447 - v.object({ 448 - boolean: v.optional(v.boolean()) 449 - }), 450 - vModelWithEnum, 451 - vModelWithArray, 452 - vModelWithDictionary 453 - ])) 454 - }); 455 - 456 - /** 457 - * This is a model that contains a simple dictionary within composition 458 - */ 459 - export const vCompositionWithOneOfAndSimpleDictionary = v.object({ 460 - propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.number())])) 461 - }); 462 - 463 - /** 464 - * This is a model that contains a dictionary of simple arrays within composition 465 - */ 466 - export const vCompositionWithOneOfAndSimpleArrayDictionary = v.object({ 467 - propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.boolean()))])) 468 - }); 469 - 470 - /** 471 - * This is a model that contains a dictionary of complex arrays (composited) within composition 472 - */ 473 - export const vCompositionWithOneOfAndComplexArrayDictionary = v.object({ 474 - propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.unknown()))])) 475 - }); 476 - 477 - /** 478 - * This is a model with one property with a 'all of' relationship 479 - */ 480 - export const vCompositionWithAllOfAndNullable = v.object({ 481 - propA: v.nullish(v.intersect([ 482 - v.object({ 483 - boolean: v.optional(v.boolean()) 484 - }), 485 - vModelWithEnum, 486 - vModelWithArray, 487 - vModelWithDictionary 488 - ])) 489 - }); 490 - 491 - /** 492 - * This is a model with one property with a 'any of' relationship 493 - */ 494 - export const vCompositionWithAnyOfAndNullable = v.object({ 495 - propA: v.nullish(v.union([ 496 - v.object({ 497 - boolean: v.optional(v.boolean()) 498 - }), 499 - vModelWithEnum, 500 - vModelWithArray, 501 - vModelWithDictionary 502 - ])) 503 - }); 504 - 505 - /** 506 - * This is a base model with two simple optional properties 507 - */ 508 - export const vCompositionBaseModel = v.object({ 509 - firstName: v.optional(v.string()), 510 - lastname: v.optional(v.string()) 511 - }); 512 - 513 - /** 514 - * This is a model that extends the base model 515 - */ 516 - export const vCompositionExtendedModel = v.intersect([vCompositionBaseModel, v.object({ 517 - age: v.number(), 518 - firstName: v.string(), 519 - lastname: v.string() 520 - })]); 521 - 522 - /** 523 - * This is a model with one nested property 524 - */ 525 - export const vModelWithProperties = v.object({ 526 - required: v.string(), 527 - requiredAndReadOnly: v.pipe(v.string(), v.readonly()), 528 - requiredAndNullable: v.nullable(v.string()), 529 - string: v.optional(v.string()), 530 - number: v.optional(v.number()), 531 - boolean: v.optional(v.boolean()), 532 - reference: v.optional(vModelWithString), 533 - 'property with space': v.optional(v.string()), 534 - default: v.optional(v.string()), 535 - try: v.optional(v.string()), 536 - '@namespace.string': v.optional(v.pipe(v.string(), v.readonly())), 537 - '@namespace.integer': v.optional(v.pipe(v.pipe(v.number(), v.integer()), v.readonly())) 538 - }); 539 - 540 - /** 541 - * This is a model with one property containing a reference 542 - */ 543 - export const vModelWithReference = v.object({ 544 - prop: v.optional(vModelWithProperties) 545 - }); 546 - 547 - /** 548 - * This is a model with one nested property 549 - */ 550 - export const vModelWithNestedProperties = v.object({ 551 - first: v.nullable(v.pipe(v.object({ 552 - second: v.nullable(v.pipe(v.object({ 553 - third: v.nullable(v.pipe(v.string(), v.readonly())) 554 - }), v.readonly())) 555 - }), v.readonly())) 556 - }); 557 - 558 - /** 559 - * This is a model with duplicated properties 560 - */ 561 - export const vModelWithDuplicateProperties = v.object({ 562 - prop: v.optional(vModelWithString) 563 - }); 564 - 565 - /** 566 - * This is a model with ordered properties 567 - */ 568 - export const vModelWithOrderedProperties = v.object({ 569 - zebra: v.optional(v.string()), 570 - apple: v.optional(v.string()), 571 - hawaii: v.optional(v.string()) 572 - }); 573 - 574 - /** 575 - * This is a model with duplicated imports 576 - */ 577 - export const vModelWithDuplicateImports = v.object({ 578 - propA: v.optional(vModelWithString), 579 - propB: v.optional(vModelWithString), 580 - propC: v.optional(vModelWithString) 581 - }); 582 - 583 - /** 584 - * This is a model that extends another model 585 - */ 586 - export const vModelThatExtends = v.intersect([vModelWithString, v.object({ 587 - propExtendsA: v.optional(v.string()), 588 - propExtendsB: v.optional(vModelWithString) 589 - })]); 590 - 591 - /** 592 - * This is a model that extends another model 593 - */ 594 - export const vModelThatExtendsExtends = v.intersect([ 595 - vModelWithString, 596 - vModelThatExtends, 597 - v.object({ 598 - propExtendsC: v.optional(v.string()), 599 - propExtendsD: v.optional(vModelWithString) 600 - }) 601 - ]); 602 - 603 - /** 604 - * This is a model that contains a some patterns 605 - */ 606 - export const vModelWithPattern = v.object({ 607 - key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), 608 - name: v.pipe(v.string(), v.maxLength(255)), 609 - enabled: v.optional(v.pipe(v.boolean(), v.readonly())), 610 - modified: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 611 - id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), 612 - text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), 613 - patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), 614 - patternWithNewline: v.optional(v.pipe(v.string(), v.regex(/aaa\nbbb/))), 615 - patternWithBacktick: v.optional(v.pipe(v.string(), v.regex(/aaa`bbb/))), 616 - patternWithUnicode: v.optional(v.pipe(v.string(), v.regex(/^\p{L}+$/u))) 617 - }); 618 - 619 - export const vFile = v.object({ 620 - id: v.optional(v.pipe(v.pipe(v.string(), v.minLength(1)), v.readonly())), 621 - updated_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 622 - created_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), 623 - mime: v.pipe(v.string(), v.minLength(1), v.maxLength(24)), 624 - file: v.optional(v.pipe(v.pipe(v.string(), v.url()), v.readonly())) 625 - }); 626 - 627 - export const vDefault = v.object({ 628 - name: v.optional(v.string()) 629 - }); 630 - 631 - export const vPageable = v.object({ 632 - page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), 0), 633 - size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))), 634 - sort: v.optional(v.array(v.string())) 635 - }); 636 - 637 - /** 638 - * This is a free-form object without additionalProperties. 639 - */ 640 - export const vFreeFormObjectWithoutAdditionalProperties = v.record(v.string(), v.unknown()); 641 - 642 - /** 643 - * This is a free-form object with additionalProperties: true. 644 - */ 645 - export const vFreeFormObjectWithAdditionalPropertiesEqTrue = v.record(v.string(), v.unknown()); 646 - 647 - /** 648 - * This is a free-form object with additionalProperties: {}. 649 - */ 650 - export const vFreeFormObjectWithAdditionalPropertiesEqEmptyObject = v.record(v.string(), v.unknown()); 651 - 652 - export const vModelWithConst = v.object({ 653 - String: v.optional(v.literal('String')), 654 - number: v.optional(v.literal(0)), 655 - null: v.optional(v.null()), 656 - withType: v.optional(v.literal('Some string')) 657 - }); 658 - 659 - /** 660 - * This is a model with one property and additionalProperties: true 661 - */ 662 - export const vModelWithAdditionalPropertiesEqTrue = v.objectWithRest({ 663 - prop: v.optional(v.string()) 664 - }, v.unknown()); 665 - 666 - export const vNestedAnyOfArraysNullable = v.object({ 667 - nullableArray: v.nullish(v.array(v.unknown())) 668 - }); 669 - 670 - /** 671 - * An object that can be null 672 - */ 673 - export const vNullableObject = v.nullish(v.object({ 674 - foo: v.optional(v.string()) 675 - }), null); 676 - 677 - /** 678 - * Some % character 679 - */ 680 - export const vCharactersInDescription = v.string(); 681 - 682 - export const vModelWithNullableObject = v.object({ 683 - data: v.optional(vNullableObject) 684 - }); 685 - 686 - /** 687 - * An object with additional properties that can be null (anyOf ref + null) 688 - */ 689 - export const vModelWithAdditionalPropertiesRef = v.object({}); 690 - 691 - export const vModelWithOneOfEnum = v.union([ 692 - v.object({ 693 - foo: v.picklist(['Bar']) 694 - }), 695 - v.object({ 696 - foo: v.picklist(['Baz']) 697 - }), 698 - v.object({ 699 - foo: v.picklist(['Qux']) 700 - }), 701 - v.object({ 702 - content: v.pipe(v.string(), v.isoTimestamp()), 703 - foo: v.picklist(['Quux']) 704 - }), 705 - v.object({ 706 - content: v.tuple([v.pipe(v.string(), v.isoTimestamp()), v.string()]), 707 - foo: v.picklist(['Corge']) 708 - }) 709 - ]); 710 - 711 - export const vModelWithNestedArrayEnumsDataFoo = v.picklist(['foo', 'bar']); 712 - 713 - export const vModelWithNestedArrayEnumsDataBar = v.picklist(['baz', 'qux']); 714 - 715 - export const vModelWithNestedArrayEnumsData = v.object({ 716 - foo: v.optional(v.array(vModelWithNestedArrayEnumsDataFoo)), 717 - bar: v.optional(v.array(vModelWithNestedArrayEnumsDataBar)) 718 - }); 719 - 720 - export const vModelWithNestedArrayEnums = v.object({ 721 - array_strings: v.optional(v.array(v.string())), 722 - data: v.optional(vModelWithNestedArrayEnumsData) 723 - }); 724 - 725 - export const vModelWithNestedCompositionEnums = v.object({ 726 - foo: v.optional(vModelWithNestedArrayEnumsDataFoo) 727 - }); 728 - 729 - export const vModelWithReadOnlyAndWriteOnly = v.object({ 730 - foo: v.string(), 731 - bar: v.pipe(v.string(), v.readonly()) 732 - }); 733 - 734 - /** 735 - * This is a model with one property containing an array 736 - */ 737 - export const vModelWithArrayReadOnlyAndWriteOnly = v.object({ 738 - prop: v.optional(v.array(vModelWithReadOnlyAndWriteOnly)), 739 - propWithFile: v.optional(v.array(v.string())), 740 - propWithNumber: v.optional(v.array(v.number())) 741 - }); 742 - 743 - export const vModelWithConstantSizeArray = v.tuple([v.number(), v.number()]); 744 - 745 - export const vModelWithAnyOfConstantSizeArray = v.tuple([ 746 - v.union([v.number(), v.string()]), 747 - v.union([v.number(), v.string()]), 748 - v.union([v.number(), v.string()]) 749 - ]); 750 - 751 - export const vModelWithPrefixItemsConstantSizeArray = v.tuple([ 752 - vModelWithInteger, 753 - v.union([v.number(), v.string()]), 754 - v.string() 755 - ]); 756 - 757 - export const vModelWithAnyOfConstantSizeArrayNullable = v.tuple([ 758 - v.nullable(v.union([v.number(), v.string()])), 759 - v.nullable(v.union([v.number(), v.string()])), 760 - v.nullable(v.union([v.number(), v.string()])) 761 - ]); 762 - 763 - export const vModelWithAnyOfConstantSizeArrayAndIntersect = v.tuple([v.intersect([v.number(), v.string()]), v.intersect([v.number(), v.string()])]); 764 - 765 - export const vModelWithNumericEnumUnion = v.object({ 766 - value: v.optional(v.unknown()) 767 - }); 768 - 769 - /** 770 - * Some description with `back ticks` 771 - */ 772 - export const vModelWithBackticksInDescription = v.object({ 773 - template: v.optional(v.string()) 774 - }); 775 - 776 - /** 777 - * Model used to test deduplication strategy (unused) 778 - */ 779 - export const vParameterSimpleParameterUnused = v.string(); 780 - 781 - /** 782 - * Model used to test deduplication strategy 783 - */ 784 - export const vPostServiceWithEmptyTagResponse = v.string(); 785 - 786 - /** 787 - * Model used to test deduplication strategy 788 - */ 789 - export const vPostServiceWithEmptyTagResponse2 = v.string(); 790 - 791 - /** 792 - * Model used to test deduplication strategy 793 - */ 794 - export const vDeleteFooData = v.string(); 795 - 796 - /** 797 - * Model used to test deduplication strategy 798 - */ 799 - export const vDeleteFooData2 = v.string(); 800 - 801 - /** 802 - * Model with restricted keyword name 803 - */ 804 - export const vImport = v.string(); 805 - 806 - export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); 807 - 808 - export const vSchemaWithFormRestrictedKeys = v.object({ 809 - description: v.optional(v.string()), 810 - 'x-enum-descriptions': v.optional(v.string()), 811 - 'x-enum-varnames': v.optional(v.string()), 812 - 'x-enumNames': v.optional(v.string()), 813 - title: v.optional(v.string()), 814 - object: v.optional(v.object({ 815 - description: v.optional(v.string()), 816 - 'x-enum-descriptions': v.optional(v.string()), 817 - 'x-enum-varnames': v.optional(v.string()), 818 - 'x-enumNames': v.optional(v.string()), 819 - title: v.optional(v.string()) 820 - })), 821 - array: v.optional(v.array(v.object({ 822 - description: v.optional(v.string()), 823 - 'x-enum-descriptions': v.optional(v.string()), 824 - 'x-enum-varnames': v.optional(v.string()), 825 - 'x-enumNames': v.optional(v.string()), 826 - title: v.optional(v.string()) 827 - }))) 828 - }); 829 - 830 - /** 831 - * This schema was giving PascalCase transformations a hard time 832 - */ 833 - export const vIoK8sApimachineryPkgApisMetaV1Preconditions = v.object({ 834 - resourceVersion: v.optional(v.string()), 835 - uid: v.optional(v.string()) 836 - }); 837 - 838 - /** 839 - * This schema was giving PascalCase transformations a hard time 840 - */ 841 - export const vIoK8sApimachineryPkgApisMetaV1DeleteOptions = v.object({ 842 - preconditions: v.optional(vIoK8sApimachineryPkgApisMetaV1Preconditions) 843 - }); 844 - 845 - export const vAdditionalPropertiesUnknownIssue = v.object({}); 846 - 847 - export const vAdditionalPropertiesUnknownIssue2 = v.object({}); 848 - 849 - export const vAdditionalPropertiesUnknownIssue3 = v.intersect([v.string(), v.object({ 850 - entries: v.object({}) 851 - })]); 852 - 853 - export const vAdditionalPropertiesIntegerIssue = v.objectWithRest({ 854 - value: v.pipe(v.number(), v.integer()) 855 - }, v.pipe(v.number(), v.integer())); 856 - 857 - export const vGenericSchemaDuplicateIssue1SystemBoolean = v.strictObject({ 858 - item: v.optional(v.boolean()), 859 - error: v.nullish(v.string()), 860 - hasError: v.optional(v.pipe(v.boolean(), v.readonly())), 861 - data: v.optional(v.strictObject({})) 862 - }); 863 - 864 - export const vGenericSchemaDuplicateIssue1SystemString = v.strictObject({ 865 - item: v.nullish(v.string()), 866 - error: v.nullish(v.string()), 867 - hasError: v.optional(v.pipe(v.boolean(), v.readonly())) 868 - }); 869 - 870 - export const vOneOfAllOfIssue = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); 871 - 872 - export const vExternalSharedModel = v.object({ 873 - id: v.string(), 874 - name: v.optional(v.string()) 875 - }); 876 - 877 - /** 878 - * External ref to shared model (A) 879 - */ 880 - export const vExternalRefA = vExternalSharedModel; 881 - 882 - /** 883 - * External ref to shared model (B) 884 - */ 885 - export const vExternalRefB = vExternalSharedModel; 886 - 887 - /** 888 - * This is a model with one nested property 889 - */ 890 - export const vModelWithPropertiesWritable = v.object({ 891 - required: v.string(), 892 - requiredAndNullable: v.nullable(v.string()), 893 - string: v.optional(v.string()), 894 - number: v.optional(v.number()), 895 - boolean: v.optional(v.boolean()), 896 - reference: v.optional(vModelWithString), 897 - 'property with space': v.optional(v.string()), 898 - default: v.optional(v.string()), 899 - try: v.optional(v.string()) 900 - }); 901 - 902 - /** 903 - * This is a model with one property containing a reference 904 - */ 905 - export const vModelWithReferenceWritable = v.object({ 906 - prop: v.optional(vModelWithPropertiesWritable) 907 - }); 908 - 909 - /** 910 - * This is a model that contains a some patterns 911 - */ 912 - export const vModelWithPatternWritable = v.object({ 913 - key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), 914 - name: v.pipe(v.string(), v.maxLength(255)), 915 - id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), 916 - text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), 917 - patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), 918 - patternWithNewline: v.optional(v.pipe(v.string(), v.regex(/aaa\nbbb/))), 919 - patternWithBacktick: v.optional(v.pipe(v.string(), v.regex(/aaa`bbb/))), 920 - patternWithUnicode: v.optional(v.pipe(v.string(), v.regex(/^\p{L}+$/u))) 921 - }); 922 - 923 - export const vFileWritable = v.object({ 924 - mime: v.pipe(v.string(), v.minLength(1), v.maxLength(24)) 925 - }); 926 - 927 - export const vModelWithReadOnlyAndWriteOnlyWritable = v.object({ 928 - foo: v.string(), 929 - baz: v.string() 930 - }); 931 - 932 - /** 933 - * This is a model with one property containing an array 934 - */ 935 - export const vModelWithArrayReadOnlyAndWriteOnlyWritable = v.object({ 936 - prop: v.optional(v.array(vModelWithReadOnlyAndWriteOnlyWritable)), 937 - propWithFile: v.optional(v.array(v.string())), 938 - propWithNumber: v.optional(v.array(v.number())) 939 - }); 940 - 941 - export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); 942 - 943 - export const vAdditionalPropertiesUnknownIssueWritable = v.object({}); 944 - 945 - export const vOneOfAllOfIssueWritable = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); 946 - 947 - export const vGenericSchemaDuplicateIssue1SystemBooleanWritable = v.strictObject({ 948 - item: v.optional(v.boolean()), 949 - error: v.nullish(v.string()), 950 - data: v.optional(v.strictObject({})) 951 - }); 952 - 953 - export const vGenericSchemaDuplicateIssue1SystemStringWritable = v.strictObject({ 954 - item: v.nullish(v.string()), 955 - error: v.nullish(v.string()) 956 - }); 957 - 958 - /** 959 - * This is a reusable parameter 960 - */ 961 - export const vSimpleParameter = v.string(); 962 - 963 - export const vCompositionWithOneOfAndProperties = v.intersect([v.union([v.strictObject({ 964 - foo: vSimpleParameter 965 - }), v.strictObject({ 966 - bar: vNonAsciiStringæøåÆøÅöôêÊ字符串 967 - })]), v.object({ 968 - baz: v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'))), 969 - qux: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255')) 970 - })]); 971 - 972 - export const vModelWithOneOfAndProperties = v.intersect([v.union([vSimpleParameter, vNonAsciiStringæøåÆøÅöôêÊ字符串]), v.object({ 973 - baz: v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 65535'))), 974 - qux: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 255')) 975 - })]); 976 - 977 - /** 978 - * Parameter with illegal characters 979 - */ 980 - export const vXFooBar = vModelWithString; 981 - 982 - /** 983 - * A reusable request body 984 - */ 985 - export const vSimpleRequestBody = vModelWithString; 986 - 987 - /** 988 - * A reusable request body 989 - */ 990 - export const vSimpleFormData = vModelWithString; 991 - 992 - export const vExportData = v.object({ 993 - body: v.optional(v.never()), 994 - path: v.optional(v.never()), 995 - query: v.optional(v.never()) 996 - }); 997 - 998 - export const vPatchApiVbyApiVersionNoTagData = v.object({ 999 - body: v.optional(v.never()), 1000 - path: v.optional(v.never()), 1001 - query: v.optional(v.never()) 1002 - }); 1003 - 1004 - export const vImportData = v.object({ 1005 - body: v.union([vModelWithReadOnlyAndWriteOnlyWritable, vModelWithArrayReadOnlyAndWriteOnlyWritable]), 1006 - path: v.optional(v.never()), 1007 - query: v.optional(v.never()) 1008 - }); 1009 - 1010 - export const vImportResponse = v.union([vModelFromZendesk, vModelWithReadOnlyAndWriteOnly]); 1011 - 1012 - export const vFooWowData = v.object({ 1013 - body: v.optional(v.never()), 1014 - path: v.optional(v.never()), 1015 - query: v.optional(v.never()) 1016 - }); 1017 - 1018 - export const vApiVVersionODataControllerCountData = v.object({ 1019 - body: v.optional(v.never()), 1020 - path: v.optional(v.never()), 1021 - query: v.optional(v.never()) 1022 - }); 1023 - 1024 - /** 1025 - * Success 1026 - */ 1027 - export const vApiVVersionODataControllerCountResponse = vModelFromZendesk; 1028 - 1029 - export const vGetApiVbyApiVersionSimpleOperationData = v.object({ 1030 - body: v.optional(v.never()), 1031 - path: v.object({ 1032 - foo_param: v.union([v.string(), v.pipe(v.string(), v.uuid())]) 1033 - }), 1034 - query: v.optional(v.never()) 1035 - }); 1036 - 1037 - /** 1038 - * Response is a simple number 1039 - */ 1040 - export const vGetApiVbyApiVersionSimpleOperationResponse = v.number(); 1041 - 1042 - export const vDeleteCallWithoutParametersAndResponseData = v.object({ 1043 - body: v.optional(v.never()), 1044 - path: v.optional(v.never()), 1045 - query: v.optional(v.never()) 1046 - }); 1047 - 1048 - export const vGetCallWithoutParametersAndResponseData = v.object({ 1049 - body: v.optional(v.never()), 1050 - path: v.optional(v.never()), 1051 - query: v.optional(v.never()) 1052 - }); 1053 - 1054 - export const vHeadCallWithoutParametersAndResponseData = v.object({ 1055 - body: v.optional(v.never()), 1056 - path: v.optional(v.never()), 1057 - query: v.optional(v.never()) 1058 - }); 1059 - 1060 - export const vOptionsCallWithoutParametersAndResponseData = v.object({ 1061 - body: v.optional(v.never()), 1062 - path: v.optional(v.never()), 1063 - query: v.optional(v.never()) 1064 - }); 1065 - 1066 - export const vPatchCallWithoutParametersAndResponseData = v.object({ 1067 - body: v.optional(v.never()), 1068 - path: v.optional(v.never()), 1069 - query: v.optional(v.never()) 1070 - }); 1071 - 1072 - export const vPostCallWithoutParametersAndResponseData = v.object({ 1073 - body: v.optional(v.never()), 1074 - path: v.optional(v.never()), 1075 - query: v.optional(v.never()) 1076 - }); 1077 - 1078 - export const vPutCallWithoutParametersAndResponseData = v.object({ 1079 - body: v.optional(v.never()), 1080 - path: v.optional(v.never()), 1081 - query: v.optional(v.never()) 1082 - }); 1083 - 1084 - export const vDeleteFooData3 = v.object({ 1085 - body: v.optional(v.never()), 1086 - path: v.object({ 1087 - foo_param: v.string(), 1088 - BarParam: v.string() 1089 - }), 1090 - query: v.optional(v.never()), 1091 - headers: v.object({ 1092 - 'x-Foo-Bar': vModelWithString 1093 - }) 1094 - }); 1095 - 1096 - export const vCallWithDescriptionsData = v.object({ 1097 - body: v.optional(v.never()), 1098 - path: v.optional(v.never()), 1099 - query: v.optional(v.object({ 1100 - parameterWithBreaks: v.optional(v.string()), 1101 - parameterWithBackticks: v.optional(v.string()), 1102 - parameterWithSlashes: v.optional(v.string()), 1103 - parameterWithExpressionPlaceholders: v.optional(v.string()), 1104 - parameterWithQuotes: v.optional(v.string()), 1105 - parameterWithReservedCharacters: v.optional(v.string()) 1106 - })) 1107 - }); 1108 - 1109 - export const vDeprecatedCallData = v.object({ 1110 - body: v.optional(v.never()), 1111 - path: v.optional(v.never()), 1112 - query: v.optional(v.never()), 1113 - headers: v.object({ 1114 - parameter: v.nullable(vDeprecatedModel) 1115 - }) 1116 - }); 1117 - 1118 - export const vCallWithParametersData = v.object({ 1119 - body: v.nullable(v.record(v.string(), v.unknown())), 1120 - path: v.object({ 1121 - parameterPath: v.nullable(v.string()), 1122 - 'api-version': v.nullable(v.string()) 1123 - }), 1124 - query: v.object({ 1125 - foo_ref_enum: v.optional(vModelWithNestedArrayEnumsDataFoo), 1126 - foo_all_of_enum: vModelWithNestedArrayEnumsDataFoo, 1127 - cursor: v.nullable(v.string()) 1128 - }), 1129 - headers: v.object({ 1130 - parameterHeader: v.nullable(v.string()) 1131 - }) 1132 - }); 1133 - 1134 - export const vCallWithWeirdParameterNamesData = v.object({ 1135 - body: v.nullable(vModelWithString), 1136 - path: v.object({ 1137 - 'parameter.path.1': v.optional(v.string()), 1138 - 'parameter-path-2': v.optional(v.string()), 1139 - 'PARAMETER-PATH-3': v.optional(v.string()), 1140 - 'api-version': v.nullable(v.string()) 1141 - }), 1142 - query: v.object({ 1143 - default: v.optional(v.string()), 1144 - 'parameter-query': v.nullable(v.string()) 1145 - }), 1146 - headers: v.object({ 1147 - 'parameter.header': v.nullable(v.string()) 1148 - }) 1149 - }); 1150 - 1151 - export const vGetCallWithOptionalParamData = v.object({ 1152 - body: vModelWithOneOfEnum, 1153 - path: v.optional(v.never()), 1154 - query: v.optional(v.object({ 1155 - page: v.optional(v.number()) 1156 - })) 1157 - }); 1158 - 1159 - export const vPostCallWithOptionalParamData = v.object({ 1160 - body: v.optional(v.object({ 1161 - offset: v.nullish(v.number()) 1162 - })), 1163 - path: v.optional(v.never()), 1164 - query: v.object({ 1165 - parameter: vPageable 1166 - }) 1167 - }); 1168 - 1169 - export const vPostCallWithOptionalParamResponse = v.union([v.number(), v.void()]); 1170 - 1171 - export const vPostApiVbyApiVersionRequestBodyData = v.object({ 1172 - body: v.optional(vSimpleRequestBody), 1173 - path: v.optional(v.never()), 1174 - query: v.optional(v.object({ 1175 - parameter: v.optional(v.string()) 1176 - })) 1177 - }); 1178 - 1179 - export const vPostApiVbyApiVersionFormDataData = v.object({ 1180 - body: v.optional(vSimpleFormData), 1181 - path: v.optional(v.never()), 1182 - query: v.optional(v.object({ 1183 - parameter: v.optional(v.string()) 1184 - })) 1185 - }); 1186 - 1187 - export const vCallWithDefaultParametersData = v.object({ 1188 - body: v.optional(v.never()), 1189 - path: v.optional(v.never()), 1190 - query: v.optional(v.object({ 1191 - parameterString: v.nullish(v.string(), 'Hello World!'), 1192 - parameterNumber: v.nullish(v.number(), 123), 1193 - parameterBoolean: v.nullish(v.boolean(), true), 1194 - parameterEnum: v.optional(v.picklist([ 1195 - 'Success', 1196 - 'Warning', 1197 - 'Error' 1198 - ])), 1199 - parameterModel: v.nullish(vModelWithString) 1200 - })) 1201 - }); 1202 - 1203 - export const vCallWithDefaultOptionalParametersData = v.object({ 1204 - body: v.optional(v.never()), 1205 - path: v.optional(v.never()), 1206 - query: v.optional(v.object({ 1207 - parameterString: v.optional(v.string(), 'Hello World!'), 1208 - parameterNumber: v.optional(v.number(), 123), 1209 - parameterBoolean: v.optional(v.boolean(), true), 1210 - parameterEnum: v.optional(v.picklist([ 1211 - 'Success', 1212 - 'Warning', 1213 - 'Error' 1214 - ])), 1215 - parameterModel: v.optional(vModelWithString, { prop: 'Hello World!' }) 1216 - })) 1217 - }); 1218 - 1219 - export const vCallToTestOrderOfParamsData = v.object({ 1220 - body: v.optional(v.never()), 1221 - path: v.optional(v.never()), 1222 - query: v.object({ 1223 - parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), 1224 - parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ''), 1225 - parameterOptionalStringWithNoDefault: v.optional(v.string()), 1226 - parameterStringWithDefault: v.optional(v.string(), 'Hello World!'), 1227 - parameterStringWithEmptyDefault: v.optional(v.string(), ''), 1228 - parameterStringWithNoDefault: v.string(), 1229 - parameterStringNullableWithNoDefault: v.nullish(v.string()), 1230 - parameterStringNullableWithDefault: v.nullish(v.string(), null) 1231 - }) 1232 - }); 1233 - 1234 - export const vDuplicateNameData = v.object({ 1235 - body: v.optional(v.never()), 1236 - path: v.optional(v.never()), 1237 - query: v.optional(v.never()) 1238 - }); 1239 - 1240 - export const vDuplicateName2Data = v.object({ 1241 - body: v.optional(v.never()), 1242 - path: v.optional(v.never()), 1243 - query: v.optional(v.never()) 1244 - }); 1245 - 1246 - export const vDuplicateName3Data = v.object({ 1247 - body: v.optional(v.never()), 1248 - path: v.optional(v.never()), 1249 - query: v.optional(v.never()) 1250 - }); 1251 - 1252 - export const vDuplicateName4Data = v.object({ 1253 - body: v.optional(v.never()), 1254 - path: v.optional(v.never()), 1255 - query: v.optional(v.never()) 1256 - }); 1257 - 1258 - export const vCallWithNoContentResponseData = v.object({ 1259 - body: v.optional(v.never()), 1260 - path: v.optional(v.never()), 1261 - query: v.optional(v.never()) 1262 - }); 1263 - 1264 - /** 1265 - * Success 1266 - */ 1267 - export const vCallWithNoContentResponseResponse = v.void(); 1268 - 1269 - export const vCallWithResponseAndNoContentResponseData = v.object({ 1270 - body: v.optional(v.never()), 1271 - path: v.optional(v.never()), 1272 - query: v.optional(v.never()) 1273 - }); 1274 - 1275 - export const vCallWithResponseAndNoContentResponseResponse = v.union([v.number(), v.void()]); 1276 - 1277 - export const vDummyAData = v.object({ 1278 - body: v.optional(v.never()), 1279 - path: v.optional(v.never()), 1280 - query: v.optional(v.never()) 1281 - }); 1282 - 1283 - export const vDummyAResponse = v400; 1284 - 1285 - export const vDummyBData = v.object({ 1286 - body: v.optional(v.never()), 1287 - path: v.optional(v.never()), 1288 - query: v.optional(v.never()) 1289 - }); 1290 - 1291 - /** 1292 - * Success 1293 - */ 1294 - export const vDummyBResponse = v.void(); 1295 - 1296 - export const vCallWithResponseData = v.object({ 1297 - body: v.optional(v.never()), 1298 - path: v.optional(v.never()), 1299 - query: v.optional(v.never()) 1300 - }); 1301 - 1302 - export const vCallWithResponseResponse = vImport; 1303 - 1304 - export const vCallWithDuplicateResponsesData = v.object({ 1305 - body: v.optional(v.never()), 1306 - path: v.optional(v.never()), 1307 - query: v.optional(v.never()) 1308 - }); 1309 - 1310 - export const vCallWithDuplicateResponsesResponse = v.union([v.intersect([vModelWithBoolean, vModelWithInteger]), vModelWithString]); 1311 - 1312 - export const vCallWithResponsesData = v.object({ 1313 - body: v.optional(v.never()), 1314 - path: v.optional(v.never()), 1315 - query: v.optional(v.never()) 1316 - }); 1317 - 1318 - export const vCallWithResponsesResponse = v.union([ 1319 - v.object({ 1320 - '@namespace.string': v.optional(v.pipe(v.string(), v.readonly())), 1321 - '@namespace.integer': v.optional(v.pipe(v.pipe(v.number(), v.integer()), v.readonly())), 1322 - value: v.optional(v.pipe(v.array(vModelWithString), v.readonly())) 1323 - }), 1324 - vModelThatExtends, 1325 - vModelThatExtendsExtends 1326 - ]); 1327 - 1328 - export const vCollectionFormatData = v.object({ 1329 - body: v.optional(v.never()), 1330 - path: v.optional(v.never()), 1331 - query: v.object({ 1332 - parameterArrayCSV: v.nullable(v.array(v.string())), 1333 - parameterArraySSV: v.nullable(v.array(v.string())), 1334 - parameterArrayTSV: v.nullable(v.array(v.string())), 1335 - parameterArrayPipes: v.nullable(v.array(v.string())), 1336 - parameterArrayMulti: v.nullable(v.array(v.string())) 1337 - }) 1338 - }); 1339 - 1340 - export const vTypesData = v.object({ 1341 - body: v.optional(v.never()), 1342 - path: v.optional(v.object({ 1343 - id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647'))) 1344 - })), 1345 - query: v.object({ 1346 - parameterNumber: v.optional(v.number(), 123), 1347 - parameterString: v.nullish(v.string(), 'default'), 1348 - parameterBoolean: v.nullish(v.boolean(), true), 1349 - parameterObject: v.nullish(v.record(v.string(), v.unknown()), null), 1350 - parameterArray: v.nullable(v.array(v.string())), 1351 - parameterDictionary: v.nullable(v.record(v.string(), v.unknown())), 1352 - parameterEnum: v.nullable(v.union([ 1353 - v.literal('Success'), 1354 - v.literal('Warning'), 1355 - v.literal('Error') 1356 - ])) 1357 - }) 1358 - }); 1359 - 1360 - export const vTypesResponse = v.union([ 1361 - v.number(), 1362 - v.string(), 1363 - v.boolean(), 1364 - v.record(v.string(), v.unknown()) 1365 - ]); 1366 - 1367 - export const vUploadFileData = v.object({ 1368 - body: v.string(), 1369 - path: v.object({ 1370 - 'api-version': v.nullable(v.string()) 1371 - }), 1372 - query: v.optional(v.never()) 1373 - }); 1374 - 1375 - export const vUploadFileResponse = v.boolean(); 1376 - 1377 - export const vFileResponseData = v.object({ 1378 - body: v.optional(v.never()), 1379 - path: v.object({ 1380 - id: v.string(), 1381 - 'api-version': v.string() 1382 - }), 1383 - query: v.optional(v.never()) 1384 - }); 1385 - 1386 - /** 1387 - * Success 1388 - */ 1389 - export const vFileResponseResponse = v.string(); 1390 - 1391 - export const vComplexTypesData = v.object({ 1392 - body: v.optional(v.never()), 1393 - path: v.optional(v.never()), 1394 - query: v.object({ 1395 - parameterObject: v.object({ 1396 - first: v.optional(v.object({ 1397 - second: v.optional(v.object({ 1398 - third: v.optional(v.string()) 1399 - })) 1400 - })) 1401 - }), 1402 - parameterReference: vModelWithString 1403 - }) 1404 - }); 1405 - 1406 - /** 1407 - * Successful response 1408 - */ 1409 - export const vComplexTypesResponse = v.array(vModelWithString); 1410 - 1411 - export const vMultipartResponseData = v.object({ 1412 - body: v.optional(v.never()), 1413 - path: v.optional(v.never()), 1414 - query: v.optional(v.never()) 1415 - }); 1416 - 1417 - /** 1418 - * OK 1419 - */ 1420 - export const vMultipartResponseResponse = v.object({ 1421 - file: v.optional(v.string()), 1422 - metadata: v.optional(v.object({ 1423 - foo: v.optional(v.string()), 1424 - bar: v.optional(v.string()) 1425 - })) 1426 - }); 1427 - 1428 - export const vMultipartRequestData = v.object({ 1429 - body: v.optional(v.object({ 1430 - content: v.optional(v.string()), 1431 - data: v.nullish(vModelWithString) 1432 - })), 1433 - path: v.optional(v.never()), 1434 - query: v.optional(v.never()) 1435 - }); 1436 - 1437 - export const vComplexParamsData = v.object({ 1438 - body: v.optional(v.object({ 1439 - key: v.nullable(v.pipe(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.readonly())), 1440 - name: v.nullable(v.pipe(v.string(), v.maxLength(255))), 1441 - enabled: v.optional(v.boolean(), true), 1442 - type: v.picklist([ 1443 - 'Monkey', 1444 - 'Horse', 1445 - 'Bird' 1446 - ]), 1447 - listOfModels: v.nullish(v.array(vModelWithString)), 1448 - listOfStrings: v.nullish(v.array(v.string())), 1449 - parameters: v.union([ 1450 - vModelWithString, 1451 - vModelWithEnum, 1452 - vModelWithArray, 1453 - vModelWithDictionary 1454 - ]), 1455 - user: v.optional(v.pipe(v.object({ 1456 - id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), v.readonly())), 1457 - name: v.nullish(v.pipe(v.string(), v.readonly())) 1458 - }), v.readonly())) 1459 - })), 1460 - path: v.object({ 1461 - id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2147483648'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2147483647')), 1462 - 'api-version': v.string() 1463 - }), 1464 - query: v.optional(v.never()) 1465 - }); 1466 - 1467 - /** 1468 - * Success 1469 - */ 1470 - export const vComplexParamsResponse = vModelWithString; 1471 - 1472 - export const vCallWithResultFromHeaderData = v.object({ 1473 - body: v.optional(v.never()), 1474 - path: v.optional(v.never()), 1475 - query: v.optional(v.never()) 1476 - }); 1477 - 1478 - export const vTestErrorCodeData = v.object({ 1479 - body: v.optional(v.never()), 1480 - path: v.optional(v.never()), 1481 - query: v.object({ 1482 - status: v.pipe(v.number(), v.integer()) 1483 - }) 1484 - }); 1485 - 1486 - export const vNonAsciiæøåÆøÅöôêÊ字符串Data = v.object({ 1487 - body: v.optional(v.never()), 1488 - path: v.optional(v.never()), 1489 - query: v.object({ 1490 - nonAsciiParamæøåÆØÅöôêÊ: v.pipe(v.number(), v.integer()) 1491 - }) 1492 - }); 1493 - 1494 - /** 1495 - * Successful response 1496 - */ 1497 - export const vNonAsciiæøåÆøÅöôêÊ字符串Response = v.array(vNonAsciiStringæøåÆøÅöôêÊ字符串); 1498 - 1499 - export const vPutWithFormUrlEncodedData = v.object({ 1500 - body: vArrayWithStrings, 1501 - path: v.optional(v.never()), 1502 - query: v.optional(v.never()) 1503 - });
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/schema-const/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/string-with-format/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/time-format/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/time-format/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata-fn/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-metadata-fn/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-types/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/validators/valibot.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts packages/openapi-ts-tests/valibot/v1/__snapshots__/3.1.x/webhooks/valibot.gen.ts
-80
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type DefaultError, queryOptions } from '@tanstack/angular-query-experimental'; 4 - 5 - import { client } from '../client.gen'; 6 - import { getBar, getFoo, type Options } from '../sdk.gen'; 7 - import type { GetBarData, GetFooData } from '../types.gen'; 8 - 9 - export type QueryKey<TOptions extends Options> = [ 10 - Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 - _id: string; 12 - _infinite?: boolean; 13 - tags?: ReadonlyArray<string>; 14 - } 15 - ]; 16 - 17 - const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 - QueryKey<TOptions>[0] 19 - ] => { 20 - const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 - if (infinite) { 22 - params._infinite = infinite; 23 - } 24 - if (tags) { 25 - params.tags = tags; 26 - } 27 - if (options?.body) { 28 - params.body = options.body; 29 - } 30 - if (options?.headers) { 31 - params.headers = options.headers; 32 - } 33 - if (options?.path) { 34 - params.path = options.path; 35 - } 36 - if (options?.query) { 37 - params.query = options.query; 38 - } 39 - return [params]; 40 - }; 41 - 42 - export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 43 - 44 - export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({ 45 - queryFn: async ({ queryKey, signal }) => { 46 - const { data } = await getFoo({ 47 - ...options, 48 - ...queryKey[0], 49 - signal, 50 - throwOnError: true 51 - }); 52 - return data; 53 - }, 54 - queryKey: getFooQueryKey(options), 55 - meta: { 56 - id: 'getFoo', 57 - method: 'get', 58 - path: '/foo' 59 - } 60 - }); 61 - 62 - export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options); 63 - 64 - export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({ 65 - queryFn: async ({ queryKey, signal }) => { 66 - const { data } = await getBar({ 67 - ...options, 68 - ...queryKey[0], 69 - signal, 70 - throwOnError: true 71 - }); 72 - return data; 73 - }, 74 - queryKey: getBarQueryKey(options), 75 - meta: { 76 - id: 'getBar', 77 - method: 'get', 78 - path: '/bar' 79 - } 80 - });
-80
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type DefaultError, queryOptions } from '@tanstack/react-query'; 4 - 5 - import { client } from '../client.gen'; 6 - import { getBar, getFoo, type Options } from '../sdk.gen'; 7 - import type { GetBarData, GetFooData } from '../types.gen'; 8 - 9 - export type QueryKey<TOptions extends Options> = [ 10 - Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 - _id: string; 12 - _infinite?: boolean; 13 - tags?: ReadonlyArray<string>; 14 - } 15 - ]; 16 - 17 - const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 - QueryKey<TOptions>[0] 19 - ] => { 20 - const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 - if (infinite) { 22 - params._infinite = infinite; 23 - } 24 - if (tags) { 25 - params.tags = tags; 26 - } 27 - if (options?.body) { 28 - params.body = options.body; 29 - } 30 - if (options?.headers) { 31 - params.headers = options.headers; 32 - } 33 - if (options?.path) { 34 - params.path = options.path; 35 - } 36 - if (options?.query) { 37 - params.query = options.query; 38 - } 39 - return [params]; 40 - }; 41 - 42 - export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 43 - 44 - export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({ 45 - queryFn: async ({ queryKey, signal }) => { 46 - const { data } = await getFoo({ 47 - ...options, 48 - ...queryKey[0], 49 - signal, 50 - throwOnError: true 51 - }); 52 - return data; 53 - }, 54 - queryKey: getFooQueryKey(options), 55 - meta: { 56 - id: 'getFoo', 57 - method: 'get', 58 - path: '/foo' 59 - } 60 - }); 61 - 62 - export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options); 63 - 64 - export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({ 65 - queryFn: async ({ queryKey, signal }) => { 66 - const { data } = await getBar({ 67 - ...options, 68 - ...queryKey[0], 69 - signal, 70 - throwOnError: true 71 - }); 72 - return data; 73 - }, 74 - queryKey: getBarQueryKey(options), 75 - meta: { 76 - id: 'getBar', 77 - method: 'get', 78 - path: '/bar' 79 - } 80 - });
-80
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type DefaultError, queryOptions } from '@tanstack/solid-query'; 4 - 5 - import { client } from '../client.gen'; 6 - import { getBar, getFoo, type Options } from '../sdk.gen'; 7 - import type { GetBarData, GetFooData } from '../types.gen'; 8 - 9 - export type QueryKey<TOptions extends Options> = [ 10 - Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 - _id: string; 12 - _infinite?: boolean; 13 - tags?: ReadonlyArray<string>; 14 - } 15 - ]; 16 - 17 - const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 - QueryKey<TOptions>[0] 19 - ] => { 20 - const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 - if (infinite) { 22 - params._infinite = infinite; 23 - } 24 - if (tags) { 25 - params.tags = tags; 26 - } 27 - if (options?.body) { 28 - params.body = options.body; 29 - } 30 - if (options?.headers) { 31 - params.headers = options.headers; 32 - } 33 - if (options?.path) { 34 - params.path = options.path; 35 - } 36 - if (options?.query) { 37 - params.query = options.query; 38 - } 39 - return [params]; 40 - }; 41 - 42 - export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 43 - 44 - export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({ 45 - queryFn: async ({ queryKey, signal }) => { 46 - const { data } = await getFoo({ 47 - ...options, 48 - ...queryKey[0], 49 - signal, 50 - throwOnError: true 51 - }); 52 - return data; 53 - }, 54 - queryKey: getFooQueryKey(options), 55 - meta: { 56 - id: 'getFoo', 57 - method: 'get', 58 - path: '/foo' 59 - } 60 - }); 61 - 62 - export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options); 63 - 64 - export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({ 65 - queryFn: async ({ queryKey, signal }) => { 66 - const { data } = await getBar({ 67 - ...options, 68 - ...queryKey[0], 69 - signal, 70 - throwOnError: true 71 - }); 72 - return data; 73 - }, 74 - queryKey: getBarQueryKey(options), 75 - meta: { 76 - id: 'getBar', 77 - method: 'get', 78 - path: '/bar' 79 - } 80 - });
-80
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type DefaultError, queryOptions } from '@tanstack/svelte-query'; 4 - 5 - import { client } from '../client.gen'; 6 - import { getBar, getFoo, type Options } from '../sdk.gen'; 7 - import type { GetBarData, GetFooData } from '../types.gen'; 8 - 9 - export type QueryKey<TOptions extends Options> = [ 10 - Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 - _id: string; 12 - _infinite?: boolean; 13 - tags?: ReadonlyArray<string>; 14 - } 15 - ]; 16 - 17 - const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 - QueryKey<TOptions>[0] 19 - ] => { 20 - const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 - if (infinite) { 22 - params._infinite = infinite; 23 - } 24 - if (tags) { 25 - params.tags = tags; 26 - } 27 - if (options?.body) { 28 - params.body = options.body; 29 - } 30 - if (options?.headers) { 31 - params.headers = options.headers; 32 - } 33 - if (options?.path) { 34 - params.path = options.path; 35 - } 36 - if (options?.query) { 37 - params.query = options.query; 38 - } 39 - return [params]; 40 - }; 41 - 42 - export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 43 - 44 - export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({ 45 - queryFn: async ({ queryKey, signal }) => { 46 - const { data } = await getFoo({ 47 - ...options, 48 - ...queryKey[0], 49 - signal, 50 - throwOnError: true 51 - }); 52 - return data; 53 - }, 54 - queryKey: getFooQueryKey(options), 55 - meta: { 56 - id: 'getFoo', 57 - method: 'get', 58 - path: '/foo' 59 - } 60 - }); 61 - 62 - export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options); 63 - 64 - export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({ 65 - queryFn: async ({ queryKey, signal }) => { 66 - const { data } = await getBar({ 67 - ...options, 68 - ...queryKey[0], 69 - signal, 70 - throwOnError: true 71 - }); 72 - return data; 73 - }, 74 - queryKey: getBarQueryKey(options), 75 - meta: { 76 - id: 'getBar', 77 - method: 'get', 78 - path: '/bar' 79 - } 80 - });
-80
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type DefaultError, queryOptions } from '@tanstack/vue-query'; 4 - 5 - import { client } from '../client.gen'; 6 - import { getBar, getFoo, type Options } from '../sdk.gen'; 7 - import type { GetBarData, GetFooData } from '../types.gen'; 8 - 9 - export type QueryKey<TOptions extends Options> = [ 10 - Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 11 - _id: string; 12 - _infinite?: boolean; 13 - tags?: ReadonlyArray<string>; 14 - } 15 - ]; 16 - 17 - const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [ 18 - QueryKey<TOptions>[0] 19 - ] => { 20 - const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0]; 21 - if (infinite) { 22 - params._infinite = infinite; 23 - } 24 - if (tags) { 25 - params.tags = tags; 26 - } 27 - if (options?.body) { 28 - params.body = options.body; 29 - } 30 - if (options?.headers) { 31 - params.headers = options.headers; 32 - } 33 - if (options?.path) { 34 - params.path = options.path; 35 - } 36 - if (options?.query) { 37 - params.query = options.query; 38 - } 39 - return [params]; 40 - }; 41 - 42 - export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options); 43 - 44 - export const getFooOptions = (options?: Options<GetFooData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getFooQueryKey>>({ 45 - queryFn: async ({ queryKey, signal }) => { 46 - const { data } = await getFoo({ 47 - ...options, 48 - ...queryKey[0], 49 - signal, 50 - throwOnError: true 51 - }); 52 - return data; 53 - }, 54 - queryKey: getFooQueryKey(options), 55 - meta: { 56 - id: 'getFoo', 57 - method: 'get', 58 - path: '/foo' 59 - } 60 - }); 61 - 62 - export const getBarQueryKey = (options?: Options<GetBarData>) => createQueryKey('getBar', options); 63 - 64 - export const getBarOptions = (options?: Options<GetBarData>) => queryOptions<unknown, DefaultError, unknown, ReturnType<typeof getBarQueryKey>>({ 65 - queryFn: async ({ queryKey, signal }) => { 66 - const { data } = await getBar({ 67 - ...options, 68 - ...queryKey[0], 69 - signal, 70 - throwOnError: true 71 - }); 72 - return data; 73 - }, 74 - queryKey: getBarQueryKey(options), 75 - meta: { 76 - id: 'getBar', 77 - method: 'get', 78 - path: '/bar' 79 - } 80 - });
-16
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { type ClientOptions, type Config, createClient, createConfig } from './client'; 4 - import type { ClientOptions as ClientOptions2 } from './types.gen'; 5 - 6 - /** 7 - * The `createClientConfig()` function will be called on client initialization 8 - * and the returned object will become the client's initial configuration. 9 - * 10 - * You may want to initialize your client this way instead of calling 11 - * `setConfig()`. This is useful for example if you're using Next.js 12 - * to ensure your client always has the correct values. 13 - */ 14 - export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>; 15 - 16 - export const client = createClient(createConfig<ClientOptions2>());
-305
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { createSseClient } from '../core/serverSentEvents.gen'; 4 - import type { HttpMethod } from '../core/types.gen'; 5 - import { getValidRequestBody } from '../core/utils.gen'; 6 - import type { 7 - Client, 8 - Config, 9 - RequestOptions, 10 - ResolvedRequestOptions, 11 - } from './types.gen'; 12 - import { 13 - buildUrl, 14 - createConfig, 15 - createInterceptors, 16 - getParseAs, 17 - mergeConfigs, 18 - mergeHeaders, 19 - setAuthParams, 20 - } from './utils.gen'; 21 - 22 - type ReqInit = Omit<RequestInit, 'body' | 'headers'> & { 23 - body?: any; 24 - headers: ReturnType<typeof mergeHeaders>; 25 - }; 26 - 27 - export const createClient = (config: Config = {}): Client => { 28 - let _config = mergeConfigs(createConfig(), config); 29 - 30 - const getConfig = (): Config => ({ ..._config }); 31 - 32 - const setConfig = (config: Config): Config => { 33 - _config = mergeConfigs(_config, config); 34 - return getConfig(); 35 - }; 36 - 37 - const interceptors = createInterceptors< 38 - Request, 39 - Response, 40 - unknown, 41 - ResolvedRequestOptions 42 - >(); 43 - 44 - const beforeRequest = async (options: RequestOptions) => { 45 - const opts = { 46 - ..._config, 47 - ...options, 48 - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, 49 - headers: mergeHeaders(_config.headers, options.headers), 50 - serializedBody: undefined as string | undefined, 51 - }; 52 - 53 - if (opts.security) { 54 - await setAuthParams({ 55 - ...opts, 56 - security: opts.security, 57 - }); 58 - } 59 - 60 - if (opts.requestValidator) { 61 - await opts.requestValidator(opts); 62 - } 63 - 64 - if (opts.body !== undefined && opts.bodySerializer) { 65 - opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined; 66 - } 67 - 68 - // remove Content-Type header if body is empty to avoid sending invalid requests 69 - if (opts.body === undefined || opts.serializedBody === '') { 70 - opts.headers.delete('Content-Type'); 71 - } 72 - 73 - const url = buildUrl(opts); 74 - 75 - return { opts, url }; 76 - }; 77 - 78 - const request: Client['request'] = async (options) => { 79 - // @ts-expect-error 80 - const { opts, url } = await beforeRequest(options); 81 - const requestInit: ReqInit = { 82 - redirect: 'follow', 83 - ...opts, 84 - body: getValidRequestBody(opts), 85 - }; 86 - 87 - let request = new Request(url, requestInit); 88 - 89 - for (const fn of interceptors.request.fns) { 90 - if (fn) { 91 - request = await fn(request, opts); 92 - } 93 - } 94 - 95 - // fetch must be assigned here, otherwise it would throw the error: 96 - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 97 - const _fetch = opts.fetch!; 98 - let response: Response; 99 - 100 - try { 101 - response = await _fetch(request); 102 - } catch (error) { 103 - // Handle fetch exceptions (AbortError, network errors, etc.) 104 - let finalError = error; 105 - 106 - for (const fn of interceptors.error.fns) { 107 - if (fn) { 108 - finalError = (await fn( 109 - error, 110 - undefined as any, 111 - request, 112 - opts, 113 - )) as unknown; 114 - } 115 - } 116 - 117 - finalError = finalError || ({} as unknown); 118 - 119 - if (opts.throwOnError) { 120 - throw finalError; 121 - } 122 - 123 - // Return error response 124 - return opts.responseStyle === 'data' 125 - ? undefined 126 - : { 127 - error: finalError, 128 - request, 129 - response: undefined as any, 130 - }; 131 - } 132 - 133 - for (const fn of interceptors.response.fns) { 134 - if (fn) { 135 - response = await fn(response, request, opts); 136 - } 137 - } 138 - 139 - const result = { 140 - request, 141 - response, 142 - }; 143 - 144 - if (response.ok) { 145 - const parseAs = 146 - (opts.parseAs === 'auto' 147 - ? getParseAs(response.headers.get('Content-Type')) 148 - : opts.parseAs) ?? 'json'; 149 - 150 - if ( 151 - response.status === 204 || 152 - response.headers.get('Content-Length') === '0' 153 - ) { 154 - let emptyData: any; 155 - switch (parseAs) { 156 - case 'arrayBuffer': 157 - case 'blob': 158 - case 'text': 159 - emptyData = await response[parseAs](); 160 - break; 161 - case 'formData': 162 - emptyData = new FormData(); 163 - break; 164 - case 'stream': 165 - emptyData = response.body; 166 - break; 167 - case 'json': 168 - default: 169 - emptyData = {}; 170 - break; 171 - } 172 - return opts.responseStyle === 'data' 173 - ? emptyData 174 - : { 175 - data: emptyData, 176 - ...result, 177 - }; 178 - } 179 - 180 - let data: any; 181 - switch (parseAs) { 182 - case 'arrayBuffer': 183 - case 'blob': 184 - case 'formData': 185 - case 'json': 186 - case 'text': 187 - data = await response[parseAs](); 188 - break; 189 - case 'stream': 190 - return opts.responseStyle === 'data' 191 - ? response.body 192 - : { 193 - data: response.body, 194 - ...result, 195 - }; 196 - } 197 - 198 - if (parseAs === 'json') { 199 - if (opts.responseValidator) { 200 - await opts.responseValidator(data); 201 - } 202 - 203 - if (opts.responseTransformer) { 204 - data = await opts.responseTransformer(data); 205 - } 206 - } 207 - 208 - return opts.responseStyle === 'data' 209 - ? data 210 - : { 211 - data, 212 - ...result, 213 - }; 214 - } 215 - 216 - const textError = await response.text(); 217 - let jsonError: unknown; 218 - 219 - try { 220 - jsonError = JSON.parse(textError); 221 - } catch { 222 - // noop 223 - } 224 - 225 - const error = jsonError ?? textError; 226 - let finalError = error; 227 - 228 - for (const fn of interceptors.error.fns) { 229 - if (fn) { 230 - finalError = (await fn(error, response, request, opts)) as string; 231 - } 232 - } 233 - 234 - finalError = finalError || ({} as string); 235 - 236 - if (opts.throwOnError) { 237 - throw finalError; 238 - } 239 - 240 - // TODO: we probably want to return error and improve types 241 - return opts.responseStyle === 'data' 242 - ? undefined 243 - : { 244 - error: finalError, 245 - ...result, 246 - }; 247 - }; 248 - 249 - const makeMethodFn = 250 - (method: Uppercase<HttpMethod>) => (options: RequestOptions) => 251 - request({ ...options, method }); 252 - 253 - const makeSseFn = 254 - (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => { 255 - const { opts, url } = await beforeRequest(options); 256 - return createSseClient({ 257 - ...opts, 258 - body: opts.body as BodyInit | null | undefined, 259 - headers: opts.headers as unknown as Record<string, string>, 260 - method, 261 - onRequest: async (url, init) => { 262 - let request = new Request(url, init); 263 - for (const fn of interceptors.request.fns) { 264 - if (fn) { 265 - request = await fn(request, opts); 266 - } 267 - } 268 - return request; 269 - }, 270 - serializedBody: getValidRequestBody(opts) as 271 - | BodyInit 272 - | null 273 - | undefined, 274 - url, 275 - }); 276 - }; 277 - 278 - return { 279 - buildUrl, 280 - connect: makeMethodFn('CONNECT'), 281 - delete: makeMethodFn('DELETE'), 282 - get: makeMethodFn('GET'), 283 - getConfig, 284 - head: makeMethodFn('HEAD'), 285 - interceptors, 286 - options: makeMethodFn('OPTIONS'), 287 - patch: makeMethodFn('PATCH'), 288 - post: makeMethodFn('POST'), 289 - put: makeMethodFn('PUT'), 290 - request, 291 - setConfig, 292 - sse: { 293 - connect: makeSseFn('CONNECT'), 294 - delete: makeSseFn('DELETE'), 295 - get: makeSseFn('GET'), 296 - head: makeSseFn('HEAD'), 297 - options: makeSseFn('OPTIONS'), 298 - patch: makeSseFn('PATCH'), 299 - post: makeSseFn('POST'), 300 - put: makeSseFn('PUT'), 301 - trace: makeSseFn('TRACE'), 302 - }, 303 - trace: makeMethodFn('TRACE'), 304 - } as Client; 305 - };
-25
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type { Auth } from '../core/auth.gen'; 4 - export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 - export { 6 - formDataBodySerializer, 7 - jsonBodySerializer, 8 - urlSearchParamsBodySerializer, 9 - } from '../core/bodySerializer.gen'; 10 - export { buildClientParams } from '../core/params.gen'; 11 - export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen'; 12 - export { createClient } from './client.gen'; 13 - export type { 14 - Client, 15 - ClientOptions, 16 - Config, 17 - CreateClientConfig, 18 - Options, 19 - RequestOptions, 20 - RequestResult, 21 - ResolvedRequestOptions, 22 - ResponseStyle, 23 - TDataShape, 24 - } from './types.gen'; 25 - export { createConfig, mergeHeaders } from './utils.gen';
-242
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Auth } from '../core/auth.gen'; 4 - import type { 5 - ServerSentEventsOptions, 6 - ServerSentEventsResult, 7 - } from '../core/serverSentEvents.gen'; 8 - import type { 9 - Client as CoreClient, 10 - Config as CoreConfig, 11 - } from '../core/types.gen'; 12 - import type { Middleware } from './utils.gen'; 13 - 14 - export type ResponseStyle = 'data' | 'fields'; 15 - 16 - export interface Config<T extends ClientOptions = ClientOptions> 17 - extends Omit<RequestInit, 'body' | 'headers' | 'method'>, 18 - CoreConfig { 19 - /** 20 - * Base URL for all requests made by this client. 21 - */ 22 - baseUrl?: T['baseUrl']; 23 - /** 24 - * Fetch API implementation. You can use this option to provide a custom 25 - * fetch instance. 26 - * 27 - * @default globalThis.fetch 28 - */ 29 - fetch?: typeof fetch; 30 - /** 31 - * Please don't use the Fetch client for Next.js applications. The `next` 32 - * options won't have any effect. 33 - * 34 - * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. 35 - */ 36 - next?: never; 37 - /** 38 - * Return the response data parsed in a specified format. By default, `auto` 39 - * will infer the appropriate method from the `Content-Type` response header. 40 - * You can override this behavior with any of the {@link Body} methods. 41 - * Select `stream` if you don't want to parse response data at all. 42 - * 43 - * @default 'auto' 44 - */ 45 - parseAs?: 46 - | 'arrayBuffer' 47 - | 'auto' 48 - | 'blob' 49 - | 'formData' 50 - | 'json' 51 - | 'stream' 52 - | 'text'; 53 - /** 54 - * Should we return only data or multiple fields (data, error, response, etc.)? 55 - * 56 - * @default 'fields' 57 - */ 58 - responseStyle?: ResponseStyle; 59 - /** 60 - * Throw an error instead of returning it in the response? 61 - * 62 - * @default false 63 - */ 64 - throwOnError?: T['throwOnError']; 65 - } 66 - 67 - export interface RequestOptions< 68 - TData = unknown, 69 - TResponseStyle extends ResponseStyle = 'fields', 70 - ThrowOnError extends boolean = boolean, 71 - Url extends string = string, 72 - > extends Config<{ 73 - responseStyle: TResponseStyle; 74 - throwOnError: ThrowOnError; 75 - }>, 76 - Pick< 77 - ServerSentEventsOptions<TData>, 78 - | 'onRequest' 79 - | 'onSseError' 80 - | 'onSseEvent' 81 - | 'sseDefaultRetryDelay' 82 - | 'sseMaxRetryAttempts' 83 - | 'sseMaxRetryDelay' 84 - > { 85 - /** 86 - * Any body that you want to add to your request. 87 - * 88 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} 89 - */ 90 - body?: unknown; 91 - path?: Record<string, unknown>; 92 - query?: Record<string, unknown>; 93 - /** 94 - * Security mechanism(s) to use for the request. 95 - */ 96 - security?: ReadonlyArray<Auth>; 97 - url: Url; 98 - } 99 - 100 - export interface ResolvedRequestOptions< 101 - TResponseStyle extends ResponseStyle = 'fields', 102 - ThrowOnError extends boolean = boolean, 103 - Url extends string = string, 104 - > extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> { 105 - serializedBody?: string; 106 - } 107 - 108 - export type RequestResult< 109 - TData = unknown, 110 - TError = unknown, 111 - ThrowOnError extends boolean = boolean, 112 - TResponseStyle extends ResponseStyle = 'fields', 113 - > = ThrowOnError extends true 114 - ? Promise< 115 - TResponseStyle extends 'data' 116 - ? TData extends Record<string, unknown> 117 - ? TData[keyof TData] 118 - : TData 119 - : { 120 - data: TData extends Record<string, unknown> 121 - ? TData[keyof TData] 122 - : TData; 123 - request: Request; 124 - response: Response; 125 - } 126 - > 127 - : Promise< 128 - TResponseStyle extends 'data' 129 - ? 130 - | (TData extends Record<string, unknown> 131 - ? TData[keyof TData] 132 - : TData) 133 - | undefined 134 - : ( 135 - | { 136 - data: TData extends Record<string, unknown> 137 - ? TData[keyof TData] 138 - : TData; 139 - error: undefined; 140 - } 141 - | { 142 - data: undefined; 143 - error: TError extends Record<string, unknown> 144 - ? TError[keyof TError] 145 - : TError; 146 - } 147 - ) & { 148 - request: Request; 149 - response: Response; 150 - } 151 - >; 152 - 153 - export interface ClientOptions { 154 - baseUrl?: string; 155 - responseStyle?: ResponseStyle; 156 - throwOnError?: boolean; 157 - } 158 - 159 - type MethodFn = < 160 - TData = unknown, 161 - TError = unknown, 162 - ThrowOnError extends boolean = false, 163 - TResponseStyle extends ResponseStyle = 'fields', 164 - >( 165 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 166 - ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 167 - 168 - type SseFn = < 169 - TData = unknown, 170 - TError = unknown, 171 - ThrowOnError extends boolean = false, 172 - TResponseStyle extends ResponseStyle = 'fields', 173 - >( 174 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>, 175 - ) => Promise<ServerSentEventsResult<TData, TError>>; 176 - 177 - type RequestFn = < 178 - TData = unknown, 179 - TError = unknown, 180 - ThrowOnError extends boolean = false, 181 - TResponseStyle extends ResponseStyle = 'fields', 182 - >( 183 - options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & 184 - Pick< 185 - Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 186 - 'method' 187 - >, 188 - ) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>; 189 - 190 - type BuildUrlFn = < 191 - TData extends { 192 - body?: unknown; 193 - path?: Record<string, unknown>; 194 - query?: Record<string, unknown>; 195 - url: string; 196 - }, 197 - >( 198 - options: TData & Options<TData>, 199 - ) => string; 200 - 201 - export type Client = CoreClient< 202 - RequestFn, 203 - Config, 204 - MethodFn, 205 - BuildUrlFn, 206 - SseFn 207 - > & { 208 - interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>; 209 - }; 210 - 211 - /** 212 - * The `createClientConfig()` function will be called on client initialization 213 - * and the returned object will become the client's initial configuration. 214 - * 215 - * You may want to initialize your client this way instead of calling 216 - * `setConfig()`. This is useful for example if you're using Next.js 217 - * to ensure your client always has the correct values. 218 - */ 219 - export type CreateClientConfig<T extends ClientOptions = ClientOptions> = ( 220 - override?: Config<ClientOptions & T>, 221 - ) => Config<Required<ClientOptions> & T>; 222 - 223 - export interface TDataShape { 224 - body?: unknown; 225 - headers?: unknown; 226 - path?: unknown; 227 - query?: unknown; 228 - url: string; 229 - } 230 - 231 - type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>; 232 - 233 - export type Options< 234 - TData extends TDataShape = TDataShape, 235 - ThrowOnError extends boolean = boolean, 236 - TResponse = unknown, 237 - TResponseStyle extends ResponseStyle = 'fields', 238 - > = OmitKeys< 239 - RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 240 - 'body' | 'path' | 'query' | 'url' 241 - > & 242 - ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
-332
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { getAuthToken } from '../core/auth.gen'; 4 - import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; 5 - import { jsonBodySerializer } from '../core/bodySerializer.gen'; 6 - import { 7 - serializeArrayParam, 8 - serializeObjectParam, 9 - serializePrimitiveParam, 10 - } from '../core/pathSerializer.gen'; 11 - import { getUrl } from '../core/utils.gen'; 12 - import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; 13 - 14 - export const createQuerySerializer = <T = unknown>({ 15 - parameters = {}, 16 - ...args 17 - }: QuerySerializerOptions = {}) => { 18 - const querySerializer = (queryParams: T) => { 19 - const search: string[] = []; 20 - if (queryParams && typeof queryParams === 'object') { 21 - for (const name in queryParams) { 22 - const value = queryParams[name]; 23 - 24 - if (value === undefined || value === null) { 25 - continue; 26 - } 27 - 28 - const options = parameters[name] || args; 29 - 30 - if (Array.isArray(value)) { 31 - const serializedArray = serializeArrayParam({ 32 - allowReserved: options.allowReserved, 33 - explode: true, 34 - name, 35 - style: 'form', 36 - value, 37 - ...options.array, 38 - }); 39 - if (serializedArray) search.push(serializedArray); 40 - } else if (typeof value === 'object') { 41 - const serializedObject = serializeObjectParam({ 42 - allowReserved: options.allowReserved, 43 - explode: true, 44 - name, 45 - style: 'deepObject', 46 - value: value as Record<string, unknown>, 47 - ...options.object, 48 - }); 49 - if (serializedObject) search.push(serializedObject); 50 - } else { 51 - const serializedPrimitive = serializePrimitiveParam({ 52 - allowReserved: options.allowReserved, 53 - name, 54 - value: value as string, 55 - }); 56 - if (serializedPrimitive) search.push(serializedPrimitive); 57 - } 58 - } 59 - } 60 - return search.join('&'); 61 - }; 62 - return querySerializer; 63 - }; 64 - 65 - /** 66 - * Infers parseAs value from provided Content-Type header. 67 - */ 68 - export const getParseAs = ( 69 - contentType: string | null, 70 - ): Exclude<Config['parseAs'], 'auto'> => { 71 - if (!contentType) { 72 - // If no Content-Type header is provided, the best we can do is return the raw response body, 73 - // which is effectively the same as the 'stream' option. 74 - return 'stream'; 75 - } 76 - 77 - const cleanContent = contentType.split(';')[0]?.trim(); 78 - 79 - if (!cleanContent) { 80 - return; 81 - } 82 - 83 - if ( 84 - cleanContent.startsWith('application/json') || 85 - cleanContent.endsWith('+json') 86 - ) { 87 - return 'json'; 88 - } 89 - 90 - if (cleanContent === 'multipart/form-data') { 91 - return 'formData'; 92 - } 93 - 94 - if ( 95 - ['application/', 'audio/', 'image/', 'video/'].some((type) => 96 - cleanContent.startsWith(type), 97 - ) 98 - ) { 99 - return 'blob'; 100 - } 101 - 102 - if (cleanContent.startsWith('text/')) { 103 - return 'text'; 104 - } 105 - 106 - return; 107 - }; 108 - 109 - const checkForExistence = ( 110 - options: Pick<RequestOptions, 'auth' | 'query'> & { 111 - headers: Headers; 112 - }, 113 - name?: string, 114 - ): boolean => { 115 - if (!name) { 116 - return false; 117 - } 118 - if ( 119 - options.headers.has(name) || 120 - options.query?.[name] || 121 - options.headers.get('Cookie')?.includes(`${name}=`) 122 - ) { 123 - return true; 124 - } 125 - return false; 126 - }; 127 - 128 - export const setAuthParams = async ({ 129 - security, 130 - ...options 131 - }: Pick<Required<RequestOptions>, 'security'> & 132 - Pick<RequestOptions, 'auth' | 'query'> & { 133 - headers: Headers; 134 - }) => { 135 - for (const auth of security) { 136 - if (checkForExistence(options, auth.name)) { 137 - continue; 138 - } 139 - 140 - const token = await getAuthToken(auth, options.auth); 141 - 142 - if (!token) { 143 - continue; 144 - } 145 - 146 - const name = auth.name ?? 'Authorization'; 147 - 148 - switch (auth.in) { 149 - case 'query': 150 - if (!options.query) { 151 - options.query = {}; 152 - } 153 - options.query[name] = token; 154 - break; 155 - case 'cookie': 156 - options.headers.append('Cookie', `${name}=${token}`); 157 - break; 158 - case 'header': 159 - default: 160 - options.headers.set(name, token); 161 - break; 162 - } 163 - } 164 - }; 165 - 166 - export const buildUrl: Client['buildUrl'] = (options) => 167 - getUrl({ 168 - baseUrl: options.baseUrl as string, 169 - path: options.path, 170 - query: options.query, 171 - querySerializer: 172 - typeof options.querySerializer === 'function' 173 - ? options.querySerializer 174 - : createQuerySerializer(options.querySerializer), 175 - url: options.url, 176 - }); 177 - 178 - export const mergeConfigs = (a: Config, b: Config): Config => { 179 - const config = { ...a, ...b }; 180 - if (config.baseUrl?.endsWith('/')) { 181 - config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); 182 - } 183 - config.headers = mergeHeaders(a.headers, b.headers); 184 - return config; 185 - }; 186 - 187 - const headersEntries = (headers: Headers): Array<[string, string]> => { 188 - const entries: Array<[string, string]> = []; 189 - headers.forEach((value, key) => { 190 - entries.push([key, value]); 191 - }); 192 - return entries; 193 - }; 194 - 195 - export const mergeHeaders = ( 196 - ...headers: Array<Required<Config>['headers'] | undefined> 197 - ): Headers => { 198 - const mergedHeaders = new Headers(); 199 - for (const header of headers) { 200 - if (!header) { 201 - continue; 202 - } 203 - 204 - const iterator = 205 - header instanceof Headers 206 - ? headersEntries(header) 207 - : Object.entries(header); 208 - 209 - for (const [key, value] of iterator) { 210 - if (value === null) { 211 - mergedHeaders.delete(key); 212 - } else if (Array.isArray(value)) { 213 - for (const v of value) { 214 - mergedHeaders.append(key, v as string); 215 - } 216 - } else if (value !== undefined) { 217 - // assume object headers are meant to be JSON stringified, i.e. their 218 - // content value in OpenAPI specification is 'application/json' 219 - mergedHeaders.set( 220 - key, 221 - typeof value === 'object' ? JSON.stringify(value) : (value as string), 222 - ); 223 - } 224 - } 225 - } 226 - return mergedHeaders; 227 - }; 228 - 229 - type ErrInterceptor<Err, Res, Req, Options> = ( 230 - error: Err, 231 - response: Res, 232 - request: Req, 233 - options: Options, 234 - ) => Err | Promise<Err>; 235 - 236 - type ReqInterceptor<Req, Options> = ( 237 - request: Req, 238 - options: Options, 239 - ) => Req | Promise<Req>; 240 - 241 - type ResInterceptor<Res, Req, Options> = ( 242 - response: Res, 243 - request: Req, 244 - options: Options, 245 - ) => Res | Promise<Res>; 246 - 247 - class Interceptors<Interceptor> { 248 - fns: Array<Interceptor | null> = []; 249 - 250 - clear(): void { 251 - this.fns = []; 252 - } 253 - 254 - eject(id: number | Interceptor): void { 255 - const index = this.getInterceptorIndex(id); 256 - if (this.fns[index]) { 257 - this.fns[index] = null; 258 - } 259 - } 260 - 261 - exists(id: number | Interceptor): boolean { 262 - const index = this.getInterceptorIndex(id); 263 - return Boolean(this.fns[index]); 264 - } 265 - 266 - getInterceptorIndex(id: number | Interceptor): number { 267 - if (typeof id === 'number') { 268 - return this.fns[id] ? id : -1; 269 - } 270 - return this.fns.indexOf(id); 271 - } 272 - 273 - update( 274 - id: number | Interceptor, 275 - fn: Interceptor, 276 - ): number | Interceptor | false { 277 - const index = this.getInterceptorIndex(id); 278 - if (this.fns[index]) { 279 - this.fns[index] = fn; 280 - return id; 281 - } 282 - return false; 283 - } 284 - 285 - use(fn: Interceptor): number { 286 - this.fns.push(fn); 287 - return this.fns.length - 1; 288 - } 289 - } 290 - 291 - export interface Middleware<Req, Res, Err, Options> { 292 - error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>; 293 - request: Interceptors<ReqInterceptor<Req, Options>>; 294 - response: Interceptors<ResInterceptor<Res, Req, Options>>; 295 - } 296 - 297 - export const createInterceptors = <Req, Res, Err, Options>(): Middleware< 298 - Req, 299 - Res, 300 - Err, 301 - Options 302 - > => ({ 303 - error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(), 304 - request: new Interceptors<ReqInterceptor<Req, Options>>(), 305 - response: new Interceptors<ResInterceptor<Res, Req, Options>>(), 306 - }); 307 - 308 - const defaultQuerySerializer = createQuerySerializer({ 309 - allowReserved: false, 310 - array: { 311 - explode: true, 312 - style: 'form', 313 - }, 314 - object: { 315 - explode: true, 316 - style: 'deepObject', 317 - }, 318 - }); 319 - 320 - const defaultHeaders = { 321 - 'Content-Type': 'application/json', 322 - }; 323 - 324 - export const createConfig = <T extends ClientOptions = ClientOptions>( 325 - override: Config<Omit<ClientOptions, keyof T> & T> = {}, 326 - ): Config<Omit<ClientOptions, keyof T> & T> => ({ 327 - ...jsonBodySerializer, 328 - headers: defaultHeaders, 329 - parseAs: 'auto', 330 - querySerializer: defaultQuerySerializer, 331 - ...override, 332 - });
-42
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/auth.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type AuthToken = string | undefined; 4 - 5 - export interface Auth { 6 - /** 7 - * Which part of the request do we use to send the auth? 8 - * 9 - * @default 'header' 10 - */ 11 - in?: 'header' | 'query' | 'cookie'; 12 - /** 13 - * Header or query parameter name. 14 - * 15 - * @default 'Authorization' 16 - */ 17 - name?: string; 18 - scheme?: 'basic' | 'bearer'; 19 - type: 'apiKey' | 'http'; 20 - } 21 - 22 - export const getAuthToken = async ( 23 - auth: Auth, 24 - callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, 25 - ): Promise<string | undefined> => { 26 - const token = 27 - typeof callback === 'function' ? await callback(auth) : callback; 28 - 29 - if (!token) { 30 - return; 31 - } 32 - 33 - if (auth.scheme === 'bearer') { 34 - return `Bearer ${token}`; 35 - } 36 - 37 - if (auth.scheme === 'basic') { 38 - return `Basic ${btoa(token)}`; 39 - } 40 - 41 - return token; 42 - };
-96
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/bodySerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { 4 - ArrayStyle, 5 - ObjectStyle, 6 - SerializerOptions, 7 - } from './pathSerializer.gen'; 8 - 9 - export type QuerySerializer = (query: Record<string, unknown>) => string; 10 - 11 - export type BodySerializer = (body: unknown) => unknown; 12 - 13 - type QuerySerializerOptionsObject = { 14 - allowReserved?: boolean; 15 - array?: Partial<SerializerOptions<ArrayStyle>>; 16 - object?: Partial<SerializerOptions<ObjectStyle>>; 17 - }; 18 - 19 - export type QuerySerializerOptions = QuerySerializerOptionsObject & { 20 - /** 21 - * Per-parameter serialization overrides. When provided, these settings 22 - * override the global array/object settings for specific parameter names. 23 - */ 24 - parameters?: Record<string, QuerySerializerOptionsObject>; 25 - }; 26 - 27 - const serializeFormDataPair = ( 28 - data: FormData, 29 - key: string, 30 - value: unknown, 31 - ): void => { 32 - if (typeof value === 'string' || value instanceof Blob) { 33 - data.append(key, value); 34 - } else if (value instanceof Date) { 35 - data.append(key, value.toISOString()); 36 - } else { 37 - data.append(key, JSON.stringify(value)); 38 - } 39 - }; 40 - 41 - const serializeUrlSearchParamsPair = ( 42 - data: URLSearchParams, 43 - key: string, 44 - value: unknown, 45 - ): void => { 46 - if (typeof value === 'string') { 47 - data.append(key, value); 48 - } else { 49 - data.append(key, JSON.stringify(value)); 50 - } 51 - }; 52 - 53 - export const formDataBodySerializer = { 54 - bodySerializer: (body: unknown): FormData => { 55 - const data = new FormData(); 56 - 57 - Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 58 - if (value === undefined || value === null) { 59 - return; 60 - } 61 - if (Array.isArray(value)) { 62 - value.forEach((v) => serializeFormDataPair(data, key, v)); 63 - } else { 64 - serializeFormDataPair(data, key, value); 65 - } 66 - }); 67 - 68 - return data; 69 - }, 70 - }; 71 - 72 - export const jsonBodySerializer = { 73 - bodySerializer: (body: unknown): string => 74 - JSON.stringify(body, (_key, value) => 75 - typeof value === 'bigint' ? value.toString() : value, 76 - ), 77 - }; 78 - 79 - export const urlSearchParamsBodySerializer = { 80 - bodySerializer: (body: unknown): string => { 81 - const data = new URLSearchParams(); 82 - 83 - Object.entries(body as Record<string, unknown>).forEach(([key, value]) => { 84 - if (value === undefined || value === null) { 85 - return; 86 - } 87 - if (Array.isArray(value)) { 88 - value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); 89 - } else { 90 - serializeUrlSearchParamsPair(data, key, value); 91 - } 92 - }); 93 - 94 - return data.toString(); 95 - }, 96 - };
-176
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/params.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - type Slot = 'body' | 'headers' | 'path' | 'query'; 4 - 5 - export type Field = 6 - | { 7 - in: Exclude<Slot, 'body'>; 8 - /** 9 - * Field name. This is the name we want the user to see and use. 10 - */ 11 - key: string; 12 - /** 13 - * Field mapped name. This is the name we want to use in the request. 14 - * If omitted, we use the same value as `key`. 15 - */ 16 - map?: string; 17 - } 18 - | { 19 - in: Extract<Slot, 'body'>; 20 - /** 21 - * Key isn't required for bodies. 22 - */ 23 - key?: string; 24 - map?: string; 25 - } 26 - | { 27 - /** 28 - * Field name. This is the name we want the user to see and use. 29 - */ 30 - key: string; 31 - /** 32 - * Field mapped name. This is the name we want to use in the request. 33 - * If `in` is omitted, `map` aliases `key` to the transport layer. 34 - */ 35 - map: Slot; 36 - }; 37 - 38 - export interface Fields { 39 - allowExtra?: Partial<Record<Slot, boolean>>; 40 - args?: ReadonlyArray<Field>; 41 - } 42 - 43 - export type FieldsConfig = ReadonlyArray<Field | Fields>; 44 - 45 - const extraPrefixesMap: Record<string, Slot> = { 46 - $body_: 'body', 47 - $headers_: 'headers', 48 - $path_: 'path', 49 - $query_: 'query', 50 - }; 51 - const extraPrefixes = Object.entries(extraPrefixesMap); 52 - 53 - type KeyMap = Map< 54 - string, 55 - | { 56 - in: Slot; 57 - map?: string; 58 - } 59 - | { 60 - in?: never; 61 - map: Slot; 62 - } 63 - >; 64 - 65 - const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { 66 - if (!map) { 67 - map = new Map(); 68 - } 69 - 70 - for (const config of fields) { 71 - if ('in' in config) { 72 - if (config.key) { 73 - map.set(config.key, { 74 - in: config.in, 75 - map: config.map, 76 - }); 77 - } 78 - } else if ('key' in config) { 79 - map.set(config.key, { 80 - map: config.map, 81 - }); 82 - } else if (config.args) { 83 - buildKeyMap(config.args, map); 84 - } 85 - } 86 - 87 - return map; 88 - }; 89 - 90 - interface Params { 91 - body: unknown; 92 - headers: Record<string, unknown>; 93 - path: Record<string, unknown>; 94 - query: Record<string, unknown>; 95 - } 96 - 97 - const stripEmptySlots = (params: Params) => { 98 - for (const [slot, value] of Object.entries(params)) { 99 - if (value && typeof value === 'object' && !Object.keys(value).length) { 100 - delete params[slot as Slot]; 101 - } 102 - } 103 - }; 104 - 105 - export const buildClientParams = ( 106 - args: ReadonlyArray<unknown>, 107 - fields: FieldsConfig, 108 - ) => { 109 - const params: Params = { 110 - body: {}, 111 - headers: {}, 112 - path: {}, 113 - query: {}, 114 - }; 115 - 116 - const map = buildKeyMap(fields); 117 - 118 - let config: FieldsConfig[number] | undefined; 119 - 120 - for (const [index, arg] of args.entries()) { 121 - if (fields[index]) { 122 - config = fields[index]; 123 - } 124 - 125 - if (!config) { 126 - continue; 127 - } 128 - 129 - if ('in' in config) { 130 - if (config.key) { 131 - const field = map.get(config.key)!; 132 - const name = field.map || config.key; 133 - if (field.in) { 134 - (params[field.in] as Record<string, unknown>)[name] = arg; 135 - } 136 - } else { 137 - params.body = arg; 138 - } 139 - } else { 140 - for (const [key, value] of Object.entries(arg ?? {})) { 141 - const field = map.get(key); 142 - 143 - if (field) { 144 - if (field.in) { 145 - const name = field.map || key; 146 - (params[field.in] as Record<string, unknown>)[name] = value; 147 - } else { 148 - params[field.map] = value; 149 - } 150 - } else { 151 - const extra = extraPrefixes.find(([prefix]) => 152 - key.startsWith(prefix), 153 - ); 154 - 155 - if (extra) { 156 - const [prefix, slot] = extra; 157 - (params[slot] as Record<string, unknown>)[ 158 - key.slice(prefix.length) 159 - ] = value; 160 - } else if ('allowExtra' in config && config.allowExtra) { 161 - for (const [slot, allowed] of Object.entries(config.allowExtra)) { 162 - if (allowed) { 163 - (params[slot as Slot] as Record<string, unknown>)[key] = value; 164 - break; 165 - } 166 - } 167 - } 168 - } 169 - } 170 - } 171 - } 172 - 173 - stripEmptySlots(params); 174 - 175 - return params; 176 - };
-181
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/pathSerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - interface SerializeOptions<T> 4 - extends SerializePrimitiveOptions, 5 - SerializerOptions<T> {} 6 - 7 - interface SerializePrimitiveOptions { 8 - allowReserved?: boolean; 9 - name: string; 10 - } 11 - 12 - export interface SerializerOptions<T> { 13 - /** 14 - * @default true 15 - */ 16 - explode: boolean; 17 - style: T; 18 - } 19 - 20 - export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; 21 - export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; 22 - type MatrixStyle = 'label' | 'matrix' | 'simple'; 23 - export type ObjectStyle = 'form' | 'deepObject'; 24 - type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; 25 - 26 - interface SerializePrimitiveParam extends SerializePrimitiveOptions { 27 - value: string; 28 - } 29 - 30 - export const separatorArrayExplode = (style: ArraySeparatorStyle) => { 31 - switch (style) { 32 - case 'label': 33 - return '.'; 34 - case 'matrix': 35 - return ';'; 36 - case 'simple': 37 - return ','; 38 - default: 39 - return '&'; 40 - } 41 - }; 42 - 43 - export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { 44 - switch (style) { 45 - case 'form': 46 - return ','; 47 - case 'pipeDelimited': 48 - return '|'; 49 - case 'spaceDelimited': 50 - return '%20'; 51 - default: 52 - return ','; 53 - } 54 - }; 55 - 56 - export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { 57 - switch (style) { 58 - case 'label': 59 - return '.'; 60 - case 'matrix': 61 - return ';'; 62 - case 'simple': 63 - return ','; 64 - default: 65 - return '&'; 66 - } 67 - }; 68 - 69 - export const serializeArrayParam = ({ 70 - allowReserved, 71 - explode, 72 - name, 73 - style, 74 - value, 75 - }: SerializeOptions<ArraySeparatorStyle> & { 76 - value: unknown[]; 77 - }) => { 78 - if (!explode) { 79 - const joinedValues = ( 80 - allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) 81 - ).join(separatorArrayNoExplode(style)); 82 - switch (style) { 83 - case 'label': 84 - return `.${joinedValues}`; 85 - case 'matrix': 86 - return `;${name}=${joinedValues}`; 87 - case 'simple': 88 - return joinedValues; 89 - default: 90 - return `${name}=${joinedValues}`; 91 - } 92 - } 93 - 94 - const separator = separatorArrayExplode(style); 95 - const joinedValues = value 96 - .map((v) => { 97 - if (style === 'label' || style === 'simple') { 98 - return allowReserved ? v : encodeURIComponent(v as string); 99 - } 100 - 101 - return serializePrimitiveParam({ 102 - allowReserved, 103 - name, 104 - value: v as string, 105 - }); 106 - }) 107 - .join(separator); 108 - return style === 'label' || style === 'matrix' 109 - ? separator + joinedValues 110 - : joinedValues; 111 - }; 112 - 113 - export const serializePrimitiveParam = ({ 114 - allowReserved, 115 - name, 116 - value, 117 - }: SerializePrimitiveParam) => { 118 - if (value === undefined || value === null) { 119 - return ''; 120 - } 121 - 122 - if (typeof value === 'object') { 123 - throw new Error( 124 - 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', 125 - ); 126 - } 127 - 128 - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; 129 - }; 130 - 131 - export const serializeObjectParam = ({ 132 - allowReserved, 133 - explode, 134 - name, 135 - style, 136 - value, 137 - valueOnly, 138 - }: SerializeOptions<ObjectSeparatorStyle> & { 139 - value: Record<string, unknown> | Date; 140 - valueOnly?: boolean; 141 - }) => { 142 - if (value instanceof Date) { 143 - return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; 144 - } 145 - 146 - if (style !== 'deepObject' && !explode) { 147 - let values: string[] = []; 148 - Object.entries(value).forEach(([key, v]) => { 149 - values = [ 150 - ...values, 151 - key, 152 - allowReserved ? (v as string) : encodeURIComponent(v as string), 153 - ]; 154 - }); 155 - const joinedValues = values.join(','); 156 - switch (style) { 157 - case 'form': 158 - return `${name}=${joinedValues}`; 159 - case 'label': 160 - return `.${joinedValues}`; 161 - case 'matrix': 162 - return `;${name}=${joinedValues}`; 163 - default: 164 - return joinedValues; 165 - } 166 - } 167 - 168 - const separator = separatorObjectExplode(style); 169 - const joinedValues = Object.entries(value) 170 - .map(([key, v]) => 171 - serializePrimitiveParam({ 172 - allowReserved, 173 - name: style === 'deepObject' ? `${name}[${key}]` : key, 174 - value: v as string, 175 - }), 176 - ) 177 - .join(separator); 178 - return style === 'label' || style === 'matrix' 179 - ? separator + joinedValues 180 - : joinedValues; 181 - };
-136
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/queryKeySerializer.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - /** 4 - * JSON-friendly union that mirrors what Pinia Colada can hash. 5 - */ 6 - export type JsonValue = 7 - | null 8 - | string 9 - | number 10 - | boolean 11 - | JsonValue[] 12 - | { [key: string]: JsonValue }; 13 - 14 - /** 15 - * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. 16 - */ 17 - export const queryKeyJsonReplacer = (_key: string, value: unknown) => { 18 - if ( 19 - value === undefined || 20 - typeof value === 'function' || 21 - typeof value === 'symbol' 22 - ) { 23 - return undefined; 24 - } 25 - if (typeof value === 'bigint') { 26 - return value.toString(); 27 - } 28 - if (value instanceof Date) { 29 - return value.toISOString(); 30 - } 31 - return value; 32 - }; 33 - 34 - /** 35 - * Safely stringifies a value and parses it back into a JsonValue. 36 - */ 37 - export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { 38 - try { 39 - const json = JSON.stringify(input, queryKeyJsonReplacer); 40 - if (json === undefined) { 41 - return undefined; 42 - } 43 - return JSON.parse(json) as JsonValue; 44 - } catch { 45 - return undefined; 46 - } 47 - }; 48 - 49 - /** 50 - * Detects plain objects (including objects with a null prototype). 51 - */ 52 - const isPlainObject = (value: unknown): value is Record<string, unknown> => { 53 - if (value === null || typeof value !== 'object') { 54 - return false; 55 - } 56 - const prototype = Object.getPrototypeOf(value as object); 57 - return prototype === Object.prototype || prototype === null; 58 - }; 59 - 60 - /** 61 - * Turns URLSearchParams into a sorted JSON object for deterministic keys. 62 - */ 63 - const serializeSearchParams = (params: URLSearchParams): JsonValue => { 64 - const entries = Array.from(params.entries()).sort(([a], [b]) => 65 - a.localeCompare(b), 66 - ); 67 - const result: Record<string, JsonValue> = {}; 68 - 69 - for (const [key, value] of entries) { 70 - const existing = result[key]; 71 - if (existing === undefined) { 72 - result[key] = value; 73 - continue; 74 - } 75 - 76 - if (Array.isArray(existing)) { 77 - (existing as string[]).push(value); 78 - } else { 79 - result[key] = [existing, value]; 80 - } 81 - } 82 - 83 - return result; 84 - }; 85 - 86 - /** 87 - * Normalizes any accepted value into a JSON-friendly shape for query keys. 88 - */ 89 - export const serializeQueryKeyValue = ( 90 - value: unknown, 91 - ): JsonValue | undefined => { 92 - if (value === null) { 93 - return null; 94 - } 95 - 96 - if ( 97 - typeof value === 'string' || 98 - typeof value === 'number' || 99 - typeof value === 'boolean' 100 - ) { 101 - return value; 102 - } 103 - 104 - if ( 105 - value === undefined || 106 - typeof value === 'function' || 107 - typeof value === 'symbol' 108 - ) { 109 - return undefined; 110 - } 111 - 112 - if (typeof value === 'bigint') { 113 - return value.toString(); 114 - } 115 - 116 - if (value instanceof Date) { 117 - return value.toISOString(); 118 - } 119 - 120 - if (Array.isArray(value)) { 121 - return stringifyToJsonValue(value); 122 - } 123 - 124 - if ( 125 - typeof URLSearchParams !== 'undefined' && 126 - value instanceof URLSearchParams 127 - ) { 128 - return serializeSearchParams(value); 129 - } 130 - 131 - if (isPlainObject(value)) { 132 - return stringifyToJsonValue(value); 133 - } 134 - 135 - return undefined; 136 - };
-266
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Config } from './types.gen'; 4 - 5 - export type ServerSentEventsOptions<TData = unknown> = Omit< 6 - RequestInit, 7 - 'method' 8 - > & 9 - Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 - /** 11 - * Fetch API implementation. You can use this option to provide a custom 12 - * fetch instance. 13 - * 14 - * @default globalThis.fetch 15 - */ 16 - fetch?: typeof fetch; 17 - /** 18 - * Implementing clients can call request interceptors inside this hook. 19 - */ 20 - onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 - /** 22 - * Callback invoked when a network or parsing error occurs during streaming. 23 - * 24 - * This option applies only if the endpoint returns a stream of events. 25 - * 26 - * @param error The error that occurred. 27 - */ 28 - onSseError?: (error: unknown) => void; 29 - /** 30 - * Callback invoked when an event is streamed from the server. 31 - * 32 - * This option applies only if the endpoint returns a stream of events. 33 - * 34 - * @param event Event streamed from the server. 35 - * @returns Nothing (void). 36 - */ 37 - onSseEvent?: (event: StreamEvent<TData>) => void; 38 - serializedBody?: RequestInit['body']; 39 - /** 40 - * Default retry delay in milliseconds. 41 - * 42 - * This option applies only if the endpoint returns a stream of events. 43 - * 44 - * @default 3000 45 - */ 46 - sseDefaultRetryDelay?: number; 47 - /** 48 - * Maximum number of retry attempts before giving up. 49 - */ 50 - sseMaxRetryAttempts?: number; 51 - /** 52 - * Maximum retry delay in milliseconds. 53 - * 54 - * Applies only when exponential backoff is used. 55 - * 56 - * This option applies only if the endpoint returns a stream of events. 57 - * 58 - * @default 30000 59 - */ 60 - sseMaxRetryDelay?: number; 61 - /** 62 - * Optional sleep function for retry backoff. 63 - * 64 - * Defaults to using `setTimeout`. 65 - */ 66 - sseSleepFn?: (ms: number) => Promise<void>; 67 - url: string; 68 - }; 69 - 70 - export interface StreamEvent<TData = unknown> { 71 - data: TData; 72 - event?: string; 73 - id?: string; 74 - retry?: number; 75 - } 76 - 77 - export type ServerSentEventsResult< 78 - TData = unknown, 79 - TReturn = void, 80 - TNext = unknown, 81 - > = { 82 - stream: AsyncGenerator< 83 - TData extends Record<string, unknown> ? TData[keyof TData] : TData, 84 - TReturn, 85 - TNext 86 - >; 87 - }; 88 - 89 - export const createSseClient = <TData = unknown>({ 90 - onRequest, 91 - onSseError, 92 - onSseEvent, 93 - responseTransformer, 94 - responseValidator, 95 - sseDefaultRetryDelay, 96 - sseMaxRetryAttempts, 97 - sseMaxRetryDelay, 98 - sseSleepFn, 99 - url, 100 - ...options 101 - }: ServerSentEventsOptions): ServerSentEventsResult<TData> => { 102 - let lastEventId: string | undefined; 103 - 104 - const sleep = 105 - sseSleepFn ?? 106 - ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); 107 - 108 - const createStream = async function* () { 109 - let retryDelay: number = sseDefaultRetryDelay ?? 3000; 110 - let attempt = 0; 111 - const signal = options.signal ?? new AbortController().signal; 112 - 113 - while (true) { 114 - if (signal.aborted) break; 115 - 116 - attempt++; 117 - 118 - const headers = 119 - options.headers instanceof Headers 120 - ? options.headers 121 - : new Headers(options.headers as Record<string, string> | undefined); 122 - 123 - if (lastEventId !== undefined) { 124 - headers.set('Last-Event-ID', lastEventId); 125 - } 126 - 127 - try { 128 - const requestInit: RequestInit = { 129 - redirect: 'follow', 130 - ...options, 131 - body: options.serializedBody, 132 - headers, 133 - signal, 134 - }; 135 - let request = new Request(url, requestInit); 136 - if (onRequest) { 137 - request = await onRequest(url, requestInit); 138 - } 139 - // fetch must be assigned here, otherwise it would throw the error: 140 - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 - const _fetch = options.fetch ?? globalThis.fetch; 142 - const response = await _fetch(request); 143 - 144 - if (!response.ok) 145 - throw new Error( 146 - `SSE failed: ${response.status} ${response.statusText}`, 147 - ); 148 - 149 - if (!response.body) throw new Error('No body in SSE response'); 150 - 151 - const reader = response.body 152 - .pipeThrough(new TextDecoderStream()) 153 - .getReader(); 154 - 155 - let buffer = ''; 156 - 157 - const abortHandler = () => { 158 - try { 159 - reader.cancel(); 160 - } catch { 161 - // noop 162 - } 163 - }; 164 - 165 - signal.addEventListener('abort', abortHandler); 166 - 167 - try { 168 - while (true) { 169 - const { done, value } = await reader.read(); 170 - if (done) break; 171 - buffer += value; 172 - // Normalize line endings: CRLF -> LF, then CR -> LF 173 - buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); 174 - 175 - const chunks = buffer.split('\n\n'); 176 - buffer = chunks.pop() ?? ''; 177 - 178 - for (const chunk of chunks) { 179 - const lines = chunk.split('\n'); 180 - const dataLines: Array<string> = []; 181 - let eventName: string | undefined; 182 - 183 - for (const line of lines) { 184 - if (line.startsWith('data:')) { 185 - dataLines.push(line.replace(/^data:\s*/, '')); 186 - } else if (line.startsWith('event:')) { 187 - eventName = line.replace(/^event:\s*/, ''); 188 - } else if (line.startsWith('id:')) { 189 - lastEventId = line.replace(/^id:\s*/, ''); 190 - } else if (line.startsWith('retry:')) { 191 - const parsed = Number.parseInt( 192 - line.replace(/^retry:\s*/, ''), 193 - 10, 194 - ); 195 - if (!Number.isNaN(parsed)) { 196 - retryDelay = parsed; 197 - } 198 - } 199 - } 200 - 201 - let data: unknown; 202 - let parsedJson = false; 203 - 204 - if (dataLines.length) { 205 - const rawData = dataLines.join('\n'); 206 - try { 207 - data = JSON.parse(rawData); 208 - parsedJson = true; 209 - } catch { 210 - data = rawData; 211 - } 212 - } 213 - 214 - if (parsedJson) { 215 - if (responseValidator) { 216 - await responseValidator(data); 217 - } 218 - 219 - if (responseTransformer) { 220 - data = await responseTransformer(data); 221 - } 222 - } 223 - 224 - onSseEvent?.({ 225 - data, 226 - event: eventName, 227 - id: lastEventId, 228 - retry: retryDelay, 229 - }); 230 - 231 - if (dataLines.length) { 232 - yield data as any; 233 - } 234 - } 235 - } 236 - } finally { 237 - signal.removeEventListener('abort', abortHandler); 238 - reader.releaseLock(); 239 - } 240 - 241 - break; // exit loop on normal completion 242 - } catch (error) { 243 - // connection failed or aborted; retry after delay 244 - onSseError?.(error); 245 - 246 - if ( 247 - sseMaxRetryAttempts !== undefined && 248 - attempt >= sseMaxRetryAttempts 249 - ) { 250 - break; // stop after firing error 251 - } 252 - 253 - // exponential backoff: double retry each attempt, cap at 30s 254 - const backoff = Math.min( 255 - retryDelay * 2 ** (attempt - 1), 256 - sseMaxRetryDelay ?? 30000, 257 - ); 258 - await sleep(backoff); 259 - } 260 - } 261 - }; 262 - 263 - const stream = createStream(); 264 - 265 - return { stream }; 266 - };
-118
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Auth, AuthToken } from './auth.gen'; 4 - import type { 5 - BodySerializer, 6 - QuerySerializer, 7 - QuerySerializerOptions, 8 - } from './bodySerializer.gen'; 9 - 10 - export type HttpMethod = 11 - | 'connect' 12 - | 'delete' 13 - | 'get' 14 - | 'head' 15 - | 'options' 16 - | 'patch' 17 - | 'post' 18 - | 'put' 19 - | 'trace'; 20 - 21 - export type Client< 22 - RequestFn = never, 23 - Config = unknown, 24 - MethodFn = never, 25 - BuildUrlFn = never, 26 - SseFn = never, 27 - > = { 28 - /** 29 - * Returns the final request URL. 30 - */ 31 - buildUrl: BuildUrlFn; 32 - getConfig: () => Config; 33 - request: RequestFn; 34 - setConfig: (config: Config) => Config; 35 - } & { 36 - [K in HttpMethod]: MethodFn; 37 - } & ([SseFn] extends [never] 38 - ? { sse?: never } 39 - : { sse: { [K in HttpMethod]: SseFn } }); 40 - 41 - export interface Config { 42 - /** 43 - * Auth token or a function returning auth token. The resolved value will be 44 - * added to the request payload as defined by its `security` array. 45 - */ 46 - auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken; 47 - /** 48 - * A function for serializing request body parameter. By default, 49 - * {@link JSON.stringify()} will be used. 50 - */ 51 - bodySerializer?: BodySerializer | null; 52 - /** 53 - * An object containing any HTTP headers that you want to pre-populate your 54 - * `Headers` object with. 55 - * 56 - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} 57 - */ 58 - headers?: 59 - | RequestInit['headers'] 60 - | Record< 61 - string, 62 - | string 63 - | number 64 - | boolean 65 - | (string | number | boolean)[] 66 - | null 67 - | undefined 68 - | unknown 69 - >; 70 - /** 71 - * The request method. 72 - * 73 - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} 74 - */ 75 - method?: Uppercase<HttpMethod>; 76 - /** 77 - * A function for serializing request query parameters. By default, arrays 78 - * will be exploded in form style, objects will be exploded in deepObject 79 - * style, and reserved characters are percent-encoded. 80 - * 81 - * This method will have no effect if the native `paramsSerializer()` Axios 82 - * API function is used. 83 - * 84 - * {@link https://swagger.io/docs/specification/serialization/#query View examples} 85 - */ 86 - querySerializer?: QuerySerializer | QuerySerializerOptions; 87 - /** 88 - * A function validating request data. This is useful if you want to ensure 89 - * the request conforms to the desired shape, so it can be safely sent to 90 - * the server. 91 - */ 92 - requestValidator?: (data: unknown) => Promise<unknown>; 93 - /** 94 - * A function transforming response data before it's returned. This is useful 95 - * for post-processing data, e.g. converting ISO strings into Date objects. 96 - */ 97 - responseTransformer?: (data: unknown) => Promise<unknown>; 98 - /** 99 - * A function validating response data. This is useful if you want to ensure 100 - * the response conforms to the desired shape, so it can be safely passed to 101 - * the transformers and returned to the user. 102 - */ 103 - responseValidator?: (data: unknown) => Promise<unknown>; 104 - } 105 - 106 - type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] 107 - ? true 108 - : [T] extends [never | undefined] 109 - ? [undefined] extends [T] 110 - ? false 111 - : true 112 - : false; 113 - 114 - export type OmitNever<T extends Record<string, unknown>> = { 115 - [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true 116 - ? never 117 - : K]: T[K]; 118 - };
-143
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/utils.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; 4 - import { 5 - type ArraySeparatorStyle, 6 - serializeArrayParam, 7 - serializeObjectParam, 8 - serializePrimitiveParam, 9 - } from './pathSerializer.gen'; 10 - 11 - export interface PathSerializer { 12 - path: Record<string, unknown>; 13 - url: string; 14 - } 15 - 16 - export const PATH_PARAM_RE = /\{[^{}]+\}/g; 17 - 18 - export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { 19 - let url = _url; 20 - const matches = _url.match(PATH_PARAM_RE); 21 - if (matches) { 22 - for (const match of matches) { 23 - let explode = false; 24 - let name = match.substring(1, match.length - 1); 25 - let style: ArraySeparatorStyle = 'simple'; 26 - 27 - if (name.endsWith('*')) { 28 - explode = true; 29 - name = name.substring(0, name.length - 1); 30 - } 31 - 32 - if (name.startsWith('.')) { 33 - name = name.substring(1); 34 - style = 'label'; 35 - } else if (name.startsWith(';')) { 36 - name = name.substring(1); 37 - style = 'matrix'; 38 - } 39 - 40 - const value = path[name]; 41 - 42 - if (value === undefined || value === null) { 43 - continue; 44 - } 45 - 46 - if (Array.isArray(value)) { 47 - url = url.replace( 48 - match, 49 - serializeArrayParam({ explode, name, style, value }), 50 - ); 51 - continue; 52 - } 53 - 54 - if (typeof value === 'object') { 55 - url = url.replace( 56 - match, 57 - serializeObjectParam({ 58 - explode, 59 - name, 60 - style, 61 - value: value as Record<string, unknown>, 62 - valueOnly: true, 63 - }), 64 - ); 65 - continue; 66 - } 67 - 68 - if (style === 'matrix') { 69 - url = url.replace( 70 - match, 71 - `;${serializePrimitiveParam({ 72 - name, 73 - value: value as string, 74 - })}`, 75 - ); 76 - continue; 77 - } 78 - 79 - const replaceValue = encodeURIComponent( 80 - style === 'label' ? `.${value as string}` : (value as string), 81 - ); 82 - url = url.replace(match, replaceValue); 83 - } 84 - } 85 - return url; 86 - }; 87 - 88 - export const getUrl = ({ 89 - baseUrl, 90 - path, 91 - query, 92 - querySerializer, 93 - url: _url, 94 - }: { 95 - baseUrl?: string; 96 - path?: Record<string, unknown>; 97 - query?: Record<string, unknown>; 98 - querySerializer: QuerySerializer; 99 - url: string; 100 - }) => { 101 - const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; 102 - let url = (baseUrl ?? '') + pathUrl; 103 - if (path) { 104 - url = defaultPathSerializer({ path, url }); 105 - } 106 - let search = query ? querySerializer(query) : ''; 107 - if (search.startsWith('?')) { 108 - search = search.substring(1); 109 - } 110 - if (search) { 111 - url += `?${search}`; 112 - } 113 - return url; 114 - }; 115 - 116 - export function getValidRequestBody(options: { 117 - body?: unknown; 118 - bodySerializer?: BodySerializer | null; 119 - serializedBody?: unknown; 120 - }) { 121 - const hasBody = options.body !== undefined; 122 - const isSerializedBody = hasBody && options.bodySerializer; 123 - 124 - if (isSerializedBody) { 125 - if ('serializedBody' in options) { 126 - const hasSerializedBody = 127 - options.serializedBody !== undefined && options.serializedBody !== ''; 128 - 129 - return hasSerializedBody ? options.serializedBody : null; 130 - } 131 - 132 - // not all clients implement a serializedBody property (i.e. client-axios) 133 - return options.body !== '' ? options.body : null; 134 - } 135 - 136 - // plain/text body 137 - if (hasBody) { 138 - return options.body; 139 - } 140 - 141 - // no body was provided 142 - return undefined; 143 - }
-4
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/index.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export { getBar, getFoo, type Options } from './sdk.gen'; 4 - export type { ClientOptions, GetBarData, GetBarResponses, GetFooData, GetFooResponses } from './types.gen';
-39
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import type { Client, Options as Options2, TDataShape } from './client'; 4 - import { client } from './client.gen'; 5 - import type { GetBarData, GetBarResponses, GetFooData, GetFooResponses } from './types.gen'; 6 - 7 - export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & { 8 - /** 9 - * You can provide a client instance returned by `createClient()` instead of 10 - * individual options. This might be also useful if you want to implement a 11 - * custom client. 12 - */ 13 - client?: Client; 14 - /** 15 - * You can pass arbitrary values through the `meta` object. This can be 16 - * used to access values that aren't defined as part of the SDK function. 17 - */ 18 - meta?: Record<string, unknown>; 19 - }; 20 - 21 - export const getFoo = <ThrowOnError extends boolean = false>(options?: Options<GetFooData, ThrowOnError>) => (options?.client ?? client).get<GetFooResponses, unknown, ThrowOnError>({ 22 - security: [{ 23 - in: 'query', 24 - name: 'foo', 25 - type: 'apiKey' 26 - }], 27 - url: '/foo', 28 - ...options 29 - }); 30 - 31 - export const getBar = <ThrowOnError extends boolean = false>(options?: Options<GetBarData, ThrowOnError>) => (options?.client ?? client).get<GetBarResponses, unknown, ThrowOnError>({ 32 - security: [{ 33 - in: 'cookie', 34 - name: 'bar', 35 - type: 'apiKey' 36 - }], 37 - url: '/bar', 38 - ...options 39 - });
-33
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/types.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - export type ClientOptions = { 4 - baseUrl: `${string}://${string}` | (string & {}); 5 - }; 6 - 7 - export type GetFooData = { 8 - body?: never; 9 - path?: never; 10 - query?: never; 11 - url: '/foo'; 12 - }; 13 - 14 - export type GetFooResponses = { 15 - /** 16 - * OK 17 - */ 18 - 200: unknown; 19 - }; 20 - 21 - export type GetBarData = { 22 - body?: never; 23 - path?: never; 24 - query?: never; 25 - url: '/bar'; 26 - }; 27 - 28 - export type GetBarResponses = { 29 - /** 30 - * OK 31 - */ 32 - 200: unknown; 33 - };
+1 -1
packages/openapi-ts-tests/main/test/additional-properties.test.ts packages/openapi-ts-tests/valibot/v1/test/additional-properties.test.ts
··· 1 1 import * as v from 'valibot'; 2 2 3 - import { setupValibotTest } from './test-helper'; 3 + import { setupValibotTest } from './utils'; 4 4 5 5 // TODO: further clean up 6 6 describe('Object Additional Properties Tests', () => {
+12 -11
packages/openapi-ts-tests/main/test/clients.test.ts
··· 239 239 }), 240 240 description: 'default output', 241 241 }, 242 - { 243 - config: createConfig({ 244 - output: 'bundle', 245 - plugins: [ 246 - customClientPlugin({ 247 - bundle: true, 248 - }), 249 - ], 250 - }), 251 - description: 'default output with bundled client', 252 - }, 242 + // TODO: enable custom client bundle, it's currently producing CJS output which fails typecheck 243 + // { 244 + // config: createConfig({ 245 + // output: 'bundle', 246 + // plugins: [ 247 + // customClientPlugin({ 248 + // bundle: true, 249 + // }), 250 + // ], 251 + // }), 252 + // description: 'default output with bundled client', 253 + // }, 253 254 { 254 255 config: createConfig({ 255 256 output: 'sdk-client-optional',
+1 -1
packages/openapi-ts-tests/main/test/const-values.test.ts packages/openapi-ts-tests/valibot/v1/test/const-values.test.ts
··· 1 1 import * as v from 'valibot'; 2 2 3 - import { setupValibotTest } from './test-helper'; 3 + import { setupValibotTest } from './utils'; 4 4 5 5 // TODO: further clean up 6 6 describe('Number Type Const Values Tests', () => {
+1 -1
packages/openapi-ts-tests/main/test/formats.test.ts packages/openapi-ts-tests/valibot/v1/test/formats.test.ts
··· 1 1 import * as v from 'valibot'; 2 2 3 - import { setupValibotTest } from './test-helper'; 3 + import { setupValibotTest } from './utils'; 4 4 5 5 // TODO: further clean up 6 6 describe('Number Type Formats Tests', () => {
+1 -1
packages/openapi-ts-tests/main/test/min-max-constraints.test.ts packages/openapi-ts-tests/valibot/v1/test/min-max-constraints.test.ts
··· 1 1 import * as v from 'valibot'; 2 2 3 - import { setupValibotTest } from './test-helper'; 3 + import { setupValibotTest } from './utils'; 4 4 5 5 // TODO: further clean up 6 6 describe('Number Type Min/Max Constraints Tests', () => {
-24
packages/openapi-ts-tests/main/test/plugins.test.ts
··· 470 470 }, 471 471 { 472 472 config: createConfig({ 473 - output: 'default', 474 - plugins: ['valibot'], 475 - }), 476 - description: 'generate Valibot schemas with Valibot plugin', 477 - }, 478 - { 479 - config: createConfig({ 480 - input: 'type-format.yaml', 481 - output: 'type-format-valibot', 482 - plugins: [ 483 - '@hey-api/transformers', 484 - '@hey-api/client-fetch', 485 - 'valibot', 486 - { 487 - name: '@hey-api/sdk', 488 - transformer: true, 489 - validator: true, 490 - }, 491 - ], 492 - }), 493 - description: 'handles various schema types and formats', 494 - }, 495 - { 496 - config: createConfig({ 497 473 input: 'type-format.yaml', 498 474 output: 'type-format-zod', 499 475 plugins: [
-74
packages/openapi-ts-tests/main/test/test-helper.ts
··· 1 - import fs from 'node:fs'; 2 - import path from 'node:path'; 3 - import { fileURLToPath } from 'node:url'; 4 - 5 - import { createClient } from '@hey-api/openapi-ts'; 6 - import * as v from 'valibot'; 7 - 8 - import { getSpecsPath } from '../../utils'; 9 - 10 - const __filename = fileURLToPath(import.meta.url); 11 - const __dirname = path.dirname(__filename); 12 - 13 - const version = '3.1.x'; 14 - 15 - const outputDir = path.join(__dirname, 'generated', version); 16 - 17 - /** 18 - * Load and evaluate the generated schemas 19 - */ 20 - function loadGeneratedSchemas(generatedPath: string): any { 21 - if (!fs.existsSync(generatedPath)) { 22 - throw new Error( 23 - `Generated schema file not found: ${generatedPath}\n` + 24 - `Schema generation may have failed. Check the input schema file for errors.`, 25 - ); 26 - } 27 - 28 - try { 29 - const generatedCode = fs.readFileSync(generatedPath, 'utf-8'); 30 - 31 - // Extract all export statements and create a proper return object 32 - const exportMatches = generatedCode.match(/export const (\w+)/g); 33 - if (!exportMatches) { 34 - // noinspection ExceptionCaughtLocallyJS 35 - throw new Error('No exported schemas found in generated code'); 36 - } 37 - 38 - // Create evaluation code that returns an object with all exports 39 - const schemaNames = exportMatches.map((match: string) => match.replace('export const ', '')); 40 - const evalCode = 41 - generatedCode 42 - .replace(/import \* as v from 'valibot';/, '') 43 - .replace(/export const/g, 'const') 44 - .replace(/v\./g, 'vModule.') + `\n\nreturn { ${schemaNames.join(', ')} };`; 45 - 46 - // Wrap in a function to capture the return value 47 - const schemaFunction = new Function('vModule', evalCode); 48 - return schemaFunction(v); 49 - } catch (error) { 50 - throw new Error( 51 - `Failed to load generated schemas from ${generatedPath}: ${error instanceof Error ? error.message : String(error)}\n` + 52 - `The generated file may contain syntax errors or be malformed.`, 53 - ); 54 - } 55 - } 56 - 57 - // TODO: further clean up 58 - export async function setupValibotTest(input: string, output: string): Promise<any> { 59 - const inputPath = path.join(getSpecsPath(), version, input); 60 - const outputPath = path.join(outputDir, output); 61 - 62 - fs.mkdirSync(outputPath, { recursive: true }); 63 - 64 - await createClient({ 65 - input: inputPath, 66 - logs: { level: 'silent' }, 67 - output: outputPath, 68 - plugins: ['valibot'], 69 - }); 70 - 71 - // Load and return the generated schemas 72 - const generatedPath = path.join(outputPath, 'valibot.gen.ts'); 73 - return loadGeneratedSchemas(generatedPath); 74 - }
+19
packages/openapi-ts-tests/valibot/v1/.gitignore
··· 1 + .DS_Store 2 + .idea 3 + .tsdown 4 + .tmp 5 + junit.xml 6 + logs 7 + node_modules 8 + npm-debug.log* 9 + temp 10 + yarn-debug.log* 11 + yarn-error.log* 12 + 13 + *.iml 14 + dist 15 + coverage 16 + .env 17 + 18 + # test files 19 + .gen/
+17
packages/openapi-ts-tests/valibot/v1/package.json
··· 1 + { 2 + "name": "@test/openapi-ts-valibot-v1", 3 + "version": "0.0.0", 4 + "private": true, 5 + "type": "module", 6 + "scripts": { 7 + "typecheck": "tsgo --noEmit" 8 + }, 9 + "devDependencies": { 10 + "@hey-api/openapi-ts": "workspace:*", 11 + "typescript": "5.9.3", 12 + "valibot": "1.2.0" 13 + }, 14 + "engines": { 15 + "node": ">=20.19.0" 16 + } 17 + }
+56
packages/openapi-ts-tests/valibot/v1/test/3.0.x.test.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import { createClient } from '@hey-api/openapi-ts'; 5 + 6 + import { getFilePaths } from '../../../utils'; 7 + import { createValibotConfig, getSnapshotsPath, getTempSnapshotsPath } from './utils'; 8 + 9 + const version = '3.0.x'; 10 + 11 + const outputDir = path.join(getTempSnapshotsPath(), version); 12 + const snapshotsDir = path.join(getSnapshotsPath(), version); 13 + 14 + describe(`OpenAPI ${version}`, () => { 15 + const createConfig = createValibotConfig({ openApiVersion: version, outputDir }); 16 + 17 + const scenarios = [ 18 + { 19 + config: createConfig({ 20 + input: 'array-items-one-of-length-1.yaml', 21 + output: 'array-items-one-of-length-1', 22 + }), 23 + description: 'generates correct array when items are oneOf array with single item', 24 + }, 25 + { 26 + config: createConfig({ 27 + input: 'enum-null.json', 28 + output: 'enum-null', 29 + }), 30 + description: 'handles null enums', 31 + }, 32 + { 33 + config: createConfig({ 34 + input: 'validators.json', 35 + output: 'validators', 36 + }), 37 + description: 'generates validator schemas', 38 + }, 39 + ]; 40 + 41 + it.each(scenarios)('$description', async ({ config }) => { 42 + await createClient(config); 43 + 44 + const outputString = config.output as string; 45 + const filePaths = getFilePaths(outputString); 46 + 47 + await Promise.all( 48 + filePaths.map(async (filePath) => { 49 + const fileContent = fs.readFileSync(filePath, 'utf-8'); 50 + await expect(fileContent).toMatchFileSnapshot( 51 + path.join(snapshotsDir, filePath.slice(outputDir.length + 1)), 52 + ); 53 + }), 54 + ); 55 + }); 56 + });
+174
packages/openapi-ts-tests/valibot/v1/test/3.1.x.test.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import { createClient } from '@hey-api/openapi-ts'; 5 + 6 + import { getFilePaths } from '../../../utils'; 7 + import { createValibotConfig, getSnapshotsPath, getTempSnapshotsPath } from './utils'; 8 + 9 + const version = '3.1.x'; 10 + 11 + const outputDir = path.join(getTempSnapshotsPath(), version); 12 + const snapshotsDir = path.join(getSnapshotsPath(), version); 13 + 14 + describe(`OpenAPI ${version}`, () => { 15 + const createConfig = createValibotConfig({ openApiVersion: version, outputDir }); 16 + 17 + const scenarios = [ 18 + { 19 + config: createConfig({ 20 + input: 'array-items-one-of-length-1.yaml', 21 + output: 'array-items-one-of-length-1', 22 + }), 23 + description: 'generates correct array when items are oneOf array with single item', 24 + }, 25 + { 26 + config: createConfig({ 27 + input: 'enum-null.json', 28 + output: 'enum-null', 29 + }), 30 + description: 'handles null enums', 31 + }, 32 + { 33 + config: createConfig({ 34 + input: 'schema-const.yaml', 35 + output: 'schema-const', 36 + }), 37 + description: 'handles various constants', 38 + }, 39 + { 40 + config: createConfig({ 41 + input: 'validators.yaml', 42 + output: 'validators', 43 + }), 44 + description: 'generates validator schemas', 45 + }, 46 + { 47 + config: createConfig({ 48 + input: 'validators.yaml', 49 + output: 'validators-metadata', 50 + plugins: [ 51 + { 52 + metadata: true, 53 + name: 'valibot', 54 + }, 55 + ], 56 + }), 57 + description: 'generates validator schemas with metadata', 58 + }, 59 + { 60 + config: createConfig({ 61 + input: 'validators.yaml', 62 + output: 'validators-metadata-fn', 63 + plugins: [ 64 + { 65 + metadata: ({ $, node, schema }) => { 66 + node 67 + .prop('custom', $.literal('value')) 68 + .prop('title', $.literal(schema.description ?? schema.type ?? '')); 69 + }, 70 + name: 'valibot', 71 + }, 72 + ], 73 + }), 74 + description: 'generates validator schemas with metadata function', 75 + }, 76 + { 77 + config: createConfig({ 78 + input: 'validators.yaml', 79 + output: 'validators-types', 80 + }), 81 + description: 'generates validator schemas with types', 82 + }, 83 + { 84 + config: createConfig({ 85 + input: 'validators-bigint-min-max.json', 86 + output: 'validators-bigint-min-max', 87 + }), 88 + description: 'validator schemas with BigInt and min/max constraints', 89 + }, 90 + { 91 + config: createConfig({ 92 + input: 'validators-circular-ref.json', 93 + output: 'validators-circular-ref', 94 + }), 95 + description: 'validator schemas with circular reference', 96 + }, 97 + { 98 + config: createConfig({ 99 + input: 'validators-circular-ref-2.yaml', 100 + output: 'validators-circular-ref-2', 101 + }), 102 + description: 'validator schemas with circular reference 2', 103 + }, 104 + { 105 + config: createConfig({ 106 + input: 'validators-union-merge.json', 107 + output: 'validators-union-merge', 108 + }), 109 + description: "validator schemas with merged unions (can't use .merge())", 110 + }, 111 + { 112 + config: createConfig({ 113 + input: 'integer-formats.yaml', 114 + output: 'integer-formats', 115 + }), 116 + description: 117 + 'generates validator schemas for all integer format combinations (number/integer/string types with int8, int16, int32, int64, uint8, uint16, uint32, uint64 formats)', 118 + }, 119 + { 120 + config: createConfig({ 121 + input: 'zoom-video-sdk.json', 122 + output: 'webhooks', 123 + }), 124 + description: 'webhook types and validator schemas', 125 + }, 126 + { 127 + config: createConfig({ 128 + input: 'string-with-format.yaml', 129 + output: 'string-with-format', 130 + }), 131 + description: 'anyOf string and binary string', 132 + }, 133 + { 134 + config: createConfig({ 135 + input: 'time-format.yaml', 136 + output: 'time-format', 137 + }), 138 + description: 'generates correct valibot schema for time format', 139 + }, 140 + { 141 + config: createConfig({ 142 + input: 'type-format.yaml', 143 + output: 'type-format-valibot', 144 + plugins: [ 145 + '@hey-api/transformers', 146 + '@hey-api/client-fetch', 147 + 'valibot', 148 + { 149 + name: '@hey-api/sdk', 150 + transformer: true, 151 + validator: true, 152 + }, 153 + ], 154 + }), 155 + description: 'handles various schema types and formats', 156 + }, 157 + ]; 158 + 159 + it.each(scenarios)('$description', async ({ config }) => { 160 + await createClient(config); 161 + 162 + const outputString = config.output as string; 163 + const filePaths = getFilePaths(outputString); 164 + 165 + await Promise.all( 166 + filePaths.map(async (filePath) => { 167 + const fileContent = fs.readFileSync(filePath, 'utf-8'); 168 + await expect(fileContent).toMatchFileSnapshot( 169 + path.join(snapshotsDir, filePath.slice(outputDir.length + 1)), 170 + ); 171 + }), 172 + ); 173 + }); 174 + });
+95
packages/openapi-ts-tests/valibot/v1/test/utils.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + import { fileURLToPath } from 'node:url'; 4 + 5 + import { createClient, type UserConfig } from '@hey-api/openapi-ts'; 6 + import * as v from 'valibot'; 7 + 8 + import { getSpecsPath } from '../../../utils'; 9 + 10 + const __filename = fileURLToPath(import.meta.url); 11 + const __dirname = path.dirname(__filename); 12 + 13 + export const getSnapshotsPath = (): string => path.join(__dirname, '..', '__snapshots__'); 14 + 15 + export const getTempSnapshotsPath = (): string => path.join(__dirname, '..', '.gen', 'snapshots'); 16 + 17 + export const createValibotConfig = 18 + ({ openApiVersion, outputDir }: { openApiVersion: string; outputDir: string }) => 19 + (userConfig: UserConfig) => { 20 + const input = userConfig.input instanceof Array ? userConfig.input[0]! : userConfig.input; 21 + const inputPath = path.join( 22 + getSpecsPath(), 23 + openApiVersion, 24 + typeof input === 'string' ? input : (input.path as string), 25 + ); 26 + const output = userConfig.output instanceof Array ? userConfig.output[0]! : userConfig.output; 27 + const outputPath = typeof output === 'string' ? output : (output?.path ?? ''); 28 + return { 29 + plugins: ['valibot'], 30 + ...userConfig, 31 + input: 32 + typeof userConfig.input === 'string' 33 + ? inputPath 34 + : { 35 + ...userConfig.input, 36 + path: inputPath, 37 + }, 38 + logs: { level: 'silent', path: './logs' }, 39 + output: path.join(outputDir, outputPath), 40 + } as UserConfig; 41 + }; 42 + 43 + function loadGeneratedSchemas(generatedPath: string): any { 44 + if (!fs.existsSync(generatedPath)) { 45 + throw new Error( 46 + `Generated schema file not found: ${generatedPath}\n` + 47 + `Schema generation may have failed. Check the input schema file for errors.`, 48 + ); 49 + } 50 + 51 + try { 52 + const generatedCode = fs.readFileSync(generatedPath, 'utf-8'); 53 + 54 + const exportMatches = generatedCode.match(/export const (\w+)/g); 55 + if (!exportMatches) { 56 + throw new Error('No exported schemas found in generated code'); 57 + } 58 + 59 + const schemaNames = exportMatches.map((match: string) => match.replace('export const ', '')); 60 + const evalCode = 61 + generatedCode 62 + .replace(/import \* as v from 'valibot';/, '') 63 + .replace(/export const/g, 'const') 64 + .replace(/v\./g, 'vModule.') + `\n\nreturn { ${schemaNames.join(', ')} };`; 65 + 66 + const schemaFunction = new Function('vModule', evalCode); 67 + return schemaFunction(v); 68 + } catch (error) { 69 + throw new Error( 70 + `Failed to load generated schemas from ${generatedPath}: ${error instanceof Error ? error.message : String(error)}\n` + 71 + `The generated file may contain syntax errors or be malformed.`, 72 + ); 73 + } 74 + } 75 + 76 + export async function setupValibotTest( 77 + input: string, 78 + output: string, 79 + version = '3.1.x', 80 + ): Promise<any> { 81 + const inputPath = path.join(getSpecsPath(), version, input); 82 + const outputPath = path.join(__dirname, '.gen', version, output); 83 + 84 + fs.mkdirSync(outputPath, { recursive: true }); 85 + 86 + await createClient({ 87 + input: inputPath, 88 + logs: { level: 'silent' }, 89 + output: outputPath, 90 + plugins: ['valibot'], 91 + }); 92 + 93 + const generatedPath = path.join(outputPath, 'valibot.gen.ts'); 94 + return loadGeneratedSchemas(generatedPath); 95 + }
+6
packages/openapi-ts-tests/valibot/v1/tsconfig.json
··· 1 + { 2 + "extends": "../../tsconfig.base.json", 3 + "include": ["test/**/*", "__snapshots__/**/*"], 4 + "exclude": [".gen/**/*"], 5 + "references": [{ "path": "../../../openapi-ts" }] 6 + }
+10
packages/openapi-ts-tests/valibot/v1/turbo.json
··· 1 + { 2 + "$schema": "../../../../node_modules/turbo/schema.json", 3 + "extends": ["//"], 4 + "tasks": { 5 + "build": { 6 + "dependsOn": [], 7 + "outputs": ["dist/**"] 8 + } 9 + } 10 + }
+7
packages/openapi-ts-tests/valibot/v1/vitest.setup.ts
··· 1 + import { fileURLToPath } from 'node:url'; 2 + 3 + import { beforeAll } from 'vitest'; 4 + 5 + beforeAll(() => { 6 + process.chdir(fileURLToPath(new URL('.', import.meta.url))); 7 + });
-6
packages/openapi-ts/src/plugins/valibot/resolvers.ts
··· 155 155 shape: (ctx: ObjectResolverContext) => ReturnType<typeof $.object>; 156 156 }; 157 157 schema: SchemaWithType<'object'>; 158 - /** 159 - * Utility functions for object schema processing. 160 - */ 161 - utils: { 162 - ast: Partial<{ hasLazy: boolean }>; 163 - }; 164 158 walk: Walker<ValibotResult, ValibotPlugin['Instance']>; 165 159 walkerCtx: SchemaVisitorContext<ValibotPlugin['Instance']>; 166 160 }
-3
packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts
··· 93 93 symbols: { 94 94 v: plugin.external('valibot.v'), 95 95 }, 96 - utils: { 97 - ast: {}, 98 - }, 99 96 walk, 100 97 walkerCtx, 101 98 };
+23 -14
pnpm-lock.yaml
··· 1522 1522 typescript: 1523 1523 specifier: 5.9.3 1524 1524 version: 5.9.3 1525 - valibot: 1526 - specifier: 1.2.0 1527 - version: 1.2.0(typescript@5.9.3) 1528 1525 vue: 1529 1526 specifier: 3.5.25 1530 1527 version: 3.5.25(typescript@5.9.3) ··· 1540 1537 typescript: 1541 1538 specifier: 5.9.3 1542 1539 version: 5.9.3 1540 + 1541 + packages/openapi-ts-tests/valibot/v1: 1542 + devDependencies: 1543 + '@hey-api/openapi-ts': 1544 + specifier: workspace:* 1545 + version: link:../../../openapi-ts 1546 + typescript: 1547 + specifier: 5.9.3 1548 + version: 5.9.3 1549 + valibot: 1550 + specifier: 1.2.0 1551 + version: 1.2.0(typescript@5.9.3) 1543 1552 1544 1553 packages/openapi-ts-tests/zod/v3: 1545 1554 devDependencies: ··· 15567 15576 dependencies: 15568 15577 '@ampproject/remapping': 2.3.0 15569 15578 '@angular-devkit/architect': 0.2101.2(chokidar@5.0.0) 15570 - '@angular-devkit/build-webpack': 0.2101.2(chokidar@5.0.0)(webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1))(webpack@5.104.1(esbuild@0.27.2)) 15579 + '@angular-devkit/build-webpack': 0.2101.2(chokidar@5.0.0)(webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)))(webpack@5.104.1(esbuild@0.27.2)) 15571 15580 '@angular-devkit/core': 21.1.2(chokidar@5.0.0) 15572 15581 '@angular/build': 21.1.2(a73756e6d925d6a2ce3b9f3b3e1fe266) 15573 15582 '@angular/compiler-cli': 21.1.2(@angular/compiler@21.1.2)(typescript@5.9.3) ··· 15617 15626 tslib: 2.8.1 15618 15627 typescript: 5.9.3 15619 15628 webpack: 5.104.1(esbuild@0.27.2) 15620 - webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.104.1) 15621 - webpack-dev-server: 5.2.2(tslib@2.8.1)(webpack@5.104.1) 15629 + webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)) 15630 + webpack-dev-server: 5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)) 15622 15631 webpack-merge: 6.0.1 15623 15632 webpack-subresource-integrity: 5.1.0(webpack@5.104.1(esbuild@0.27.2)) 15624 15633 optionalDependencies: ··· 15656 15665 dependencies: 15657 15666 '@ampproject/remapping': 2.3.0 15658 15667 '@angular-devkit/architect': 0.2101.2(chokidar@5.0.0) 15659 - '@angular-devkit/build-webpack': 0.2101.2(chokidar@5.0.0)(webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1))(webpack@5.104.1(esbuild@0.27.2)) 15668 + '@angular-devkit/build-webpack': 0.2101.2(chokidar@5.0.0)(webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)))(webpack@5.104.1(esbuild@0.27.2)) 15660 15669 '@angular-devkit/core': 21.1.2(chokidar@5.0.0) 15661 15670 '@angular/build': 21.1.2(13c6cf4e4b76000cae827571b33755bd) 15662 15671 '@angular/compiler-cli': 21.1.2(@angular/compiler@21.1.2)(typescript@5.9.3) ··· 15706 15715 tslib: 2.8.1 15707 15716 typescript: 5.9.3 15708 15717 webpack: 5.104.1(esbuild@0.27.2) 15709 - webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.104.1) 15710 - webpack-dev-server: 5.2.2(tslib@2.8.1)(webpack@5.104.1) 15718 + webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)) 15719 + webpack-dev-server: 5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)) 15711 15720 webpack-merge: 6.0.1 15712 15721 webpack-subresource-integrity: 5.1.0(webpack@5.104.1(esbuild@0.27.2)) 15713 15722 optionalDependencies: ··· 15741 15750 - webpack-cli 15742 15751 - yaml 15743 15752 15744 - '@angular-devkit/build-webpack@0.2101.2(chokidar@5.0.0)(webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1))(webpack@5.104.1(esbuild@0.27.2))': 15753 + '@angular-devkit/build-webpack@0.2101.2(chokidar@5.0.0)(webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)))(webpack@5.104.1(esbuild@0.27.2))': 15745 15754 dependencies: 15746 15755 '@angular-devkit/architect': 0.2101.2(chokidar@5.0.0) 15747 15756 rxjs: 7.8.2 15748 15757 webpack: 5.104.1(esbuild@0.27.2) 15749 - webpack-dev-server: 5.2.2(tslib@2.8.1)(webpack@5.104.1) 15758 + webpack-dev-server: 5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)) 15750 15759 transitivePeerDependencies: 15751 15760 - chokidar 15752 15761 ··· 32331 32340 32332 32341 webidl-conversions@8.0.1: {} 32333 32342 32334 - webpack-dev-middleware@7.4.5(tslib@2.8.1)(webpack@5.104.1): 32343 + webpack-dev-middleware@7.4.5(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)): 32335 32344 dependencies: 32336 32345 colorette: 2.0.20 32337 32346 memfs: 4.56.10(tslib@2.8.1) ··· 32344 32353 transitivePeerDependencies: 32345 32354 - tslib 32346 32355 32347 - webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1): 32356 + webpack-dev-server@5.2.2(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)): 32348 32357 dependencies: 32349 32358 '@types/bonjour': 3.5.13 32350 32359 '@types/connect-history-api-fallback': 1.5.4 ··· 32372 32381 serve-index: 1.9.1 32373 32382 sockjs: 0.3.24 32374 32383 spdy: 4.0.2 32375 - webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.104.1) 32384 + webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.104.1(esbuild@0.27.2)) 32376 32385 ws: 8.18.3 32377 32386 optionalDependencies: 32378 32387 webpack: 5.104.1(esbuild@0.27.2)
+8
vitest.config.ts
··· 68 68 { 69 69 extends: true, 70 70 test: { 71 + name: '@test/openapi-ts-valibot-v1', 72 + root: 'packages/openapi-ts-tests/valibot/v1', 73 + setupFiles: ['./vitest.setup.ts'], 74 + }, 75 + }, 76 + { 77 + extends: true, 78 + test: { 71 79 name: '@test/openapi-ts-zod-v3', 72 80 root: 'packages/openapi-ts-tests/zod/v3', 73 81 setupFiles: ['./vitest.setup.ts'],