Skip to content

Commit

Permalink
[@typespec/http-specs] Fixed paths in specs/routes (#5717)
Browse files Browse the repository at this point in the history
Fixes the Issue #5430.
  • Loading branch information
sarangan12 authored Jan 23, 2025
1 parent 8567833 commit 732db95
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 49 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/Issue5430-2025-0-23-10-22-11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-specs"
---

Fixed paths in the specs/routes.
6 changes: 6 additions & 0 deletions packages/http-specs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/http-specs/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
48 changes: 24 additions & 24 deletions packages/http-specs/specs/routes/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<int32>): void;
Expand Down
48 changes: 24 additions & 24 deletions packages/http-specs/specs/routes/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 732db95

Please sign in to comment.