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

add local option for zod datetimes

+76 -36
+3
examples/openapi-ts-angular-common/angular.json
··· 88 88 } 89 89 } 90 90 } 91 + }, 92 + "cli": { 93 + "analytics": false 91 94 } 92 95 }
+3
examples/openapi-ts-angular/angular.json
··· 88 88 } 89 89 } 90 90 } 91 + }, 92 + "cli": { 93 + "analytics": false 91 94 } 92 95 }
+1
packages/openapi-ts/src/plugins/zod/config.ts
··· 67 67 68 68 plugin.config.dates = context.valueToObject({ 69 69 defaultValue: { 70 + local: false, 70 71 offset: false, 71 72 }, 72 73 value: plugin.config.dates,
+17 -12
packages/openapi-ts/src/plugins/zod/mini/plugin.ts
··· 536 536 }), 537 537 }); 538 538 539 + const dateTimeOptions: { key: string; value: boolean }[] = []; 540 + 541 + if (plugin.config.dates.offset) { 542 + dateTimeOptions.push({ key: 'offset', value: true }); 543 + } 544 + if (plugin.config.dates.local) { 545 + dateTimeOptions.push({ key: 'local', value: true }); 546 + } 547 + 539 548 if (schema.format) { 540 549 switch (schema.format) { 541 550 case 'date': ··· 558 567 }), 559 568 name: identifiers.datetime, 560 569 }), 561 - parameters: plugin.config.dates.offset 562 - ? [ 563 - tsc.objectExpression({ 564 - obj: [ 565 - { 566 - key: 'offset', 567 - value: true, 568 - }, 569 - ], 570 - }), 571 - ] 572 - : [], 570 + parameters: 571 + dateTimeOptions.length > 0 572 + ? [ 573 + tsc.objectExpression({ 574 + obj: dateTimeOptions, 575 + }), 576 + ] 577 + : [], 573 578 }); 574 579 break; 575 580 case 'email':
+18
packages/openapi-ts/src/plugins/zod/types.d.ts
··· 34 34 */ 35 35 dates?: { 36 36 /** 37 + * Whether to allow unqualified (timezone-less) datetimes: 38 + * 39 + * When enabled, Zod will accept datetime strings without timezone information. 40 + * When disabled, Zod will require timezone information in datetime strings. 41 + * 42 + * @default false 43 + */ 44 + local?: boolean; 45 + /** 37 46 * Whether to include timezone offset information when handling dates. 38 47 * 39 48 * When enabled, date strings will preserve timezone information. ··· 365 374 * date validation features. 366 375 */ 367 376 dates: { 377 + /** 378 + * Whether to allow unqualified (timezone-less) datetimes: 379 + * 380 + * When enabled, Zod will accept datetime strings without timezone information. 381 + * When disabled, Zod will require timezone information in datetime strings. 382 + * 383 + * @default false 384 + */ 385 + local: boolean; 368 386 /** 369 387 * Whether to include timezone offset information when handling dates. 370 388 *
+17 -12
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
··· 449 449 }), 450 450 }); 451 451 452 + const dateTimeOptions: { key: string; value: boolean }[] = []; 453 + 454 + if (plugin.config.dates.offset) { 455 + dateTimeOptions.push({ key: 'offset', value: true }); 456 + } 457 + if (plugin.config.dates.local) { 458 + dateTimeOptions.push({ key: 'local', value: true }); 459 + } 460 + 452 461 if (schema.format) { 453 462 switch (schema.format) { 454 463 case 'date': ··· 465 474 expression: stringExpression, 466 475 name: identifiers.datetime, 467 476 }), 468 - parameters: plugin.config.dates.offset 469 - ? [ 470 - tsc.objectExpression({ 471 - obj: [ 472 - { 473 - key: 'offset', 474 - value: true, 475 - }, 476 - ], 477 - }), 478 - ] 479 - : [], 477 + parameters: 478 + dateTimeOptions.length > 0 479 + ? [ 480 + tsc.objectExpression({ 481 + obj: dateTimeOptions, 482 + }), 483 + ] 484 + : [], 480 485 }); 481 486 break; 482 487 case 'email':
+17 -12
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
··· 515 515 }), 516 516 }); 517 517 518 + const dateTimeOptions: { key: string; value: boolean }[] = []; 519 + 520 + if (plugin.config.dates.offset) { 521 + dateTimeOptions.push({ key: 'offset', value: true }); 522 + } 523 + if (plugin.config.dates.local) { 524 + dateTimeOptions.push({ key: 'local', value: true }); 525 + } 526 + 518 527 if (schema.format) { 519 528 switch (schema.format) { 520 529 case 'date': ··· 537 546 }), 538 547 name: identifiers.datetime, 539 548 }), 540 - parameters: plugin.config.dates.offset 541 - ? [ 542 - tsc.objectExpression({ 543 - obj: [ 544 - { 545 - key: 'offset', 546 - value: true, 547 - }, 548 - ], 549 - }), 550 - ] 551 - : [], 549 + parameters: 550 + dateTimeOptions.length > 0 551 + ? [ 552 + tsc.objectExpression({ 553 + obj: dateTimeOptions, 554 + }), 555 + ] 556 + : [], 552 557 }); 553 558 break; 554 559 case 'email':