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

Fix missing defaults in Zod generation for $ref and anyOf schemas

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

+16
+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 }); 298 299 299 300 const schemaItems: Array<IR.SchemaObject> = []; 300 301 const schemaType = getSchemaType({ schema }); ··· 533 534 state: SchemaState; 534 535 }): IR.SchemaObject => { 535 536 const irSchema: IR.SchemaObject = {}; 537 + 538 + // Parse metadata from the schema (like default, description, etc.) 539 + parseSchemaMeta({ irSchema, schema }); 540 + 536 541 // Inline non-component refs (e.g. #/paths/...) to avoid generating orphaned named types 537 542 const isComponentsRef = schema.$ref.startsWith('#/definitions/'); 538 543 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 }); 304 305 305 306 const schemaItems: Array<IR.SchemaObject> = []; 306 307 const schemaType = getSchemaType({ schema }); ··· 474 475 state: SchemaState; 475 476 }): IR.SchemaObject => { 476 477 let irSchema = initIrSchema({ schema }); 478 + parseSchemaMeta({ irSchema, schema }); 477 479 478 480 const schemaItems: Array<IR.SchemaObject> = []; 479 481 const schemaType = getSchemaType({ schema }); ··· 640 642 state: SchemaState; 641 643 }): IR.SchemaObject => { 642 644 let irSchema = initIrSchema({ schema }); 645 + parseSchemaMeta({ irSchema, schema }); 643 646 644 647 let schemaItems: Array<IR.SchemaObject> = []; 645 648 const schemaType = getSchemaType({ schema }); ··· 758 761 } 759 762 760 763 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 }); 761 768 762 769 // refs using unicode characters become encoded, didn't investigate why 763 770 // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`
+4
packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts
··· 382 382 state: SchemaState; 383 383 }): IR.SchemaObject => { 384 384 let irSchema = initIrSchema({ schema }); 385 + parseSchemaMeta({ irSchema, schema }); 385 386 386 387 const schemaItems: Array<IR.SchemaObject> = []; 387 388 const schemaTypes = getSchemaTypes({ schema }); ··· 543 544 state: SchemaState; 544 545 }): IR.SchemaObject => { 545 546 let irSchema = initIrSchema({ schema }); 547 + parseSchemaMeta({ irSchema, schema }); 546 548 547 549 const schemaItems: Array<IR.SchemaObject> = []; 548 550 const schemaTypes = getSchemaTypes({ schema }); ··· 699 701 state: SchemaState; 700 702 }): IR.SchemaObject => { 701 703 let irSchema = initIrSchema({ schema }); 704 + parseSchemaMeta({ irSchema, schema }); 702 705 703 706 let schemaItems: Array<IR.SchemaObject> = []; 704 707 const schemaTypes = getSchemaTypes({ schema }); ··· 817 820 } 818 821 819 822 let irSchema = initIrSchema({ schema }); 823 + parseSchemaMeta({ irSchema, schema }); 820 824 821 825 const irRefSchema: IR.SchemaObject = {}; 822 826