@typespec/http-specs 0.1.0-alpha.2 → 0.1.0-alpha.20

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.
Files changed (186) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/README.md +11 -3
  3. package/dist/specs/encode/bytes/mockapi.js +16 -24
  4. package/dist/specs/encode/bytes/mockapi.js.map +1 -1
  5. package/dist/specs/encode/datetime/mockapi.js +2 -2
  6. package/dist/specs/encode/datetime/mockapi.js.map +1 -1
  7. package/dist/specs/encode/duration/mockapi.js +2 -2
  8. package/dist/specs/encode/duration/mockapi.js.map +1 -1
  9. package/dist/specs/encode/numeric/mockapi.js +2 -2
  10. package/dist/specs/encode/numeric/mockapi.js.map +1 -1
  11. package/dist/specs/helper.d.ts +2 -2
  12. package/dist/specs/helper.d.ts.map +1 -1
  13. package/dist/specs/parameters/basic/mockapi.d.ts.map +1 -1
  14. package/dist/specs/parameters/basic/mockapi.js +3 -3
  15. package/dist/specs/parameters/basic/mockapi.js.map +1 -1
  16. package/dist/specs/parameters/body-optionality/mockapi.d.ts.map +1 -1
  17. package/dist/specs/parameters/body-optionality/mockapi.js +4 -4
  18. package/dist/specs/parameters/body-optionality/mockapi.js.map +1 -1
  19. package/dist/specs/parameters/collection-format/mockapi.js +4 -15
  20. package/dist/specs/parameters/collection-format/mockapi.js.map +1 -1
  21. package/dist/specs/parameters/path/mockapi.d.ts.map +1 -0
  22. package/dist/specs/parameters/path/mockapi.js +29 -0
  23. package/dist/specs/parameters/path/mockapi.js.map +1 -0
  24. package/dist/specs/parameters/spread/mockapi.d.ts.map +1 -1
  25. package/dist/specs/parameters/spread/mockapi.js +19 -19
  26. package/dist/specs/parameters/spread/mockapi.js.map +1 -1
  27. package/dist/specs/payload/json-merge-patch/mockapi.js +4 -4
  28. package/dist/specs/payload/json-merge-patch/mockapi.js.map +1 -1
  29. package/dist/specs/payload/media-type/mockapi.js +2 -2
  30. package/dist/specs/payload/media-type/mockapi.js.map +1 -1
  31. package/dist/specs/payload/multipart/mockapi.d.ts.map +1 -1
  32. package/dist/specs/payload/multipart/mockapi.js +42 -60
  33. package/dist/specs/payload/multipart/mockapi.js.map +1 -1
  34. package/dist/specs/payload/pageable/mockapi.d.ts +3 -0
  35. package/dist/specs/payload/pageable/mockapi.d.ts.map +1 -0
  36. package/dist/specs/payload/pageable/mockapi.js +115 -0
  37. package/dist/specs/payload/pageable/mockapi.js.map +1 -0
  38. package/dist/specs/payload/xml/mockapi.js +1 -4
  39. package/dist/specs/payload/xml/mockapi.js.map +1 -1
  40. package/dist/specs/response/status-code-range/mockapi.d.ts +3 -0
  41. package/dist/specs/response/status-code-range/mockapi.d.ts.map +1 -0
  42. package/dist/specs/response/status-code-range/mockapi.js +29 -0
  43. package/dist/specs/response/status-code-range/mockapi.js.map +1 -0
  44. package/dist/specs/routes/mockapi.js +25 -25
  45. package/dist/specs/routes/mockapi.js.map +1 -1
  46. package/dist/specs/serialization/encoded-name/json/mockapi.js +1 -1
  47. package/dist/specs/serialization/encoded-name/json/mockapi.js.map +1 -1
  48. package/dist/specs/server/versions/not-versioned/mockapi.js +1 -1
  49. package/dist/specs/server/versions/not-versioned/mockapi.js.map +1 -1
  50. package/dist/specs/server/versions/versioned/mockapi.js +8 -12
  51. package/dist/specs/server/versions/versioned/mockapi.js.map +1 -1
  52. package/dist/specs/special-words/mockapi.d.ts.map +1 -1
  53. package/dist/specs/special-words/mockapi.js +6 -6
  54. package/dist/specs/special-words/mockapi.js.map +1 -1
  55. package/dist/specs/streaming/jsonl/mockapi.d.ts +3 -0
  56. package/dist/specs/streaming/jsonl/mockapi.d.ts.map +1 -0
  57. package/dist/specs/streaming/jsonl/mockapi.js +30 -0
  58. package/dist/specs/streaming/jsonl/mockapi.js.map +1 -0
  59. package/dist/specs/type/array/mockapi.js +1 -1
  60. package/dist/specs/type/array/mockapi.js.map +1 -1
  61. package/dist/specs/type/dictionary/mockapi.js +1 -1
  62. package/dist/specs/type/dictionary/mockapi.js.map +1 -1
  63. package/dist/specs/type/enum/extensible/mockapi.js +1 -1
  64. package/dist/specs/type/enum/extensible/mockapi.js.map +1 -1
  65. package/dist/specs/type/enum/fixed/mockapi.js +2 -2
  66. package/dist/specs/type/enum/fixed/mockapi.js.map +1 -1
  67. package/dist/specs/type/model/empty/mockapi.js +2 -2
  68. package/dist/specs/type/model/empty/mockapi.js.map +1 -1
  69. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js +1 -1
  70. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js.map +1 -1
  71. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js +2 -2
  72. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js.map +1 -1
  73. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js +2 -2
  74. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js.map +1 -1
  75. package/dist/specs/type/model/inheritance/recursive/mockapi.js +1 -1
  76. package/dist/specs/type/model/inheritance/recursive/mockapi.js.map +1 -1
  77. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js +2 -2
  78. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js.map +1 -1
  79. package/dist/specs/type/model/usage/mockapi.js +4 -4
  80. package/dist/specs/type/model/usage/mockapi.js.map +1 -1
  81. package/dist/specs/type/model/visibility/mockapi.js +9 -10
  82. package/dist/specs/type/model/visibility/mockapi.js.map +1 -1
  83. package/dist/specs/type/property/additional-properties/mockapi.js +9 -6
  84. package/dist/specs/type/property/additional-properties/mockapi.js.map +1 -1
  85. package/dist/specs/type/property/nullable/mockapi.js +2 -6
  86. package/dist/specs/type/property/nullable/mockapi.js.map +1 -1
  87. package/dist/specs/type/property/optionality/mockapi.js +1 -1
  88. package/dist/specs/type/property/optionality/mockapi.js.map +1 -1
  89. package/dist/specs/type/property/value-types/mockapi.js +3 -3
  90. package/dist/specs/type/property/value-types/mockapi.js.map +1 -1
  91. package/dist/specs/type/scalar/mockapi.js +9 -9
  92. package/dist/specs/type/scalar/mockapi.js.map +1 -1
  93. package/dist/specs/type/union/mockapi.js +2 -2
  94. package/dist/specs/type/union/mockapi.js.map +1 -1
  95. package/dist/specs/versioning/added/mockapi.js +6 -6
  96. package/dist/specs/versioning/added/mockapi.js.map +1 -1
  97. package/dist/specs/versioning/madeOptional/mockapi.js +2 -2
  98. package/dist/specs/versioning/madeOptional/mockapi.js.map +1 -1
  99. package/dist/specs/versioning/removed/mockapi.js +46 -2
  100. package/dist/specs/versioning/removed/mockapi.js.map +1 -1
  101. package/dist/specs/versioning/renamedFrom/mockapi.js +5 -5
  102. package/dist/specs/versioning/renamedFrom/mockapi.js.map +1 -1
  103. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js +1 -1
  104. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js.map +1 -1
  105. package/dist/specs/versioning/typeChangedFrom/mockapi.js +3 -3
  106. package/dist/specs/versioning/typeChangedFrom/mockapi.js.map +1 -1
  107. package/package.json +23 -17
  108. package/spec-summary.md +393 -175
  109. package/specs/encode/bytes/main.tsp +28 -20
  110. package/specs/encode/bytes/mockapi.ts +13 -31
  111. package/specs/encode/datetime/main.tsp +2 -7
  112. package/specs/encode/datetime/mockapi.ts +2 -2
  113. package/specs/encode/duration/main.tsp +2 -7
  114. package/specs/encode/duration/mockapi.ts +2 -2
  115. package/specs/encode/numeric/mockapi.ts +2 -2
  116. package/specs/parameters/basic/mockapi.ts +3 -3
  117. package/specs/parameters/body-optionality/mockapi.ts +4 -4
  118. package/specs/parameters/collection-format/main.tsp +5 -25
  119. package/specs/parameters/collection-format/mockapi.ts +4 -16
  120. package/specs/parameters/path/main.tsp +48 -0
  121. package/specs/parameters/path/mockapi.ts +34 -0
  122. package/specs/parameters/spread/mockapi.ts +19 -19
  123. package/specs/payload/json-merge-patch/main.tsp +2 -2
  124. package/specs/payload/json-merge-patch/mockapi.ts +4 -4
  125. package/specs/payload/media-type/mockapi.ts +2 -2
  126. package/specs/payload/multipart/main.tsp +34 -32
  127. package/specs/payload/multipart/mockapi.ts +42 -59
  128. package/specs/payload/pageable/main.tsp +252 -0
  129. package/specs/payload/pageable/mockapi.ts +138 -0
  130. package/specs/payload/xml/mockapi.ts +1 -4
  131. package/specs/response/status-code-range/main.tsp +82 -0
  132. package/specs/response/status-code-range/mockapi.ts +31 -0
  133. package/specs/routes/main.tsp +48 -48
  134. package/specs/routes/mockapi.ts +25 -25
  135. package/specs/serialization/encoded-name/json/main.tsp +1 -1
  136. package/specs/serialization/encoded-name/json/mockapi.ts +1 -1
  137. package/specs/server/endpoint/not-defined/main.tsp +1 -3
  138. package/specs/server/path/multiple/main.tsp +3 -5
  139. package/specs/server/versions/not-versioned/mockapi.ts +1 -1
  140. package/specs/server/versions/versioned/main.tsp +1 -1
  141. package/specs/server/versions/versioned/mockapi.ts +6 -12
  142. package/specs/special-headers/conditional-request/main.tsp +1 -1
  143. package/specs/special-headers/repeatability/main.tsp +2 -2
  144. package/specs/special-words/main.tsp +6 -6
  145. package/specs/special-words/mockapi.ts +6 -6
  146. package/specs/streaming/jsonl/main.tsp +33 -0
  147. package/specs/streaming/jsonl/mockapi.ts +32 -0
  148. package/specs/type/array/mockapi.ts +1 -1
  149. package/specs/type/dictionary/mockapi.ts +1 -1
  150. package/specs/type/enum/extensible/main.tsp +18 -2
  151. package/specs/type/enum/extensible/mockapi.ts +1 -1
  152. package/specs/type/enum/fixed/main.tsp +15 -3
  153. package/specs/type/enum/fixed/mockapi.ts +2 -2
  154. package/specs/type/model/empty/mockapi.ts +2 -2
  155. package/specs/type/model/inheritance/enum-discriminator/mockapi.ts +1 -1
  156. package/specs/type/model/inheritance/nested-discriminator/mockapi.ts +2 -2
  157. package/specs/type/model/inheritance/not-discriminated/mockapi.ts +2 -2
  158. package/specs/type/model/inheritance/recursive/mockapi.ts +1 -1
  159. package/specs/type/model/inheritance/single-discriminator/mockapi.ts +2 -2
  160. package/specs/type/model/usage/mockapi.ts +4 -4
  161. package/specs/type/model/visibility/main.tsp +17 -21
  162. package/specs/type/model/visibility/mockapi.ts +9 -10
  163. package/specs/type/property/additional-properties/main.tsp +17 -17
  164. package/specs/type/property/additional-properties/mockapi.ts +10 -10
  165. package/specs/type/property/nullable/mockapi.ts +7 -8
  166. package/specs/type/property/optionality/mockapi.ts +1 -1
  167. package/specs/type/property/value-types/mockapi.ts +3 -3
  168. package/specs/type/scalar/main.tsp +58 -9
  169. package/specs/type/scalar/mockapi.ts +9 -9
  170. package/specs/type/union/mockapi.ts +2 -2
  171. package/specs/versioning/added/mockapi.ts +6 -6
  172. package/specs/versioning/madeOptional/mockapi.ts +2 -2
  173. package/specs/versioning/removed/main.tsp +65 -3
  174. package/specs/versioning/removed/mockapi.ts +49 -2
  175. package/specs/versioning/renamedFrom/mockapi.ts +5 -5
  176. package/specs/versioning/returnTypeChangedFrom/main.tsp +17 -2
  177. package/specs/versioning/returnTypeChangedFrom/mockapi.ts +1 -1
  178. package/specs/versioning/typeChangedFrom/mockapi.ts +3 -3
  179. package/temp/.tsbuildinfo +1 -1
  180. package/tspconfig.yaml +0 -2
  181. package/dist/specs/type/model/templated/mockapi.d.ts.map +0 -1
  182. package/dist/specs/type/model/templated/mockapi.js +0 -63
  183. package/dist/specs/type/model/templated/mockapi.js.map +0 -1
  184. package/specs/type/model/templated/main.tsp +0 -130
  185. package/specs/type/model/templated/mockapi.ts +0 -66
  186. /package/dist/specs/{type/model/templated → parameters/path}/mockapi.d.ts +0 -0
