Describe the bug
When a TypeSpec operation uses bracket notation in @query (common for JSON:API style APIs), the http-client-js emitter generates a URI template with percent-encoded variable names (filter%5BisActive%5D) but uses camelCase property names (filterIsActive) as the expand object keys. Since these don't match, uri-template's parse().expand() silently drops the query parameters from the URL.
Reproduction
TypeSpec definition:
model ClientFilterParams {
@query("filter[isActive]") filterIsActive?: boolean;
@query("page[number]") pageNumber?: int32;
}
Generated code (clientsClientOperations.ts):
const path = parse("/api/v1/clients{?filter%5BisActive%5D,page%5Bnumber%5D}").expand({
...(options?.filterIsActive && { filterIsActive: options.filterIsActive }),
...(options?.pageNumber && { pageNumber: options.pageNumber }),
});
The template variable names are filter%5BisActive%5D and page%5Bnumber%5D, but the expand keys are filterIsActive and pageNumber. The uri-template library requires these to match.
Expected: expand keys should use the encoded names:
const path = parse("/api/v1/clients{?filter%5BisActive%5D,page%5Bnumber%5D}").expand({
...(options?.filterIsActive && { "filter%5BisActive%5D": options.filterIsActive }),
...(options?.pageNumber && { "page%5Bnumber%5D": options.pageNumber }),
});
Result: Query parameters like filter[isActive]=true and page[number]=1 are silently dropped from the URL.
Versions: @typespec/http-client-js@0.14.1, @typespec/compiler@1.10.0
Checklist
Describe the bug
When a TypeSpec operation uses bracket notation in
@query(common for JSON:API style APIs), thehttp-client-jsemitter generates a URI template with percent-encoded variable names (filter%5BisActive%5D) but uses camelCase property names (filterIsActive) as the expand object keys. Since these don't match,uri-template'sparse().expand()silently drops the query parameters from the URL.Reproduction
TypeSpec definition:
Generated code (
clientsClientOperations.ts):The template variable names are
filter%5BisActive%5Dandpage%5Bnumber%5D, but the expand keys arefilterIsActiveandpageNumber. Theuri-templatelibrary requires these to match.Expected: expand keys should use the encoded names:
Result: Query parameters like
filter[isActive]=trueandpage[number]=1are silently dropped from the URL.Versions:
@typespec/http-client-js@0.14.1,@typespec/compiler@1.10.0Checklist