fix(sdk): add 'deepObject' to ArrayStyle to fix compile error with array query parameters#3818
Conversation
|
|
|
Someone 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 — When an OpenAPI spec declares Key changes
Summary | 20 files | 2 commits | base:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3818 +/- ##
==========================================
+ Coverage 39.58% 39.74% +0.16%
==========================================
Files 532 532
Lines 19581 19581
Branches 5835 5829 -6
==========================================
+ Hits 7751 7783 +32
+ Misses 9582 9557 -25
+ Partials 2248 2241 -7
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:
|
There was a problem hiding this comment.
Reviewed — no issues found.
The fix correctly normalizes deepObject to form for array/tuple query parameters before evaluating whether a serializer override is needed. This matches the OpenAPI spec (deepObject is only defined for object-typed parameters) and avoids emitting style: 'deepObject' which is not assignable to the client SDK's ArrayStyle type. The arrayStyle local variable is cleanly threaded through both the guard condition and the style emission, so both explode: true (skip override entirely) and explode: false (emit only { explode: false }) cases are handled correctly.
Task list (6/6 completed)
- Read the PR description and diff overview
- Review the core logic change in operation.ts
- Review the test spec and test registration
- Review generated snapshot files for correctness
- Verify against OpenAPI 3.1 spec behavior for deepObject + arrays
- Self-critique and submit review
@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: |
|
@mrlubos I really need this fix, could you check it? |
5f801ff to
9876b05
Compare
46cdd28 to
da11892
Compare
da11892 to
1d69355
Compare
…back to 'form' When an array query parameter has `style: deepObject` the generator was emitting `style: 'deepObject'` in sdk.gen.ts, but `ArrayStyle` in every client bundle did not include that value, causing a TypeScript compile error in the generated output. The correct fix is to add `'deepObject'` to the `ArrayStyle` union in all client bundles (client-core, client-nuxt, client-next, client-angular, custom-client). The generator now faithfully preserves the style from the spec. Users who need bracket notation serialisation (products[0]=...) can supply a custom `querySerializer`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1d69355 to
3b0134f
Compare

Summary
style: 'deepObject'insdk.gen.tsfor array/tuple query parameters that carrystyle: deepObjectin the spec. However,ArrayStylewas defined as'form' | 'spaceDelimited' | 'pipeDelimited'—'deepObject'was missing from the union — so the generated code failed TypeScript compilation withType '"deepObject"' is not assignable to type 'ArrayStyle | undefined'.deepObjectwithformin the generator. This broke real-world serialisation — backends like Laravel/PHP that usestyle: deepObjecton arrays expectproducts[0]=...&products[1]=...bracket notation, not plainformstyle.'deepObject'to theArrayStyleunion in every client bundle. The generator already emits the right thing; the type just didn't cover it. Users who need bracket notation can pass a customquerySerializer.Changes
packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/pathSerializer.ts'deepObject'to exportedArrayStyle(inherited by fetch/axios/ky/ofetch clients)packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/types.ts'deepObject'to localArrayStylepackages/openapi-ts/src/plugins/@hey-api/client-next/bundle/utils.ts'deepObject'to localArrayStylepackages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts'deepObject'to localArrayStylepackages/custom-client/src/core/pathSerializer.ts+utils.ts'deepObject'toArrayStylepackages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.tsstyle: 'deepObject'as-isspecs/3.1.x/parameter-array-deep-object.jsonGET /foowithproductsarray param +style: deepObjectpackages/openapi-ts-tests/main/test/3.1.x.test.tssdk.gen.tsnow assertsstyle: 'deepObject'is presentpackages/openapi-ts-tests/main/test/__snapshots__/…pathSerializer.gen.tseverywhere reflects the widerArrayStyletypeTest plan
'handles array query parameter with deepObject style'passes and assertsstyle: 'deepObject'is emitted insdk.gen.tspnpm typecheckexits cleanCloses #3868
🤖 Generated with Claude Code