From 732db95a893133806ecdb7c42e6e8f96ab935bcf Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 23 Jan 2025 10:49:09 -0800 Subject: [PATCH] [@typespec/http-specs] Fixed paths in specs/routes (#5717) Fixes the Issue https://github.com/microsoft/typespec/issues/5430. --- .../changes/Issue5430-2025-0-23-10-22-11.md | 7 +++ packages/http-specs/CHANGELOG.md | 6 +++ packages/http-specs/package.json | 2 +- packages/http-specs/specs/routes/main.tsp | 48 +++++++++---------- packages/http-specs/specs/routes/mockapi.ts | 48 +++++++++---------- 5 files changed, 62 insertions(+), 49 deletions(-) create mode 100644 .chronus/changes/Issue5430-2025-0-23-10-22-11.md diff --git a/.chronus/changes/Issue5430-2025-0-23-10-22-11.md b/.chronus/changes/Issue5430-2025-0-23-10-22-11.md new file mode 100644 index 0000000000..cd427533b9 --- /dev/null +++ b/.chronus/changes/Issue5430-2025-0-23-10-22-11.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-specs" +--- + +Fixed paths in the specs/routes. \ No newline at end of file diff --git a/packages/http-specs/CHANGELOG.md b/packages/http-specs/CHANGELOG.md index a1cb3b80a1..e530ca5869 100644 --- a/packages/http-specs/CHANGELOG.md +++ b/packages/http-specs/CHANGELOG.md @@ -1,5 +1,11 @@ # @typespec/http-specs +## 0.1.0-alpha.8 + +### Bug Fixes + +- [#5717](https://github.com/microsoft/typespec/pull/5717) Fixed paths in the specs/routes. + ## 0.1.0-alpha.7 No changes, version bump only. diff --git a/packages/http-specs/package.json b/packages/http-specs/package.json index d1c5d56efc..7169e4e0f6 100644 --- a/packages/http-specs/package.json +++ b/packages/http-specs/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-specs", - "version": "0.1.0-alpha.7", + "version": "0.1.0-alpha.8", "description": "Spec scenarios and mock apis", "main": "dist/index.js", "type": "module", diff --git a/packages/http-specs/specs/routes/main.tsp b/packages/http-specs/specs/routes/main.tsp index 9364b1aa81..5881b03d97 100644 --- a/packages/http-specs/specs/routes/main.tsp +++ b/packages/http-specs/specs/routes/main.tsp @@ -87,7 +87,7 @@ namespace PathParameters { @scenarioDoc(""" Test simple expansion with explode: false when passed a primitive value. Param value: "a" - Expected path: /routes/simple/standard/primitivea + Expected path: /routes/path/simple/standard/primitivea """) @route("primitive{param}") op primitive(param: string): void; @@ -96,7 +96,7 @@ namespace PathParameters { @scenarioDoc(""" Test simple expansion with explode: false when passed an array value. Param value: ["a","b"] - Expected path: /routes/simple/standard/arraya,b + Expected path: /routes/path/simple/standard/arraya,b """) @route("array{param}") op array(param: string[]): void; @@ -105,7 +105,7 @@ namespace PathParameters { @scenarioDoc(""" Test simple expansion with explode: false when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/simple/standard/recorda,1,b,2 + Expected path: /routes/path/simple/standard/recorda,1,b,2 """) @route("record{param}") op record(param: Record): void; @@ -117,7 +117,7 @@ namespace PathParameters { @scenarioDoc(""" Test simple expansion with explode: true when passed a primitive value. Param value: "a" - Expected path: /routes/simple/explode/primitivea + Expected path: /routes/path/simple/explode/primitivea """) @route("primitive{param*}") op primitive(param: string): void; @@ -126,7 +126,7 @@ namespace PathParameters { @scenarioDoc(""" Test simple expansion with explode: true when passed an array value. Param value: ["a","b"] - Expected path: /routes/simple/explode/arraya.b + Expected path: /routes/path/simple/explode/arraya.b """) @route("array{param*}") op array(param: string[]): void; @@ -135,7 +135,7 @@ namespace PathParameters { @scenarioDoc(""" Test simple expansion with explode: true when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/simple/explode/recorda=1,b=2 + Expected path: /routes/path/simple/explode/recorda=1,b=2 """) @route("record{param*}") op record(param: Record): void; @@ -150,7 +150,7 @@ namespace PathParameters { @scenarioDoc(""" Test path expansion with explode: false when passed a primitive value. Param value: "a" - Expected path: /routes/path/standard/primitive/a + Expected path: /routes/path/path/standard/primitive/a """) @route("primitive{/param}") op primitive(param: string): void; @@ -159,7 +159,7 @@ namespace PathParameters { @scenarioDoc(""" Test path expansion with explode: false when passed an array value. Param value: ["a","b"] - Expected path: /routes/path/standard/array/a,b + Expected path: /routes/path/path/standard/array/a,b """) @route("array{/param}") op array(param: string[]): void; @@ -168,7 +168,7 @@ namespace PathParameters { @scenarioDoc(""" Test path expansion with explode: false when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/path/standard/record/a,1,b,2 + Expected path: /routes/path/path/standard/record/a,1,b,2 """) @route("record{/param}") op record(param: Record): void; @@ -180,7 +180,7 @@ namespace PathParameters { @scenarioDoc(""" Test path expansion with explode: true when passed a primitive value. Param value: "a" - Expected path: /routes/path/explode/primitive/a + Expected path: /routes/path/path/explode/primitive/a """) @route("primitive{/param*}") op primitive(param: string): void; @@ -189,7 +189,7 @@ namespace PathParameters { @scenarioDoc(""" Test path expansion with explode: true when passed an array value. Param value: ["a","b"] - Expected path: /routes/path/explode/array/a/b + Expected path: /routes/path/path/explode/array/a/b """) @route("array{/param*}") op array(param: string[]): void; @@ -198,7 +198,7 @@ namespace PathParameters { @scenarioDoc(""" Test path expansion with explode: true when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/path/explode/record/a=1/b=2 + Expected path: /routes/path/path/explode/record/a=1/b=2 """) @route("record{/param*}") op record(param: Record): void; @@ -213,7 +213,7 @@ namespace PathParameters { @scenarioDoc(""" Test label expansion with explode: false when passed a primitive value. Param value: "a" - Expected path: /routes/label/standard/primitive.a + Expected path: /routes/path/label/standard/primitive.a """) @route("primitive{.param}") op primitive(param: string): void; @@ -222,7 +222,7 @@ namespace PathParameters { @scenarioDoc(""" Test label expansion with explode: false when passed an array value. Param value: ["a","b"] - Expected path: /routes/label/standard/array.a,b + Expected path: /routes/path/label/standard/array.a,b """) @route("array{.param}") op array(param: string[]): void; @@ -231,7 +231,7 @@ namespace PathParameters { @scenarioDoc(""" Test label expansion with explode: false when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/label/standard/record.a,1,b,2 + Expected path: /routes/path/label/standard/record.a,1,b,2 """) @route("record{.param}") op record(param: Record): void; @@ -243,7 +243,7 @@ namespace PathParameters { @scenarioDoc(""" Test label expansion with explode: true when passed a primitive value. Param value: "a" - Expected path: /routes/label/explode/primitive.a + Expected path: /routes/path/label/explode/primitive.a """) @route("primitive{.param*}") op primitive(param: string): void; @@ -252,7 +252,7 @@ namespace PathParameters { @scenarioDoc(""" Test label expansion with explode: true when passed an array value. Param value: ["a","b"] - Expected path: /routes/label/explode/array.a.b + Expected path: /routes/path/label/explode/array.a.b """) @route("array{.param*}") op array(param: string[]): void; @@ -261,7 +261,7 @@ namespace PathParameters { @scenarioDoc(""" Test label expansion with explode: true when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/label/explode/record.a=1.b=2 + Expected path: /routes/path/label/explode/record.a=1.b=2 """) @route("record{.param*}") op record(param: Record): void; @@ -276,7 +276,7 @@ namespace PathParameters { @scenarioDoc(""" Test matrix expansion with explode: false when passed a primitive value. Param value: "a" - Expected path: /routes/matrix/standard/primitive;a + Expected path: /routes/path/matrix/standard/primitive;a """) @route("primitive{;param}") op primitive(param: string): void; @@ -285,7 +285,7 @@ namespace PathParameters { @scenarioDoc(""" Test matrix expansion with explode: false when passed an array value. Param value: ["a","b"] - Expected path: /routes/matrix/standard/array;a,b + Expected path: /routes/path/matrix/standard/array;a,b """) @route("array{;param}") op array(param: string[]): void; @@ -294,7 +294,7 @@ namespace PathParameters { @scenarioDoc(""" Test matrix expansion with explode: false when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/matrix/standard/record;a,1,b,2 + Expected path: /routes/path/matrix/standard/record;a,1,b,2 """) @route("record{;param}") op record(param: Record): void; @@ -306,7 +306,7 @@ namespace PathParameters { @scenarioDoc(""" Test matrix expansion with explode: true when passed a primitive value. Param value: "a" - Expected path: /routes/matrix/explode/primitive;a + Expected path: /routes/path/matrix/explode/primitive;a """) @route("primitive{;param*}") op primitive(param: string): void; @@ -315,7 +315,7 @@ namespace PathParameters { @scenarioDoc(""" Test matrix expansion with explode: true when passed an array value. Param value: ["a","b"] - Expected path: /routes/matrix/explode/array;a.b + Expected path: /routes/path/matrix/explode/array;a.b """) @route("array{;param*}") op array(param: string[]): void; @@ -324,7 +324,7 @@ namespace PathParameters { @scenarioDoc(""" Test matrix expansion with explode: true when passed a record value. Param value: {a: 1, b: 2} - Expected path: /routes/matrix/explode/record;a=1;b=2 + Expected path: /routes/path/matrix/explode/record;a=1;b=2 """) @route("record{;param*}") op record(param: Record): void; diff --git a/packages/http-specs/specs/routes/mockapi.ts b/packages/http-specs/specs/routes/mockapi.ts index b1a8013c4e..b1ce8c36cb 100644 --- a/packages/http-specs/specs/routes/mockapi.ts +++ b/packages/http-specs/specs/routes/mockapi.ts @@ -61,76 +61,76 @@ Scenarios.Routes_PathParameters_ReservedExpansion_annotation = createTests( "/routes/path/reserved-expansion/annotation/foo/bar%20baz", ); Scenarios.Routes_PathParameters_SimpleExpansion_Standard_primitive = createTests( - "/routes/simple/standard/primitivea", + "/routes/path/simple/standard/primitivea", ); Scenarios.Routes_PathParameters_SimpleExpansion_Standard_array = createTests( - "/routes/simple/standard/arraya,b", + "/routes/path/simple/standard/arraya,b", ); Scenarios.Routes_PathParameters_SimpleExpansion_Standard_record = createTests( - "/routes/simple/standard/recorda,1,b,2", + "/routes/path/simple/standard/recorda,1,b,2", ); Scenarios.Routes_PathParameters_SimpleExpansion_Explode_primitive = createTests( - "/routes/simple/standard/primitivea", + "/routes/path/simple/standard/primitivea", ); Scenarios.Routes_PathParameters_SimpleExpansion_Explode_array = createTests( - "/routes/simple/standard/arraya,b", + "/routes/path/simple/standard/arraya,b", ); Scenarios.Routes_PathParameters_SimpleExpansion_Explode_record = createTests( - "/routes/simple/standard/recorda=1,b=2", + "/routes/path/simple/standard/recorda=1,b=2", ); Scenarios.Routes_PathParameters_PathExpansion_Standard_primitive = createTests( - "/routes/path/standard/primitive/a", + "/routes/path/path/standard/primitive/a", ); Scenarios.Routes_PathParameters_PathExpansion_Standard_array = createTests( - "/routes/path/standard/array/a,b", + "/routes/path/path/standard/array/a,b", ); Scenarios.Routes_PathParameters_PathExpansion_Standard_record = createTests( - "/routes/path/standard/record/a,1,b,2", + "/routes/path/path/standard/record/a,1,b,2", ); Scenarios.Routes_PathParameters_PathExpansion_Explode_primitive = createTests( - "/routes/path/standard/primitive/a", + "/routes/path/path/standard/primitive/a", ); Scenarios.Routes_PathParameters_PathExpansion_Explode_array = createTests( - "/routes/path/standard/array/a/b", + "/routes/path/path/standard/array/a/b", ); Scenarios.Routes_PathParameters_PathExpansion_Explode_record = createTests( - "/routes/path/standard/record/a=1/b=2", + "/routes/path/path/standard/record/a=1/b=2", ); Scenarios.Routes_PathParameters_LabelExpansion_Standard_primitive = createTests( - "/routes/label/standard/primitive.a", + "/routes/path/label/standard/primitive.a", ); Scenarios.Routes_PathParameters_LabelExpansion_Standard_array = createTests( - "/routes/label/standard/array.a,b", + "/routes/path/label/standard/array.a,b", ); Scenarios.Routes_PathParameters_LabelExpansion_Standard_record = createTests( - "/routes/label/standard/record.a,1,b,2", + "/routes/path/label/standard/record.a,1,b,2", ); Scenarios.Routes_PathParameters_LabelExpansion_Explode_primitive = createTests( - "/routes/label/standard/primitive.a", + "/routes/path/label/standard/primitive.a", ); Scenarios.Routes_PathParameters_LabelExpansion_Explode_array = createTests( - "/routes/label/standard/array.a.b", + "/routes/path/label/standard/array.a.b", ); Scenarios.Routes_PathParameters_LabelExpansion_Explode_record = createTests( - "/routes/label/standard/record.a=1.b=2", + "/routes/path/label/standard/record.a=1.b=2", ); Scenarios.Routes_PathParameters_MatrixExpansion_Standard_primitive = createTests( - "/routes/matrix/standard/primitive;a", + "/routes/path/matrix/standard/primitive;a", ); Scenarios.Routes_PathParameters_MatrixExpansion_Standard_array = createTests( - "/routes/matrix/standard/array;a,b", + "/routes/path/matrix/standard/array;a,b", ); Scenarios.Routes_PathParameters_MatrixExpansion_Standard_record = createTests( - "/routes/matrix/standard/record;a,1,b,2", + "/routes/path/matrix/standard/record;a,1,b,2", ); Scenarios.Routes_PathParameters_MatrixExpansion_Explode_primitive = createTests( - "/routes/matrix/standard/primitive;a", + "/routes/path/matrix/standard/primitive;a", ); Scenarios.Routes_PathParameters_MatrixExpansion_Explode_array = createTests( - "/routes/matrix/standard/array;a;b", + "/routes/path/matrix/standard/array;a;b", ); Scenarios.Routes_PathParameters_MatrixExpansion_Explode_record = createTests( - "/routes/matrix/standard/record;a=1;b=2", + "/routes/path/matrix/standard/record;a=1;b=2", ); Scenarios.Routes_QueryParameters_templateOnly = createTests("/routes/query/template-only?param=a"); Scenarios.Routes_QueryParameters_explicit = createTests("/routes/query/explicit?param=a");