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.

Revert changes to OpenAPI 2.0.x and 3.0.x parsers - fix only applies to 3.1.x

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

+6 -220
+2 -6
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts
··· 1471 1471 'Error' 1472 1472 ])), 1473 1473 parameterModel: z.optional(z.union([ 1474 - z._default(zModelWithString, { 1475 - prop: 'Hello World!' 1476 - }), 1474 + zModelWithString, 1477 1475 z.null() 1478 1476 ])) 1479 1477 })) ··· 1491 1489 'Warning', 1492 1490 'Error' 1493 1491 ])), 1494 - parameterModel: z._default(z.optional(zModelWithString), { 1495 - prop: 'Hello World!' 1496 - }) 1492 + parameterModel: z.optional(zModelWithString) 1497 1493 })) 1498 1494 }); 1499 1495
-36
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/defaults-with-ref-and-anyof/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as z from 'zod/mini'; 4 - 5 - export const zAudioFormat = z.enum([ 6 - 'pcm_16bit_44.1khz', 7 - 'pcm_16bit_24khz' 8 - ]); 9 - 10 - export const zLanguage = z.enum([ 11 - 'en', 12 - 'es', 13 - 'fr' 14 - ]); 15 - 16 - export const zNestedConfig = z.object({ 17 - model: z._default(z.string(), 'gpt-4'), 18 - temperature: z._default(z.number(), 1) 19 - }); 20 - 21 - export const zTestSchema = z.object({ 22 - primitiveDefault: z._default(z.number(), 42), 23 - refWithPrimitiveDefault: z._default(zAudioFormat, 'pcm_16bit_44.1khz'), 24 - refWithObjectDefault: z._default(zNestedConfig, { 25 - model: 'gpt-4', 26 - temperature: 1 27 - }), 28 - anyOfWithNullDefault: z._default(z.union([ 29 - z.number(), 30 - z.unknown() 31 - ]), null), 32 - anyOfWithRefAndNullDefault: z._default(z.union([ 33 - zLanguage, 34 - z.unknown() 35 - ]), null) 36 - });
+2 -6
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts
··· 1469 1469 'Error' 1470 1470 ]).optional(), 1471 1471 parameterModel: z.union([ 1472 - zModelWithString.default({ 1473 - prop: 'Hello World!' 1474 - }), 1472 + zModelWithString, 1475 1473 z.null() 1476 1474 ]).optional() 1477 1475 }).optional() ··· 1489 1487 'Warning', 1490 1488 'Error' 1491 1489 ]).optional(), 1492 - parameterModel: zModelWithString.optional().default({ 1493 - prop: 'Hello World!' 1494 - }) 1490 + parameterModel: zModelWithString.optional() 1495 1491 }).optional() 1496 1492 }); 1497 1493
-36
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/defaults-with-ref-and-anyof/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { z } from 'zod/v3'; 4 - 5 - export const zAudioFormat = z.enum([ 6 - 'pcm_16bit_44.1khz', 7 - 'pcm_16bit_24khz' 8 - ]); 9 - 10 - export const zLanguage = z.enum([ 11 - 'en', 12 - 'es', 13 - 'fr' 14 - ]); 15 - 16 - export const zNestedConfig = z.object({ 17 - model: z.string().default('gpt-4'), 18 - temperature: z.number().default(1) 19 - }); 20 - 21 - export const zTestSchema = z.object({ 22 - primitiveDefault: z.number().default(42), 23 - refWithPrimitiveDefault: zAudioFormat.default('pcm_16bit_44.1khz'), 24 - refWithObjectDefault: zNestedConfig.default({ 25 - model: 'gpt-4', 26 - temperature: 1 27 - }), 28 - anyOfWithNullDefault: z.union([ 29 - z.number(), 30 - z.unknown() 31 - ]).default(null), 32 - anyOfWithRefAndNullDefault: z.union([ 33 - zLanguage, 34 - z.unknown() 35 - ]).default(null) 36 - });
+2 -6
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts
··· 1471 1471 'Error' 1472 1472 ])), 1473 1473 parameterModel: z.optional(z.union([ 1474 - zModelWithString.default({ 1475 - prop: 'Hello World!' 1476 - }), 1474 + zModelWithString, 1477 1475 z.null() 1478 1476 ])) 1479 1477 })) ··· 1491 1489 'Warning', 1492 1490 'Error' 1493 1491 ])), 1494 - parameterModel: z.optional(zModelWithString).default({ 1495 - prop: 'Hello World!' 1496 - }) 1492 + parameterModel: z.optional(zModelWithString) 1497 1493 })) 1498 1494 }); 1499 1495
-36
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/defaults-with-ref-and-anyof/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { z } from 'zod'; 4 - 5 - export const zAudioFormat = z.enum([ 6 - 'pcm_16bit_44.1khz', 7 - 'pcm_16bit_24khz' 8 - ]); 9 - 10 - export const zLanguage = z.enum([ 11 - 'en', 12 - 'es', 13 - 'fr' 14 - ]); 15 - 16 - export const zNestedConfig = z.object({ 17 - model: z.string().default('gpt-4'), 18 - temperature: z.number().default(1) 19 - }); 20 - 21 - export const zTestSchema = z.object({ 22 - primitiveDefault: z.number().default(42), 23 - refWithPrimitiveDefault: zAudioFormat.default('pcm_16bit_44.1khz'), 24 - refWithObjectDefault: zNestedConfig.default({ 25 - model: 'gpt-4', 26 - temperature: 1 27 - }), 28 - anyOfWithNullDefault: z.union([ 29 - z.number(), 30 - z.unknown() 31 - ]).default(null), 32 - anyOfWithRefAndNullDefault: z.union([ 33 - zLanguage, 34 - z.unknown() 35 - ]).default(null) 36 - });
-7
packages/openapi-ts-tests/zod/v4/test/3.0.x.test.ts
··· 51 51 }, 52 52 { 53 53 config: createConfig({ 54 - input: 'defaults-with-ref-and-anyof.json', 55 - output: 'defaults-with-ref-and-anyof', 56 - }), 57 - description: 'preserves defaults with $ref and anyOf', 58 - }, 59 - { 60 - config: createConfig({ 61 54 input: 'enum-null.json', 62 55 output: 'enum-null', 63 56 }),
-5
packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts
··· 295 295 state: SchemaState; 296 296 }): IR.SchemaObject => { 297 297 let irSchema = initIrSchema({ schema }); 298 - parseSchemaMeta({ irSchema, schema }); 299 298 300 299 const schemaItems: Array<IR.SchemaObject> = []; 301 300 const schemaType = getSchemaType({ schema }); ··· 534 533 state: SchemaState; 535 534 }): IR.SchemaObject => { 536 535 const irSchema: IR.SchemaObject = {}; 537 - 538 - // Parse metadata from the schema (like default, description, etc.) 539 - parseSchemaMeta({ irSchema, schema }); 540 - 541 536 // Inline non-component refs (e.g. #/paths/...) to avoid generating orphaned named types 542 537 const isComponentsRef = schema.$ref.startsWith('#/definitions/'); 543 538 if (!isComponentsRef) {
-7
packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts
··· 301 301 state: SchemaState; 302 302 }): IR.SchemaObject => { 303 303 let irSchema = initIrSchema({ schema }); 304 - parseSchemaMeta({ irSchema, schema }); 305 304 306 305 const schemaItems: Array<IR.SchemaObject> = []; 307 306 const schemaType = getSchemaType({ schema }); ··· 475 474 state: SchemaState; 476 475 }): IR.SchemaObject => { 477 476 let irSchema = initIrSchema({ schema }); 478 - parseSchemaMeta({ irSchema, schema }); 479 477 480 478 const schemaItems: Array<IR.SchemaObject> = []; 481 479 const schemaType = getSchemaType({ schema }); ··· 642 640 state: SchemaState; 643 641 }): IR.SchemaObject => { 644 642 let irSchema = initIrSchema({ schema }); 645 - parseSchemaMeta({ irSchema, schema }); 646 643 647 644 let schemaItems: Array<IR.SchemaObject> = []; 648 645 const schemaType = getSchemaType({ schema }); ··· 761 758 } 762 759 763 760 const irSchema: IR.SchemaObject = {}; 764 - 765 - // Parse metadata from the schema (like default, description, etc.) 766 - // Cast to SchemaObject to access these fields 767 - parseSchemaMeta({ irSchema, schema: schema as unknown as SchemaObject }); 768 761 769 762 // refs using unicode characters become encoded, didn't investigate why 770 763 // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`
-75
specs/3.0.x/defaults-with-ref-and-anyof.json
··· 1 - { 2 - "openapi": "3.0.0", 3 - "info": { 4 - "title": "Defaults with $ref and anyOf", 5 - "version": "1.0.0" 6 - }, 7 - "paths": {}, 8 - "components": { 9 - "schemas": { 10 - "AudioFormat": { 11 - "type": "string", 12 - "enum": ["pcm_16bit_44.1khz", "pcm_16bit_24khz"] 13 - }, 14 - "Language": { 15 - "type": "string", 16 - "enum": ["en", "es", "fr"] 17 - }, 18 - "NestedConfig": { 19 - "type": "object", 20 - "properties": { 21 - "model": { 22 - "type": "string", 23 - "default": "gpt-4" 24 - }, 25 - "temperature": { 26 - "type": "number", 27 - "default": 1 28 - } 29 - }, 30 - "required": ["model", "temperature"] 31 - }, 32 - "TestSchema": { 33 - "type": "object", 34 - "properties": { 35 - "primitiveDefault": { 36 - "type": "number", 37 - "default": 42 38 - }, 39 - "refWithPrimitiveDefault": { 40 - "allOf": [{ "$ref": "#/components/schemas/AudioFormat" }], 41 - "default": "pcm_16bit_44.1khz" 42 - }, 43 - "refWithObjectDefault": { 44 - "allOf": [{ "$ref": "#/components/schemas/NestedConfig" }], 45 - "default": { 46 - "model": "gpt-4", 47 - "temperature": 1 48 - } 49 - }, 50 - "anyOfWithNullDefault": { 51 - "anyOf": [ 52 - { "type": "number" }, 53 - { "type": "string", "enum": [null] } 54 - ], 55 - "default": null 56 - }, 57 - "anyOfWithRefAndNullDefault": { 58 - "anyOf": [ 59 - { "$ref": "#/components/schemas/Language" }, 60 - { "type": "string", "enum": [null] } 61 - ], 62 - "default": null 63 - } 64 - }, 65 - "required": [ 66 - "primitiveDefault", 67 - "refWithPrimitiveDefault", 68 - "refWithObjectDefault", 69 - "anyOfWithNullDefault", 70 - "anyOfWithRefAndNullDefault" 71 - ] 72 - } 73 - } 74 - } 75 - }