From 53e3427495958595c15f83f9cf1c78ee76d542fa Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 14 Apr 2023 08:06:39 -0700 Subject: [PATCH 1/2] HotFix: query format not accepting anything other than `csv` and `multi` (#1821) --- .../fix-query-format_2023-04-13-15-20.json | 10 +++++++++ packages/http/src/decorators.ts | 4 +--- packages/http/test/http-decorators.test.ts | 21 +++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json diff --git a/common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json b/common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json new file mode 100644 index 00000000000..3d87b68851e --- /dev/null +++ b/common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@typespec/http", + "comment": "**Fix** query format not accepting anything other than `csv` and `multi`", + "type": "none" + } + ], + "packageName": "@typespec/http" +} \ No newline at end of file diff --git a/packages/http/src/decorators.ts b/packages/http/src/decorators.ts index c7e5506ceaf..bfc5d4523a5 100644 --- a/packages/http/src/decorators.ts +++ b/packages/http/src/decorators.ts @@ -104,9 +104,7 @@ export function $query( } const format = queryNameOrOptions.properties.get("format")?.type; if (format?.kind === "String") { - if (format.value === "multi" || format.value === "csv") { - options.format = format.value; - } + options.format = format.value as any; // That value should have already been validated by the TypeSpec dec } } } diff --git a/packages/http/test/http-decorators.test.ts b/packages/http/test/http-decorators.test.ts index 129c9dc60a3..c43eae583ef 100644 --- a/packages/http/test/http-decorators.test.ts +++ b/packages/http/test/http-decorators.test.ts @@ -210,16 +210,19 @@ describe("http: decorators", () => { strictEqual(getQueryParamName(runner.program, select), "$select"); }); - it("override query with QueryOptions", async () => { - const { selects } = await runner.compile(` - @put op test(@test @query({name: "$select", format: "csv"}) selects: string[]): string; - `); - deepStrictEqual(getQueryParamOptions(runner.program, selects), { - type: "query", - name: "$select", - format: "csv", + describe("change format for array value", () => { + ["csv", "tsv", "ssv", "pipes"].forEach((format) => { + it(`set query format to "${format}"`, async () => { + const { selects } = await runner.compile(` + op test(@test @query({name: "$select", format: "${format}"}) selects: string[]): string; + `); + deepStrictEqual(getQueryParamOptions(runner.program, selects), { + type: "query", + name: "$select", + format, + }); + }); }); - strictEqual(getQueryParamName(runner.program, selects), "$select"); }); }); From ef21823d83e31aa86d5f2e5e75adca79d0e0986d Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 14 Apr 2023 08:24:13 -0700 Subject: [PATCH 2/2] Publish: Http hotfix (#1824) --- .../http/fix-query-format_2023-04-13-15-20.json | 10 ---------- packages/http/CHANGELOG.json | 12 ++++++++++++ packages/http/CHANGELOG.md | 9 ++++++++- packages/http/package.json | 2 +- packages/openapi/package.json | 4 ++-- packages/openapi3/package.json | 4 ++-- packages/playground/package.json | 2 +- packages/rest/package.json | 2 +- packages/samples/package.json | 2 +- packages/website/package.json | 2 +- 10 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json diff --git a/common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json b/common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json deleted file mode 100644 index 3d87b68851e..00000000000 --- a/common/changes/@typespec/http/fix-query-format_2023-04-13-15-20.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@typespec/http", - "comment": "**Fix** query format not accepting anything other than `csv` and `multi`", - "type": "none" - } - ], - "packageName": "@typespec/http" -} \ No newline at end of file diff --git a/packages/http/CHANGELOG.json b/packages/http/CHANGELOG.json index b244f1b5280..b4c6c5418d5 100644 --- a/packages/http/CHANGELOG.json +++ b/packages/http/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@typespec/http", "entries": [ + { + "version": "0.43.1", + "tag": "@typespec/http_v0.43.1", + "date": "Fri, 14 Apr 2023 15:09:01 GMT", + "comments": { + "patch": [ + { + "comment": "**Fix** query format not accepting anything other than `csv` and `multi`" + } + ] + } + }, { "version": "0.43.0", "tag": "@typespec/http_v0.43.0", diff --git a/packages/http/CHANGELOG.md b/packages/http/CHANGELOG.md index 7269fe28f41..81b45449866 100644 --- a/packages/http/CHANGELOG.md +++ b/packages/http/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @typespec/http -This log was last generated on Tue, 11 Apr 2023 18:49:17 GMT and should not be manually modified. +This log was last generated on Fri, 14 Apr 2023 15:09:01 GMT and should not be manually modified. + +## 0.43.1 +Fri, 14 Apr 2023 15:09:01 GMT + +### Patches + +- **Fix** query format not accepting anything other than `csv` and `multi` ## 0.43.0 Tue, 11 Apr 2023 18:49:17 GMT diff --git a/packages/http/package.json b/packages/http/package.json index adcbc5fe1a0..bf2402b3c6e 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http", - "version": "0.43.0", + "version": "0.43.1", "author": "Microsoft Corporation", "description": "TypeSpec HTTP protocol binding", "homepage": "https://github.com/Microsoft/typespec", diff --git a/packages/openapi/package.json b/packages/openapi/package.json index 4393a76b799..059749850c9 100644 --- a/packages/openapi/package.json +++ b/packages/openapi/package.json @@ -53,14 +53,14 @@ ], "peerDependencies": { "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0" }, "devDependencies": { "@types/mocha": "~10.0.0", "@types/node": "~18.11.9", "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0", "@typespec/eslint-config-typespec": "~0.6.0", "@typespec/library-linter": "~0.43.0", diff --git a/packages/openapi3/package.json b/packages/openapi3/package.json index 1f8f37423d5..0a8faee7ff1 100644 --- a/packages/openapi3/package.json +++ b/packages/openapi3/package.json @@ -57,7 +57,7 @@ "peerDependencies": { "@typespec/versioning": "~0.43.0", "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0", "@typespec/openapi": "~0.43.0" }, @@ -66,7 +66,7 @@ "@types/node": "~18.11.9", "@types/js-yaml": "~4.0.1", "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0", "@typespec/openapi": "~0.43.0", "@typespec/versioning": "~0.43.0", diff --git a/packages/playground/package.json b/packages/playground/package.json index c1dacbca187..f86bbff253c 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -43,7 +43,7 @@ "dependencies": { "@typespec/versioning": "~0.43.0", "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0", "@typespec/openapi3": "~0.43.0", "@typespec/openapi": "~0.43.0", diff --git a/packages/rest/package.json b/packages/rest/package.json index bddd20eb06d..a12a94ee3e2 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -58,7 +58,7 @@ "@types/mocha": "~10.0.0", "@types/node": "~18.11.9", "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/eslint-config-typespec": "~0.6.0", "@typespec/library-linter": "~0.43.0", "@typespec/eslint-plugin": "~0.43.0", diff --git a/packages/samples/package.json b/packages/samples/package.json index cd8c2f478f6..0402f65b569 100644 --- a/packages/samples/package.json +++ b/packages/samples/package.json @@ -36,7 +36,7 @@ "dependencies": { "@typespec/versioning": "~0.43.0", "@typespec/compiler": "~0.43.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0", "@typespec/openapi": "~0.43.0", "@typespec/openapi3": "~0.43.0", diff --git a/packages/website/package.json b/packages/website/package.json index 2d41a5bc027..7137860fd85 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -33,7 +33,7 @@ "devDependencies": { "@typespec/ref-doc": "~0.1.0", "@typespec/spec": "0.1.0", - "@typespec/http": "~0.43.0", + "@typespec/http": "~0.43.1", "@typespec/rest": "~0.43.0", "@typespec/openapi": "~0.43.0", "@typespec/versioning": "~0.43.0",