Skip to content

fix(http-client): serialize style:deepObject query params with bracket notation#150

Open
ToyVo wants to merge 2 commits intobasketry:mainfrom
ToyVo:publish-http-client-0.3.3
Open

fix(http-client): serialize style:deepObject query params with bracket notation#150
ToyVo wants to merge 2 commits intobasketry:mainfrom
ToyVo:publish-http-client-0.3.3

Conversation

@ToyVo
Copy link
Copy Markdown

@ToyVo ToyVo commented May 1, 2026

Problem

Object-typed query parameters (ComplexValue in the Basketry IR) were being passed directly to encodeURIComponent, which:

Fails TypeScript strict type checking — encodeURIComponent only accepts string | number | boolean
Produces [object:Object] at runtime, breaking the actual API call
This affects any OAS spec that uses style: deepObject for query parameters (e.g. filter: Record<string, string> or page: {number?, size?}).

Fix

In buildQuery(), the case undefined: branch now detects object-typed query params by looking up the type via getTypeByName:

Map types (mapProperties) → Object.entries(value).forEach(([key, v]) => query.push(name[key]=v))
Structured object types (properties) → one if (prop !== undefined) query.push(...) per property
Everything else (enum refs, primitives) → unchanged encodeURIComponent(value) path
No IR changes required — detection is purely based on the type structure already present in the service IR.

Tests

Added getGizmosFilter (map type) and getGizmosPage (structured object) to the snapshot IR fixture, covering both deepObject serialization paths. Updated snapshot files accordingly. All 42 test suites pass.

ToyVo added 2 commits May 1, 2026 11:07
…et notation

Object-typed query parameters (ComplexValue with mapProperties or named
properties) were emitting encodeURIComponent(object), which fails TypeScript
strict checks and serializes to [object Object] at runtime.

Fix: detect ComplexValue query params by looking up the type via getTypeByName.
- Map types (mapProperties)  → Object.entries loop → name[key]=value
- Structured types (properties) → per-property checks → name[prop]=value
- Enum refs and other ComplexValues (no matching type) → unchanged scalar path

Adds getGizmosFilter (map) and getGizmosPage (object) to the snapshot IR and
updates the http-client snapshot to cover both deepObject cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant