@typespec/http-specs 0.1.0-alpha.33 → 0.1.0-alpha.35-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 +7 -0
- package/dist/specs/payload/xml/mockapi.d.ts.map +1 -1
- package/dist/specs/payload/xml/mockapi.js +47 -3
- package/dist/specs/payload/xml/mockapi.js.map +1 -1
- package/manifest.json +11200 -0
- package/package.json +13 -13
- package/specs/payload/xml/mockapi.ts +48 -6
- package/specs/special-words/main.tsp +48 -42
- package/temp/.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-specs",
|
|
3
3
|
"displayName": "Http Specs",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.35-dev.1",
|
|
5
5
|
"description": "Spec scenarios and mock apis",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -22,27 +22,27 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/microsoft/typespec#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"@typespec/spector": "^0.1.0-alpha.24",
|
|
27
|
-
"
|
|
25
|
+
"@typespec/spec-api": "^0.1.0-alpha.13 || >= 0.1.0-alpha.14-dev.1",
|
|
26
|
+
"@typespec/spector": "^0.1.0-alpha.24 || >= 0.1.0-dev.0",
|
|
27
|
+
"deep-equal": "^2.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/deep-equal": "^1.0.1",
|
|
31
31
|
"@types/multer": "^2.0.0",
|
|
32
32
|
"@types/node": "~25.3.0",
|
|
33
|
+
"@typespec/json-schema": "^1.10.0 || >= 1.11.0-dev.0",
|
|
34
|
+
"@typespec/openapi": "^1.10.0 || >= 1.11.0-dev.0",
|
|
35
|
+
"@typespec/openapi3": "^1.10.0 || >= 1.11.0-dev.0",
|
|
33
36
|
"concurrently": "^9.1.2",
|
|
34
37
|
"rimraf": "~6.1.3",
|
|
35
|
-
"typescript": "~5.9.3"
|
|
36
|
-
"@typespec/json-schema": "^1.10.0",
|
|
37
|
-
"@typespec/openapi": "^1.10.0",
|
|
38
|
-
"@typespec/openapi3": "^1.10.0"
|
|
38
|
+
"typescript": "~5.9.3"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@typespec/compiler": "^1.10.0",
|
|
42
|
-
"@typespec/http": "^1.10.0",
|
|
43
|
-
"@typespec/rest": "^0.80.0",
|
|
44
|
-
"@typespec/versioning": "^0.80.0",
|
|
45
|
-
"@typespec/xml": "^0.80.0"
|
|
41
|
+
"@typespec/compiler": "^1.10.0 || >= 1.11.0-dev.0",
|
|
42
|
+
"@typespec/http": "^1.10.0 || >= 1.11.0-dev.0",
|
|
43
|
+
"@typespec/rest": "^0.80.0 || >= 0.81.0-dev.0",
|
|
44
|
+
"@typespec/versioning": "^0.80.0 || >= 0.81.0-dev.0",
|
|
45
|
+
"@typespec/xml": "^0.80.0 || >= 0.81.0-dev.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
@@ -136,6 +136,16 @@ export const modelWithDatetime = `
|
|
|
136
136
|
</ModelWithDatetime>
|
|
137
137
|
`;
|
|
138
138
|
|
|
139
|
+
// Some clients serialize UTC datetimes without trailing zero milliseconds. Both
|
|
140
|
+
// "2022-08-26T18:38:00.000Z" and "2022-08-26T18:38:00Z" are valid RFC3339 representations
|
|
141
|
+
// of the same instant; accept either form.
|
|
142
|
+
const modelWithDatetimeNoMs = `
|
|
143
|
+
<ModelWithDatetime>
|
|
144
|
+
<rfc3339>2022-08-26T18:38:00Z</rfc3339>
|
|
145
|
+
<rfc7231>Fri, 26 Aug 2022 14:38:00 GMT</rfc7231>
|
|
146
|
+
</ModelWithDatetime>
|
|
147
|
+
`;
|
|
148
|
+
|
|
139
149
|
function createServerTests(uri: string, data?: any) {
|
|
140
150
|
return {
|
|
141
151
|
get: passOnSuccess({
|
|
@@ -251,12 +261,44 @@ const Payload_Xml_ModelWithEnum = createServerTests("/payload/xml/modelWithEnum"
|
|
|
251
261
|
Scenarios.Payload_Xml_ModelWithEnumValue_get = Payload_Xml_ModelWithEnum.get;
|
|
252
262
|
Scenarios.Payload_Xml_ModelWithEnumValue_put = Payload_Xml_ModelWithEnum.put;
|
|
253
263
|
|
|
254
|
-
|
|
255
|
-
"/payload/xml/modelWithDatetime",
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
264
|
+
Scenarios.Payload_Xml_ModelWithDatetimeValue_get = passOnSuccess({
|
|
265
|
+
uri: "/payload/xml/modelWithDatetime",
|
|
266
|
+
method: "get",
|
|
267
|
+
request: {},
|
|
268
|
+
response: {
|
|
269
|
+
status: 200,
|
|
270
|
+
body: xml(modelWithDatetime),
|
|
271
|
+
},
|
|
272
|
+
kind: "MockApiDefinition",
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
Scenarios.Payload_Xml_ModelWithDatetimeValue_put = passOnSuccess({
|
|
276
|
+
uri: "/payload/xml/modelWithDatetime",
|
|
277
|
+
method: "put",
|
|
278
|
+
request: {
|
|
279
|
+
body: xml(modelWithDatetime),
|
|
280
|
+
},
|
|
281
|
+
handler: (req: MockRequest) => {
|
|
282
|
+
req.expect.containsHeader("content-type", "application/xml");
|
|
283
|
+
// Accept both "2022-08-26T18:38:00.000Z" and "2022-08-26T18:38:00Z" as equivalent UTC datetimes.
|
|
284
|
+
let firstError: unknown;
|
|
285
|
+
try {
|
|
286
|
+
req.expect.xmlBodyEquals(modelWithDatetime);
|
|
287
|
+
} catch (e) {
|
|
288
|
+
firstError = e;
|
|
289
|
+
}
|
|
290
|
+
if (firstError !== undefined) {
|
|
291
|
+
req.expect.xmlBodyEquals(modelWithDatetimeNoMs);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
status: 204,
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
response: {
|
|
298
|
+
status: 204,
|
|
299
|
+
},
|
|
300
|
+
kind: "MockApiDefinition",
|
|
301
|
+
});
|
|
260
302
|
|
|
261
303
|
export const xmlError = `
|
|
262
304
|
<XmlErrorBody>
|
|
@@ -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
|
}
|