@typespec/http-specs 0.1.0-alpha.34 → 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/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.34",
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
- "deep-equal": "^2.2.0",
26
- "@typespec/spec-api": "^0.1.0-alpha.13",
27
- "@typespec/spector": "^0.1.0-alpha.24"
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
- const Payload_Xml_ModelWithDatetime = createServerTests(
255
- "/payload/xml/modelWithDatetime",
256
- modelWithDatetime,
257
- );
258
- Scenarios.Payload_Xml_ModelWithDatetimeValue_get = Payload_Xml_ModelWithDatetime.get;
259
- Scenarios.Payload_Xml_ModelWithDatetimeValue_put = Payload_Xml_ModelWithDatetime.put;
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>