Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tcgc fix uri template #1330

Merged
merged 2 commits into from
Aug 8, 2024
Merged
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/tcgc-fix-uri-template-2024-7-8-15-19-24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

Fix collectionFormat for "csv"
6 changes: 1 addition & 5 deletions packages/typespec-client-generator-core/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,7 @@ function getCollectionFormat(
? getHeaderFieldOptions(program, type)
: undefined
)?.format;
if (
tspCollectionFormat === "form" ||
tspCollectionFormat === "simple" ||
tspCollectionFormat === "csv"
) {
if (tspCollectionFormat === "form" || tspCollectionFormat === "simple") {
return undefined;
}
return tspCollectionFormat;
Expand Down
18 changes: 18 additions & 0 deletions packages/typespec-client-generator-core/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,24 @@ describe("typespec-client-generator-core: package", () => {
strictEqual(queryParm.collectionFormat, "multi");
});

it("query collection format for csv", async () => {
await runner.compile(`@server("http://localhost:3000", "endpoint")
@service({})
namespace My.Service;

#suppress "deprecated" "Legacy test"
op myOp(@query({format: "csv"}) query: string): void;
`);
const sdkPackage = runner.context.sdkPackage;
const method = getServiceMethodOfClient(sdkPackage);
strictEqual(method.kind, "basic");

strictEqual(method.operation.parameters.length, 1);
const queryParm = method.operation.parameters[0];
strictEqual(queryParm.kind, "query");
strictEqual(queryParm.collectionFormat, "csv");
});

it("body basic", async () => {
await runner.compile(`@server("http://localhost:3000", "endpoint")
@service({})
Expand Down
Loading