@typespec/http-specs 0.1.0-dev.0 → 0.1.0-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 +19 -0
- package/dist/specs/encode/duration/mockapi.js +5 -0
- package/dist/specs/encode/duration/mockapi.js.map +1 -1
- package/dist/specs/payload/multipart/mockapi.js +16 -9
- package/dist/specs/payload/multipart/mockapi.js.map +1 -1
- package/dist/specs/payload/pageable/mockapi.d.ts.map +1 -1
- package/dist/specs/payload/pageable/mockapi.js +37 -5
- package/dist/specs/payload/pageable/mockapi.js.map +1 -1
- package/dist/specs/payload/xml/mockapi.d.ts +16 -5
- package/dist/specs/payload/xml/mockapi.d.ts.map +1 -1
- package/dist/specs/payload/xml/mockapi.js +285 -59
- package/dist/specs/payload/xml/mockapi.js.map +1 -1
- package/manifest.json +427 -82
- package/package.json +17 -17
- package/spec-summary.md +392 -0
- package/specs/encode/duration/mockapi.ts +5 -0
- package/specs/payload/multipart/mockapi.ts +16 -9
- package/specs/payload/pageable/main.tsp +47 -0
- package/specs/payload/pageable/mockapi.ts +40 -5
- package/specs/payload/xml/main.tsp +490 -179
- package/specs/payload/xml/mockapi.ts +370 -74
- package/specs/special-words/main.tsp +48 -42
- package/temp/.tsbuildinfo +1 -1
|
@@ -2,6 +2,10 @@ import { MockRequest, passOnCode, passOnSuccess, ScenarioMockApi, xml } from "@t
|
|
|
2
2
|
|
|
3
3
|
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
|
4
4
|
|
|
5
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
// §1 — Primitive properties
|
|
7
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
|
|
5
9
|
export const simpleModel = `
|
|
6
10
|
<SimpleModel>
|
|
7
11
|
<name>foo</name>
|
|
@@ -9,6 +13,51 @@ export const simpleModel = `
|
|
|
9
13
|
</SimpleModel>
|
|
10
14
|
`;
|
|
11
15
|
|
|
16
|
+
export const modelWithRenamedProperty = `
|
|
17
|
+
<ModelWithRenamedProperty>
|
|
18
|
+
<renamedTitle>foo</renamedTitle>
|
|
19
|
+
<author>bar</author>
|
|
20
|
+
</ModelWithRenamedProperty>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const modelWithRenamedFields = `
|
|
24
|
+
<ModelWithRenamedFieldsSrc>
|
|
25
|
+
<InputData>
|
|
26
|
+
<name>foo</name>
|
|
27
|
+
<age>123</age>
|
|
28
|
+
</InputData>
|
|
29
|
+
<OutputData>
|
|
30
|
+
<name>bar</name>
|
|
31
|
+
<age>456</age>
|
|
32
|
+
</OutputData>
|
|
33
|
+
</ModelWithRenamedFieldsSrc>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
37
|
+
// §2 — Nested models
|
|
38
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
export const modelWithNestedModel = `
|
|
41
|
+
<ModelWithNestedModel>
|
|
42
|
+
<nested>
|
|
43
|
+
<name>foo</name>
|
|
44
|
+
<age>123</age>
|
|
45
|
+
</nested>
|
|
46
|
+
</ModelWithNestedModel>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export const modelWithRenamedNestedModel = `
|
|
50
|
+
<ModelWithRenamedNestedModel>
|
|
51
|
+
<author>
|
|
52
|
+
<name>foo</name>
|
|
53
|
+
</author>
|
|
54
|
+
</ModelWithRenamedNestedModel>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
58
|
+
// §3 — Array of primitive types
|
|
59
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
12
61
|
export const modelWithSimpleArrays = `
|
|
13
62
|
<ModelWithSimpleArrays>
|
|
14
63
|
<colors>
|
|
@@ -23,33 +72,6 @@ export const modelWithSimpleArrays = `
|
|
|
23
72
|
</ModelWithSimpleArrays>
|
|
24
73
|
`;
|
|
25
74
|
|
|
26
|
-
export const modelWithArrayOfModel = `
|
|
27
|
-
<ModelWithArrayOfModel>
|
|
28
|
-
<items>
|
|
29
|
-
<SimpleModel>
|
|
30
|
-
<name>foo</name>
|
|
31
|
-
<age>123</age>
|
|
32
|
-
</SimpleModel>
|
|
33
|
-
<SimpleModel>
|
|
34
|
-
<name>bar</name>
|
|
35
|
-
<age>456</age>
|
|
36
|
-
</SimpleModel>
|
|
37
|
-
</items>
|
|
38
|
-
</ModelWithArrayOfModel>
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
|
-
export const modelWithOptionalField = `
|
|
42
|
-
<ModelWithOptionalField>
|
|
43
|
-
<item>widget</item>
|
|
44
|
-
</ModelWithOptionalField>
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
export const modelWithAttributes = `
|
|
48
|
-
<ModelWithAttributes id1="123" id2="foo">
|
|
49
|
-
<enabled>true</enabled>
|
|
50
|
-
</ModelWithAttributes>
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
75
|
export const modelWithUnwrappedArray = `
|
|
54
76
|
<ModelWithUnwrappedArray>
|
|
55
77
|
<colors>red</colors>
|
|
@@ -74,31 +96,150 @@ export const modelWithRenamedArrays = `
|
|
|
74
96
|
</ModelWithRenamedArrays>
|
|
75
97
|
`;
|
|
76
98
|
|
|
77
|
-
export const
|
|
78
|
-
<
|
|
79
|
-
<
|
|
99
|
+
export const modelWithWrappedPrimitiveCustomItemNames = `
|
|
100
|
+
<ModelWithWrappedPrimitiveCustomItemNames>
|
|
101
|
+
<ItemsTags>
|
|
102
|
+
<ItemName>fiction</ItemName>
|
|
103
|
+
<ItemName>classic</ItemName>
|
|
104
|
+
</ItemsTags>
|
|
105
|
+
</ModelWithWrappedPrimitiveCustomItemNames>
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
109
|
+
// §4 — Array of complex types
|
|
110
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
export const modelWithArrayOfModel = `
|
|
113
|
+
<ModelWithArrayOfModel>
|
|
114
|
+
<items>
|
|
115
|
+
<SimpleModel>
|
|
116
|
+
<name>foo</name>
|
|
117
|
+
<age>123</age>
|
|
118
|
+
</SimpleModel>
|
|
119
|
+
<SimpleModel>
|
|
120
|
+
<name>bar</name>
|
|
121
|
+
<age>456</age>
|
|
122
|
+
</SimpleModel>
|
|
123
|
+
</items>
|
|
124
|
+
</ModelWithArrayOfModel>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
export const modelWithUnwrappedModelArray = `
|
|
128
|
+
<ModelWithUnwrappedModelArray>
|
|
129
|
+
<items>
|
|
80
130
|
<name>foo</name>
|
|
81
131
|
<age>123</age>
|
|
82
|
-
</
|
|
83
|
-
<
|
|
132
|
+
</items>
|
|
133
|
+
<items>
|
|
84
134
|
<name>bar</name>
|
|
85
135
|
<age>456</age>
|
|
86
|
-
</
|
|
87
|
-
</
|
|
136
|
+
</items>
|
|
137
|
+
</ModelWithUnwrappedModelArray>
|
|
88
138
|
`;
|
|
89
139
|
|
|
90
|
-
export const
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
|
|
140
|
+
export const modelWithRenamedWrappedModelArray = `
|
|
141
|
+
<ModelWithRenamedWrappedModelArray>
|
|
142
|
+
<AllItems>
|
|
143
|
+
<SimpleModel>
|
|
144
|
+
<name>foo</name>
|
|
145
|
+
<age>123</age>
|
|
146
|
+
</SimpleModel>
|
|
147
|
+
<SimpleModel>
|
|
148
|
+
<name>bar</name>
|
|
149
|
+
<age>456</age>
|
|
150
|
+
</SimpleModel>
|
|
151
|
+
</AllItems>
|
|
152
|
+
</ModelWithRenamedWrappedModelArray>
|
|
94
153
|
`;
|
|
95
154
|
|
|
155
|
+
export const modelWithRenamedUnwrappedModelArray = `
|
|
156
|
+
<ModelWithRenamedUnwrappedModelArray>
|
|
157
|
+
<ModelItem>
|
|
158
|
+
<name>foo</name>
|
|
159
|
+
<age>123</age>
|
|
160
|
+
</ModelItem>
|
|
161
|
+
<ModelItem>
|
|
162
|
+
<name>bar</name>
|
|
163
|
+
<age>456</age>
|
|
164
|
+
</ModelItem>
|
|
165
|
+
</ModelWithRenamedUnwrappedModelArray>
|
|
166
|
+
`;
|
|
167
|
+
|
|
168
|
+
export const modelWithRenamedWrappedAndItemModelArray = `
|
|
169
|
+
<ModelWithRenamedWrappedAndItemModelArray>
|
|
170
|
+
<AllBooks>
|
|
171
|
+
<XmlBook>
|
|
172
|
+
<title>The Great Gatsby</title>
|
|
173
|
+
</XmlBook>
|
|
174
|
+
<XmlBook>
|
|
175
|
+
<title>Les Miserables</title>
|
|
176
|
+
</XmlBook>
|
|
177
|
+
</AllBooks>
|
|
178
|
+
</ModelWithRenamedWrappedAndItemModelArray>
|
|
179
|
+
`;
|
|
180
|
+
|
|
181
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
182
|
+
// §5 — Attributes
|
|
183
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
184
|
+
|
|
185
|
+
export const modelWithAttributes = `
|
|
186
|
+
<ModelWithAttributes id1="123" id2="foo">
|
|
187
|
+
<enabled>true</enabled>
|
|
188
|
+
</ModelWithAttributes>
|
|
189
|
+
`;
|
|
190
|
+
|
|
191
|
+
export const modelWithRenamedAttribute = `
|
|
192
|
+
<ModelWithRenamedAttribute xml-id="123">
|
|
193
|
+
<title>The Great Gatsby</title>
|
|
194
|
+
<author>F. Scott Fitzgerald</author>
|
|
195
|
+
</ModelWithRenamedAttribute>
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
199
|
+
// §6/§7 — Namespace and prefix
|
|
200
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
201
|
+
|
|
202
|
+
export const modelWithNamespace = `
|
|
203
|
+
<smp:ModelWithNamespace xmlns:smp="http://example.com/schema">
|
|
204
|
+
<id>123</id>
|
|
205
|
+
<title>The Great Gatsby</title>
|
|
206
|
+
</smp:ModelWithNamespace>
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
export const modelWithNamespaceOnProperties = `
|
|
210
|
+
<smp:ModelWithNamespaceOnProperties xmlns:smp="http://example.com/schema" xmlns:ns2="http://example.com/ns2">
|
|
211
|
+
<id>123</id>
|
|
212
|
+
<smp:title>The Great Gatsby</smp:title>
|
|
213
|
+
<ns2:author>F. Scott Fitzgerald</ns2:author>
|
|
214
|
+
</smp:ModelWithNamespaceOnProperties>
|
|
215
|
+
`;
|
|
216
|
+
|
|
217
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
218
|
+
// §8 — Text content
|
|
219
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
220
|
+
|
|
96
221
|
export const modelWithText = `
|
|
97
222
|
<ModelWithText language="foo">
|
|
98
223
|
This is some text.
|
|
99
224
|
</ModelWithText>
|
|
100
225
|
`;
|
|
101
226
|
|
|
227
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
228
|
+
// Additional scenarios (not in the guide)
|
|
229
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
230
|
+
|
|
231
|
+
export const modelWithOptionalField = `
|
|
232
|
+
<ModelWithOptionalField>
|
|
233
|
+
<item>widget</item>
|
|
234
|
+
</ModelWithOptionalField>
|
|
235
|
+
`;
|
|
236
|
+
|
|
237
|
+
export const modelWithEmptyArray = `
|
|
238
|
+
<ModelWithEmptyArray>
|
|
239
|
+
<items />
|
|
240
|
+
</ModelWithEmptyArray>
|
|
241
|
+
`;
|
|
242
|
+
|
|
102
243
|
export const modelWithDictionary = `
|
|
103
244
|
<ModelWithDictionary>
|
|
104
245
|
<metadata>
|
|
@@ -136,6 +277,27 @@ export const modelWithDatetime = `
|
|
|
136
277
|
</ModelWithDatetime>
|
|
137
278
|
`;
|
|
138
279
|
|
|
280
|
+
// Some clients serialize UTC datetimes without trailing zero milliseconds. Both
|
|
281
|
+
// "2022-08-26T18:38:00.000Z" and "2022-08-26T18:38:00Z" are valid RFC3339 representations
|
|
282
|
+
// of the same instant; accept either form.
|
|
283
|
+
const modelWithDatetimeNoMs = `
|
|
284
|
+
<ModelWithDatetime>
|
|
285
|
+
<rfc3339>2022-08-26T18:38:00Z</rfc3339>
|
|
286
|
+
<rfc7231>Fri, 26 Aug 2022 14:38:00 GMT</rfc7231>
|
|
287
|
+
</ModelWithDatetime>
|
|
288
|
+
`;
|
|
289
|
+
|
|
290
|
+
export const xmlError = `
|
|
291
|
+
<XmlErrorBody>
|
|
292
|
+
<message>Something went wrong</message>
|
|
293
|
+
<code>400</code>
|
|
294
|
+
</XmlErrorBody>
|
|
295
|
+
`;
|
|
296
|
+
|
|
297
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
298
|
+
// Scenario registrations
|
|
299
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
300
|
+
|
|
139
301
|
function createServerTests(uri: string, data?: any) {
|
|
140
302
|
return {
|
|
141
303
|
get: passOnSuccess({
|
|
@@ -169,10 +331,46 @@ function createServerTests(uri: string, data?: any) {
|
|
|
169
331
|
};
|
|
170
332
|
}
|
|
171
333
|
|
|
334
|
+
// §1 — Primitive properties
|
|
335
|
+
|
|
172
336
|
const Payload_Xml_SimpleModel = createServerTests("/payload/xml/simpleModel", simpleModel);
|
|
173
337
|
Scenarios.Payload_Xml_SimpleModelValue_get = Payload_Xml_SimpleModel.get;
|
|
174
338
|
Scenarios.Payload_Xml_SimpleModelValue_put = Payload_Xml_SimpleModel.put;
|
|
175
339
|
|
|
340
|
+
const Payload_Xml_ModelWithRenamedProperty = createServerTests(
|
|
341
|
+
"/payload/xml/modelWithRenamedProperty",
|
|
342
|
+
modelWithRenamedProperty,
|
|
343
|
+
);
|
|
344
|
+
Scenarios.Payload_Xml_ModelWithRenamedPropertyValue_get = Payload_Xml_ModelWithRenamedProperty.get;
|
|
345
|
+
Scenarios.Payload_Xml_ModelWithRenamedPropertyValue_put = Payload_Xml_ModelWithRenamedProperty.put;
|
|
346
|
+
|
|
347
|
+
const Payload_Xml_ModelWithRenamedFields = createServerTests(
|
|
348
|
+
"/payload/xml/modelWithRenamedFields",
|
|
349
|
+
modelWithRenamedFields,
|
|
350
|
+
);
|
|
351
|
+
Scenarios.Payload_Xml_ModelWithRenamedFieldsValue_get = Payload_Xml_ModelWithRenamedFields.get;
|
|
352
|
+
Scenarios.Payload_Xml_ModelWithRenamedFieldsValue_put = Payload_Xml_ModelWithRenamedFields.put;
|
|
353
|
+
|
|
354
|
+
// §2 — Nested models
|
|
355
|
+
|
|
356
|
+
const Payload_Xml_ModelWithNestedModel = createServerTests(
|
|
357
|
+
"/payload/xml/modelWithNestedModel",
|
|
358
|
+
modelWithNestedModel,
|
|
359
|
+
);
|
|
360
|
+
Scenarios.Payload_Xml_ModelWithNestedModelValue_get = Payload_Xml_ModelWithNestedModel.get;
|
|
361
|
+
Scenarios.Payload_Xml_ModelWithNestedModelValue_put = Payload_Xml_ModelWithNestedModel.put;
|
|
362
|
+
|
|
363
|
+
const Payload_Xml_ModelWithRenamedNestedModel = createServerTests(
|
|
364
|
+
"/payload/xml/modelWithRenamedNestedModel",
|
|
365
|
+
modelWithRenamedNestedModel,
|
|
366
|
+
);
|
|
367
|
+
Scenarios.Payload_Xml_ModelWithRenamedNestedModelValue_get =
|
|
368
|
+
Payload_Xml_ModelWithRenamedNestedModel.get;
|
|
369
|
+
Scenarios.Payload_Xml_ModelWithRenamedNestedModelValue_put =
|
|
370
|
+
Payload_Xml_ModelWithRenamedNestedModel.put;
|
|
371
|
+
|
|
372
|
+
// §3 — Array of primitive types
|
|
373
|
+
|
|
176
374
|
const Payload_Xml_ModelWithSimpleArrays = createServerTests(
|
|
177
375
|
"/payload/xml/modelWithSimpleArrays",
|
|
178
376
|
modelWithSimpleArrays,
|
|
@@ -180,6 +378,31 @@ const Payload_Xml_ModelWithSimpleArrays = createServerTests(
|
|
|
180
378
|
Scenarios.Payload_Xml_ModelWithSimpleArraysValue_get = Payload_Xml_ModelWithSimpleArrays.get;
|
|
181
379
|
Scenarios.Payload_Xml_ModelWithSimpleArraysValue_put = Payload_Xml_ModelWithSimpleArrays.put;
|
|
182
380
|
|
|
381
|
+
const Payload_Xml_ModelWithUnwrappedArray = createServerTests(
|
|
382
|
+
"/payload/xml/modelWithUnwrappedArray",
|
|
383
|
+
modelWithUnwrappedArray,
|
|
384
|
+
);
|
|
385
|
+
Scenarios.Payload_Xml_ModelWithUnwrappedArrayValue_get = Payload_Xml_ModelWithUnwrappedArray.get;
|
|
386
|
+
Scenarios.Payload_Xml_ModelWithUnwrappedArrayValue_put = Payload_Xml_ModelWithUnwrappedArray.put;
|
|
387
|
+
|
|
388
|
+
const Payload_Xml_ModelWithRenamedArrays = createServerTests(
|
|
389
|
+
"/payload/xml/modelWithRenamedArrays",
|
|
390
|
+
modelWithRenamedArrays,
|
|
391
|
+
);
|
|
392
|
+
Scenarios.Payload_Xml_ModelWithRenamedArraysValue_get = Payload_Xml_ModelWithRenamedArrays.get;
|
|
393
|
+
Scenarios.Payload_Xml_ModelWithRenamedArraysValue_put = Payload_Xml_ModelWithRenamedArrays.put;
|
|
394
|
+
|
|
395
|
+
const Payload_Xml_ModelWithWrappedPrimitiveCustomItemNames = createServerTests(
|
|
396
|
+
"/payload/xml/modelWithWrappedPrimitiveCustomItemNames",
|
|
397
|
+
modelWithWrappedPrimitiveCustomItemNames,
|
|
398
|
+
);
|
|
399
|
+
Scenarios.Payload_Xml_ModelWithWrappedPrimitiveCustomItemNamesValue_get =
|
|
400
|
+
Payload_Xml_ModelWithWrappedPrimitiveCustomItemNames.get;
|
|
401
|
+
Scenarios.Payload_Xml_ModelWithWrappedPrimitiveCustomItemNamesValue_put =
|
|
402
|
+
Payload_Xml_ModelWithWrappedPrimitiveCustomItemNames.put;
|
|
403
|
+
|
|
404
|
+
// §4 — Array of complex types
|
|
405
|
+
|
|
183
406
|
const Payload_Xml_ModelWithArrayOfModel = createServerTests(
|
|
184
407
|
"/payload/xml/modelWithArrayOfModel",
|
|
185
408
|
modelWithArrayOfModel,
|
|
@@ -187,12 +410,43 @@ const Payload_Xml_ModelWithArrayOfModel = createServerTests(
|
|
|
187
410
|
Scenarios.Payload_Xml_ModelWithArrayOfModelValue_get = Payload_Xml_ModelWithArrayOfModel.get;
|
|
188
411
|
Scenarios.Payload_Xml_ModelWithArrayOfModelValue_put = Payload_Xml_ModelWithArrayOfModel.put;
|
|
189
412
|
|
|
190
|
-
const
|
|
191
|
-
"/payload/xml/
|
|
192
|
-
|
|
413
|
+
const Payload_Xml_ModelWithUnwrappedModelArray = createServerTests(
|
|
414
|
+
"/payload/xml/modelWithUnwrappedModelArray",
|
|
415
|
+
modelWithUnwrappedModelArray,
|
|
193
416
|
);
|
|
194
|
-
Scenarios.
|
|
195
|
-
|
|
417
|
+
Scenarios.Payload_Xml_ModelWithUnwrappedModelArrayValue_get =
|
|
418
|
+
Payload_Xml_ModelWithUnwrappedModelArray.get;
|
|
419
|
+
Scenarios.Payload_Xml_ModelWithUnwrappedModelArrayValue_put =
|
|
420
|
+
Payload_Xml_ModelWithUnwrappedModelArray.put;
|
|
421
|
+
|
|
422
|
+
const Payload_Xml_ModelWithRenamedWrappedModelArray = createServerTests(
|
|
423
|
+
"/payload/xml/modelWithRenamedWrappedModelArray",
|
|
424
|
+
modelWithRenamedWrappedModelArray,
|
|
425
|
+
);
|
|
426
|
+
Scenarios.Payload_Xml_ModelWithRenamedWrappedModelArrayValue_get =
|
|
427
|
+
Payload_Xml_ModelWithRenamedWrappedModelArray.get;
|
|
428
|
+
Scenarios.Payload_Xml_ModelWithRenamedWrappedModelArrayValue_put =
|
|
429
|
+
Payload_Xml_ModelWithRenamedWrappedModelArray.put;
|
|
430
|
+
|
|
431
|
+
const Payload_Xml_ModelWithRenamedUnwrappedModelArray = createServerTests(
|
|
432
|
+
"/payload/xml/modelWithRenamedUnwrappedModelArray",
|
|
433
|
+
modelWithRenamedUnwrappedModelArray,
|
|
434
|
+
);
|
|
435
|
+
Scenarios.Payload_Xml_ModelWithRenamedUnwrappedModelArrayValue_get =
|
|
436
|
+
Payload_Xml_ModelWithRenamedUnwrappedModelArray.get;
|
|
437
|
+
Scenarios.Payload_Xml_ModelWithRenamedUnwrappedModelArrayValue_put =
|
|
438
|
+
Payload_Xml_ModelWithRenamedUnwrappedModelArray.put;
|
|
439
|
+
|
|
440
|
+
const Payload_Xml_ModelWithRenamedWrappedAndItemModelArray = createServerTests(
|
|
441
|
+
"/payload/xml/modelWithRenamedWrappedAndItemModelArray",
|
|
442
|
+
modelWithRenamedWrappedAndItemModelArray,
|
|
443
|
+
);
|
|
444
|
+
Scenarios.Payload_Xml_ModelWithRenamedWrappedAndItemModelArrayValue_get =
|
|
445
|
+
Payload_Xml_ModelWithRenamedWrappedAndItemModelArray.get;
|
|
446
|
+
Scenarios.Payload_Xml_ModelWithRenamedWrappedAndItemModelArrayValue_put =
|
|
447
|
+
Payload_Xml_ModelWithRenamedWrappedAndItemModelArray.put;
|
|
448
|
+
|
|
449
|
+
// §5 — Attributes
|
|
196
450
|
|
|
197
451
|
const Payload_Xml_ModelWithAttributes = createServerTests(
|
|
198
452
|
"/payload/xml/modelWithAttributes",
|
|
@@ -201,26 +455,47 @@ const Payload_Xml_ModelWithAttributes = createServerTests(
|
|
|
201
455
|
Scenarios.Payload_Xml_ModelWithAttributesValue_get = Payload_Xml_ModelWithAttributes.get;
|
|
202
456
|
Scenarios.Payload_Xml_ModelWithAttributesValue_put = Payload_Xml_ModelWithAttributes.put;
|
|
203
457
|
|
|
204
|
-
const
|
|
205
|
-
"/payload/xml/
|
|
206
|
-
|
|
458
|
+
const Payload_Xml_ModelWithRenamedAttribute = createServerTests(
|
|
459
|
+
"/payload/xml/modelWithRenamedAttribute",
|
|
460
|
+
modelWithRenamedAttribute,
|
|
207
461
|
);
|
|
208
|
-
Scenarios.
|
|
209
|
-
|
|
462
|
+
Scenarios.Payload_Xml_ModelWithRenamedAttributeValue_get =
|
|
463
|
+
Payload_Xml_ModelWithRenamedAttribute.get;
|
|
464
|
+
Scenarios.Payload_Xml_ModelWithRenamedAttributeValue_put =
|
|
465
|
+
Payload_Xml_ModelWithRenamedAttribute.put;
|
|
210
466
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
467
|
+
// §6/§7 — Namespace and prefix
|
|
468
|
+
|
|
469
|
+
const Payload_Xml_ModelWithNamespace = createServerTests(
|
|
470
|
+
"/payload/xml/modelWithNamespace",
|
|
471
|
+
modelWithNamespace,
|
|
214
472
|
);
|
|
215
|
-
Scenarios.
|
|
216
|
-
Scenarios.
|
|
473
|
+
Scenarios.Payload_Xml_ModelWithNamespaceValue_get = Payload_Xml_ModelWithNamespace.get;
|
|
474
|
+
Scenarios.Payload_Xml_ModelWithNamespaceValue_put = Payload_Xml_ModelWithNamespace.put;
|
|
217
475
|
|
|
218
|
-
const
|
|
219
|
-
"/payload/xml/
|
|
220
|
-
|
|
476
|
+
const Payload_Xml_ModelWithNamespaceOnProperties = createServerTests(
|
|
477
|
+
"/payload/xml/modelWithNamespaceOnProperties",
|
|
478
|
+
modelWithNamespaceOnProperties,
|
|
221
479
|
);
|
|
222
|
-
Scenarios.
|
|
223
|
-
|
|
480
|
+
Scenarios.Payload_Xml_ModelWithNamespaceOnPropertiesValue_get =
|
|
481
|
+
Payload_Xml_ModelWithNamespaceOnProperties.get;
|
|
482
|
+
Scenarios.Payload_Xml_ModelWithNamespaceOnPropertiesValue_put =
|
|
483
|
+
Payload_Xml_ModelWithNamespaceOnProperties.put;
|
|
484
|
+
|
|
485
|
+
// §8 — Text content
|
|
486
|
+
|
|
487
|
+
const Payload_Xml_ModelWithText = createServerTests("/payload/xml/modelWithText", modelWithText);
|
|
488
|
+
Scenarios.Payload_Xml_ModelWithTextValue_get = Payload_Xml_ModelWithText.get;
|
|
489
|
+
Scenarios.Payload_Xml_ModelWithTextValue_put = Payload_Xml_ModelWithText.put;
|
|
490
|
+
|
|
491
|
+
// Additional scenarios
|
|
492
|
+
|
|
493
|
+
const Payload_Xml_ModelWithOptionalField = createServerTests(
|
|
494
|
+
"/payload/xml/modelWithOptionalField",
|
|
495
|
+
modelWithOptionalField,
|
|
496
|
+
);
|
|
497
|
+
Scenarios.Payload_Xml_ModelWithOptionalFieldValue_get = Payload_Xml_ModelWithOptionalField.get;
|
|
498
|
+
Scenarios.Payload_Xml_ModelWithOptionalFieldValue_put = Payload_Xml_ModelWithOptionalField.put;
|
|
224
499
|
|
|
225
500
|
const Payload_Xml_ModelWithEmptyArray = createServerTests(
|
|
226
501
|
"/payload/xml/modelWithEmptyArray",
|
|
@@ -229,10 +504,6 @@ const Payload_Xml_ModelWithEmptyArray = createServerTests(
|
|
|
229
504
|
Scenarios.Payload_Xml_ModelWithEmptyArrayValue_get = Payload_Xml_ModelWithEmptyArray.get;
|
|
230
505
|
Scenarios.Payload_Xml_ModelWithEmptyArrayValue_put = Payload_Xml_ModelWithEmptyArray.put;
|
|
231
506
|
|
|
232
|
-
const Payload_Xml_ModelWithText = createServerTests("/payload/xml/modelWithText", modelWithText);
|
|
233
|
-
Scenarios.Payload_Xml_ModelWithTextValue_get = Payload_Xml_ModelWithText.get;
|
|
234
|
-
Scenarios.Payload_Xml_ModelWithTextValue_put = Payload_Xml_ModelWithText.put;
|
|
235
|
-
|
|
236
507
|
const Payload_Xml_ModelWithDictionary = createServerTests(
|
|
237
508
|
"/payload/xml/modelWithDictionary",
|
|
238
509
|
modelWithDictionary,
|
|
@@ -251,19 +522,44 @@ const Payload_Xml_ModelWithEnum = createServerTests("/payload/xml/modelWithEnum"
|
|
|
251
522
|
Scenarios.Payload_Xml_ModelWithEnumValue_get = Payload_Xml_ModelWithEnum.get;
|
|
252
523
|
Scenarios.Payload_Xml_ModelWithEnumValue_put = Payload_Xml_ModelWithEnum.put;
|
|
253
524
|
|
|
254
|
-
|
|
255
|
-
"/payload/xml/modelWithDatetime",
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
525
|
+
Scenarios.Payload_Xml_ModelWithDatetimeValue_get = passOnSuccess({
|
|
526
|
+
uri: "/payload/xml/modelWithDatetime",
|
|
527
|
+
method: "get",
|
|
528
|
+
request: {},
|
|
529
|
+
response: {
|
|
530
|
+
status: 200,
|
|
531
|
+
body: xml(modelWithDatetime),
|
|
532
|
+
},
|
|
533
|
+
kind: "MockApiDefinition",
|
|
534
|
+
});
|
|
260
535
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
536
|
+
Scenarios.Payload_Xml_ModelWithDatetimeValue_put = passOnSuccess({
|
|
537
|
+
uri: "/payload/xml/modelWithDatetime",
|
|
538
|
+
method: "put",
|
|
539
|
+
request: {
|
|
540
|
+
body: xml(modelWithDatetime),
|
|
541
|
+
},
|
|
542
|
+
handler: (req: MockRequest) => {
|
|
543
|
+
req.expect.containsHeader("content-type", "application/xml");
|
|
544
|
+
// Accept both "2022-08-26T18:38:00.000Z" and "2022-08-26T18:38:00Z" as equivalent UTC datetimes.
|
|
545
|
+
let firstError: unknown;
|
|
546
|
+
try {
|
|
547
|
+
req.expect.xmlBodyEquals(modelWithDatetime);
|
|
548
|
+
} catch (e) {
|
|
549
|
+
firstError = e;
|
|
550
|
+
}
|
|
551
|
+
if (firstError !== undefined) {
|
|
552
|
+
req.expect.xmlBodyEquals(modelWithDatetimeNoMs);
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
status: 204,
|
|
556
|
+
};
|
|
557
|
+
},
|
|
558
|
+
response: {
|
|
559
|
+
status: 204,
|
|
560
|
+
},
|
|
561
|
+
kind: "MockApiDefinition",
|
|
562
|
+
});
|
|
267
563
|
|
|
268
564
|
Scenarios.Payload_Xml_XmlErrorValue_get = passOnCode(400, {
|
|
269
565
|
uri: "/payload/xml/error",
|
|
@@ -290,51 +290,51 @@ namespace ModelProperties {
|
|
|
290
290
|
op withList(@body body: ModelWithList): void;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
/**
|
|
294
|
-
* Verify enum member names that are special words using extensible enum (union).
|
|
295
|
-
*/
|
|
296
|
-
union ExtensibleString {
|
|
297
|
-
string,
|
|
298
|
-
and: "and",
|
|
299
|
-
as: "as",
|
|
300
|
-
assert: "assert",
|
|
301
|
-
async: "async",
|
|
302
|
-
await: "await",
|
|
303
|
-
break: "break",
|
|
304
|
-
class: "class",
|
|
305
|
-
constructor: "constructor",
|
|
306
|
-
continue: "continue",
|
|
307
|
-
def: "def",
|
|
308
|
-
del: "del",
|
|
309
|
-
elif: "elif",
|
|
310
|
-
`else`: "else",
|
|
311
|
-
except: "except",
|
|
312
|
-
exec: "exec",
|
|
313
|
-
finally: "finally",
|
|
314
|
-
for: "for",
|
|
315
|
-
from: "from",
|
|
316
|
-
global: "global",
|
|
317
|
-
`if`: "if",
|
|
318
|
-
`import`: "import",
|
|
319
|
-
in: "in",
|
|
320
|
-
`is`: "is",
|
|
321
|
-
lambda: "lambda",
|
|
322
|
-
not: "not",
|
|
323
|
-
or: "or",
|
|
324
|
-
pass: "pass",
|
|
325
|
-
raise: "raise",
|
|
326
|
-
`return`: "return",
|
|
327
|
-
try: "try",
|
|
328
|
-
while: "while",
|
|
329
|
-
with: "with",
|
|
330
|
-
yield: "yield",
|
|
331
|
-
}
|
|
332
|
-
|
|
333
293
|
/**
|
|
334
294
|
* Verify enum member names that are special words.
|
|
335
295
|
*/
|
|
336
296
|
@route("/extensible-strings")
|
|
337
|
-
|
|
297
|
+
namespace ExtensibleStrings {
|
|
298
|
+
/**
|
|
299
|
+
* Verify enum member names that are special words using extensible enum (union).
|
|
300
|
+
*/
|
|
301
|
+
union ExtensibleString {
|
|
302
|
+
string,
|
|
303
|
+
and: "and",
|
|
304
|
+
as: "as",
|
|
305
|
+
assert: "assert",
|
|
306
|
+
async: "async",
|
|
307
|
+
await: "await",
|
|
308
|
+
break: "break",
|
|
309
|
+
class: "class",
|
|
310
|
+
constructor: "constructor",
|
|
311
|
+
continue: "continue",
|
|
312
|
+
def: "def",
|
|
313
|
+
del: "del",
|
|
314
|
+
elif: "elif",
|
|
315
|
+
`else`: "else",
|
|
316
|
+
except: "except",
|
|
317
|
+
exec: "exec",
|
|
318
|
+
finally: "finally",
|
|
319
|
+
for: "for",
|
|
320
|
+
from: "from",
|
|
321
|
+
global: "global",
|
|
322
|
+
`if`: "if",
|
|
323
|
+
`import`: "import",
|
|
324
|
+
in: "in",
|
|
325
|
+
`is`: "is",
|
|
326
|
+
lambda: "lambda",
|
|
327
|
+
not: "not",
|
|
328
|
+
or: "or",
|
|
329
|
+
pass: "pass",
|
|
330
|
+
raise: "raise",
|
|
331
|
+
`return`: "return",
|
|
332
|
+
try: "try",
|
|
333
|
+
while: "while",
|
|
334
|
+
with: "with",
|
|
335
|
+
yield: "yield",
|
|
336
|
+
}
|
|
337
|
+
|
|
338
338
|
@scenario
|
|
339
339
|
@scenarioDoc("""
|
|
340
340
|
Verify that enum members with special word names can be sent and received properly.
|
|
@@ -342,5 +342,11 @@ interface ExtensibleStrings {
|
|
|
342
342
|
""")
|
|
343
343
|
@put
|
|
344
344
|
@route("/string")
|
|
345
|
-
putExtensibleStringValue(
|
|
345
|
+
op putExtensibleStringValue(
|
|
346
|
+
@header contentType: "application/json",
|
|
347
|
+
@body body: ExtensibleString,
|
|
348
|
+
): {
|
|
349
|
+
@header contentType: "application/json";
|
|
350
|
+
@body body: ExtensibleString;
|
|
351
|
+
};
|
|
346
352
|
}
|