@typespec/http-specs 0.1.0-alpha.1 → 0.1.0-alpha.10-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/specs/authentication/api-key/mockapi.js +1 -1
- package/dist/specs/authentication/api-key/mockapi.js.map +1 -1
- package/dist/specs/helper.d.ts +2 -2
- package/dist/specs/helper.d.ts.map +1 -1
- package/dist/specs/payload/pageable/mockapi.d.ts.map +1 -0
- package/dist/specs/payload/pageable/mockapi.js +48 -0
- package/dist/specs/payload/pageable/mockapi.js.map +1 -0
- package/dist/specs/response/status-code-range/mockapi.d.ts +3 -0
- package/dist/specs/response/status-code-range/mockapi.d.ts.map +1 -0
- package/dist/specs/response/status-code-range/mockapi.js +33 -0
- package/dist/specs/response/status-code-range/mockapi.js.map +1 -0
- package/dist/specs/routes/mockapi.js +24 -24
- package/dist/specs/routes/mockapi.js.map +1 -1
- package/dist/specs/type/dictionary/mockapi.js +6 -0
- package/dist/specs/type/dictionary/mockapi.js.map +1 -1
- package/dist/specs/type/property/additional-properties/mockapi.d.ts.map +1 -1
- package/dist/specs/type/property/additional-properties/mockapi.js +7 -0
- package/dist/specs/type/property/additional-properties/mockapi.js.map +1 -1
- package/dist/specs/type/property/nullable/mockapi.js +9 -0
- package/dist/specs/type/property/nullable/mockapi.js.map +1 -1
- package/dist/specs/type/property/optionality/mockapi.js +6 -0
- package/dist/specs/type/property/optionality/mockapi.js.map +1 -1
- package/dist/specs/type/property/value-types/mockapi.js +6 -0
- package/dist/specs/type/property/value-types/mockapi.js.map +1 -1
- package/dist/specs/versioning/removed/mockapi.js +44 -0
- package/dist/specs/versioning/removed/mockapi.js.map +1 -1
- package/package.json +15 -13
- package/spec-summary.md +136 -95
- package/specs/authentication/api-key/mockapi.ts +1 -1
- package/specs/payload/pageable/main.tsp +55 -0
- package/specs/payload/pageable/mockapi.ts +49 -0
- package/specs/response/status-code-range/main.tsp +82 -0
- package/specs/response/status-code-range/mockapi.ts +35 -0
- package/specs/routes/main.tsp +24 -24
- package/specs/routes/mockapi.ts +24 -24
- package/specs/type/dictionary/mockapi.ts +6 -0
- package/specs/type/model/visibility/main.tsp +9 -5
- package/specs/type/property/additional-properties/mockapi.ts +8 -1
- package/specs/type/property/nullable/mockapi.ts +9 -0
- package/specs/type/property/optionality/mockapi.ts +6 -0
- package/specs/type/property/value-types/mockapi.ts +6 -0
- package/specs/versioning/removed/main.tsp +63 -1
- package/specs/versioning/removed/mockapi.ts +47 -0
- package/temp/.tsbuildinfo +1 -1
- package/dist/specs/type/model/templated/mockapi.d.ts.map +0 -1
- package/dist/specs/type/model/templated/mockapi.js +0 -63
- package/dist/specs/type/model/templated/mockapi.js.map +0 -1
- package/specs/type/model/templated/main.tsp +0 -130
- package/specs/type/model/templated/mockapi.ts +0 -66
- /package/dist/specs/{type/model/templated → payload/pageable}/mockapi.d.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
|
|
2
|
+
|
|
3
|
+
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
|
4
|
+
|
|
5
|
+
Scenarios.Response_StatusCodeRange_errorResponseStatusCodeInRange = passOnSuccess({
|
|
6
|
+
uri: "/response/status-code-range/error-response-status-code-in-range",
|
|
7
|
+
method: "get",
|
|
8
|
+
request: {
|
|
9
|
+
status: 494,
|
|
10
|
+
},
|
|
11
|
+
response: {
|
|
12
|
+
status: 494,
|
|
13
|
+
body: json({
|
|
14
|
+
code: "request-header-too-large",
|
|
15
|
+
message: "Request header too large",
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
kind: "MockApiDefinition",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
Scenarios.Response_StatusCodeRange_errorResponseStatusCode404 = passOnSuccess({
|
|
22
|
+
uri: "/response/status-code-range/error-response-status-code-404",
|
|
23
|
+
method: "get",
|
|
24
|
+
request: {
|
|
25
|
+
status: 404,
|
|
26
|
+
},
|
|
27
|
+
response: {
|
|
28
|
+
status: 404,
|
|
29
|
+
body: json({
|
|
30
|
+
code: "not-found",
|
|
31
|
+
resourceId: "resource1",
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
kind: "MockApiDefinition",
|
|
35
|
+
});
|
package/specs/routes/main.tsp
CHANGED
|
@@ -87,7 +87,7 @@ namespace PathParameters {
|
|
|
87
87
|
@scenarioDoc("""
|
|
88
88
|
Test simple expansion with explode: false when passed a primitive value.
|
|
89
89
|
Param value: "a"
|
|
90
|
-
Expected path: /routes/simple/standard/primitivea
|
|
90
|
+
Expected path: /routes/path/simple/standard/primitivea
|
|
91
91
|
""")
|
|
92
92
|
@route("primitive{param}")
|
|
93
93
|
op primitive(param: string): void;
|
|
@@ -96,7 +96,7 @@ namespace PathParameters {
|
|
|
96
96
|
@scenarioDoc("""
|
|
97
97
|
Test simple expansion with explode: false when passed an array value.
|
|
98
98
|
Param value: ["a","b"]
|
|
99
|
-
Expected path: /routes/simple/standard/arraya,b
|
|
99
|
+
Expected path: /routes/path/simple/standard/arraya,b
|
|
100
100
|
""")
|
|
101
101
|
@route("array{param}")
|
|
102
102
|
op array(param: string[]): void;
|
|
@@ -105,7 +105,7 @@ namespace PathParameters {
|
|
|
105
105
|
@scenarioDoc("""
|
|
106
106
|
Test simple expansion with explode: false when passed a record value.
|
|
107
107
|
Param value: {a: 1, b: 2}
|
|
108
|
-
Expected path: /routes/simple/standard/recorda,1,b,2
|
|
108
|
+
Expected path: /routes/path/simple/standard/recorda,1,b,2
|
|
109
109
|
""")
|
|
110
110
|
@route("record{param}")
|
|
111
111
|
op record(param: Record<int32>): void;
|
|
@@ -117,7 +117,7 @@ namespace PathParameters {
|
|
|
117
117
|
@scenarioDoc("""
|
|
118
118
|
Test simple expansion with explode: true when passed a primitive value.
|
|
119
119
|
Param value: "a"
|
|
120
|
-
Expected path: /routes/simple/explode/primitivea
|
|
120
|
+
Expected path: /routes/path/simple/explode/primitivea
|
|
121
121
|
""")
|
|
122
122
|
@route("primitive{param*}")
|
|
123
123
|
op primitive(param: string): void;
|
|
@@ -126,7 +126,7 @@ namespace PathParameters {
|
|
|
126
126
|
@scenarioDoc("""
|
|
127
127
|
Test simple expansion with explode: true when passed an array value.
|
|
128
128
|
Param value: ["a","b"]
|
|
129
|
-
Expected path: /routes/simple/explode/arraya.b
|
|
129
|
+
Expected path: /routes/path/simple/explode/arraya.b
|
|
130
130
|
""")
|
|
131
131
|
@route("array{param*}")
|
|
132
132
|
op array(param: string[]): void;
|
|
@@ -135,7 +135,7 @@ namespace PathParameters {
|
|
|
135
135
|
@scenarioDoc("""
|
|
136
136
|
Test simple expansion with explode: true when passed a record value.
|
|
137
137
|
Param value: {a: 1, b: 2}
|
|
138
|
-
Expected path: /routes/simple/explode/recorda=1,b=2
|
|
138
|
+
Expected path: /routes/path/simple/explode/recorda=1,b=2
|
|
139
139
|
""")
|
|
140
140
|
@route("record{param*}")
|
|
141
141
|
op record(param: Record<int32>): void;
|
|
@@ -150,7 +150,7 @@ namespace PathParameters {
|
|
|
150
150
|
@scenarioDoc("""
|
|
151
151
|
Test path expansion with explode: false when passed a primitive value.
|
|
152
152
|
Param value: "a"
|
|
153
|
-
Expected path: /routes/path/standard/primitive/a
|
|
153
|
+
Expected path: /routes/path/path/standard/primitive/a
|
|
154
154
|
""")
|
|
155
155
|
@route("primitive{/param}")
|
|
156
156
|
op primitive(param: string): void;
|
|
@@ -159,7 +159,7 @@ namespace PathParameters {
|
|
|
159
159
|
@scenarioDoc("""
|
|
160
160
|
Test path expansion with explode: false when passed an array value.
|
|
161
161
|
Param value: ["a","b"]
|
|
162
|
-
Expected path: /routes/path/standard/array/a,b
|
|
162
|
+
Expected path: /routes/path/path/standard/array/a,b
|
|
163
163
|
""")
|
|
164
164
|
@route("array{/param}")
|
|
165
165
|
op array(param: string[]): void;
|
|
@@ -168,7 +168,7 @@ namespace PathParameters {
|
|
|
168
168
|
@scenarioDoc("""
|
|
169
169
|
Test path expansion with explode: false when passed a record value.
|
|
170
170
|
Param value: {a: 1, b: 2}
|
|
171
|
-
Expected path: /routes/path/standard/record/a,1,b,2
|
|
171
|
+
Expected path: /routes/path/path/standard/record/a,1,b,2
|
|
172
172
|
""")
|
|
173
173
|
@route("record{/param}")
|
|
174
174
|
op record(param: Record<int32>): void;
|
|
@@ -180,7 +180,7 @@ namespace PathParameters {
|
|
|
180
180
|
@scenarioDoc("""
|
|
181
181
|
Test path expansion with explode: true when passed a primitive value.
|
|
182
182
|
Param value: "a"
|
|
183
|
-
Expected path: /routes/path/explode/primitive/a
|
|
183
|
+
Expected path: /routes/path/path/explode/primitive/a
|
|
184
184
|
""")
|
|
185
185
|
@route("primitive{/param*}")
|
|
186
186
|
op primitive(param: string): void;
|
|
@@ -189,7 +189,7 @@ namespace PathParameters {
|
|
|
189
189
|
@scenarioDoc("""
|
|
190
190
|
Test path expansion with explode: true when passed an array value.
|
|
191
191
|
Param value: ["a","b"]
|
|
192
|
-
Expected path: /routes/path/explode/array/a/b
|
|
192
|
+
Expected path: /routes/path/path/explode/array/a/b
|
|
193
193
|
""")
|
|
194
194
|
@route("array{/param*}")
|
|
195
195
|
op array(param: string[]): void;
|
|
@@ -198,7 +198,7 @@ namespace PathParameters {
|
|
|
198
198
|
@scenarioDoc("""
|
|
199
199
|
Test path expansion with explode: true when passed a record value.
|
|
200
200
|
Param value: {a: 1, b: 2}
|
|
201
|
-
Expected path: /routes/path/explode/record/a=1/b=2
|
|
201
|
+
Expected path: /routes/path/path/explode/record/a=1/b=2
|
|
202
202
|
""")
|
|
203
203
|
@route("record{/param*}")
|
|
204
204
|
op record(param: Record<int32>): void;
|
|
@@ -213,7 +213,7 @@ namespace PathParameters {
|
|
|
213
213
|
@scenarioDoc("""
|
|
214
214
|
Test label expansion with explode: false when passed a primitive value.
|
|
215
215
|
Param value: "a"
|
|
216
|
-
Expected path: /routes/label/standard/primitive.a
|
|
216
|
+
Expected path: /routes/path/label/standard/primitive.a
|
|
217
217
|
""")
|
|
218
218
|
@route("primitive{.param}")
|
|
219
219
|
op primitive(param: string): void;
|
|
@@ -222,7 +222,7 @@ namespace PathParameters {
|
|
|
222
222
|
@scenarioDoc("""
|
|
223
223
|
Test label expansion with explode: false when passed an array value.
|
|
224
224
|
Param value: ["a","b"]
|
|
225
|
-
Expected path: /routes/label/standard/array.a,b
|
|
225
|
+
Expected path: /routes/path/label/standard/array.a,b
|
|
226
226
|
""")
|
|
227
227
|
@route("array{.param}")
|
|
228
228
|
op array(param: string[]): void;
|
|
@@ -231,7 +231,7 @@ namespace PathParameters {
|
|
|
231
231
|
@scenarioDoc("""
|
|
232
232
|
Test label expansion with explode: false when passed a record value.
|
|
233
233
|
Param value: {a: 1, b: 2}
|
|
234
|
-
Expected path: /routes/label/standard/record.a,1,b,2
|
|
234
|
+
Expected path: /routes/path/label/standard/record.a,1,b,2
|
|
235
235
|
""")
|
|
236
236
|
@route("record{.param}")
|
|
237
237
|
op record(param: Record<int32>): void;
|
|
@@ -243,7 +243,7 @@ namespace PathParameters {
|
|
|
243
243
|
@scenarioDoc("""
|
|
244
244
|
Test label expansion with explode: true when passed a primitive value.
|
|
245
245
|
Param value: "a"
|
|
246
|
-
Expected path: /routes/label/explode/primitive.a
|
|
246
|
+
Expected path: /routes/path/label/explode/primitive.a
|
|
247
247
|
""")
|
|
248
248
|
@route("primitive{.param*}")
|
|
249
249
|
op primitive(param: string): void;
|
|
@@ -252,7 +252,7 @@ namespace PathParameters {
|
|
|
252
252
|
@scenarioDoc("""
|
|
253
253
|
Test label expansion with explode: true when passed an array value.
|
|
254
254
|
Param value: ["a","b"]
|
|
255
|
-
Expected path: /routes/label/explode/array.a.b
|
|
255
|
+
Expected path: /routes/path/label/explode/array.a.b
|
|
256
256
|
""")
|
|
257
257
|
@route("array{.param*}")
|
|
258
258
|
op array(param: string[]): void;
|
|
@@ -261,7 +261,7 @@ namespace PathParameters {
|
|
|
261
261
|
@scenarioDoc("""
|
|
262
262
|
Test label expansion with explode: true when passed a record value.
|
|
263
263
|
Param value: {a: 1, b: 2}
|
|
264
|
-
Expected path: /routes/label/explode/record.a=1.b=2
|
|
264
|
+
Expected path: /routes/path/label/explode/record.a=1.b=2
|
|
265
265
|
""")
|
|
266
266
|
@route("record{.param*}")
|
|
267
267
|
op record(param: Record<int32>): void;
|
|
@@ -276,7 +276,7 @@ namespace PathParameters {
|
|
|
276
276
|
@scenarioDoc("""
|
|
277
277
|
Test matrix expansion with explode: false when passed a primitive value.
|
|
278
278
|
Param value: "a"
|
|
279
|
-
Expected path: /routes/matrix/standard/primitive;a
|
|
279
|
+
Expected path: /routes/path/matrix/standard/primitive;param=a
|
|
280
280
|
""")
|
|
281
281
|
@route("primitive{;param}")
|
|
282
282
|
op primitive(param: string): void;
|
|
@@ -285,7 +285,7 @@ namespace PathParameters {
|
|
|
285
285
|
@scenarioDoc("""
|
|
286
286
|
Test matrix expansion with explode: false when passed an array value.
|
|
287
287
|
Param value: ["a","b"]
|
|
288
|
-
Expected path: /routes/matrix/standard/array;a
|
|
288
|
+
Expected path: /routes/path/matrix/standard/array;param=a;param=b
|
|
289
289
|
""")
|
|
290
290
|
@route("array{;param}")
|
|
291
291
|
op array(param: string[]): void;
|
|
@@ -294,7 +294,7 @@ namespace PathParameters {
|
|
|
294
294
|
@scenarioDoc("""
|
|
295
295
|
Test matrix expansion with explode: false when passed a record value.
|
|
296
296
|
Param value: {a: 1, b: 2}
|
|
297
|
-
Expected path: /routes/matrix/standard/record;a
|
|
297
|
+
Expected path: /routes/path/matrix/standard/record;a=1;b=2
|
|
298
298
|
""")
|
|
299
299
|
@route("record{;param}")
|
|
300
300
|
op record(param: Record<int32>): void;
|
|
@@ -306,7 +306,7 @@ namespace PathParameters {
|
|
|
306
306
|
@scenarioDoc("""
|
|
307
307
|
Test matrix expansion with explode: true when passed a primitive value.
|
|
308
308
|
Param value: "a"
|
|
309
|
-
Expected path: /routes/matrix/explode/primitive;a
|
|
309
|
+
Expected path: /routes/path/matrix/explode/primitive;param=a
|
|
310
310
|
""")
|
|
311
311
|
@route("primitive{;param*}")
|
|
312
312
|
op primitive(param: string): void;
|
|
@@ -315,7 +315,7 @@ namespace PathParameters {
|
|
|
315
315
|
@scenarioDoc("""
|
|
316
316
|
Test matrix expansion with explode: true when passed an array value.
|
|
317
317
|
Param value: ["a","b"]
|
|
318
|
-
Expected path: /routes/matrix/explode/array;a
|
|
318
|
+
Expected path: /routes/path/matrix/explode/array;param=a;param=b
|
|
319
319
|
""")
|
|
320
320
|
@route("array{;param*}")
|
|
321
321
|
op array(param: string[]): void;
|
|
@@ -324,7 +324,7 @@ namespace PathParameters {
|
|
|
324
324
|
@scenarioDoc("""
|
|
325
325
|
Test matrix expansion with explode: true when passed a record value.
|
|
326
326
|
Param value: {a: 1, b: 2}
|
|
327
|
-
Expected path: /routes/matrix/explode/record;a=1;b=2
|
|
327
|
+
Expected path: /routes/path/matrix/explode/record;a=1;b=2
|
|
328
328
|
""")
|
|
329
329
|
@route("record{;param*}")
|
|
330
330
|
op record(param: Record<int32>): void;
|
package/specs/routes/mockapi.ts
CHANGED
|
@@ -61,76 +61,76 @@ Scenarios.Routes_PathParameters_ReservedExpansion_annotation = createTests(
|
|
|
61
61
|
"/routes/path/reserved-expansion/annotation/foo/bar%20baz",
|
|
62
62
|
);
|
|
63
63
|
Scenarios.Routes_PathParameters_SimpleExpansion_Standard_primitive = createTests(
|
|
64
|
-
"/routes/simple/standard/primitivea",
|
|
64
|
+
"/routes/path/simple/standard/primitivea",
|
|
65
65
|
);
|
|
66
66
|
Scenarios.Routes_PathParameters_SimpleExpansion_Standard_array = createTests(
|
|
67
|
-
"/routes/simple/standard/arraya,b",
|
|
67
|
+
"/routes/path/simple/standard/arraya,b",
|
|
68
68
|
);
|
|
69
69
|
Scenarios.Routes_PathParameters_SimpleExpansion_Standard_record = createTests(
|
|
70
|
-
"/routes/simple/standard/recorda,1,b,2",
|
|
70
|
+
"/routes/path/simple/standard/recorda,1,b,2",
|
|
71
71
|
);
|
|
72
72
|
Scenarios.Routes_PathParameters_SimpleExpansion_Explode_primitive = createTests(
|
|
73
|
-
"/routes/simple/
|
|
73
|
+
"/routes/path/simple/explode/primitivea",
|
|
74
74
|
);
|
|
75
75
|
Scenarios.Routes_PathParameters_SimpleExpansion_Explode_array = createTests(
|
|
76
|
-
"/routes/simple/
|
|
76
|
+
"/routes/path/simple/explode/arraya,b",
|
|
77
77
|
);
|
|
78
78
|
Scenarios.Routes_PathParameters_SimpleExpansion_Explode_record = createTests(
|
|
79
|
-
"/routes/simple/
|
|
79
|
+
"/routes/path/simple/explode/recorda=1,b=2",
|
|
80
80
|
);
|
|
81
81
|
Scenarios.Routes_PathParameters_PathExpansion_Standard_primitive = createTests(
|
|
82
|
-
"/routes/path/standard/primitive/a",
|
|
82
|
+
"/routes/path/path/standard/primitive/a",
|
|
83
83
|
);
|
|
84
84
|
Scenarios.Routes_PathParameters_PathExpansion_Standard_array = createTests(
|
|
85
|
-
"/routes/path/standard/array/a,b",
|
|
85
|
+
"/routes/path/path/standard/array/a,b",
|
|
86
86
|
);
|
|
87
87
|
Scenarios.Routes_PathParameters_PathExpansion_Standard_record = createTests(
|
|
88
|
-
"/routes/path/standard/record/a,1,b,2",
|
|
88
|
+
"/routes/path/path/standard/record/a,1,b,2",
|
|
89
89
|
);
|
|
90
90
|
Scenarios.Routes_PathParameters_PathExpansion_Explode_primitive = createTests(
|
|
91
|
-
"/routes/path/
|
|
91
|
+
"/routes/path/path/explode/primitive/a",
|
|
92
92
|
);
|
|
93
93
|
Scenarios.Routes_PathParameters_PathExpansion_Explode_array = createTests(
|
|
94
|
-
"/routes/path/
|
|
94
|
+
"/routes/path/path/explode/array/a/b",
|
|
95
95
|
);
|
|
96
96
|
Scenarios.Routes_PathParameters_PathExpansion_Explode_record = createTests(
|
|
97
|
-
"/routes/path/
|
|
97
|
+
"/routes/path/path/explode/record/a=1/b=2",
|
|
98
98
|
);
|
|
99
99
|
Scenarios.Routes_PathParameters_LabelExpansion_Standard_primitive = createTests(
|
|
100
|
-
"/routes/label/standard/primitive.a",
|
|
100
|
+
"/routes/path/label/standard/primitive.a",
|
|
101
101
|
);
|
|
102
102
|
Scenarios.Routes_PathParameters_LabelExpansion_Standard_array = createTests(
|
|
103
|
-
"/routes/label/standard/array.a,b",
|
|
103
|
+
"/routes/path/label/standard/array.a,b",
|
|
104
104
|
);
|
|
105
105
|
Scenarios.Routes_PathParameters_LabelExpansion_Standard_record = createTests(
|
|
106
|
-
"/routes/label/standard/record.a,1,b,2",
|
|
106
|
+
"/routes/path/label/standard/record.a,1,b,2",
|
|
107
107
|
);
|
|
108
108
|
Scenarios.Routes_PathParameters_LabelExpansion_Explode_primitive = createTests(
|
|
109
|
-
"/routes/label/
|
|
109
|
+
"/routes/path/label/explode/primitive.a",
|
|
110
110
|
);
|
|
111
111
|
Scenarios.Routes_PathParameters_LabelExpansion_Explode_array = createTests(
|
|
112
|
-
"/routes/label/
|
|
112
|
+
"/routes/path/label/explode/array.a.b",
|
|
113
113
|
);
|
|
114
114
|
Scenarios.Routes_PathParameters_LabelExpansion_Explode_record = createTests(
|
|
115
|
-
"/routes/label/
|
|
115
|
+
"/routes/path/label/explode/record.a=1.b=2",
|
|
116
116
|
);
|
|
117
117
|
Scenarios.Routes_PathParameters_MatrixExpansion_Standard_primitive = createTests(
|
|
118
|
-
"/routes/matrix/standard/primitive;a",
|
|
118
|
+
"/routes/path/matrix/standard/primitive;param=a",
|
|
119
119
|
);
|
|
120
120
|
Scenarios.Routes_PathParameters_MatrixExpansion_Standard_array = createTests(
|
|
121
|
-
"/routes/matrix/standard/array;a,b",
|
|
121
|
+
"/routes/path/matrix/standard/array;param=a,b",
|
|
122
122
|
);
|
|
123
123
|
Scenarios.Routes_PathParameters_MatrixExpansion_Standard_record = createTests(
|
|
124
|
-
"/routes/matrix/standard/record;a,1,b,2",
|
|
124
|
+
"/routes/path/matrix/standard/record;param=a,1,b,2",
|
|
125
125
|
);
|
|
126
126
|
Scenarios.Routes_PathParameters_MatrixExpansion_Explode_primitive = createTests(
|
|
127
|
-
"/routes/matrix/
|
|
127
|
+
"/routes/path/matrix/explode/primitive;param=a",
|
|
128
128
|
);
|
|
129
129
|
Scenarios.Routes_PathParameters_MatrixExpansion_Explode_array = createTests(
|
|
130
|
-
"/routes/matrix/
|
|
130
|
+
"/routes/path/matrix/explode/array;param=a;param=b",
|
|
131
131
|
);
|
|
132
132
|
Scenarios.Routes_PathParameters_MatrixExpansion_Explode_record = createTests(
|
|
133
|
-
"/routes/matrix/
|
|
133
|
+
"/routes/path/matrix/explode/record;a=1;b=2",
|
|
134
134
|
);
|
|
135
135
|
Scenarios.Routes_QueryParameters_templateOnly = createTests("/routes/query/template-only?param=a");
|
|
136
136
|
Scenarios.Routes_QueryParameters_explicit = createTests("/routes/query/explicit?param=a");
|
|
@@ -11,24 +11,28 @@ namespace Type.Model.Visibility;
|
|
|
11
11
|
@doc("Output model with visibility properties.")
|
|
12
12
|
model VisibilityModel {
|
|
13
13
|
@doc("Required string, illustrating a readonly property.")
|
|
14
|
-
@visibility(
|
|
14
|
+
@visibility(Lifecycle.Read)
|
|
15
15
|
readProp: string;
|
|
16
16
|
|
|
17
17
|
@doc("Required int32, illustrating a query property.")
|
|
18
|
-
@visibility(
|
|
18
|
+
@visibility(Lifecycle.Query)
|
|
19
19
|
queryProp: int32;
|
|
20
20
|
|
|
21
21
|
@doc("Required string[], illustrating a create property.")
|
|
22
|
-
@visibility(
|
|
22
|
+
@visibility(Lifecycle.Create)
|
|
23
23
|
createProp: string[];
|
|
24
24
|
|
|
25
25
|
@doc("Required int32[], illustrating a update property.")
|
|
26
|
-
@visibility(
|
|
26
|
+
@visibility(Lifecycle.Update)
|
|
27
27
|
updateProp: int32[];
|
|
28
28
|
|
|
29
29
|
@doc("Required bool, illustrating a delete property.")
|
|
30
|
-
@visibility(
|
|
30
|
+
@visibility(Lifecycle.Delete)
|
|
31
31
|
deleteProp: boolean;
|
|
32
|
+
|
|
33
|
+
@doc("Property that does not exist in any payload.")
|
|
34
|
+
@invisible(Lifecycle)
|
|
35
|
+
noneProp: "none";
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
/** RoundTrip model with readonly optional properties. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
|
|
1
|
+
import { json, MockRequest, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
|
|
2
2
|
|
|
3
3
|
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
|
4
4
|
|
|
@@ -119,6 +119,13 @@ function createServerTests(url: string, value: any) {
|
|
|
119
119
|
response: {
|
|
120
120
|
status: 204,
|
|
121
121
|
},
|
|
122
|
+
handler: (req: MockRequest) => {
|
|
123
|
+
const expectedBody = JSON.parse(JSON.stringify(value));
|
|
124
|
+
req.expect.coercedBodyEquals(expectedBody);
|
|
125
|
+
return {
|
|
126
|
+
status: 204,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
122
129
|
kind: "MockApiDefinition",
|
|
123
130
|
}),
|
|
124
131
|
};
|
|
@@ -29,6 +29,15 @@ function createServerTests(url: string, value: unknown, patchNullableProperty?:
|
|
|
29
29
|
response: {
|
|
30
30
|
status: 204,
|
|
31
31
|
},
|
|
32
|
+
handler: (req) => {
|
|
33
|
+
req.expect.coercedBodyEquals({
|
|
34
|
+
requiredProperty: "foo",
|
|
35
|
+
nullableProperty: patchNullableProperty || null,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
status: 204,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
32
41
|
kind: "MockApiDefinition",
|
|
33
42
|
}),
|
|
34
43
|
};
|
|
@@ -21,7 +21,7 @@ using TypeSpec.Versioning;
|
|
|
21
21
|
endpoint: url,
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Need to be set as 'v1' or 'v2' in client.
|
|
24
|
+
* Need to be set as 'v1', 'v2preview' or 'v2' in client.
|
|
25
25
|
*/
|
|
26
26
|
version: Versions,
|
|
27
27
|
}
|
|
@@ -37,6 +37,11 @@ enum Versions {
|
|
|
37
37
|
*/
|
|
38
38
|
v1: "v1",
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The V2 Preview version.
|
|
42
|
+
*/
|
|
43
|
+
v2preview: "v2preview",
|
|
44
|
+
|
|
40
45
|
/**
|
|
41
46
|
* The version v2.
|
|
42
47
|
*/
|
|
@@ -67,6 +72,14 @@ model ModelV2 {
|
|
|
67
72
|
unionProp: UnionV2;
|
|
68
73
|
}
|
|
69
74
|
|
|
75
|
+
model ModelV3 {
|
|
76
|
+
id: string;
|
|
77
|
+
|
|
78
|
+
@removed(Versions.v2preview)
|
|
79
|
+
@added(Versions.v2)
|
|
80
|
+
enumProp: EnumV3;
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
enum EnumV2 {
|
|
71
84
|
@removed(Versions.v2)
|
|
72
85
|
enumMemberV1,
|
|
@@ -74,6 +87,14 @@ enum EnumV2 {
|
|
|
74
87
|
enumMemberV2,
|
|
75
88
|
}
|
|
76
89
|
|
|
90
|
+
enum EnumV3 {
|
|
91
|
+
@removed(Versions.v2preview)
|
|
92
|
+
@added(Versions.v2)
|
|
93
|
+
enumMemberV1,
|
|
94
|
+
|
|
95
|
+
enumMemberV2Preview,
|
|
96
|
+
}
|
|
97
|
+
|
|
77
98
|
@removed(Versions.v2)
|
|
78
99
|
union UnionV1 {
|
|
79
100
|
string,
|
|
@@ -124,3 +145,44 @@ interface InterfaceV1 {
|
|
|
124
145
|
@route("/v1")
|
|
125
146
|
v1InInterface(@body body: ModelV1): ModelV1;
|
|
126
147
|
}
|
|
148
|
+
|
|
149
|
+
/** This operation will pass different paths and different request bodies based on different versions. */
|
|
150
|
+
@scenario
|
|
151
|
+
@scenarioDoc("""
|
|
152
|
+
path: "/versioning/removed/api-version[:]v1/v3"
|
|
153
|
+
Expected request body:
|
|
154
|
+
```json
|
|
155
|
+
{ "id": "123", "enumProp": "enumMemberV1" }
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Expected response body:
|
|
159
|
+
```json
|
|
160
|
+
{ "id": "123", "enumProp": "enumMemberV1" }
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
path: "/versioning/removed/api-version[:]v2preview/v3"
|
|
164
|
+
Expected request body:
|
|
165
|
+
```json
|
|
166
|
+
{ "id": "123"}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Expected response body:
|
|
170
|
+
```json
|
|
171
|
+
{ "id": "123"}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
path: "/versioning/removed/api-version[:]v2/v3"
|
|
175
|
+
Expected request body:
|
|
176
|
+
```json
|
|
177
|
+
{ "id": "123", "enumProp": "enumMemberV1" }
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Expected response body:
|
|
181
|
+
```json
|
|
182
|
+
{ "id": "123", "enumProp": "enumMemberV1" }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
""")
|
|
186
|
+
@post
|
|
187
|
+
@route("/v3")
|
|
188
|
+
op modelV3(@body body: ModelV3): ModelV3;
|
|
@@ -18,3 +18,50 @@ Scenarios.Versioning_Removed_v2 = passOnSuccess({
|
|
|
18
18
|
},
|
|
19
19
|
kind: "MockApiDefinition",
|
|
20
20
|
});
|
|
21
|
+
|
|
22
|
+
Scenarios.Versioning_Removed_modelV3 = passOnSuccess({
|
|
23
|
+
uri: `/versioning/removed/api-version[:]v1/v3`,
|
|
24
|
+
method: "post",
|
|
25
|
+
request: {
|
|
26
|
+
body: {
|
|
27
|
+
id: "123",
|
|
28
|
+
enumProp: "enumMemberV1",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
response: {
|
|
32
|
+
status: 200,
|
|
33
|
+
body: json({ id: "123", enumProp: "enumMemberV1" }),
|
|
34
|
+
},
|
|
35
|
+
kind: "MockApiDefinition",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
Scenarios.Versioning_Removed_modelV3_V2 = passOnSuccess({
|
|
39
|
+
uri: `/versioning/removed/api-version[:]v2/v3`,
|
|
40
|
+
method: "post",
|
|
41
|
+
request: {
|
|
42
|
+
body: {
|
|
43
|
+
id: "123",
|
|
44
|
+
enumProp: "enumMemberV1",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
response: {
|
|
48
|
+
status: 200,
|
|
49
|
+
body: json({ id: "123", enumProp: "enumMemberV1" }),
|
|
50
|
+
},
|
|
51
|
+
kind: "MockApiDefinition",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Scenarios.Versioning_Removed_modelV3_V2preview = passOnSuccess({
|
|
55
|
+
uri: `/versioning/removed/api-version[:]v2preview/v3`,
|
|
56
|
+
method: "post",
|
|
57
|
+
request: {
|
|
58
|
+
body: {
|
|
59
|
+
id: "123",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
response: {
|
|
63
|
+
status: 200,
|
|
64
|
+
body: json({ id: "123" }),
|
|
65
|
+
},
|
|
66
|
+
kind: "MockApiDefinition",
|
|
67
|
+
});
|