@typespec/http-specs 0.1.0-alpha.24-dev.2 → 0.1.0-alpha.24-dev.3
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/dist/specs/payload/pageable/mockapi.js +221 -0
- package/dist/specs/payload/pageable/mockapi.js.map +1 -1
- package/package.json +1 -1
- package/spec-summary.md +140 -0
- package/specs/payload/pageable/main.tsp +162 -0
- package/specs/payload/pageable/mockapi.ts +245 -0
- package/temp/.tsbuildinfo +1 -1
|
@@ -118,6 +118,40 @@ Scenarios.Payload_Pageable_ServerDrivenPagination_link = passOnSuccess([
|
|
|
118
118
|
},
|
|
119
119
|
]);
|
|
120
120
|
|
|
121
|
+
Scenarios.Payload_Pageable_ServerDrivenPagination_nestedLink = passOnSuccess([
|
|
122
|
+
{
|
|
123
|
+
uri: "/payload/pageable/server-driven-pagination/nested-link",
|
|
124
|
+
method: "get",
|
|
125
|
+
request: {},
|
|
126
|
+
response: {
|
|
127
|
+
status: 200,
|
|
128
|
+
body: json({
|
|
129
|
+
nestedItems: {
|
|
130
|
+
pets: FirstPage,
|
|
131
|
+
},
|
|
132
|
+
nestedNext: {
|
|
133
|
+
next: dyn`${dynItem("baseUrl")}/payload/pageable/server-driven-pagination/nested-link/nextPage`,
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
},
|
|
137
|
+
kind: "MockApiDefinition",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
uri: "/payload/pageable/server-driven-pagination/nested-link/nextPage",
|
|
141
|
+
method: "get",
|
|
142
|
+
request: {},
|
|
143
|
+
response: {
|
|
144
|
+
status: 200,
|
|
145
|
+
body: json({
|
|
146
|
+
nestedItems: {
|
|
147
|
+
pets: SecondPage,
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
},
|
|
151
|
+
kind: "MockApiDefinition",
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
|
|
121
155
|
Scenarios.Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestQueryResponseBody =
|
|
122
156
|
createTests("query", "body");
|
|
123
157
|
|
|
@@ -126,5 +160,216 @@ Scenarios.Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestHeade
|
|
|
126
160
|
|
|
127
161
|
Scenarios.Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestQueryResponseHeader =
|
|
128
162
|
createTests("query", "header");
|
|
163
|
+
|
|
129
164
|
Scenarios.Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestHeaderResponseHeader =
|
|
130
165
|
createTests("header", "header");
|
|
166
|
+
|
|
167
|
+
Scenarios.Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestQueryNestedResponseBody =
|
|
168
|
+
passOnSuccess([
|
|
169
|
+
{
|
|
170
|
+
uri: "/payload/pageable/server-driven-pagination/continuationtoken/request-query-nested-response-body",
|
|
171
|
+
method: "get",
|
|
172
|
+
request: { headers: { foo: "foo" }, query: { bar: "bar" } },
|
|
173
|
+
response: {
|
|
174
|
+
status: 200,
|
|
175
|
+
body: json({
|
|
176
|
+
nestedItems: {
|
|
177
|
+
pets: FirstPage,
|
|
178
|
+
},
|
|
179
|
+
nestedNext: {
|
|
180
|
+
nextToken: "page2",
|
|
181
|
+
},
|
|
182
|
+
}),
|
|
183
|
+
},
|
|
184
|
+
handler: (req: MockRequest) => {
|
|
185
|
+
req.expect.containsHeader("foo", "foo");
|
|
186
|
+
req.expect.containsQueryParam("bar", "bar");
|
|
187
|
+
const token = req.query?.token;
|
|
188
|
+
|
|
189
|
+
switch (token) {
|
|
190
|
+
case undefined:
|
|
191
|
+
return {
|
|
192
|
+
status: 200,
|
|
193
|
+
body: json({
|
|
194
|
+
nestedItems: {
|
|
195
|
+
pets: FirstPage,
|
|
196
|
+
},
|
|
197
|
+
nestedNext: {
|
|
198
|
+
nextToken: "page2",
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
};
|
|
202
|
+
case "page2":
|
|
203
|
+
return {
|
|
204
|
+
status: 200,
|
|
205
|
+
body: json({
|
|
206
|
+
nestedItems: {
|
|
207
|
+
pets: SecondPage,
|
|
208
|
+
},
|
|
209
|
+
}),
|
|
210
|
+
};
|
|
211
|
+
default:
|
|
212
|
+
throw new ValidationError(
|
|
213
|
+
"Unsupported continuation token",
|
|
214
|
+
`"undefined" | "page2"`,
|
|
215
|
+
token,
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
kind: "MockApiDefinition",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
uri: "/payload/pageable/server-driven-pagination/continuationtoken/request-query-nested-response-body",
|
|
223
|
+
method: "get",
|
|
224
|
+
request: RequestTokenInQuery,
|
|
225
|
+
response: {
|
|
226
|
+
status: 200,
|
|
227
|
+
body: json({
|
|
228
|
+
nestedItems: {
|
|
229
|
+
pets: SecondPage,
|
|
230
|
+
},
|
|
231
|
+
}),
|
|
232
|
+
},
|
|
233
|
+
handler: (req: MockRequest) => {
|
|
234
|
+
req.expect.containsHeader("foo", "foo");
|
|
235
|
+
req.expect.containsQueryParam("bar", "bar");
|
|
236
|
+
const token = req.query?.token;
|
|
237
|
+
|
|
238
|
+
switch (token) {
|
|
239
|
+
case undefined:
|
|
240
|
+
return {
|
|
241
|
+
status: 200,
|
|
242
|
+
body: json({
|
|
243
|
+
nestedItems: {
|
|
244
|
+
pets: FirstPage,
|
|
245
|
+
},
|
|
246
|
+
nestedNext: {
|
|
247
|
+
nextToken: "page2",
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
};
|
|
251
|
+
case "page2":
|
|
252
|
+
return {
|
|
253
|
+
status: 200,
|
|
254
|
+
body: json({
|
|
255
|
+
nestedItems: {
|
|
256
|
+
pets: SecondPage,
|
|
257
|
+
},
|
|
258
|
+
}),
|
|
259
|
+
};
|
|
260
|
+
default:
|
|
261
|
+
throw new ValidationError(
|
|
262
|
+
"Unsupported continuation token",
|
|
263
|
+
`"undefined" | "page2"`,
|
|
264
|
+
token,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
kind: "MockApiDefinition",
|
|
269
|
+
},
|
|
270
|
+
]);
|
|
271
|
+
|
|
272
|
+
Scenarios.Payload_Pageable_ServerDrivenPagination_ContinuationToken_requestHeaderNestedResponseBody =
|
|
273
|
+
passOnSuccess([
|
|
274
|
+
{
|
|
275
|
+
uri: "/payload/pageable/server-driven-pagination/continuationtoken/request-header-nested-response-body",
|
|
276
|
+
method: "get",
|
|
277
|
+
request: { headers: { foo: "foo" }, query: { bar: "bar" } },
|
|
278
|
+
response: {
|
|
279
|
+
status: 200,
|
|
280
|
+
body: json({
|
|
281
|
+
nestedItems: {
|
|
282
|
+
pets: FirstPage,
|
|
283
|
+
},
|
|
284
|
+
nestedNext: {
|
|
285
|
+
nextToken: "page2",
|
|
286
|
+
},
|
|
287
|
+
}),
|
|
288
|
+
},
|
|
289
|
+
handler: (req: MockRequest) => {
|
|
290
|
+
req.expect.containsHeader("foo", "foo");
|
|
291
|
+
req.expect.containsQueryParam("bar", "bar");
|
|
292
|
+
const token = req.headers?.token;
|
|
293
|
+
|
|
294
|
+
switch (token) {
|
|
295
|
+
case undefined:
|
|
296
|
+
return {
|
|
297
|
+
status: 200,
|
|
298
|
+
body: json({
|
|
299
|
+
nestedItems: {
|
|
300
|
+
pets: FirstPage,
|
|
301
|
+
},
|
|
302
|
+
nestedNext: {
|
|
303
|
+
nextToken: "page2",
|
|
304
|
+
},
|
|
305
|
+
}),
|
|
306
|
+
};
|
|
307
|
+
case "page2":
|
|
308
|
+
return {
|
|
309
|
+
status: 200,
|
|
310
|
+
body: json({
|
|
311
|
+
nestedItems: {
|
|
312
|
+
pets: SecondPage,
|
|
313
|
+
},
|
|
314
|
+
}),
|
|
315
|
+
};
|
|
316
|
+
default:
|
|
317
|
+
throw new ValidationError(
|
|
318
|
+
"Unsupported continuation token",
|
|
319
|
+
`"undefined" | "page2"`,
|
|
320
|
+
token,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
kind: "MockApiDefinition",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
uri: "/payload/pageable/server-driven-pagination/continuationtoken/request-header-nested-response-body",
|
|
328
|
+
method: "get",
|
|
329
|
+
request: RequestTokenInHeader,
|
|
330
|
+
response: {
|
|
331
|
+
status: 200,
|
|
332
|
+
body: json({
|
|
333
|
+
nestedItems: {
|
|
334
|
+
pets: SecondPage,
|
|
335
|
+
},
|
|
336
|
+
}),
|
|
337
|
+
},
|
|
338
|
+
handler: (req: MockRequest) => {
|
|
339
|
+
req.expect.containsHeader("foo", "foo");
|
|
340
|
+
req.expect.containsQueryParam("bar", "bar");
|
|
341
|
+
const token = req.headers?.token;
|
|
342
|
+
|
|
343
|
+
switch (token) {
|
|
344
|
+
case undefined:
|
|
345
|
+
return {
|
|
346
|
+
status: 200,
|
|
347
|
+
body: json({
|
|
348
|
+
nestedItems: {
|
|
349
|
+
pets: FirstPage,
|
|
350
|
+
},
|
|
351
|
+
nestedNext: {
|
|
352
|
+
nextToken: "page2",
|
|
353
|
+
},
|
|
354
|
+
}),
|
|
355
|
+
};
|
|
356
|
+
case "page2":
|
|
357
|
+
return {
|
|
358
|
+
status: 200,
|
|
359
|
+
body: json({
|
|
360
|
+
nestedItems: {
|
|
361
|
+
pets: SecondPage,
|
|
362
|
+
},
|
|
363
|
+
}),
|
|
364
|
+
};
|
|
365
|
+
default:
|
|
366
|
+
throw new ValidationError(
|
|
367
|
+
"Unsupported continuation token",
|
|
368
|
+
`"undefined" | "page2"`,
|
|
369
|
+
token,
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
kind: "MockApiDefinition",
|
|
374
|
+
},
|
|
375
|
+
]);
|