WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/query-list-parameter-2025-12-17-23-13-48.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/http-specs"
---

Add test for query parameter with list/array type to verify CSV serialization
8 changes: 8 additions & 0 deletions packages/http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,14 @@ Second request path:

Expect to handle a constant value for query and mock api returns nothing

### Parameters_Query_QueryList_post

- Endpoint: `post /parameters/query/list`

Expect to handle a list of values for query parameter.
The list should be serialized as CSV (comma-separated values).
Pass array ["a", "b", "c"] and expect it to be serialized as "a,b,c".

### Parameters_Spread_Alias_spreadAsRequestBody

- Endpoint: `put /parameters/spread/alias/request-body`
Expand Down
17 changes: 17 additions & 0 deletions packages/http-specs/specs/parameters/query/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ interface Constant {
queryParam: "constantValue",
): void;
}

@doc("List query parameter verification")
@route("/list")
interface QueryList {
/** send list query parameter */
@scenario
@scenarioDoc("""
Expect to handle a list of values for query parameter.
The list should be serialized as CSV (comma-separated values).
Pass array ["a", "b", "c"] and expect it to be serialized as "a,b,c".
""")
@post
post(
@query
listParameter: string[],
): void;
}
12 changes: 12 additions & 0 deletions packages/http-specs/specs/parameters/query/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ Scenarios.Parameters_Query_Constant_post = passOnSuccess({
},
kind: "MockApiDefinition",
});

Scenarios.Parameters_Query_QueryList_post = passOnSuccess({
uri: "/parameters/query/list",
method: `post`,
request: {
query: { listParameter: "a,b,c" },
},
response: {
status: 204,
},
kind: "MockApiDefinition",
});
Loading