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