@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
|
@@ -6,127 +6,27 @@ using Http;
|
|
|
6
6
|
using Spector;
|
|
7
7
|
using TypeSpec.Xml;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/** Sends and receives bodies in XML format. */
|
|
10
10
|
@scenarioService("/payload/xml")
|
|
11
11
|
namespace Payload.Xml;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
14
|
+
// Shared types
|
|
15
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
/** §1.1 — Contains fields of primitive types. */
|
|
14
18
|
model SimpleModel {
|
|
15
19
|
name: string;
|
|
16
20
|
age: int32;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
@
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@doc("Contains an array of models.")
|
|
26
|
-
model ModelWithArrayOfModel {
|
|
27
|
-
items: SimpleModel[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@doc("Contains an optional field.")
|
|
31
|
-
model ModelWithOptionalField {
|
|
32
|
-
item: string;
|
|
33
|
-
value?: int32;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@doc("Contains fields that are XML attributes.")
|
|
37
|
-
model ModelWithAttributes {
|
|
38
|
-
@attribute id1: int32;
|
|
39
|
-
@attribute id2: string;
|
|
40
|
-
enabled: boolean;
|
|
23
|
+
@nsDeclarations
|
|
24
|
+
enum Namespaces {
|
|
25
|
+
smp: "http://example.com/schema",
|
|
26
|
+
ns2: "http://example.com/ns2",
|
|
41
27
|
}
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
model ModelWithUnwrappedArray {
|
|
45
|
-
@unwrapped colors: string[];
|
|
46
|
-
counts: int32[];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@doc("Contains fields of wrapped and unwrapped arrays of primitive types that have different XML representations.")
|
|
50
|
-
model ModelWithRenamedArrays {
|
|
51
|
-
@name("Colors") @unwrapped colors: string[];
|
|
52
|
-
@name("Counts") counts: int32[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@doc("Contains fields of the same type that have different XML representation.")
|
|
56
|
-
@name("ModelWithRenamedFieldsSrc")
|
|
57
|
-
model ModelWithRenamedFields {
|
|
58
|
-
@name("InputData") inputData: SimpleModel;
|
|
59
|
-
@name("OutputData") outputData: SimpleModel;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@doc("Contains an array of models that's supposed to be sent/received as an empty XML element.")
|
|
63
|
-
model ModelWithEmptyArray {
|
|
64
|
-
items: SimpleModel[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@doc("Contains an attribute and text.")
|
|
68
|
-
model ModelWithText {
|
|
69
|
-
@attribute language: string;
|
|
70
|
-
@unwrapped content: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@doc("Contains a dictionary of key value pairs.")
|
|
74
|
-
model ModelWithDictionary {
|
|
75
|
-
metadata: Record<string>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@doc("Uses encodedName instead of Xml.Name which is functionally equivalent.")
|
|
79
|
-
@encodedName("application/xml", "ModelWithEncodedNamesSrc")
|
|
80
|
-
model ModelWithEncodedNames {
|
|
81
|
-
@encodedName("application/xml", "SimpleModelData") modelData: SimpleModel;
|
|
82
|
-
@encodedName("application/xml", "PossibleColors") colors: string[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@doc("Status values for the model with enum.")
|
|
86
|
-
union Status {
|
|
87
|
-
string,
|
|
88
|
-
|
|
89
|
-
@doc("Pending status.")
|
|
90
|
-
pending: "pending",
|
|
91
|
-
|
|
92
|
-
@doc("Success status.")
|
|
93
|
-
success: "success",
|
|
94
|
-
|
|
95
|
-
@doc("Error status.")
|
|
96
|
-
error: "error",
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@doc("Contains a single property with an enum value.")
|
|
100
|
-
model ModelWithEnum {
|
|
101
|
-
status: Status;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@doc("Contains datetime properties with different encodings.")
|
|
105
|
-
model ModelWithDatetime {
|
|
106
|
-
@encode(DateTimeKnownEncoding.rfc3339)
|
|
107
|
-
@doc("DateTime value with rfc3339 encoding.")
|
|
108
|
-
rfc3339: utcDateTime;
|
|
109
|
-
|
|
110
|
-
@encode(DateTimeKnownEncoding.rfc7231)
|
|
111
|
-
@doc("DateTime value with rfc7231 encoding.")
|
|
112
|
-
rfc7231: utcDateTime;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@doc("An error response body in XML format.")
|
|
116
|
-
@error
|
|
117
|
-
model XmlError {
|
|
118
|
-
@statusCode _: 400;
|
|
119
|
-
@header("content-type") contentType: "application/xml";
|
|
120
|
-
@body body: XmlErrorBody;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@doc("The body of an XML error response.")
|
|
124
|
-
model XmlErrorBody {
|
|
125
|
-
message: string;
|
|
126
|
-
code: int32;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@doc("Template for XML operations")
|
|
29
|
+
/** Template for XML operations */
|
|
130
30
|
interface XmlOperations<TModel, TDoc extends valueof string> {
|
|
131
31
|
@scenario
|
|
132
32
|
@scenarioDoc("""
|
|
@@ -152,7 +52,11 @@ interface XmlOperations<TModel, TDoc extends valueof string> {
|
|
|
152
52
|
put(@header("content-type") contentType: "application/xml", @body input: TModel): void;
|
|
153
53
|
}
|
|
154
54
|
|
|
155
|
-
|
|
55
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
56
|
+
// §1 — Primitive properties
|
|
57
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
58
|
+
|
|
59
|
+
/** §1.1 — Operations for the SimpleModel type. */
|
|
156
60
|
@route("/simpleModel")
|
|
157
61
|
interface SimpleModelValue
|
|
158
62
|
extends XmlOperations<
|
|
@@ -165,7 +69,113 @@ interface SimpleModelValue
|
|
|
165
69
|
"""
|
|
166
70
|
> {}
|
|
167
71
|
|
|
168
|
-
|
|
72
|
+
/** §1.2 — Contains a scalar property with a custom XML name. */
|
|
73
|
+
model ModelWithRenamedProperty {
|
|
74
|
+
@name("renamedTitle")
|
|
75
|
+
title: string;
|
|
76
|
+
|
|
77
|
+
author: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** §1.2 — Operations for the ModelWithRenamedProperty type. */
|
|
81
|
+
@route("/modelWithRenamedProperty")
|
|
82
|
+
interface ModelWithRenamedPropertyValue
|
|
83
|
+
extends XmlOperations<
|
|
84
|
+
ModelWithRenamedProperty,
|
|
85
|
+
"""
|
|
86
|
+
<ModelWithRenamedProperty>
|
|
87
|
+
<renamedTitle>foo</renamedTitle>
|
|
88
|
+
<author>bar</author>
|
|
89
|
+
</ModelWithRenamedProperty>
|
|
90
|
+
"""
|
|
91
|
+
> {}
|
|
92
|
+
|
|
93
|
+
/** §1.3, §2.3 — Contains fields of the same type that have different XML representation. */
|
|
94
|
+
@name("ModelWithRenamedFieldsSrc")
|
|
95
|
+
model ModelWithRenamedFields {
|
|
96
|
+
@name("InputData") inputData: SimpleModel;
|
|
97
|
+
@name("OutputData") outputData: SimpleModel;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** §1.3, §2.3 — Operations for the ModelWithRenamedFields type. */
|
|
101
|
+
@route("/modelWithRenamedFields")
|
|
102
|
+
interface ModelWithRenamedFieldsValue
|
|
103
|
+
extends XmlOperations<
|
|
104
|
+
ModelWithRenamedFields,
|
|
105
|
+
"""
|
|
106
|
+
<ModelWithRenamedFieldsSrc>
|
|
107
|
+
<InputData>
|
|
108
|
+
<name>foo</name>
|
|
109
|
+
<age>123</age>
|
|
110
|
+
</InputData>
|
|
111
|
+
<OutputData>
|
|
112
|
+
<name>bar</name>
|
|
113
|
+
<age>456</age>
|
|
114
|
+
</OutputData>
|
|
115
|
+
</ModelWithRenamedFieldsSrc>
|
|
116
|
+
"""
|
|
117
|
+
> {}
|
|
118
|
+
|
|
119
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
120
|
+
// §2 — Nested models
|
|
121
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
122
|
+
|
|
123
|
+
/** §2.1 — Contains a property that references another model. */
|
|
124
|
+
model ModelWithNestedModel {
|
|
125
|
+
nested: SimpleModel;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** §2.1 — Operations for the ModelWithNestedModel type. */
|
|
129
|
+
@route("/modelWithNestedModel")
|
|
130
|
+
interface ModelWithNestedModelValue
|
|
131
|
+
extends XmlOperations<
|
|
132
|
+
ModelWithNestedModel,
|
|
133
|
+
"""
|
|
134
|
+
<ModelWithNestedModel>
|
|
135
|
+
<nested>
|
|
136
|
+
<name>foo</name>
|
|
137
|
+
<age>123</age>
|
|
138
|
+
</nested>
|
|
139
|
+
</ModelWithNestedModel>
|
|
140
|
+
"""
|
|
141
|
+
> {}
|
|
142
|
+
|
|
143
|
+
/** Author model with a custom XML name. */
|
|
144
|
+
@name("XmlAuthor")
|
|
145
|
+
model Author {
|
|
146
|
+
name: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** §2.2 — Contains a property whose type has @Xml.name. The property name takes precedence. */
|
|
150
|
+
model ModelWithRenamedNestedModel {
|
|
151
|
+
author: Author;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** §2.2 — Operations for the ModelWithRenamedNestedModel type. */
|
|
155
|
+
@route("/modelWithRenamedNestedModel")
|
|
156
|
+
interface ModelWithRenamedNestedModelValue
|
|
157
|
+
extends XmlOperations<
|
|
158
|
+
ModelWithRenamedNestedModel,
|
|
159
|
+
"""
|
|
160
|
+
<ModelWithRenamedNestedModel>
|
|
161
|
+
<author>
|
|
162
|
+
<name>foo</name>
|
|
163
|
+
</author>
|
|
164
|
+
</ModelWithRenamedNestedModel>
|
|
165
|
+
"""
|
|
166
|
+
> {}
|
|
167
|
+
|
|
168
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
169
|
+
// §3 — Array of primitive types
|
|
170
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
171
|
+
|
|
172
|
+
/** §3.1 — Contains fields of arrays of primitive types. */
|
|
173
|
+
model ModelWithSimpleArrays {
|
|
174
|
+
colors: string[];
|
|
175
|
+
counts: int32[];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** §3.1 — Operations for the ModelWithSimpleArrays type. */
|
|
169
179
|
@route("/modelWithSimpleArrays")
|
|
170
180
|
interface ModelWithSimpleArraysValue
|
|
171
181
|
extends XmlOperations<
|
|
@@ -185,7 +195,89 @@ interface ModelWithSimpleArraysValue
|
|
|
185
195
|
"""
|
|
186
196
|
> {}
|
|
187
197
|
|
|
188
|
-
|
|
198
|
+
/** §3.2 — Contains fields of wrapped and unwrapped arrays of primitive types. */
|
|
199
|
+
model ModelWithUnwrappedArray {
|
|
200
|
+
@unwrapped colors: string[];
|
|
201
|
+
counts: int32[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** §3.2 — Operations for the ModelWithUnwrappedArray type. */
|
|
205
|
+
@route("/modelWithUnwrappedArray")
|
|
206
|
+
interface ModelWithUnwrappedArrayValue
|
|
207
|
+
extends XmlOperations<
|
|
208
|
+
ModelWithUnwrappedArray,
|
|
209
|
+
"""
|
|
210
|
+
<ModelWithUnwrappedArray>
|
|
211
|
+
<colors>red</colors>
|
|
212
|
+
<colors>green</colors>
|
|
213
|
+
<colors>blue</colors>
|
|
214
|
+
<counts>
|
|
215
|
+
<int32>1</int32>
|
|
216
|
+
<int32>2</int32>
|
|
217
|
+
</counts>
|
|
218
|
+
</ModelWithUnwrappedArray>
|
|
219
|
+
"""
|
|
220
|
+
> {}
|
|
221
|
+
|
|
222
|
+
/** §3.3, §3.4 — Contains fields of wrapped and unwrapped arrays of primitive types that have different XML representations. */
|
|
223
|
+
model ModelWithRenamedArrays {
|
|
224
|
+
@name("Colors") @unwrapped colors: string[];
|
|
225
|
+
@name("Counts") counts: int32[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** §3.3, §3.4 — Operations for the ModelWithRenamedArrays type. */
|
|
229
|
+
@route("/modelWithRenamedArrays")
|
|
230
|
+
interface ModelWithRenamedArraysValue
|
|
231
|
+
extends XmlOperations<
|
|
232
|
+
ModelWithRenamedArrays,
|
|
233
|
+
"""
|
|
234
|
+
<ModelWithRenamedArrays>
|
|
235
|
+
<Colors>red</Colors>
|
|
236
|
+
<Colors>green</Colors>
|
|
237
|
+
<Colors>blue</Colors>
|
|
238
|
+
<Counts>
|
|
239
|
+
<int32>1</int32>
|
|
240
|
+
<int32>2</int32>
|
|
241
|
+
</Counts>
|
|
242
|
+
</ModelWithRenamedArrays>
|
|
243
|
+
"""
|
|
244
|
+
> {}
|
|
245
|
+
|
|
246
|
+
/** Custom scalar with a custom XML item name. */
|
|
247
|
+
@name("ItemName")
|
|
248
|
+
scalar tag extends string;
|
|
249
|
+
|
|
250
|
+
/** §3.5 — Contains a wrapped primitive array with custom wrapper and item names. */
|
|
251
|
+
model ModelWithWrappedPrimitiveCustomItemNames {
|
|
252
|
+
@name("ItemsTags")
|
|
253
|
+
tags: tag[];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** §3.5 — Operations for the ModelWithWrappedPrimitiveCustomItemNames type. */
|
|
257
|
+
@route("/modelWithWrappedPrimitiveCustomItemNames")
|
|
258
|
+
interface ModelWithWrappedPrimitiveCustomItemNamesValue
|
|
259
|
+
extends XmlOperations<
|
|
260
|
+
ModelWithWrappedPrimitiveCustomItemNames,
|
|
261
|
+
"""
|
|
262
|
+
<ModelWithWrappedPrimitiveCustomItemNames>
|
|
263
|
+
<ItemsTags>
|
|
264
|
+
<ItemName>fiction</ItemName>
|
|
265
|
+
<ItemName>classic</ItemName>
|
|
266
|
+
</ItemsTags>
|
|
267
|
+
</ModelWithWrappedPrimitiveCustomItemNames>
|
|
268
|
+
"""
|
|
269
|
+
> {}
|
|
270
|
+
|
|
271
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
272
|
+
// §4 — Array of complex types
|
|
273
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
274
|
+
|
|
275
|
+
/** §4.1 — Contains an array of models. */
|
|
276
|
+
model ModelWithArrayOfModel {
|
|
277
|
+
items: SimpleModel[];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** §4.1 — Operations for the ModelWithArrayOfModel type. */
|
|
189
281
|
@route("/modelWithArrayOfModel")
|
|
190
282
|
interface ModelWithArrayOfModelValue
|
|
191
283
|
extends XmlOperations<
|
|
@@ -206,19 +298,127 @@ interface ModelWithArrayOfModelValue
|
|
|
206
298
|
"""
|
|
207
299
|
> {}
|
|
208
300
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
301
|
+
/** §4.2 — Contains an unwrapped array of models. */
|
|
302
|
+
model ModelWithUnwrappedModelArray {
|
|
303
|
+
@unwrapped
|
|
304
|
+
items: SimpleModel[];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** §4.2 — Operations for the ModelWithUnwrappedModelArray type. */
|
|
308
|
+
@route("/modelWithUnwrappedModelArray")
|
|
309
|
+
interface ModelWithUnwrappedModelArrayValue
|
|
212
310
|
extends XmlOperations<
|
|
213
|
-
|
|
311
|
+
ModelWithUnwrappedModelArray,
|
|
214
312
|
"""
|
|
215
|
-
<
|
|
216
|
-
<
|
|
217
|
-
|
|
313
|
+
<ModelWithUnwrappedModelArray>
|
|
314
|
+
<items>
|
|
315
|
+
<name>foo</name>
|
|
316
|
+
<age>123</age>
|
|
317
|
+
</items>
|
|
318
|
+
<items>
|
|
319
|
+
<name>bar</name>
|
|
320
|
+
<age>456</age>
|
|
321
|
+
</items>
|
|
322
|
+
</ModelWithUnwrappedModelArray>
|
|
218
323
|
"""
|
|
219
324
|
> {}
|
|
220
325
|
|
|
221
|
-
|
|
326
|
+
/** §4.3 — Contains a wrapped array of models with a custom wrapper name. */
|
|
327
|
+
model ModelWithRenamedWrappedModelArray {
|
|
328
|
+
@name("AllItems")
|
|
329
|
+
items: SimpleModel[];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** §4.3 — Operations for the ModelWithRenamedWrappedModelArray type. */
|
|
333
|
+
@route("/modelWithRenamedWrappedModelArray")
|
|
334
|
+
interface ModelWithRenamedWrappedModelArrayValue
|
|
335
|
+
extends XmlOperations<
|
|
336
|
+
ModelWithRenamedWrappedModelArray,
|
|
337
|
+
"""
|
|
338
|
+
<ModelWithRenamedWrappedModelArray>
|
|
339
|
+
<AllItems>
|
|
340
|
+
<SimpleModel>
|
|
341
|
+
<name>foo</name>
|
|
342
|
+
<age>123</age>
|
|
343
|
+
</SimpleModel>
|
|
344
|
+
<SimpleModel>
|
|
345
|
+
<name>bar</name>
|
|
346
|
+
<age>456</age>
|
|
347
|
+
</SimpleModel>
|
|
348
|
+
</AllItems>
|
|
349
|
+
</ModelWithRenamedWrappedModelArray>
|
|
350
|
+
"""
|
|
351
|
+
> {}
|
|
352
|
+
|
|
353
|
+
/** §4.4 — Contains an unwrapped array of models with a custom item name. */
|
|
354
|
+
model ModelWithRenamedUnwrappedModelArray {
|
|
355
|
+
@name("ModelItem")
|
|
356
|
+
@unwrapped
|
|
357
|
+
items: SimpleModel[];
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** §4.4 — Operations for the ModelWithRenamedUnwrappedModelArray type. */
|
|
361
|
+
@route("/modelWithRenamedUnwrappedModelArray")
|
|
362
|
+
interface ModelWithRenamedUnwrappedModelArrayValue
|
|
363
|
+
extends XmlOperations<
|
|
364
|
+
ModelWithRenamedUnwrappedModelArray,
|
|
365
|
+
"""
|
|
366
|
+
<ModelWithRenamedUnwrappedModelArray>
|
|
367
|
+
<ModelItem>
|
|
368
|
+
<name>foo</name>
|
|
369
|
+
<age>123</age>
|
|
370
|
+
</ModelItem>
|
|
371
|
+
<ModelItem>
|
|
372
|
+
<name>bar</name>
|
|
373
|
+
<age>456</age>
|
|
374
|
+
</ModelItem>
|
|
375
|
+
</ModelWithRenamedUnwrappedModelArray>
|
|
376
|
+
"""
|
|
377
|
+
> {}
|
|
378
|
+
|
|
379
|
+
/** Book model with a custom XML name. */
|
|
380
|
+
@name("XmlBook")
|
|
381
|
+
model Book {
|
|
382
|
+
title: string;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** §4.5 — Contains a wrapped array of models with custom wrapper and item names. */
|
|
386
|
+
model ModelWithRenamedWrappedAndItemModelArray {
|
|
387
|
+
@name("AllBooks")
|
|
388
|
+
books: Book[];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** §4.5 — Operations for the ModelWithRenamedWrappedAndItemModelArray type. */
|
|
392
|
+
@route("/modelWithRenamedWrappedAndItemModelArray")
|
|
393
|
+
interface ModelWithRenamedWrappedAndItemModelArrayValue
|
|
394
|
+
extends XmlOperations<
|
|
395
|
+
ModelWithRenamedWrappedAndItemModelArray,
|
|
396
|
+
"""
|
|
397
|
+
<ModelWithRenamedWrappedAndItemModelArray>
|
|
398
|
+
<AllBooks>
|
|
399
|
+
<XmlBook>
|
|
400
|
+
<title>The Great Gatsby</title>
|
|
401
|
+
</XmlBook>
|
|
402
|
+
<XmlBook>
|
|
403
|
+
<title>Les Miserables</title>
|
|
404
|
+
</XmlBook>
|
|
405
|
+
</AllBooks>
|
|
406
|
+
</ModelWithRenamedWrappedAndItemModelArray>
|
|
407
|
+
"""
|
|
408
|
+
> {}
|
|
409
|
+
|
|
410
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
411
|
+
// §5 — Attributes
|
|
412
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
413
|
+
|
|
414
|
+
/** §5.1 — Contains fields that are XML attributes. */
|
|
415
|
+
model ModelWithAttributes {
|
|
416
|
+
@attribute id1: int32;
|
|
417
|
+
@attribute id2: string;
|
|
418
|
+
enabled: boolean;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** §5.1 — Operations for the ModelWithAttributes type. */
|
|
222
422
|
@route("/modelWithAttributes")
|
|
223
423
|
interface ModelWithAttributesValue
|
|
224
424
|
extends XmlOperations<
|
|
@@ -230,74 +430,90 @@ interface ModelWithAttributesValue
|
|
|
230
430
|
"""
|
|
231
431
|
> {}
|
|
232
432
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
"""
|
|
239
|
-
<ModelWithUnwrappedArray>
|
|
240
|
-
<colors>red</colors>
|
|
241
|
-
<colors>green</colors>
|
|
242
|
-
<colors>blue</colors>
|
|
243
|
-
<counts>
|
|
244
|
-
<int32>1</int32>
|
|
245
|
-
<int32>2</int32>
|
|
246
|
-
</counts>
|
|
247
|
-
</ModelWithUnwrappedArray>
|
|
248
|
-
"""
|
|
249
|
-
> {}
|
|
433
|
+
/** §5.2 — Contains a renamed XML attribute. */
|
|
434
|
+
model ModelWithRenamedAttribute {
|
|
435
|
+
@attribute
|
|
436
|
+
@name("xml-id")
|
|
437
|
+
id: int32;
|
|
250
438
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
439
|
+
title: string;
|
|
440
|
+
author: string;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** §5.2 — Operations for the ModelWithRenamedAttribute type. */
|
|
444
|
+
@route("/modelWithRenamedAttribute")
|
|
445
|
+
interface ModelWithRenamedAttributeValue
|
|
254
446
|
extends XmlOperations<
|
|
255
|
-
|
|
447
|
+
ModelWithRenamedAttribute,
|
|
256
448
|
"""
|
|
257
|
-
<
|
|
258
|
-
<
|
|
259
|
-
<
|
|
260
|
-
|
|
261
|
-
<Counts>
|
|
262
|
-
<int32>1</int32>
|
|
263
|
-
<int32>2</int32>
|
|
264
|
-
</Counts>
|
|
265
|
-
</ModelWithRenamedArrays>
|
|
449
|
+
<ModelWithRenamedAttribute xml-id="123">
|
|
450
|
+
<title>The Great Gatsby</title>
|
|
451
|
+
<author>F. Scott Fitzgerald</author>
|
|
452
|
+
</ModelWithRenamedAttribute>
|
|
266
453
|
"""
|
|
267
454
|
> {}
|
|
268
455
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
456
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
457
|
+
// §6/§7 — Namespace and prefix
|
|
458
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
459
|
+
|
|
460
|
+
/** §6.1, §7.1 — Contains fields with XML namespace on the model. */
|
|
461
|
+
@ns(Namespaces.smp)
|
|
462
|
+
model ModelWithNamespace {
|
|
463
|
+
id: int32;
|
|
464
|
+
title: string;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** §6.1, §7.1 — Operations for the ModelWithNamespace type. */
|
|
468
|
+
@route("/modelWithNamespace")
|
|
469
|
+
interface ModelWithNamespaceValue
|
|
272
470
|
extends XmlOperations<
|
|
273
|
-
|
|
471
|
+
ModelWithNamespace,
|
|
274
472
|
"""
|
|
275
|
-
<
|
|
276
|
-
<
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
</InputData>
|
|
280
|
-
<OutputData>
|
|
281
|
-
<name>bar</name>
|
|
282
|
-
<age>456</age>
|
|
283
|
-
</OutputData>
|
|
284
|
-
</ModelWithRenamedFieldsSrc>
|
|
473
|
+
<smp:ModelWithNamespace xmlns:smp="http://example.com/schema">
|
|
474
|
+
<id>123</id>
|
|
475
|
+
<title>The Great Gatsby</title>
|
|
476
|
+
</smp:ModelWithNamespace>
|
|
285
477
|
"""
|
|
286
478
|
> {}
|
|
287
479
|
|
|
288
|
-
|
|
289
|
-
@
|
|
290
|
-
|
|
480
|
+
/** §6.2, §7.2 — Contains fields with different XML namespaces on individual properties. */
|
|
481
|
+
@ns(Namespaces.smp)
|
|
482
|
+
model ModelWithNamespaceOnProperties {
|
|
483
|
+
id: int32;
|
|
484
|
+
|
|
485
|
+
@ns(Namespaces.smp)
|
|
486
|
+
title: string;
|
|
487
|
+
|
|
488
|
+
@ns(Namespaces.ns2)
|
|
489
|
+
author: string;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/** §6.2, §7.2 — Operations for the ModelWithNamespaceOnProperties type. */
|
|
493
|
+
@route("/modelWithNamespaceOnProperties")
|
|
494
|
+
interface ModelWithNamespaceOnPropertiesValue
|
|
291
495
|
extends XmlOperations<
|
|
292
|
-
|
|
496
|
+
ModelWithNamespaceOnProperties,
|
|
293
497
|
"""
|
|
294
|
-
<
|
|
295
|
-
<
|
|
296
|
-
|
|
498
|
+
<smp:ModelWithNamespaceOnProperties xmlns:smp="http://example.com/schema" xmlns:ns2="http://example.com/ns2">
|
|
499
|
+
<id>123</id>
|
|
500
|
+
<smp:title>The Great Gatsby</smp:title>
|
|
501
|
+
<ns2:author>F. Scott Fitzgerald</ns2:author>
|
|
502
|
+
</smp:ModelWithNamespaceOnProperties>
|
|
297
503
|
"""
|
|
298
504
|
> {}
|
|
299
505
|
|
|
300
|
-
|
|
506
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
507
|
+
// §8 — Text content
|
|
508
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
509
|
+
|
|
510
|
+
/** §8.1 — Contains an attribute and text. */
|
|
511
|
+
model ModelWithText {
|
|
512
|
+
@attribute language: string;
|
|
513
|
+
@unwrapped content: string;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** §8.1 — Operations for the ModelWithText type. */
|
|
301
517
|
@route("/modelWithText")
|
|
302
518
|
interface ModelWithTextValue
|
|
303
519
|
extends XmlOperations<
|
|
@@ -309,7 +525,51 @@ interface ModelWithTextValue
|
|
|
309
525
|
"""
|
|
310
526
|
> {}
|
|
311
527
|
|
|
312
|
-
|
|
528
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
529
|
+
// Additional scenarios (not in the guide)
|
|
530
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
531
|
+
|
|
532
|
+
/** Contains an optional field. */
|
|
533
|
+
model ModelWithOptionalField {
|
|
534
|
+
item: string;
|
|
535
|
+
value?: int32;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** Operations for the ModelWithOptionalField type. */
|
|
539
|
+
@route("/modelWithOptionalField")
|
|
540
|
+
interface ModelWithOptionalFieldValue
|
|
541
|
+
extends XmlOperations<
|
|
542
|
+
ModelWithOptionalField,
|
|
543
|
+
"""
|
|
544
|
+
<ModelWithOptionalField>
|
|
545
|
+
<item>widget</item>
|
|
546
|
+
</ModelWithOptionalField>
|
|
547
|
+
"""
|
|
548
|
+
> {}
|
|
549
|
+
|
|
550
|
+
/** Contains an array of models that's supposed to be sent/received as an empty XML element. */
|
|
551
|
+
model ModelWithEmptyArray {
|
|
552
|
+
items: SimpleModel[];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** Operations for the ModelWithEmptyArray type. */
|
|
556
|
+
@route("/modelWithEmptyArray")
|
|
557
|
+
interface ModelWithEmptyArrayValue
|
|
558
|
+
extends XmlOperations<
|
|
559
|
+
ModelWithEmptyArray,
|
|
560
|
+
"""
|
|
561
|
+
<ModelWithEmptyArray>
|
|
562
|
+
<items />
|
|
563
|
+
</ModelWithEmptyArray>
|
|
564
|
+
"""
|
|
565
|
+
> {}
|
|
566
|
+
|
|
567
|
+
/** Contains a dictionary of key value pairs. */
|
|
568
|
+
model ModelWithDictionary {
|
|
569
|
+
metadata: Record<string>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** Operations for the ModelWithDictionary type. */
|
|
313
573
|
@route("/modelWithDictionary")
|
|
314
574
|
interface ModelWithDictionaryValue
|
|
315
575
|
extends XmlOperations<
|
|
@@ -325,7 +585,14 @@ interface ModelWithDictionaryValue
|
|
|
325
585
|
"""
|
|
326
586
|
> {}
|
|
327
587
|
|
|
328
|
-
|
|
588
|
+
/** Uses encodedName instead of Xml.Name which is functionally equivalent. */
|
|
589
|
+
@encodedName("application/xml", "ModelWithEncodedNamesSrc")
|
|
590
|
+
model ModelWithEncodedNames {
|
|
591
|
+
@encodedName("application/xml", "SimpleModelData") modelData: SimpleModel;
|
|
592
|
+
@encodedName("application/xml", "PossibleColors") colors: string[];
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** Operations for the ModelWithEncodedNames type. */
|
|
329
596
|
@route("/modelWithEncodedNames")
|
|
330
597
|
interface ModelWithEncodedNamesValue
|
|
331
598
|
extends XmlOperations<
|
|
@@ -345,7 +612,26 @@ interface ModelWithEncodedNamesValue
|
|
|
345
612
|
"""
|
|
346
613
|
> {}
|
|
347
614
|
|
|
348
|
-
|
|
615
|
+
/** Status values for the model with enum. */
|
|
616
|
+
union Status {
|
|
617
|
+
string,
|
|
618
|
+
|
|
619
|
+
/** Pending status. */
|
|
620
|
+
pending: "pending",
|
|
621
|
+
|
|
622
|
+
/** Success status. */
|
|
623
|
+
success: "success",
|
|
624
|
+
|
|
625
|
+
/** Error status. */
|
|
626
|
+
error: "error",
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** Contains a single property with an enum value. */
|
|
630
|
+
model ModelWithEnum {
|
|
631
|
+
status: Status;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** Operations for the ModelWithEnum type. */
|
|
349
635
|
@route("/modelWithEnum")
|
|
350
636
|
interface ModelWithEnumValue
|
|
351
637
|
extends XmlOperations<
|
|
@@ -357,7 +643,18 @@ interface ModelWithEnumValue
|
|
|
357
643
|
"""
|
|
358
644
|
> {}
|
|
359
645
|
|
|
360
|
-
|
|
646
|
+
/** Contains datetime properties with different encodings. */
|
|
647
|
+
model ModelWithDatetime {
|
|
648
|
+
/** DateTime value with rfc3339 encoding. */
|
|
649
|
+
@encode(DateTimeKnownEncoding.rfc3339)
|
|
650
|
+
rfc3339: utcDateTime;
|
|
651
|
+
|
|
652
|
+
/** DateTime value with rfc7231 encoding. */
|
|
653
|
+
@encode(DateTimeKnownEncoding.rfc7231)
|
|
654
|
+
rfc7231: utcDateTime;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** Operations for the ModelWithDatetime type. */
|
|
361
658
|
@route("/modelWithDatetime")
|
|
362
659
|
interface ModelWithDatetimeValue
|
|
363
660
|
extends XmlOperations<
|
|
@@ -370,7 +667,21 @@ interface ModelWithDatetimeValue
|
|
|
370
667
|
"""
|
|
371
668
|
> {}
|
|
372
669
|
|
|
373
|
-
|
|
670
|
+
/** An error response body in XML format. */
|
|
671
|
+
@error
|
|
672
|
+
model XmlError {
|
|
673
|
+
@statusCode _: 400;
|
|
674
|
+
@header("content-type") contentType: "application/xml";
|
|
675
|
+
@body body: XmlErrorBody;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** The body of an XML error response. */
|
|
679
|
+
model XmlErrorBody {
|
|
680
|
+
message: string;
|
|
681
|
+
code: int32;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** Operations that return an error response in XML format. */
|
|
374
685
|
@route("/error")
|
|
375
686
|
interface XmlErrorValue {
|
|
376
687
|
@scenario
|