@@ -58,7 +58,7 @@ model InnerModel {
58
58
  }
59
59
  ],
60
60
  "intValue": 1,
61
- "floatValue": 1.1,
61
+ "floatValue": 1.25,
62
62
  "innerModel": {
63
63
  "name": "InnerMadge",
64
64
  "description": "innerDesc"
@@ -85,7 +85,7 @@ model InnerModel {
85
85
  }
86
86
  ],
87
87
  "intValue": 1,
88
- "floatValue": 1.1,
88
+ "floatValue": 1.25,
89
89
  "innerModel": {
90
90
  "name": "InnerMadge",
91
91
  "description": "innerDesc"
@@ -18,7 +18,7 @@ export const expectedCreateBody = {
18
18
  },
19
19
  ],
20
20
  intValue: 1,
21
- floatValue: 1.1,
21
+ floatValue: 1.25,
22
22
  innerModel: {
23
23
  name: "InnerMadge",
24
24
  description: "innerDesc",
@@ -45,7 +45,7 @@ Scenarios.Payload_JsonMergePatch_createResource = passOnSuccess({
45
45
  uri: "/json-merge-patch/create/resource",
46
46
  method: "put",
47
47
  request: {
48
- body: expectedCreateBody,
48
+ body: json(expectedCreateBody),
49
49
  },
50
50
  response: {
51
51
  status: 200,
@@ -58,7 +58,7 @@ Scenarios.Payload_JsonMergePatch_updateResource = passOnSuccess({
58
58
  uri: "/json-merge-patch/update/resource",
59
59
  method: "patch",
60
60
  request: {
61
- body: expectedUpdateBody,
61
+ body: json(expectedUpdateBody),
62
62
  },
63
63
  response: {
64
64
  status: 200,
@@ -78,7 +78,7 @@ Scenarios.Payload_JsonMergePatch_updateOptionalResource = passOnSuccess({
78
78
  uri: "/json-merge-patch/update/resource/optional",
79
79
  method: "patch",
80
80
  request: {
81
- body: expectedUpdateBody,
81
+ body: json(expectedUpdateBody),
82
82
  },
83
83
  response: {
84
84
  status: 200,
@@ -6,7 +6,7 @@ Scenarios.Payload_MediaType_StringBody_sendAsText = passOnSuccess({
6
6
  uri: "/payload/media-type/string-body/sendAsText",
7
7
  method: "post",
8
8
  request: {
9
- body: "{cat}",
9
+ body: json("{cat}"),
10
10
  headers: {
11
11
  "Content-Type": "text/plain",
12
12
  },
@@ -36,7 +36,7 @@ Scenarios.Payload_MediaType_StringBody_sendAsJson = passOnSuccess({
36
36
  uri: "/payload/media-type/string-body/sendAsJson",
37
37
  method: "post",
38
38
  request: {
39
- body: "foo",
39
+ body: json("foo"),
40
40
  headers: {
41
41
  "Content-Type": "application/json",
42
42
  },
@@ -9,8 +9,8 @@ using Spector;
9
9
  namespace Payload.MultiPart;
10
10
 
11
11
  model MultiPartRequest {
12
- id: string;
13
- profileImage: bytes;
12
+ id: HttpPart<string>;
13
+ profileImage: HttpPart<bytes>;
14
14
  }
15
15
 
16
16
  model Address {
@@ -52,25 +52,25 @@ model ComplexHttpPartsModelRequest {
52
52
  }
53
53
 
54
54
  model ComplexPartsRequest {
55
- id: string;
56
- address: Address;
57
- profileImage: bytes;
58
- pictures: bytes[];
55
+ id: HttpPart<string>;
56
+ address: HttpPart<Address>;
57
+ profileImage: HttpPart<bytes>;
58
+ pictures: HttpPart<bytes>[];
59
59
  }
60
60
 
61
61
  model JsonPartRequest {
62
- address: Address;
63
- profileImage: bytes;
62
+ address: HttpPart<Address>;
63
+ profileImage: HttpPart<bytes>;
64
64
  }
65
65
 
66
66
  model BinaryArrayPartsRequest {
67
- id: string;
68
- pictures: bytes[];
67
+ id: HttpPart<string>;
68
+ pictures: HttpPart<bytes>[];
69
69
  }
70
70
 
71
71
  model MultiBinaryPartsRequest {
72
- profileImage: bytes;
73
- picture?: bytes;
72
+ profileImage: HttpPart<bytes>;
73
+ picture?: HttpPart<bytes>;
74
74
  }
75
75
 
76
76
  @route("/form-data")
@@ -79,9 +79,9 @@ namespace FormData {
79
79
  @scenarioDoc("""
80
80
  Expect request (
81
81
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.4, content-type of file part shall be labeled with
82
- appropriate media type, cadl-ranch will check it; content-type of other parts is optional, cadl-ranch will ignore it.
82
+ appropriate media type, server will check it; content-type of other parts is optional, server will ignore it.
83
83
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.2, filename of file part SHOULD be supplied.
84
- If there are duplicated filename in same fieldName, cadl-ranch can't parse them all.
84
+ If there are duplicated filename in same fieldName, server can't parse them all.
85
85
  ):
86
86
  ```
87
87
  POST /upload HTTP/1.1
@@ -106,16 +106,16 @@ namespace FormData {
106
106
  @route("/mixed-parts")
107
107
  op basic(
108
108
  @header contentType: "multipart/form-data",
109
- @body body: MultiPartRequest,
109
+ @multipartBody body: MultiPartRequest,
110
110
  ): NoContentResponse;
111
111
 
112
112
  @scenario
113
113
  @scenarioDoc("""
114
114
  Expect request (
115
115
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.4, content-type of file part shall be labeled with
116
- appropriate media type, cadl-ranch will check it; content-type of other parts is optional, cadl-ranch will ignore it.
116
+ appropriate media type, server will check it; content-type of other parts is optional, server will ignore it.
117
117
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.2, filename of file part SHOULD be supplied.
118
- If there are duplicated filename in same fieldName, cadl-ranch can't parse them all.
118
+ If there are duplicated filename in same fieldName, server can't parse them all.
119
119
  ):
120
120
  ```
121
121
  POST /upload HTTP/1.1
@@ -166,16 +166,16 @@ namespace FormData {
166
166
  @route("/complex-parts")
167
167
  op fileArrayAndBasic(
168
168
  @header contentType: "multipart/form-data",
169
- @body body: ComplexPartsRequest,
169
+ @multipartBody body: ComplexPartsRequest,
170
170
  ): NoContentResponse;
171
171
 
172
172
  @scenario
173
173
  @scenarioDoc("""
174
174
  Expect request (
175
175
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.4, content-type of file part shall be labeled with
176
- appropriate media type, cadl-ranch will check it; content-type of other parts is optional, cadl-ranch will ignore it.
176
+ appropriate media type, server will check it; content-type of other parts is optional, server will ignore it.
177
177
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.2, filename of file part SHOULD be supplied.
178
- If there are duplicated filename in same fieldName, cadl-ranch can't parse them all.
178
+ If there are duplicated filename in same fieldName, server can't parse them all.
179
179
  ):
180
180
  ```
181
181
  POST /upload HTTP/1.1
@@ -202,16 +202,16 @@ namespace FormData {
202
202
  @route("/json-part")
203
203
  op jsonPart(
204
204
  @header contentType: "multipart/form-data",
205
- @body body: JsonPartRequest,
205
+ @multipartBody body: JsonPartRequest,
206
206
  ): NoContentResponse;
207
207
 
208
208
  @scenario
209
209
  @scenarioDoc("""
210
210
  Expect request (
211
211
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.4, content-type of file part shall be labeled with
212
- appropriate media type, cadl-ranch will check it; content-type of other parts is optional, cadl-ranch will ignore it.
212
+ appropriate media type, server will check it; content-type of other parts is optional, server will ignore it.
213
213
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.2, filename of file part SHOULD be supplied.
214
- If there are duplicated filename in same fieldName, cadl-ranch can't parse them all.
214
+ If there are duplicated filename in same fieldName, server can't parse them all.
215
215
  ):
216
216
  ```
217
217
  POST /upload HTTP/1.1
@@ -241,16 +241,16 @@ namespace FormData {
241
241
  @route("/binary-array-parts")
242
242
  op binaryArrayParts(
243
243
  @header contentType: "multipart/form-data",
244
- @body body: BinaryArrayPartsRequest,
244
+ @multipartBody body: BinaryArrayPartsRequest,
245
245
  ): NoContentResponse;
246
246
 
247
247
  @scenario
248
248
  @scenarioDoc("""
249
249
  Please send request twice, first time with only profileImage, second time with both profileImage and picture(
250
250
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.4, content-type of file part shall be labeled with
251
- appropriate media type, cadl-ranch will check it; content-type of other parts is optional, cadl-ranch will ignore it.
251
+ appropriate media type, server will check it; content-type of other parts is optional, server will ignore it.
252
252
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.2, filename of file part SHOULD be supplied.
253
- If there are duplicated filename in same fieldName, cadl-ranch can't parse them all.
253
+ If there are duplicated filename in same fieldName, server can't parse them all.
254
254
  ):
255
255
  ```
256
256
  POST /upload HTTP/1.1
@@ -275,7 +275,7 @@ namespace FormData {
275
275
  @route("/multi-binary-parts")
276
276
  op multiBinaryParts(
277
277
  @header contentType: "multipart/form-data",
278
- @body body: MultiBinaryPartsRequest,
278
+ @multipartBody body: MultiBinaryPartsRequest,
279
279
  ): NoContentResponse;
280
280
 
281
281
  @scenario
@@ -304,16 +304,16 @@ namespace FormData {
304
304
  @route("/check-filename-and-content-type")
305
305
  op checkFileNameAndContentType(
306
306
  @header contentType: "multipart/form-data",
307
- @body body: MultiPartRequest,
307
+ @multipartBody body: MultiPartRequest,
308
308
  ): NoContentResponse;
309
309
 
310
310
  @scenario
311
311
  @scenarioDoc("""
312
312
  Expect request (
313
313
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.4, content-type of file part shall be labeled with
314
- appropriate media type, cadl-ranch will check it; content-type of other parts is optional, cadl-ranch will ignore it.
314
+ appropriate media type, server will check it; content-type of other parts is optional, server will ignore it.
315
315
  - according to https://datatracker.ietf.org/doc/html/rfc7578#section-4.2, filename of file part SHOULD be supplied.
316
- If there are duplicated filename in same filedName, cadl-ranch can't parse them all.
316
+ If there are duplicated filename in same filedName, server can't parse them all.
317
317
  ):
318
318
  ```
319
319
  POST /multipart/form-data/anonymous-model HTTP/1.1
@@ -333,7 +333,9 @@ namespace FormData {
333
333
  @route("/anonymous-model")
334
334
  op anonymousModel(
335
335
  @header contentType: "multipart/form-data",
336
- profileImage: MultiPartRequest.profileImage,
336
+ @multipartBody body: {
337
+ profileImage: HttpPart<bytes>;
338
+ },
337
339
  ): NoContentResponse;
338
340
 
339
341
  namespace HttpParts {
@@ -412,7 +414,7 @@ namespace FormData {
412
414
  }
413
415
  @scenario
414
416
  @scenarioDoc("""
415
- For File part, filename will not be checked but it is necessary otherwise cadl-ranch can't parse it;
417
+ For File part, filename will not be checked but it is necessary otherwise server can't parse it;
416
418
  content-type will be checked with value "application/octet-stream". Expect request:
417
419
  ```
418
420
  POST /upload HTTP/1.1
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  MockRequest,
3
+ multipart,
3
4
  passOnSuccess,
4
5
  ScenarioMockApi,
5
6
  ValidationError,
@@ -29,7 +30,7 @@ function checkFile(
29
30
  fileName: string | undefined = undefined,
30
31
  mustCheckContentType: boolean = true,
31
32
  ) {
32
- // cadl-ranch depends on multer, which sets the mimetype to "text/plain" if this part has no content-type header
33
+ // server depends on multer, which sets the mimetype to "text/plain" if this part has no content-type header
33
34
  if (mustCheckContentType || file.mimetype !== "text/plain") {
34
35
  req.expect.deepEqual(file.mimetype, contentType);
35
36
  }
@@ -185,11 +186,7 @@ Scenarios.Payload_MultiPart_FormData_basic = passOnSuccess({
185
186
  uri: "/multipart/form-data/mixed-parts",
186
187
  method: "post",
187
188
  request: {
188
- headers: {
189
- "Content-Type": "multipart/form-data",
190
- },
191
- body: { id: 123 },
192
- files: [files[0]],
189
+ body: multipart({ parts: { id: 123 }, files: [files[0]] }),
193
190
  },
194
191
  response: { status: 204 },
195
192
  handler: (req: MockRequest) => createHandler(req, [checkId, checkProfileImage]),
@@ -199,11 +196,10 @@ Scenarios.Payload_MultiPart_FormData_fileArrayAndBasic = passOnSuccess({
199
196
  uri: "/multipart/form-data/complex-parts",
200
197
  method: "post",
201
198
  request: {
202
- headers: {
203
- "Content-Type": "multipart/form-data",
204
- },
205
- body: { id: 123, address: { city: "X" } },
206
- files: [files[0], files[1], files[1]],
199
+ body: multipart({
200
+ parts: { id: 123, address: { city: "X" } },
201
+ files: [files[0], files[1], files[1]],
202
+ }),
207
203
  },
208
204
  response: { status: 204 },
209
205
  handler: (req: MockRequest) => createHandler(req, [checkId, checkAddress, checkAllFiles]),
@@ -213,11 +209,7 @@ Scenarios.Payload_MultiPart_FormData_jsonPart = passOnSuccess({
213
209
  uri: "/multipart/form-data/json-part",
214
210
  method: "post",
215
211
  request: {
216
- headers: {
217
- "Content-Type": "multipart/form-data",
218
- },
219
- body: { address: { city: "X" } },
220
- files: [files[0]],
212
+ body: multipart({ parts: { address: { city: "X" } }, files: [files[0]] }),
221
213
  },
222
214
  response: { status: 204 },
223
215
  handler: (req: MockRequest) => createHandler(req, [checkAddress, checkProfileImage]),
@@ -227,11 +219,7 @@ Scenarios.Payload_MultiPart_FormData_binaryArrayParts = passOnSuccess({
227
219
  uri: "/multipart/form-data/binary-array-parts",
228
220
  method: "post",
229
221
  request: {
230
- headers: {
231
- "Content-Type": "multipart/form-data",
232
- },
233
- body: { id: 123 },
234
- files: [files[1], files[1]],
222
+ body: multipart({ parts: { id: 123 }, files: [files[1], files[1]] }),
235
223
  },
236
224
  response: { status: 204 },
237
225
  handler: (req: MockRequest) => createHandler(req, [checkId, checkPictures]),
@@ -245,10 +233,9 @@ Scenarios.Payload_MultiPart_FormData_multiBinaryParts = withServiceKeys([
245
233
  uri: "/multipart/form-data/multi-binary-parts",
246
234
  method: "post",
247
235
  request: {
248
- headers: {
249
- "Content-Type": "multipart/form-data",
250
- },
251
- files: [files[0]],
236
+ body: multipart({
237
+ files: [files[0]],
238
+ }),
252
239
  },
253
240
  response: { status: 204 },
254
241
  handler: createMultiBinaryPartsHandler,
@@ -258,10 +245,9 @@ Scenarios.Payload_MultiPart_FormData_multiBinaryParts = withServiceKeys([
258
245
  uri: "/multipart/form-data/multi-binary-parts",
259
246
  method: "post",
260
247
  request: {
261
- headers: {
262
- "Content-Type": "multipart/form-data",
263
- },
264
- files: [files[0], { ...files[1], fieldname: "picture" }],
248
+ body: multipart({
249
+ files: [files[0], { ...files[1], fieldname: "picture" }],
250
+ }),
265
251
  },
266
252
  response: { status: 204 },
267
253
  handler: createMultiBinaryPartsHandler,
@@ -272,11 +258,10 @@ Scenarios.Payload_MultiPart_FormData_checkFileNameAndContentType = passOnSuccess
272
258
  uri: "/multipart/form-data/check-filename-and-content-type",
273
259
  method: "post",
274
260
  request: {
275
- headers: {
276
- "Content-Type": "multipart/form-data",
277
- },
278
- body: { id: 123 },
279
- files: [{ ...files[0], mimetype: "image/jpg", originalname: "hello.jpg" }],
261
+ body: multipart({
262
+ parts: { id: 123 },
263
+ files: [{ ...files[0], mimetype: "image/jpg", originalname: "hello.jpg" }],
264
+ }),
280
265
  },
281
266
  response: { status: 204 },
282
267
  handler: (req: MockRequest) => createHandler(req, [checkId, checkFileNameAndContentType]),
@@ -286,10 +271,9 @@ Scenarios.Payload_MultiPart_FormData_anonymousModel = passOnSuccess({
286
271
  uri: "/multipart/form-data/anonymous-model",
287
272
  method: "post",
288
273
  request: {
289
- headers: {
290
- "Content-Type": "multipart/form-data",
291
- },
292
- files: [files[0]],
274
+ body: multipart({
275
+ files: [files[0]],
276
+ }),
293
277
  },
294
278
  response: { status: 204 },
295
279
  handler: (req: MockRequest) => createHandler(req, [checkProfileImage]),
@@ -299,10 +283,9 @@ Scenarios.Payload_MultiPart_FormData_HttpParts_ContentType_imageJpegContentType
299
283
  uri: "/multipart/form-data/check-filename-and-specific-content-type-with-httppart",
300
284
  method: "post",
301
285
  request: {
302
- headers: {
303
- "Content-Type": "multipart/form-data",
304
- },
305
- files: [{ ...files[0], mimetype: "image/jpg", originalname: "hello.jpg" }],
286
+ body: multipart({
287
+ files: [{ ...files[0], mimetype: "image/jpg", originalname: "hello.jpg" }],
288
+ }),
306
289
  },
307
290
  response: { status: 204 },
308
291
  handler: (req: MockRequest) => createHandler(req, [checkFileNameAndContentType]),
@@ -312,10 +295,9 @@ Scenarios.Payload_MultiPart_FormData_HttpParts_ContentType_requiredContentType =
312
295
  uri: "/multipart/form-data/check-filename-and-required-content-type-with-httppart",
313
296
  method: "post",
314
297
  request: {
315
- headers: {
316
- "Content-Type": "multipart/form-data",
317
- },
318
- files: [files[0]],
298
+ body: multipart({
299
+ files: [files[0]],
300
+ }),
319
301
  },
320
302
  response: { status: 204 },
321
303
  handler: (req: MockRequest) => createHandler(req, [checkProfileImage]),
@@ -325,10 +307,9 @@ Scenarios.Payload_MultiPart_FormData_HttpParts_ContentType_optionalContentType =
325
307
  uri: "/multipart/form-data/file-with-http-part-optional-content-type",
326
308
  method: "post",
327
309
  request: {
328
- headers: {
329
- "Content-Type": "multipart/form-data",
330
- },
331
- files: [files[0]],
310
+ body: multipart({
311
+ files: [files[0]],
312
+ }),
332
313
  },
333
314
  response: { status: 204 },
334
315
  handler: (req: MockRequest) => createHandler(req, [checkOptionalContentType]),
@@ -338,11 +319,14 @@ Scenarios.Payload_MultiPart_FormData_HttpParts_jsonArrayAndFileArray = passOnSuc
338
319
  uri: "/multipart/form-data/complex-parts-with-httppart",
339
320
  method: "post",
340
321
  request: {
341
- headers: {
342
- "Content-Type": "multipart/form-data",
343
- },
344
- body: { id: 123, address: { city: "X" }, previousAddresses: [{ city: "Y" }, { city: "Z" }] },
345
- files: [files[0], files[1], files[1]],
322
+ body: multipart({
323
+ parts: {
324
+ id: 123,
325
+ address: { city: "X" },
326
+ previousAddresses: [{ city: "Y" }, { city: "Z" }],
327
+ },
328
+ files: [files[0], files[1], files[1]],
329
+ }),
346
330
  },
347
331
  response: { status: 204 },
348
332
  handler: (req: MockRequest) =>
@@ -353,10 +337,9 @@ Scenarios.Payload_MultiPart_FormData_HttpParts_NonString_float = passOnSuccess({
353
337
  uri: "/multipart/form-data/non-string-float",
354
338
  method: "post",
355
339
  request: {
356
- body: { temperature: 0.5 },
357
- headers: {
358
- "Content-Type": "multipart/form-data",
359
- },
340
+ body: multipart({
341
+ parts: { temperature: 0.5 },
342
+ }),
360
343
  },
361
344
  response: { status: 204 },
362
345
  handler: (req: MockRequest) => createHandler(req, [checkFloat]),