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 10 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)
|
🦋 Changeset detectedLatest commit: 383f420 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@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 | 583 files | 10 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.
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.07% 39.90% -0.17%
==========================================
Files 522 530 +8
Lines 19311 19507 +196
Branches 5766 5832 +66
==========================================
+ Hits 7738 7784 +46
- Misses 9371 9489 +118
- Partials 2202 2234 +32
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: |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…params snapshot Update snapshot to match upstream main change from hey-api#3757 which adds headers: Headers to ResolvedRequestOptions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…remaining clients Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Dear @mrlubos |

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