fix: serialize format: date query params as YYYY-MM-DD#3723
fix: serialize format: date query params as YYYY-MM-DD#3723rolego wants to merge 4 commits intohey-api:mainfrom
Conversation
…l ISO timestamp When dates: true is enabled in @hey-api/transformers, query parameters with format: date are typed as Date. Previously, Date objects were serialized via .toISOString() producing full timestamps like 2025-12-17T00:00:00.000Z instead of the expected 2025-12-17. Adds a date option to QuerySerializerOptions and emits per-parameter date format hints in the SDK codegen. All 7 client bundles now check instanceof Date before serializing query params.
|
|
|
Reviewed PR #3723. The approach is sound — Task list (6/6 completed)
|
|
|
@rolego is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
|
TL;DR — Query parameters declared with Key changes
Summary | 576 files | 4 commits | base: Runtime
|
There was a problem hiding this comment.
Important
The codegen emits querySerializer date hints unconditionally — even when @hey-api/transformers is not enabled (and the param type is string, not Date). This is harmless at runtime but adds dead config to every generated SDK that has format: date query params without transformers. Consider gating the hint emission on the transformer plugin being active, consistent with how responseTransformer is already gated at line 350.
No runtime tests exist for the new instanceof Date branch — only snapshot coverage for the generated code. A unit test for createQuerySerializer with a Date value and { date: 'date' } option would be valuable.
The overall approach is sound: placing instanceof Date before Array.isArray() is correct (since Date passes typeof value === 'object' and would otherwise be serialized as [object Object]), the date type option is cleanly scoped, and all 7 client bundles are updated consistently. The new else if branch in operation.ts follows the existing pattern for array/object serializers.
packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/bodySerializer.ts
Show resolved
Hide resolved
Only emit per-parameter date format hints in querySerializer config when @hey-api/transformers is enabled with dates: true. Without the transformer, params are typed as string (not Date), so the instanceof Date check would never match at runtime.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3723 +/- ##
==========================================
- Coverage 40.24% 40.21% -0.04%
==========================================
Files 520 520
Lines 19302 19335 +33
Branches 5726 5745 +19
==========================================
+ Hits 7769 7776 +7
- Misses 9337 9348 +11
- Partials 2196 2211 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/spec-types
@hey-api/types
@hey-api/vite-plugin
commit: |

Summary
dates: trueis enabled in@hey-api/transformers, query parameters withformat: dateare typed asDate. Previously,Dateobjects were serialized via.toISOString()producing full timestamps like2025-12-17T00:00:00.000Zinstead of the RFC 3339 full-date2025-12-17.dateoption toQuerySerializerOptionsand emits per-parameter date format hints ({ date: 'date' }or{ date: 'date-time' }) in the SDK codegen.instanceof Datebefore serializing query params, using.toISOString().slice(0, 10)forformat: dateand full.toISOString()forformat: date-time.Test plan
specs/3.1.x/transformers-date-query-params.jsonwith bothdateanddate-timequery params3.1.x.test.ts— verifies generated SDK emitsquerySerializer: { parameters: { stichdatum: { date: 'date' }, timestamp: { date: 'date-time' } } }instanceof Datecheck in generated client codepnpm build,pnpm typecheck, andpnpm lintpassstichdatum=2025-12-17is sent instead ofstichdatum=2025-12-17T00:00:00.000Z