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

Merge pull request #1265 from hey-api/fix/parameters-explode-false

fix: handle non-exploded array query parameters

authored by

Lubos and committed by
GitHub
f31d4e27 37970e0d

+498 -234
+5
.changeset/eight-poets-arrive.md
···
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: handle non-exploded array query parameters
+6 -3
packages/openapi-ts/src/compiler/utils.ts
··· 10 name: string; 11 } 12 13 - const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); 14 15 export const createSourceFile = (sourceText: string) => 16 ts.createSourceFile( 17 '', 18 sourceText, 19 - ts.ScriptTarget.ES2015, 20 - undefined, 21 ts.ScriptKind.TS, 22 ); 23
··· 10 name: string; 11 } 12 13 + const printer = ts.createPrinter({ 14 + newLine: ts.NewLineKind.LineFeed, 15 + removeComments: false, 16 + }); 17 18 export const createSourceFile = (sourceText: string) => 19 ts.createSourceFile( 20 '', 21 sourceText, 22 + ts.ScriptTarget.ESNext, 23 + false, 24 ts.ScriptKind.TS, 25 ); 26
+13 -8
packages/openapi-ts/src/index.ts
··· 223 '@hey-api/schemas', 224 '@hey-api/services', 225 ] 226 - ).map((plugin) => { 227 - if (typeof plugin === 'string') { 228 - return plugin; 229 - } 230 231 - // @ts-expect-error 232 - userPluginsConfig[plugin.name] = plugin; 233 - return plugin.name; 234 - }); 235 236 const pluginOrder = getPluginOrder({ 237 pluginConfigs: {
··· 223 '@hey-api/schemas', 224 '@hey-api/services', 225 ] 226 + ) 227 + .map((plugin) => { 228 + if (typeof plugin === 'string') { 229 + return plugin; 230 + } 231 + 232 + if (plugin.name) { 233 + // @ts-expect-error 234 + userPluginsConfig[plugin.name] = plugin; 235 + } 236 237 + return plugin.name; 238 + }) 239 + .filter(Boolean); 240 241 const pluginOrder = getPluginOrder({ 242 pluginConfigs: {
+19
packages/openapi-ts/src/ir/ir.d.ts
··· 61 62 export interface IRParameterObject { 63 /** 64 * Endpoint parameters must specify their location. 65 */ 66 location: 'cookie' | 'header' | 'path' | 'query'; ··· 72 pagination?: boolean | string; 73 required?: boolean; 74 schema: IRSchemaObject; 75 } 76 77 export interface IRResponsesObject {
··· 61 62 export interface IRParameterObject { 63 /** 64 + * Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of `contentType` (implicit or explicit) SHALL be ignored. 65 + */ 66 + allowReserved?: boolean; 67 + /** 68 + * When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When `style` is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of `contentType` (implicit or explicit) SHALL be ignored. 69 + */ 70 + explode: boolean; 71 + /** 72 * Endpoint parameters must specify their location. 73 */ 74 location: 'cookie' | 'header' | 'path' | 'query'; ··· 80 pagination?: boolean | string; 81 required?: boolean; 82 schema: IRSchemaObject; 83 + /** 84 + * Describes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of `in`): for `query` - `form`; for `path` - `simple`; for `header` - `simple`; for `cookie` - `form`. 85 + */ 86 + style: 87 + | 'deepObject' 88 + | 'form' 89 + | 'label' 90 + | 'matrix' 91 + | 'pipeDelimited' 92 + | 'simple' 93 + | 'spaceDelimited'; 94 } 95 96 export interface IRResponsesObject {
+57
packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts
··· 9 import { paginationField } from './pagination'; 10 import { schemaToIrSchema } from './schema'; 11 12 export const parametersArrayToObject = ({ 13 context, 14 parameters, ··· 141 schema: finalSchema, 142 }); 143 144 const irParameter: IRParameterObject = { 145 location: parameter.in, 146 name: parameter.name, 147 schema: schemaToIrSchema({ 148 context, 149 schema: finalSchema, 150 }), 151 }; 152 153 if (pagination) {
··· 9 import { paginationField } from './pagination'; 10 import { schemaToIrSchema } from './schema'; 11 12 + /** 13 + * Returns default parameter `allowReserved` based on value of `in`. 14 + */ 15 + const defaultAllowReserved = ( 16 + _in: ParameterObject['in'], 17 + ): boolean | undefined => { 18 + switch (_in) { 19 + // this keyword only applies to parameters with an `in` value of `query` 20 + case 'query': 21 + return false; 22 + default: 23 + return; 24 + } 25 + }; 26 + 27 + /** 28 + * Returns default parameter `explode` based on value of `style`. 29 + */ 30 + const defaultExplode = (style: Required<ParameterObject>['style']): boolean => { 31 + switch (style) { 32 + // default value for `deepObject` is `false`, but that behavior is undefined 33 + // so we use `true` to make this work with the `client-fetch` package 34 + case 'deepObject': 35 + case 'form': 36 + return true; 37 + default: 38 + return false; 39 + } 40 + }; 41 + 42 + /** 43 + * Returns default parameter `style` based on value of `in`. 44 + */ 45 + const defaultStyle = ( 46 + _in: ParameterObject['in'], 47 + ): Required<ParameterObject>['style'] => { 48 + switch (_in) { 49 + case 'header': 50 + case 'path': 51 + return 'simple'; 52 + case 'cookie': 53 + case 'query': 54 + return 'form'; 55 + } 56 + }; 57 + 58 export const parametersArrayToObject = ({ 59 context, 60 parameters, ··· 187 schema: finalSchema, 188 }); 189 190 + const style = parameter.style || defaultStyle(parameter.in); 191 + const explode = 192 + parameter.explode !== undefined ? parameter.explode : defaultExplode(style); 193 + const allowReserved = 194 + parameter.allowReserved !== undefined 195 + ? parameter.allowReserved 196 + : defaultAllowReserved(parameter.in); 197 + 198 const irParameter: IRParameterObject = { 199 + allowReserved, 200 + explode, 201 location: parameter.in, 202 name: parameter.name, 203 schema: schemaToIrSchema({ 204 context, 205 schema: finalSchema, 206 }), 207 + style, 208 }; 209 210 if (pagination) {
+57
packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts
··· 9 import { paginationField } from './pagination'; 10 import { schemaToIrSchema } from './schema'; 11 12 export const parametersArrayToObject = ({ 13 context, 14 parameters, ··· 134 schema: finalSchema, 135 }); 136 137 const irParameter: IRParameterObject = { 138 location: parameter.in, 139 name: parameter.name, 140 schema: schemaToIrSchema({ 141 context, 142 schema: finalSchema, 143 }), 144 }; 145 146 if (pagination) {
··· 9 import { paginationField } from './pagination'; 10 import { schemaToIrSchema } from './schema'; 11 12 + /** 13 + * Returns default parameter `allowReserved` based on value of `in`. 14 + */ 15 + const defaultAllowReserved = ( 16 + _in: ParameterObject['in'], 17 + ): boolean | undefined => { 18 + switch (_in) { 19 + // this keyword only applies to parameters with an `in` value of `query` 20 + case 'query': 21 + return false; 22 + default: 23 + return; 24 + } 25 + }; 26 + 27 + /** 28 + * Returns default parameter `explode` based on value of `style`. 29 + */ 30 + const defaultExplode = (style: Required<ParameterObject>['style']): boolean => { 31 + switch (style) { 32 + // default value for `deepObject` is `false`, but that behavior is undefined 33 + // so we use `true` to make this work with the `client-fetch` package 34 + case 'deepObject': 35 + case 'form': 36 + return true; 37 + default: 38 + return false; 39 + } 40 + }; 41 + 42 + /** 43 + * Returns default parameter `style` based on value of `in`. 44 + */ 45 + const defaultStyle = ( 46 + _in: ParameterObject['in'], 47 + ): Required<ParameterObject>['style'] => { 48 + switch (_in) { 49 + case 'header': 50 + case 'path': 51 + return 'simple'; 52 + case 'cookie': 53 + case 'query': 54 + return 'form'; 55 + } 56 + }; 57 + 58 export const parametersArrayToObject = ({ 59 context, 60 parameters, ··· 180 schema: finalSchema, 181 }); 182 183 + const style = parameter.style || defaultStyle(parameter.in); 184 + const explode = 185 + parameter.explode !== undefined ? parameter.explode : defaultExplode(style); 186 + const allowReserved = 187 + parameter.allowReserved !== undefined 188 + ? parameter.allowReserved 189 + : defaultAllowReserved(parameter.in); 190 + 191 const irParameter: IRParameterObject = { 192 + allowReserved, 193 + explode, 194 location: parameter.in, 195 name: parameter.name, 196 schema: schemaToIrSchema({ 197 context, 198 schema: finalSchema, 199 }), 200 + style, 201 }; 202 203 if (pagination) {
+32
packages/openapi-ts/src/plugins/@hey-api/services/plugin.ts
··· 153 } 154 } 155 156 return compiler.objectExpression({ 157 identifiers: ['responseTransformer'], 158 obj,
··· 153 } 154 } 155 156 + for (const name in operation.parameters?.query) { 157 + const parameter = operation.parameters.query[name]; 158 + if ( 159 + (parameter.schema.type === 'array' || 160 + parameter.schema.type === 'tuple') && 161 + (parameter.style !== 'form' || !parameter.explode) 162 + ) { 163 + // override the default settings for `querySerializer` 164 + if (context.config.client.name === '@hey-api/client-fetch') { 165 + obj.push({ 166 + key: 'querySerializer', 167 + value: [ 168 + { 169 + key: 'array', 170 + value: [ 171 + { 172 + key: 'explode', 173 + value: false, 174 + }, 175 + { 176 + key: 'style', 177 + value: 'form', 178 + }, 179 + ], 180 + }, 181 + ], 182 + }); 183 + } 184 + break; 185 + } 186 + } 187 + 188 return compiler.objectExpression({ 189 identifiers: ['responseTransformer'], 190 obj,
+8
packages/openapi-ts/test/3.0.x.spec.ts
··· 75 }), 76 description: 'handles empty response status codes', 77 }, 78 ]; 79 80 it.each(scenarios)('$description', async ({ config }) => {
··· 75 }), 76 description: 'handles empty response status codes', 77 }, 78 + { 79 + config: createConfig({ 80 + input: 'parameter-explode-false.json', 81 + output: 'parameter-explode-false', 82 + plugins: ['@hey-api/services'], 83 + }), 84 + description: 'handles non-exploded array query parameters', 85 + }, 86 ]; 87 88 it.each(scenarios)('$description', async ({ config }) => {
+8
packages/openapi-ts/test/3.1.x.spec.ts
··· 108 }, 109 { 110 config: createConfig({ 111 input: 'required-all-of-ref.json', 112 output: 'required-all-of-ref', 113 plugins: [
··· 108 }, 109 { 110 config: createConfig({ 111 + input: 'parameter-explode-false.json', 112 + output: 'parameter-explode-false', 113 + plugins: ['@hey-api/services'], 114 + }), 115 + description: 'handles non-exploded array query parameters', 116 + }, 117 + { 118 + config: createConfig({ 119 input: 'required-all-of-ref.json', 120 output: 'required-all-of-ref', 121 plugins: [
+3
packages/openapi-ts/test/__snapshots__/3.0.x/parameter-explode-false/index.ts
···
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen'; 3 + export * from './services.gen';
+19
packages/openapi-ts/test/__snapshots__/3.0.x/parameter-explode-false/services.gen.ts
···
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; 4 + import type { PostFooData } from './types.gen'; 5 + 6 + export const client = createClient(createConfig()); 7 + 8 + export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => { 9 + return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 10 + ...options, 11 + url: '/foo', 12 + querySerializer: { 13 + array: { 14 + explode: false, 15 + style: 'form' 16 + } 17 + } 18 + }); 19 + };
+9
packages/openapi-ts/test/__snapshots__/3.0.x/parameter-explode-false/types.gen.ts
···
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type PostFooData = { 4 + body?: never; 5 + path?: never; 6 + query?: { 7 + foo?: Array<string>; 8 + }; 9 + };
+83 -77
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts
··· 79 80 export const SimpleReferenceSchema = { 81 description: 'This is a simple reference', 82 - '$ref': '#/components/schemas/ModelWithString' 83 } as const; 84 85 export const SimpleStringWithPatternSchema = { 86 description: 'This is a simple string', 87 maxLength: 64, 88 - pattern: '^[a-zA-Z0-9_]*$', 89 - type: ['string', 'null'] 90 } as const; 91 92 export const EnumWithStringsSchema = { ··· 215 anyOf: [ 216 {}, 217 { 218 - type: 'null' 219 } 220 ] 221 } ··· 377 properties: { 378 nullableProp1: { 379 description: 'This is a simple string property', 380 - type: ['string', 'null'] 381 }, 382 nullableRequiredProp1: { 383 description: 'This is a simple string property', 384 - type: ['string', 'null'] 385 }, 386 nullableProp2: { 387 description: 'This is a simple string property', 388 - type: ['string', 'null'] 389 }, 390 nullableRequiredProp2: { 391 description: 'This is a simple string property', 392 - type: ['string', 'null'] 393 }, 394 'foo_bar-enum': { 395 description: 'This is a simple enum with strings', ··· 740 anyOf: [ 741 { 742 items: { 743 - anyOf: [ 744 { 745 '$ref': '#/components/schemas/ModelWithDictionary' 746 - }, 747 - { 748 - type: 'null' 749 } 750 ] 751 }, ··· 753 }, 754 { 755 items: { 756 - anyOf: [ 757 { 758 '$ref': '#/components/schemas/ModelWithArray' 759 - }, 760 - { 761 - type: 'null' 762 } 763 ] 764 }, ··· 775 } as const; 776 777 export const ConstValueSchema = { 778 - type: 'string', 779 - const: 'ConstValue' 780 } as const; 781 782 export const CompositionWithNestedAnyOfAndNullSchema = { ··· 784 type: 'object', 785 properties: { 786 propA: { 787 - anyOf: [ 788 { 789 items: { 790 anyOf: [ ··· 797 ] 798 }, 799 type: 'array' 800 - }, 801 - { 802 - type: 'null' 803 } 804 ], 805 title: 'Scopes' ··· 812 type: 'object', 813 properties: { 814 propA: { 815 - type: ['object', 'null'], 816 oneOf: [ 817 { 818 type: 'object', ··· 914 type: 'object', 915 properties: { 916 propA: { 917 - type: ['object', 'null'], 918 allOf: [ 919 { 920 type: 'object', ··· 943 type: 'object', 944 properties: { 945 propA: { 946 - type: ['object', 'null'], 947 anyOf: [ 948 { 949 type: 'object', ··· 1009 readOnly: true 1010 }, 1011 requiredAndNullable: { 1012 - type: ['string', 'null'] 1013 }, 1014 string: { 1015 type: 'string' ··· 1049 required: ['first'], 1050 properties: { 1051 first: { 1052 - type: ['object', 'null'], 1053 required: ['second'], 1054 readOnly: true, 1055 properties: { 1056 second: { 1057 - type: ['object', 'null'], 1058 required: ['third'], 1059 readOnly: true, 1060 properties: { 1061 third: { 1062 - type: ['string', 'null'], 1063 required: true, 1064 - readOnly: true 1065 } 1066 } 1067 } ··· 1294 type: 'object', 1295 properties: { 1296 String: { 1297 - const: 'String' 1298 }, 1299 number: { 1300 - const: 0 1301 }, 1302 null: { 1303 - const: null 1304 }, 1305 withType: { 1306 - type: 'string', 1307 - const: 'Some string' 1308 } 1309 } 1310 } as const; ··· 1324 export const NestedAnyOfArraysNullableSchema = { 1325 properties: { 1326 nullableArray: { 1327 - anyOf: [ 1328 { 1329 items: { 1330 anyOf: [ ··· 1337 ] 1338 }, 1339 type: 'array' 1340 - }, 1341 - { 1342 - type: 'null' 1343 } 1344 ] 1345 } ··· 1374 required: ['baz', 'qux'], 1375 properties: { 1376 baz: { 1377 - type: ['integer', 'null'], 1378 format: 'uint16', 1379 - minimum: 0 1380 }, 1381 qux: { 1382 type: 'integer', ··· 1387 } as const; 1388 1389 export const NullableObjectSchema = { 1390 - type: ['object', 'null'], 1391 description: 'An object that can be null', 1392 properties: { 1393 foo: { 1394 type: 'string' ··· 1463 properties: { 1464 content: { 1465 type: 'array', 1466 - prefixItems: [ 1467 - { 1468 - type: 'string', 1469 - format: 'date-time' 1470 - }, 1471 - { 1472 - type: 'string' 1473 - } 1474 - ], 1475 maxItems: 2, 1476 minItems: 2 1477 }, ··· 1589 1590 export const ModelWithPrefixItemsConstantSizeArraySchema = { 1591 type: 'array', 1592 - prefixItems: [ 1593 - { 1594 - '$ref': '#/components/schemas/ModelWithInteger' 1595 - }, 1596 - { 1597 - oneOf: [ 1598 - { 1599 - type: 'number' 1600 - }, 1601 - { 1602 - type: 'string' 1603 - } 1604 - ] 1605 - }, 1606 - { 1607 - type: 'string' 1608 - } 1609 - ] 1610 } as const; 1611 1612 export const ModelWithAnyOfConstantSizeArrayNullableSchema = { 1613 - type: ['array'], 1614 items: { 1615 oneOf: [ 1616 { 1617 - type: ['number', 'null'] 1618 }, 1619 { 1620 type: 'string' ··· 1718 required: ['baz', 'qux'], 1719 properties: { 1720 baz: { 1721 - type: ['integer', 'null'], 1722 format: 'uint16', 1723 - minimum: 0 1724 }, 1725 qux: { 1726 type: 'integer', ··· 1761 } as const; 1762 1763 export const SchemaWithFormRestrictedKeysSchema = { 1764 - type: 'object', 1765 properties: { 1766 description: { 1767 type: 'string' ··· 1949 type: 'boolean' 1950 }, 1951 error: { 1952 - type: ['string', 'null'] 1953 }, 1954 hasError: { 1955 type: 'boolean', ··· 1968 type: 'object', 1969 properties: { 1970 item: { 1971 - type: ['string', 'null'] 1972 }, 1973 error: { 1974 - type: ['string', 'null'] 1975 }, 1976 hasError: { 1977 type: 'boolean',
··· 79 80 export const SimpleReferenceSchema = { 81 description: 'This is a simple reference', 82 + allOf: [ 83 + { 84 + '$ref': '#/components/schemas/ModelWithString' 85 + } 86 + ] 87 } as const; 88 89 export const SimpleStringWithPatternSchema = { 90 description: 'This is a simple string', 91 + type: 'string', 92 + nullable: true, 93 maxLength: 64, 94 + pattern: '^[a-zA-Z0-9_]*$' 95 } as const; 96 97 export const EnumWithStringsSchema = { ··· 220 anyOf: [ 221 {}, 222 { 223 + nullable: true 224 } 225 ] 226 } ··· 382 properties: { 383 nullableProp1: { 384 description: 'This is a simple string property', 385 + type: 'string', 386 + nullable: true 387 }, 388 nullableRequiredProp1: { 389 description: 'This is a simple string property', 390 + type: 'string', 391 + nullable: true 392 }, 393 nullableProp2: { 394 description: 'This is a simple string property', 395 + nullable: true, 396 + type: 'string' 397 }, 398 nullableRequiredProp2: { 399 description: 'This is a simple string property', 400 + nullable: true, 401 + type: 'string' 402 }, 403 'foo_bar-enum': { 404 description: 'This is a simple enum with strings', ··· 749 anyOf: [ 750 { 751 items: { 752 + nullable: true, 753 + allOf: [ 754 { 755 '$ref': '#/components/schemas/ModelWithDictionary' 756 } 757 ] 758 }, ··· 760 }, 761 { 762 items: { 763 + nullable: true, 764 + allOf: [ 765 { 766 '$ref': '#/components/schemas/ModelWithArray' 767 } 768 ] 769 }, ··· 780 } as const; 781 782 export const ConstValueSchema = { 783 + enum: ['ConstValue'], 784 + type: 'string' 785 } as const; 786 787 export const CompositionWithNestedAnyOfAndNullSchema = { ··· 789 type: 'object', 790 properties: { 791 propA: { 792 + nullable: true, 793 + allOf: [ 794 { 795 items: { 796 anyOf: [ ··· 803 ] 804 }, 805 type: 'array' 806 } 807 ], 808 title: 'Scopes' ··· 815 type: 'object', 816 properties: { 817 propA: { 818 + nullable: true, 819 + type: 'object', 820 oneOf: [ 821 { 822 type: 'object', ··· 918 type: 'object', 919 properties: { 920 propA: { 921 + nullable: true, 922 + type: 'object', 923 allOf: [ 924 { 925 type: 'object', ··· 948 type: 'object', 949 properties: { 950 propA: { 951 + nullable: true, 952 + type: 'object', 953 anyOf: [ 954 { 955 type: 'object', ··· 1015 readOnly: true 1016 }, 1017 requiredAndNullable: { 1018 + type: 'string', 1019 + nullable: true 1020 }, 1021 string: { 1022 type: 'string' ··· 1056 required: ['first'], 1057 properties: { 1058 first: { 1059 + type: 'object', 1060 required: ['second'], 1061 readOnly: true, 1062 + nullable: true, 1063 properties: { 1064 second: { 1065 + type: 'object', 1066 required: ['third'], 1067 readOnly: true, 1068 + nullable: true, 1069 properties: { 1070 third: { 1071 + type: 'string', 1072 required: true, 1073 + readOnly: true, 1074 + nullable: true 1075 } 1076 } 1077 } ··· 1304 type: 'object', 1305 properties: { 1306 String: { 1307 + enum: ['String'], 1308 + type: 'string' 1309 }, 1310 number: { 1311 + enum: [0], 1312 + type: 'number' 1313 }, 1314 null: { 1315 + nullable: true 1316 }, 1317 withType: { 1318 + enum: ['Some string'], 1319 + type: 'string' 1320 } 1321 } 1322 } as const; ··· 1336 export const NestedAnyOfArraysNullableSchema = { 1337 properties: { 1338 nullableArray: { 1339 + nullable: true, 1340 + allOf: [ 1341 { 1342 items: { 1343 anyOf: [ ··· 1350 ] 1351 }, 1352 type: 'array' 1353 } 1354 ] 1355 } ··· 1384 required: ['baz', 'qux'], 1385 properties: { 1386 baz: { 1387 + type: 'integer', 1388 format: 'uint16', 1389 + minimum: 0, 1390 + nullable: true 1391 }, 1392 qux: { 1393 type: 'integer', ··· 1398 } as const; 1399 1400 export const NullableObjectSchema = { 1401 description: 'An object that can be null', 1402 + nullable: true, 1403 + type: 'object', 1404 properties: { 1405 foo: { 1406 type: 'string' ··· 1475 properties: { 1476 content: { 1477 type: 'array', 1478 + items: { 1479 + type: 'string', 1480 + format: 'date-time' 1481 + }, 1482 maxItems: 2, 1483 minItems: 2 1484 }, ··· 1596 1597 export const ModelWithPrefixItemsConstantSizeArraySchema = { 1598 type: 'array', 1599 + items: { 1600 + oneOf: [ 1601 + { 1602 + '$ref': '#/components/schemas/ModelWithInteger' 1603 + }, 1604 + { 1605 + type: 'number' 1606 + }, 1607 + { 1608 + type: 'string' 1609 + } 1610 + ] 1611 + } 1612 } as const; 1613 1614 export const ModelWithAnyOfConstantSizeArrayNullableSchema = { 1615 + type: 'array', 1616 items: { 1617 oneOf: [ 1618 { 1619 + type: 'number', 1620 + nullable: true 1621 }, 1622 { 1623 type: 'string' ··· 1721 required: ['baz', 'qux'], 1722 properties: { 1723 baz: { 1724 + type: 'integer', 1725 format: 'uint16', 1726 + minimum: 0, 1727 + nullable: true 1728 }, 1729 qux: { 1730 type: 'integer', ··· 1765 } as const; 1766 1767 export const SchemaWithFormRestrictedKeysSchema = { 1768 properties: { 1769 description: { 1770 type: 'string' ··· 1952 type: 'boolean' 1953 }, 1954 error: { 1955 + type: 'string', 1956 + nullable: true 1957 }, 1958 hasError: { 1959 type: 'boolean', ··· 1972 type: 'object', 1973 properties: { 1974 item: { 1975 + type: 'string', 1976 + nullable: true 1977 }, 1978 error: { 1979 + type: 'string', 1980 + nullable: true 1981 }, 1982 hasError: { 1983 type: 'boolean',
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/services/default/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+4 -8
packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 - data?: unknown | null; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 - null?: null; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 - export type ModelWithPrefixItemsConstantSizeArray = [ 755 - ModelWithInteger, 756 - number | string, 757 - string 758 - ]; 759 760 export type ModelWithAnyOfConstantSizeArrayNullable = [ 761 number | null | string, ··· 1344 /** 1345 * This is an enum parameter 1346 */ 1347 - parameterEnum: 'Success' | 'Warning' | 'Error' | null; 1348 }; 1349 }; 1350
··· 153 }>; 154 155 export type AnyOfAnyAndNull = { 156 + data?: unknown; 157 }; 158 159 /** ··· 655 export type ModelWithConst = { 656 String?: 'String'; 657 number?: 0; 658 + null?: unknown; 659 withType?: 'Some string'; 660 }; 661 ··· 751 number | string 752 ]; 753 754 + export type ModelWithPrefixItemsConstantSizeArray = Array<ModelWithInteger | number | string>; 755 756 export type ModelWithAnyOfConstantSizeArrayNullable = [ 757 number | null | string, ··· 1340 /** 1341 * This is an enum parameter 1342 */ 1343 + parameterEnum: 'Success' | 'Warning' | 'Error'; 1344 }; 1345 }; 1346
+3
packages/openapi-ts/test/__snapshots__/3.1.x/parameter-explode-false/index.ts
···
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen'; 3 + export * from './services.gen';
+19
packages/openapi-ts/test/__snapshots__/3.1.x/parameter-explode-false/services.gen.ts
···
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { createClient, createConfig, type Options } from '@hey-api/client-fetch'; 4 + import type { PostFooData } from './types.gen'; 5 + 6 + export const client = createClient(createConfig()); 7 + 8 + export const postFoo = <ThrowOnError extends boolean = false>(options?: Options<PostFooData, ThrowOnError>) => { 9 + return (options?.client ?? client).post<unknown, unknown, ThrowOnError>({ 10 + ...options, 11 + url: '/foo', 12 + querySerializer: { 13 + array: { 14 + explode: false, 15 + style: 'form' 16 + } 17 + } 18 + }); 19 + };
+9
packages/openapi-ts/test/__snapshots__/3.1.x/parameter-explode-false/types.gen.ts
···
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type PostFooData = { 4 + body?: never; 5 + path?: never; 6 + query?: { 7 + foo?: Array<string>; 8 + }; 9 + };
+1 -1
packages/openapi-ts/test/plugins.spec.ts
··· 27 client: '@hey-api/client-fetch', 28 experimentalParser: true, 29 ...userConfig, 30 - input: path.join(__dirname, 'spec', '3.1.x', 'full.json'), 31 output: path.join( 32 outputDir, 33 typeof userConfig.plugins[0] === 'string'
··· 27 client: '@hey-api/client-fetch', 28 experimentalParser: true, 29 ...userConfig, 30 + input: path.join(__dirname, 'spec', version, 'full.json'), 31 output: path.join( 32 outputDir, 33 typeof userConfig.plugins[0] === 'string'
+21 -17
packages/openapi-ts/test/sample.cjs
··· 13 input: { 14 // include: 15 // '^(#/components/schemas/import|#/paths/api/v{api-version}/simple/options)$', 16 - path: './test/spec/3.0.x/full.json', 17 // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 18 }, 19 // name: 'foo', ··· 23 path: './test/generated/sample/', 24 }, 25 plugins: [ 26 - // { 27 - // name: '@hey-api/schemas', 28 - // type: 'json', 29 - // }, 30 - // { 31 - // // asClass: true, 32 - // // include... 33 - // name: '@hey-api/services', 34 - // // serviceNameBuilder: '^Parameters', 35 - // }, 36 - // { 37 - // dates: true, 38 - // name: '@hey-api/transformers', 39 - // }, 40 { 41 // enums: 'typescript', 42 // enums: 'typescript+namespace', ··· 45 // style: 'PascalCase', 46 tree: true, 47 }, 48 - // '@tanstack/react-query', 49 - // 'zod', 50 ], 51 // useOptions: false, 52 };
··· 13 input: { 14 // include: 15 // '^(#/components/schemas/import|#/paths/api/v{api-version}/simple/options)$', 16 + path: './test/spec/3.0.x/parameter-explode-false.json', 17 // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 18 }, 19 // name: 'foo', ··· 23 path: './test/generated/sample/', 24 }, 25 plugins: [ 26 + { 27 + // name: '@hey-api/schemas', 28 + // type: 'json', 29 + }, 30 + { 31 + // asClass: true, 32 + // include... 33 + name: '@hey-api/services', 34 + // serviceNameBuilder: '^Parameters', 35 + }, 36 + { 37 + // dates: true, 38 + // name: '@hey-api/transformers', 39 + }, 40 { 41 // enums: 'typescript', 42 // enums: 'typescript+namespace', ··· 45 // style: 'PascalCase', 46 tree: true, 47 }, 48 + { 49 + // name: '@tanstack/react-query', 50 + }, 51 + { 52 + // name: 'zod', 53 + }, 54 ], 55 // useOptions: false, 56 };
+31
packages/openapi-ts/test/spec/3.0.x/parameter-explode-false.json
···
··· 1 + { 2 + "openapi": "3.0.0", 3 + "info": { 4 + "title": "OpenAPI 3.0.0 parameter explode false example", 5 + "version": "1" 6 + }, 7 + "paths": { 8 + "/foo": { 9 + "post": { 10 + "parameters": [ 11 + { 12 + "name": "foo", 13 + "in": "query", 14 + "explode": false, 15 + "schema": { 16 + "type": "array", 17 + "items": { 18 + "type": "string" 19 + } 20 + } 21 + } 22 + ], 23 + "responses": { 24 + "default": { 25 + "description": "OK" 26 + } 27 + } 28 + } 29 + } 30 + } 31 + }
+31
packages/openapi-ts/test/spec/3.1.x/parameter-explode-false.json
···
··· 1 + { 2 + "openapi": "3.1.0", 3 + "info": { 4 + "title": "OpenAPI 3.1.0 parameter explode false example", 5 + "version": "1" 6 + }, 7 + "paths": { 8 + "/foo": { 9 + "post": { 10 + "parameters": [ 11 + { 12 + "name": "foo", 13 + "in": "query", 14 + "explode": false, 15 + "schema": { 16 + "type": "array", 17 + "items": { 18 + "type": "string" 19 + } 20 + } 21 + } 22 + ], 23 + "responses": { 24 + "default": { 25 + "description": "OK" 26 + } 27 + } 28 + } 29 + } 30 + } 31 + }