@typespec/http-specs 0.37.2

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 (334) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +36 -0
  4. package/assets/image.jpg +0 -0
  5. package/assets/image.png +0 -0
  6. package/dist/specs/authentication/api-key/mockapi.d.ts +3 -0
  7. package/dist/specs/authentication/api-key/mockapi.d.ts.map +1 -0
  8. package/dist/specs/authentication/api-key/mockapi.js +45 -0
  9. package/dist/specs/authentication/api-key/mockapi.js.map +1 -0
  10. package/dist/specs/authentication/commonapi.d.ts +9 -0
  11. package/dist/specs/authentication/commonapi.d.ts.map +1 -0
  12. package/dist/specs/authentication/commonapi.js +19 -0
  13. package/dist/specs/authentication/commonapi.js.map +1 -0
  14. package/dist/specs/authentication/http/custom/mockapi.d.ts +3 -0
  15. package/dist/specs/authentication/http/custom/mockapi.d.ts.map +1 -0
  16. package/dist/specs/authentication/http/custom/mockapi.js +45 -0
  17. package/dist/specs/authentication/http/custom/mockapi.js.map +1 -0
  18. package/dist/specs/authentication/oauth2/mockapi.d.ts +3 -0
  19. package/dist/specs/authentication/oauth2/mockapi.d.ts.map +1 -0
  20. package/dist/specs/authentication/oauth2/mockapi.js +42 -0
  21. package/dist/specs/authentication/oauth2/mockapi.js.map +1 -0
  22. package/dist/specs/authentication/union/mockapi.d.ts +3 -0
  23. package/dist/specs/authentication/union/mockapi.d.ts.map +1 -0
  24. package/dist/specs/authentication/union/mockapi.js +37 -0
  25. package/dist/specs/authentication/union/mockapi.js.map +1 -0
  26. package/dist/specs/encode/bytes/mockapi.d.ts +3 -0
  27. package/dist/specs/encode/bytes/mockapi.d.ts.map +1 -0
  28. package/dist/specs/encode/bytes/mockapi.js +179 -0
  29. package/dist/specs/encode/bytes/mockapi.js.map +1 -0
  30. package/dist/specs/encode/datetime/mockapi.d.ts +3 -0
  31. package/dist/specs/encode/datetime/mockapi.d.ts.map +1 -0
  32. package/dist/specs/encode/datetime/mockapi.js +160 -0
  33. package/dist/specs/encode/datetime/mockapi.js.map +1 -0
  34. package/dist/specs/encode/duration/mockapi.d.ts +3 -0
  35. package/dist/specs/encode/duration/mockapi.d.ts.map +1 -0
  36. package/dist/specs/encode/duration/mockapi.js +116 -0
  37. package/dist/specs/encode/duration/mockapi.js.map +1 -0
  38. package/dist/specs/encode/numeric/mockapi.d.ts +3 -0
  39. package/dist/specs/encode/numeric/mockapi.d.ts.map +1 -0
  40. package/dist/specs/encode/numeric/mockapi.js +29 -0
  41. package/dist/specs/encode/numeric/mockapi.js.map +1 -0
  42. package/dist/specs/helper.d.ts +3 -0
  43. package/dist/specs/helper.d.ts.map +1 -0
  44. package/dist/specs/helper.js +7 -0
  45. package/dist/specs/helper.js.map +1 -0
  46. package/dist/specs/parameters/basic/mockapi.d.ts +3 -0
  47. package/dist/specs/parameters/basic/mockapi.d.ts.map +1 -0
  48. package/dist/specs/parameters/basic/mockapi.js +24 -0
  49. package/dist/specs/parameters/basic/mockapi.js.map +1 -0
  50. package/dist/specs/parameters/body-optionality/mockapi.d.ts +3 -0
  51. package/dist/specs/parameters/body-optionality/mockapi.d.ts.map +1 -0
  52. package/dist/specs/parameters/body-optionality/mockapi.js +62 -0
  53. package/dist/specs/parameters/body-optionality/mockapi.js.map +1 -0
  54. package/dist/specs/parameters/collection-format/mockapi.d.ts +3 -0
  55. package/dist/specs/parameters/collection-format/mockapi.d.ts.map +1 -0
  56. package/dist/specs/parameters/collection-format/mockapi.js +106 -0
  57. package/dist/specs/parameters/collection-format/mockapi.js.map +1 -0
  58. package/dist/specs/parameters/spread/mockapi.d.ts +3 -0
  59. package/dist/specs/parameters/spread/mockapi.d.ts.map +1 -0
  60. package/dist/specs/parameters/spread/mockapi.js +206 -0
  61. package/dist/specs/parameters/spread/mockapi.js.map +1 -0
  62. package/dist/specs/payload/json-merge-patch/mockapi.d.ts +40 -0
  63. package/dist/specs/payload/json-merge-patch/mockapi.d.ts.map +1 -0
  64. package/dist/specs/payload/json-merge-patch/mockapi.js +141 -0
  65. package/dist/specs/payload/json-merge-patch/mockapi.js.map +1 -0
  66. package/dist/specs/payload/media-type/mockapi.d.ts +3 -0
  67. package/dist/specs/payload/media-type/mockapi.d.ts.map +1 -0
  68. package/dist/specs/payload/media-type/mockapi.js +84 -0
  69. package/dist/specs/payload/media-type/mockapi.js.map +1 -0
  70. package/dist/specs/payload/multipart/mockapi.d.ts +3 -0
  71. package/dist/specs/payload/multipart/mockapi.d.ts.map +1 -0
  72. package/dist/specs/payload/multipart/mockapi.js +153 -0
  73. package/dist/specs/payload/multipart/mockapi.js.map +1 -0
  74. package/dist/specs/payload/xml/mockapi.d.ts +15 -0
  75. package/dist/specs/payload/xml/mockapi.d.ts.map +1 -0
  76. package/dist/specs/payload/xml/mockapi.js +189 -0
  77. package/dist/specs/payload/xml/mockapi.js.map +1 -0
  78. package/dist/specs/routes/mockapi.d.ts +3 -0
  79. package/dist/specs/routes/mockapi.d.ts.map +1 -0
  80. package/dist/specs/routes/mockapi.js +63 -0
  81. package/dist/specs/routes/mockapi.js.map +1 -0
  82. package/dist/specs/serialization/encoded-name/json/mockapi.d.ts +3 -0
  83. package/dist/specs/serialization/encoded-name/json/mockapi.d.ts.map +1 -0
  84. package/dist/specs/serialization/encoded-name/json/mockapi.js +32 -0
  85. package/dist/specs/serialization/encoded-name/json/mockapi.js.map +1 -0
  86. package/dist/specs/server/endpoint/not-defined/mockapi.d.ts +3 -0
  87. package/dist/specs/server/endpoint/not-defined/mockapi.d.ts.map +1 -0
  88. package/dist/specs/server/endpoint/not-defined/mockapi.js +15 -0
  89. package/dist/specs/server/endpoint/not-defined/mockapi.js.map +1 -0
  90. package/dist/specs/server/path/multiple/mockapi.d.ts +3 -0
  91. package/dist/specs/server/path/multiple/mockapi.d.ts.map +1 -0
  92. package/dist/specs/server/path/multiple/mockapi.js +27 -0
  93. package/dist/specs/server/path/multiple/mockapi.js.map +1 -0
  94. package/dist/specs/server/path/single/mockapi.d.ts +3 -0
  95. package/dist/specs/server/path/single/mockapi.d.ts.map +1 -0
  96. package/dist/specs/server/path/single/mockapi.js +15 -0
  97. package/dist/specs/server/path/single/mockapi.js.map +1 -0
  98. package/dist/specs/server/versions/not-versioned/mockapi.d.ts +3 -0
  99. package/dist/specs/server/versions/not-versioned/mockapi.d.ts.map +1 -0
  100. package/dist/specs/server/versions/not-versioned/mockapi.js +46 -0
  101. package/dist/specs/server/versions/not-versioned/mockapi.js.map +1 -0
  102. package/dist/specs/server/versions/versioned/mockapi.d.ts +3 -0
  103. package/dist/specs/server/versions/versioned/mockapi.d.ts.map +1 -0
  104. package/dist/specs/server/versions/versioned/mockapi.js +47 -0
  105. package/dist/specs/server/versions/versioned/mockapi.js.map +1 -0
  106. package/dist/specs/special-headers/conditional-request/mockapi.d.ts +3 -0
  107. package/dist/specs/special-headers/conditional-request/mockapi.d.ts.map +1 -0
  108. package/dist/specs/special-headers/conditional-request/mockapi.js +79 -0
  109. package/dist/specs/special-headers/conditional-request/mockapi.js.map +1 -0
  110. package/dist/specs/special-headers/repeatability/mockapi.d.ts +3 -0
  111. package/dist/specs/special-headers/repeatability/mockapi.d.ts.map +1 -0
  112. package/dist/specs/special-headers/repeatability/mockapi.js +36 -0
  113. package/dist/specs/special-headers/repeatability/mockapi.js.map +1 -0
  114. package/dist/specs/special-words/dec.d.ts +22 -0
  115. package/dist/specs/special-words/dec.d.ts.map +1 -0
  116. package/dist/specs/special-words/dec.js +37 -0
  117. package/dist/specs/special-words/dec.js.map +1 -0
  118. package/dist/specs/special-words/mockapi.d.ts +3 -0
  119. package/dist/specs/special-words/mockapi.d.ts.map +1 -0
  120. package/dist/specs/special-words/mockapi.js +246 -0
  121. package/dist/specs/special-words/mockapi.js.map +1 -0
  122. package/dist/specs/type/array/mockapi.d.ts +3 -0
  123. package/dist/specs/type/array/mockapi.d.ts.map +1 -0
  124. package/dist/specs/type/array/mockapi.js +104 -0
  125. package/dist/specs/type/array/mockapi.js.map +1 -0
  126. package/dist/specs/type/dictionary/mockapi.d.ts +3 -0
  127. package/dist/specs/type/dictionary/mockapi.d.ts.map +1 -0
  128. package/dist/specs/type/dictionary/mockapi.js +103 -0
  129. package/dist/specs/type/dictionary/mockapi.js.map +1 -0
  130. package/dist/specs/type/enum/extensible/mockapi.d.ts +3 -0
  131. package/dist/specs/type/enum/extensible/mockapi.d.ts.map +1 -0
  132. package/dist/specs/type/enum/extensible/mockapi.js +46 -0
  133. package/dist/specs/type/enum/extensible/mockapi.js.map +1 -0
  134. package/dist/specs/type/enum/fixed/mockapi.d.ts +3 -0
  135. package/dist/specs/type/enum/fixed/mockapi.d.ts.map +1 -0
  136. package/dist/specs/type/enum/fixed/mockapi.js +53 -0
  137. package/dist/specs/type/enum/fixed/mockapi.js.map +1 -0
  138. package/dist/specs/type/model/empty/mockapi.d.ts +3 -0
  139. package/dist/specs/type/model/empty/mockapi.d.ts.map +1 -0
  140. package/dist/specs/type/model/empty/mockapi.js +48 -0
  141. package/dist/specs/type/model/empty/mockapi.js.map +1 -0
  142. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.d.ts +3 -0
  143. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.d.ts.map +1 -0
  144. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js +79 -0
  145. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js.map +1 -0
  146. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.d.ts +3 -0
  147. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.d.ts.map +1 -0
  148. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js +147 -0
  149. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js.map +1 -0
  150. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.d.ts +3 -0
  151. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.d.ts.map +1 -0
  152. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js +47 -0
  153. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js.map +1 -0
  154. package/dist/specs/type/model/inheritance/recursive/mockapi.d.ts +3 -0
  155. package/dist/specs/type/model/inheritance/recursive/mockapi.d.ts.map +1 -0
  156. package/dist/specs/type/model/inheritance/recursive/mockapi.js +47 -0
  157. package/dist/specs/type/model/inheritance/recursive/mockapi.js.map +1 -0
  158. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.d.ts +3 -0
  159. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.d.ts.map +1 -0
  160. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js +122 -0
  161. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js.map +1 -0
  162. package/dist/specs/type/model/templated/mockapi.d.ts +3 -0
  163. package/dist/specs/type/model/templated/mockapi.d.ts.map +1 -0
  164. package/dist/specs/type/model/templated/mockapi.js +99 -0
  165. package/dist/specs/type/model/templated/mockapi.js.map +1 -0
  166. package/dist/specs/type/model/usage/mockapi.d.ts +3 -0
  167. package/dist/specs/type/model/usage/mockapi.d.ts.map +1 -0
  168. package/dist/specs/type/model/usage/mockapi.js +52 -0
  169. package/dist/specs/type/model/usage/mockapi.js.map +1 -0
  170. package/dist/specs/type/model/visibility/mockapi.d.ts +3 -0
  171. package/dist/specs/type/model/visibility/mockapi.d.ts.map +1 -0
  172. package/dist/specs/type/model/visibility/mockapi.js +138 -0
  173. package/dist/specs/type/model/visibility/mockapi.js.map +1 -0
  174. package/dist/specs/type/property/additional-properties/mockapi.d.ts +3 -0
  175. package/dist/specs/type/property/additional-properties/mockapi.d.ts.map +1 -0
  176. package/dist/specs/type/property/additional-properties/mockapi.js +346 -0
  177. package/dist/specs/type/property/additional-properties/mockapi.js.map +1 -0
  178. package/dist/specs/type/property/nullable/mockapi.d.ts +3 -0
  179. package/dist/specs/type/property/nullable/mockapi.d.ts.map +1 -0
  180. package/dist/specs/type/property/nullable/mockapi.js +147 -0
  181. package/dist/specs/type/property/nullable/mockapi.js.map +1 -0
  182. package/dist/specs/type/property/optionality/mockapi.d.ts +3 -0
  183. package/dist/specs/type/property/optionality/mockapi.d.ts.map +1 -0
  184. package/dist/specs/type/property/optionality/mockapi.js +197 -0
  185. package/dist/specs/type/property/optionality/mockapi.js.map +1 -0
  186. package/dist/specs/type/property/value-types/mockapi.d.ts +3 -0
  187. package/dist/specs/type/property/value-types/mockapi.d.ts.map +1 -0
  188. package/dist/specs/type/property/value-types/mockapi.js +213 -0
  189. package/dist/specs/type/property/value-types/mockapi.js.map +1 -0
  190. package/dist/specs/type/scalar/mockapi.d.ts +3 -0
  191. package/dist/specs/type/scalar/mockapi.d.ts.map +1 -0
  192. package/dist/specs/type/scalar/mockapi.js +274 -0
  193. package/dist/specs/type/scalar/mockapi.js.map +1 -0
  194. package/dist/specs/type/union/mockapi.d.ts +3 -0
  195. package/dist/specs/type/union/mockapi.d.ts.map +1 -0
  196. package/dist/specs/type/union/mockapi.js +113 -0
  197. package/dist/specs/type/union/mockapi.js.map +1 -0
  198. package/dist/specs/versioning/added/mockapi.d.ts +3 -0
  199. package/dist/specs/versioning/added/mockapi.d.ts.map +1 -0
  200. package/dist/specs/versioning/added/mockapi.js +76 -0
  201. package/dist/specs/versioning/added/mockapi.js.map +1 -0
  202. package/dist/specs/versioning/madeOptional/mockapi.d.ts +3 -0
  203. package/dist/specs/versioning/madeOptional/mockapi.d.ts.map +1 -0
  204. package/dist/specs/versioning/madeOptional/mockapi.js +24 -0
  205. package/dist/specs/versioning/madeOptional/mockapi.js.map +1 -0
  206. package/dist/specs/versioning/removed/mockapi.d.ts +3 -0
  207. package/dist/specs/versioning/removed/mockapi.d.ts.map +1 -0
  208. package/dist/specs/versioning/removed/mockapi.js +26 -0
  209. package/dist/specs/versioning/removed/mockapi.js.map +1 -0
  210. package/dist/specs/versioning/renamedFrom/mockapi.d.ts +3 -0
  211. package/dist/specs/versioning/renamedFrom/mockapi.d.ts.map +1 -0
  212. package/dist/specs/versioning/renamedFrom/mockapi.js +53 -0
  213. package/dist/specs/versioning/renamedFrom/mockapi.js.map +1 -0
  214. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.d.ts +3 -0
  215. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.d.ts.map +1 -0
  216. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js +25 -0
  217. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js.map +1 -0
  218. package/dist/specs/versioning/typeChangedFrom/mockapi.d.ts +3 -0
  219. package/dist/specs/versioning/typeChangedFrom/mockapi.d.ts.map +1 -0
  220. package/dist/specs/versioning/typeChangedFrom/mockapi.js +29 -0
  221. package/dist/specs/versioning/typeChangedFrom/mockapi.js.map +1 -0
  222. package/package.json +53 -0
  223. package/specs/README.md +3 -0
  224. package/specs/authentication/api-key/main.tsp +39 -0
  225. package/specs/authentication/api-key/mockapi.ts +47 -0
  226. package/specs/authentication/commonapi.ts +43 -0
  227. package/specs/authentication/http/custom/main.tsp +39 -0
  228. package/specs/authentication/http/custom/mockapi.ts +47 -0
  229. package/specs/authentication/oauth2/main.tsp +44 -0
  230. package/specs/authentication/oauth2/mockapi.ts +44 -0
  231. package/specs/authentication/union/main.tsp +29 -0
  232. package/specs/authentication/union/mockapi.ts +39 -0
  233. package/specs/encode/bytes/main.tsp +369 -0
  234. package/specs/encode/bytes/mockapi.ts +309 -0
  235. package/specs/encode/datetime/main.tsp +344 -0
  236. package/specs/encode/datetime/mockapi.ts +274 -0
  237. package/specs/encode/duration/main.tsp +322 -0
  238. package/specs/encode/duration/mockapi.ts +204 -0
  239. package/specs/encode/numeric/main.tsp +71 -0
  240. package/specs/encode/numeric/mockapi.ts +39 -0
  241. package/specs/helper.ts +8 -0
  242. package/specs/parameters/basic/main.tsp +61 -0
  243. package/specs/parameters/basic/mockapi.ts +29 -0
  244. package/specs/parameters/body-optionality/main.tsp +63 -0
  245. package/specs/parameters/body-optionality/mockapi.ts +71 -0
  246. package/specs/parameters/collection-format/main.tsp +95 -0
  247. package/specs/parameters/collection-format/mockapi.ts +113 -0
  248. package/specs/parameters/spread/main.tsp +340 -0
  249. package/specs/parameters/spread/mockapi.ts +216 -0
  250. package/specs/payload/json-merge-patch/main.tsp +183 -0
  251. package/specs/payload/json-merge-patch/mockapi.ts +146 -0
  252. package/specs/payload/media-type/main.tsp +54 -0
  253. package/specs/payload/media-type/mockapi.ts +88 -0
  254. package/specs/payload/multipart/main.tsp +499 -0
  255. package/specs/payload/multipart/mockapi.ts +226 -0
  256. package/specs/payload/xml/main.tsp +312 -0
  257. package/specs/payload/xml/mockapi.ts +244 -0
  258. package/specs/routes/main.tsp +476 -0
  259. package/specs/routes/mockapi.ts +158 -0
  260. package/specs/scratch/.gitignore +3 -0
  261. package/specs/serialization/encoded-name/json/main.tsp +45 -0
  262. package/specs/serialization/encoded-name/json/mockapi.ts +34 -0
  263. package/specs/server/endpoint/not-defined/main.tsp +19 -0
  264. package/specs/server/endpoint/not-defined/mockapi.ts +16 -0
  265. package/specs/server/path/multiple/main.tsp +46 -0
  266. package/specs/server/path/multiple/mockapi.ts +29 -0
  267. package/specs/server/path/single/main.tsp +23 -0
  268. package/specs/server/path/single/mockapi.ts +16 -0
  269. package/specs/server/versions/not-versioned/main.tsp +39 -0
  270. package/specs/server/versions/not-versioned/mockapi.ts +55 -0
  271. package/specs/server/versions/versioned/main.tsp +65 -0
  272. package/specs/server/versions/versioned/mockapi.ts +68 -0
  273. package/specs/special-headers/conditional-request/main.tsp +89 -0
  274. package/specs/special-headers/conditional-request/mockapi.ts +83 -0
  275. package/specs/special-headers/repeatability/main.tsp +39 -0
  276. package/specs/special-headers/repeatability/mockapi.ts +47 -0
  277. package/specs/special-words/dec.js +52 -0
  278. package/specs/special-words/main.tsp +238 -0
  279. package/specs/special-words/mockapi.ts +407 -0
  280. package/specs/type/array/main.tsp +132 -0
  281. package/specs/type/array/mockapi.ts +119 -0
  282. package/specs/type/dictionary/main.tsp +122 -0
  283. package/specs/type/dictionary/mockapi.ts +115 -0
  284. package/specs/type/enum/extensible/main.tsp +64 -0
  285. package/specs/type/enum/extensible/mockapi.ts +55 -0
  286. package/specs/type/enum/fixed/main.tsp +60 -0
  287. package/specs/type/enum/fixed/mockapi.ts +55 -0
  288. package/specs/type/model/empty/main.tsp +39 -0
  289. package/specs/type/model/empty/mockapi.ts +51 -0
  290. package/specs/type/model/inheritance/enum-discriminator/main.tsp +169 -0
  291. package/specs/type/model/inheritance/enum-discriminator/mockapi.ts +99 -0
  292. package/specs/type/model/inheritance/nested-discriminator/main.tsp +223 -0
  293. package/specs/type/model/inheritance/nested-discriminator/mockapi.ts +150 -0
  294. package/specs/type/model/inheritance/not-discriminated/main.tsp +53 -0
  295. package/specs/type/model/inheritance/not-discriminated/mockapi.ts +49 -0
  296. package/specs/type/model/inheritance/recursive/main.tsp +70 -0
  297. package/specs/type/model/inheritance/recursive/mockapi.ts +48 -0
  298. package/specs/type/model/inheritance/single-discriminator/main.tsp +171 -0
  299. package/specs/type/model/inheritance/single-discriminator/mockapi.ts +126 -0
  300. package/specs/type/model/templated/main.tsp +130 -0
  301. package/specs/type/model/templated/mockapi.ts +102 -0
  302. package/specs/type/model/usage/main.tsp +48 -0
  303. package/specs/type/model/usage/mockapi.ts +56 -0
  304. package/specs/type/model/visibility/main.tsp +152 -0
  305. package/specs/type/model/visibility/mockapi.ts +139 -0
  306. package/specs/type/property/additional-properties/main.tsp +591 -0
  307. package/specs/type/property/additional-properties/mockapi.ts +477 -0
  308. package/specs/type/property/nullable/client.tsp +21 -0
  309. package/specs/type/property/nullable/main.tsp +162 -0
  310. package/specs/type/property/nullable/mockapi.ts +202 -0
  311. package/specs/type/property/optionality/main.tsp +258 -0
  312. package/specs/type/property/optionality/mockapi.ts +308 -0
  313. package/specs/type/property/value-types/main.tsp +285 -0
  314. package/specs/type/property/value-types/mockapi.ts +297 -0
  315. package/specs/type/scalar/main.tsp +164 -0
  316. package/specs/type/scalar/mockapi.ts +280 -0
  317. package/specs/type/union/main.tsp +262 -0
  318. package/specs/type/union/mockapi.ts +137 -0
  319. package/specs/versioning/added/main.tsp +135 -0
  320. package/specs/versioning/added/mockapi.ts +79 -0
  321. package/specs/versioning/madeOptional/main.tsp +64 -0
  322. package/specs/versioning/madeOptional/mockapi.ts +25 -0
  323. package/specs/versioning/removed/main.tsp +125 -0
  324. package/specs/versioning/removed/mockapi.ts +27 -0
  325. package/specs/versioning/renamedFrom/main.tsp +111 -0
  326. package/specs/versioning/renamedFrom/mockapi.ts +55 -0
  327. package/specs/versioning/returnTypeChangedFrom/main.tsp +56 -0
  328. package/specs/versioning/returnTypeChangedFrom/mockapi.ts +26 -0
  329. package/specs/versioning/typeChangedFrom/main.tsp +70 -0
  330. package/specs/versioning/typeChangedFrom/mockapi.ts +30 -0
  331. package/temp/.tsbuildinfo +1 -0
  332. package/tsconfig.build.json +9 -0
  333. package/tsconfig.json +11 -0
  334. package/tspconfig.yaml +2 -0
@@ -0,0 +1,280 @@
1
+ import { json, MockRequest, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
2
+
3
+ export const Scenarios: Record<string, ScenarioMockApi> = {};
4
+
5
+ Scenarios.Type_Scalar_String_get = passOnSuccess({
6
+ uri: "/type/scalar/string",
7
+ method: `get`,
8
+ request: {},
9
+ response: {
10
+ status: 200,
11
+ body: json("test"),
12
+ },
13
+ handler: (req: MockRequest) => {
14
+ return { status: 200, body: json("test") };
15
+ },
16
+ kind: "MockApiDefinition",
17
+ });
18
+
19
+ Scenarios.Type_Scalar_String_put = passOnSuccess({
20
+ uri: "/type/scalar/string",
21
+ method: `put`,
22
+ request: {
23
+ body: "test",
24
+ headers: {
25
+ "Content-Type": "text/plain",
26
+ },
27
+ },
28
+ response: {
29
+ status: 204,
30
+ },
31
+ handler: (req: MockRequest) => {
32
+ req.expect.bodyEquals("test");
33
+ return { status: 204 };
34
+ },
35
+ kind: "MockApiDefinition",
36
+ });
37
+
38
+ Scenarios.Type_Scalar_Boolean_get = passOnSuccess({
39
+ uri: "/type/scalar/boolean",
40
+ method: `get`,
41
+ request: {},
42
+ response: {
43
+ status: 200,
44
+ body: json(true),
45
+ },
46
+ handler: (req: MockRequest) => {
47
+ return { status: 200, body: json(true) };
48
+ },
49
+ kind: "MockApiDefinition",
50
+ });
51
+
52
+ Scenarios.Type_Scalar_Boolean_put = passOnSuccess({
53
+ uri: "/type/scalar/boolean",
54
+ method: `put`,
55
+ request: {
56
+ body: true,
57
+ headers: {
58
+ "Content-Type": "application/json; charset=utf-8",
59
+ },
60
+ },
61
+ response: {
62
+ status: 204,
63
+ },
64
+ handler: (req: MockRequest) => {
65
+ req.expect.bodyEquals(true);
66
+ return { status: 204 };
67
+ },
68
+ kind: "MockApiDefinition",
69
+ });
70
+
71
+ Scenarios.Type_Scalar_Unknown_get = passOnSuccess({
72
+ uri: "/type/scalar/unknown",
73
+ method: `get`,
74
+ request: {},
75
+ response: {
76
+ status: 200,
77
+ body: json("test"),
78
+ },
79
+ handler: (req: MockRequest) => {
80
+ return { status: 200, body: json("test") };
81
+ },
82
+ kind: "MockApiDefinition",
83
+ });
84
+ Scenarios.Type_Scalar_Unknown_put = passOnSuccess({
85
+ uri: "/type/scalar/unknown",
86
+ method: `put`,
87
+ request: {
88
+ body: "test",
89
+ headers: {
90
+ "Content-Type": "text/plain",
91
+ },
92
+ },
93
+ response: {
94
+ status: 204,
95
+ },
96
+ handler: (req: MockRequest) => {
97
+ req.expect.bodyEquals("test");
98
+ return { status: 204 };
99
+ },
100
+ kind: "MockApiDefinition",
101
+ });
102
+
103
+ Scenarios.Type_Scalar_DecimalType_responseBody = passOnSuccess({
104
+ uri: "/type/scalar/decimal/response_body",
105
+ method: `get`,
106
+ request: {},
107
+ response: {
108
+ status: 200,
109
+ body: json(0.33333),
110
+ },
111
+ handler: (req: MockRequest) => {
112
+ return {
113
+ status: 200,
114
+ body: json(0.33333),
115
+ };
116
+ },
117
+ kind: "MockApiDefinition",
118
+ });
119
+ Scenarios.Type_Scalar_Decimal128Type_responseBody = passOnSuccess({
120
+ uri: "/type/scalar/decimal128/response_body",
121
+ method: `get`,
122
+ request: {},
123
+ response: {
124
+ status: 200,
125
+ body: json(0.33333),
126
+ },
127
+ handler: (req: MockRequest) => {
128
+ return {
129
+ status: 200,
130
+ body: json(0.33333),
131
+ };
132
+ },
133
+ kind: "MockApiDefinition",
134
+ });
135
+ Scenarios.Type_Scalar_DecimalType_requestBody = passOnSuccess({
136
+ uri: "/type/scalar/decimal/resquest_body",
137
+ method: `put`,
138
+ request: {
139
+ body: 0.33333,
140
+ headers: {
141
+ "Content-Type": "application/json; charset=utf-8",
142
+ },
143
+ },
144
+ response: {
145
+ status: 204,
146
+ },
147
+ handler: (req: MockRequest) => {
148
+ req.expect.bodyEquals(0.33333);
149
+ return {
150
+ status: 204,
151
+ };
152
+ },
153
+ kind: "MockApiDefinition",
154
+ });
155
+ Scenarios.Type_Scalar_Decimal128Type_requestBody = passOnSuccess({
156
+ uri: "/type/scalar/decimal128/resquest_body",
157
+ method: `put`,
158
+ request: {
159
+ body: 0.33333,
160
+ headers: {
161
+ "Content-Type": "application/json; charset=utf-8",
162
+ },
163
+ },
164
+ response: {
165
+ status: 204,
166
+ },
167
+ handler: (req: MockRequest) => {
168
+ req.expect.bodyEquals(0.33333);
169
+ return {
170
+ status: 204,
171
+ };
172
+ },
173
+ kind: "MockApiDefinition",
174
+ });
175
+ Scenarios.Type_Scalar_DecimalType_requestParameter = passOnSuccess({
176
+ uri: "/type/scalar/decimal/request_parameter",
177
+ method: `get`,
178
+ request: {
179
+ params: { value: 0.33333 },
180
+ },
181
+ response: {
182
+ status: 204,
183
+ },
184
+ handler: (req: MockRequest) => {
185
+ req.expect.containsQueryParam("value", "0.33333");
186
+ return {
187
+ status: 204,
188
+ };
189
+ },
190
+ kind: "MockApiDefinition",
191
+ });
192
+ Scenarios.Type_Scalar_Decimal128Type_requestParameter = passOnSuccess({
193
+ uri: "/type/scalar/decimal128/request_parameter",
194
+ method: `get`,
195
+ request: {
196
+ params: { value: 0.33333 },
197
+ },
198
+ response: {
199
+ status: 204,
200
+ },
201
+ handler: (req: MockRequest) => {
202
+ req.expect.containsQueryParam("value", "0.33333");
203
+ return {
204
+ status: 204,
205
+ };
206
+ },
207
+ kind: "MockApiDefinition",
208
+ });
209
+ Scenarios.Type_Scalar_DecimalVerify_prepareVerify = passOnSuccess({
210
+ uri: "/type/scalar/decimal/prepare_verify",
211
+ method: `get`,
212
+ request: {},
213
+ response: {
214
+ status: 200,
215
+ body: json([0.1, 0.1, 0.1]),
216
+ },
217
+ handler: (req: MockRequest) => {
218
+ return {
219
+ status: 200,
220
+ body: json([0.1, 0.1, 0.1]),
221
+ };
222
+ },
223
+ kind: "MockApiDefinition",
224
+ });
225
+ Scenarios.Type_Scalar_Decimal128Verify_prepareVerify = passOnSuccess({
226
+ uri: "/type/scalar/decimal128/prepare_verify",
227
+ method: `get`,
228
+ request: {},
229
+ response: {
230
+ status: 200,
231
+ body: json([0.1, 0.1, 0.1]),
232
+ },
233
+ handler: (req: MockRequest) => {
234
+ return {
235
+ status: 200,
236
+ body: json([0.1, 0.1, 0.1]),
237
+ };
238
+ },
239
+ kind: "MockApiDefinition",
240
+ });
241
+ Scenarios.Type_Scalar_DecimalVerify_verify = passOnSuccess({
242
+ uri: "/type/scalar/decimal/verify",
243
+ method: `post`,
244
+ request: {
245
+ body: 0.3,
246
+ headers: {
247
+ "Content-Type": "application/json; charset=utf-8",
248
+ },
249
+ },
250
+ response: {
251
+ status: 204,
252
+ },
253
+ handler: (req: MockRequest) => {
254
+ req.expect.bodyEquals(0.3);
255
+ return {
256
+ status: 204,
257
+ };
258
+ },
259
+ kind: "MockApiDefinition",
260
+ });
261
+ Scenarios.Type_Scalar_Decimal128Verify_verify = passOnSuccess({
262
+ uri: "/type/scalar/decimal128/verify",
263
+ method: `post`,
264
+ request: {
265
+ body: 0.3,
266
+ headers: {
267
+ "Content-Type": "application/json; charset=utf-8",
268
+ },
269
+ },
270
+ response: {
271
+ status: 204,
272
+ },
273
+ handler: (req: MockRequest) => {
274
+ req.expect.bodyEquals(0.3);
275
+ return {
276
+ status: 204,
277
+ };
278
+ },
279
+ kind: "MockApiDefinition",
280
+ });
@@ -0,0 +1,262 @@
1
+ import "@typespec/http";
2
+ import "@typespec/spec-lib";
3
+
4
+ using TypeSpec.Http;
5
+ using Azure.ClientGenerator.Core;
6
+
7
+ /**
8
+ * Describe scenarios for various combinations of unions.
9
+ */
10
+ @supportedBy("dpg")
11
+ @scenarioService("/type/union")
12
+ namespace Type.Union;
13
+
14
+ model Cat {
15
+ name: string;
16
+ }
17
+
18
+ model Dog {
19
+ bark: string;
20
+ }
21
+
22
+ enum LR {
23
+ left,
24
+ right,
25
+ }
26
+ enum UD {
27
+ up,
28
+ down,
29
+ }
30
+
31
+ /**
32
+ * Describe union of string "a" | "b" | "c"
33
+ */
34
+ @route("/strings-only")
35
+ @operationGroup
36
+ interface StringsOnly extends GetAndSend<"a" | "b" | "c", "\"b\""> {}
37
+
38
+ /**
39
+ * Describe union of string string | "b" | "c"
40
+ */
41
+ @route("/string-extensible")
42
+ @operationGroup
43
+ interface StringExtensible extends GetAndSend<string | "b" | "c", "\"custom\""> {}
44
+
45
+ union StringExtensibleNamedUnion {
46
+ string,
47
+ OptionB: "b",
48
+ "c",
49
+ }
50
+ /**
51
+ * Describe union of string string | "b" | "c" but where the union is named and some of the variants are named
52
+ */
53
+ @route("/string-extensible-named")
54
+ @operationGroup
55
+ interface StringExtensibleNamed extends GetAndSend<StringExtensibleNamedUnion, "\"custom\""> {}
56
+
57
+ /**
58
+ * Describe union of integer 1 | 2 | 3
59
+ */
60
+ @route("/ints-only")
61
+ @operationGroup
62
+ interface IntsOnly extends GetAndSend<1 | 2 | 3, "2"> {}
63
+
64
+ /**
65
+ * Describe union of floats 1.1 | 2.2 | 3.3
66
+ */
67
+ @route("/floats-only")
68
+ @operationGroup
69
+ interface FloatsOnly extends GetAndSend<1.1 | 2.2 | 3.3, "2.2"> {}
70
+
71
+ /**
72
+ * Describe union of models
73
+ */
74
+ @route("/models-only")
75
+ @operationGroup
76
+ interface ModelsOnly
77
+ extends GetAndSend<
78
+ Cat | Dog,
79
+ """
80
+ {
81
+ "name": "test"
82
+ }
83
+ """
84
+ > {}
85
+
86
+ model EnumsOnlyCases {
87
+ /** This should be receive/send the left variant */
88
+ lr: LR | UD;
89
+
90
+ /** This should be receive/send the up variant */
91
+ ud: UD | UD;
92
+ }
93
+
94
+ /**
95
+ * Describe union of 2 different enums
96
+ */
97
+ @route("/enums-only")
98
+ @operationGroup
99
+ interface EnumsOnly
100
+ extends GetAndSend<
101
+ LR | UD,
102
+ """
103
+ {
104
+ "lr": "right",
105
+ "ud": "up"
106
+ }
107
+ """,
108
+ EnumsOnlyCases
109
+ > {}
110
+
111
+ model StringAndArrayCases {
112
+ /** This should be receive/send the string variant */
113
+ string: string | string[];
114
+
115
+ /** This should be receive/send the array variant */
116
+ array: string | string[];
117
+ }
118
+
119
+ /**
120
+ * Describe union of a string and an array of strings
121
+ */
122
+ @route("/string-and-array")
123
+ @operationGroup
124
+ interface StringAndArray
125
+ extends GetAndSend<
126
+ string | string[],
127
+ """
128
+ {
129
+ "string": "test",
130
+ "array": ["test1", "test2"]
131
+ }
132
+ """,
133
+ StringAndArrayCases
134
+ > {}
135
+
136
+ alias MixedLiteralsUnion = "a" | 2 | 3.3 | true;
137
+ model MixedLiteralsCases {
138
+ /** This should be receive/send the "a" variant */
139
+ stringLiteral: MixedLiteralsUnion;
140
+
141
+ /** This should be receive/send the 2 variant */
142
+ intLiteral: MixedLiteralsUnion;
143
+
144
+ /** This should be receive/send the 3.3 variant */
145
+ floatLiteral: MixedLiteralsUnion;
146
+
147
+ /** This should be receive/send the true variant */
148
+ booleanLiteral: MixedLiteralsUnion;
149
+ }
150
+
151
+ /**
152
+ * Describe union of floats "a" | 2 | 3.3
153
+ */
154
+ @route("/mixed-literals")
155
+ @operationGroup
156
+ interface MixedLiterals
157
+ extends GetAndSend<
158
+ MixedLiteralsUnion,
159
+ """
160
+ {
161
+ "stringLiteral": "a",
162
+ "intLiteral": 2,
163
+ "floatLiteral": 3.3,
164
+ "booleanLiteral": true
165
+ }
166
+ """,
167
+ MixedLiteralsCases
168
+ > {}
169
+
170
+ alias MixedTypesUnion = Cat | "a" | int32 | boolean;
171
+ model MixedTypesCases {
172
+ /** This should be receive/send the Cat variant */
173
+ `model`: MixedTypesUnion;
174
+
175
+ /** This should be receive/send the "a" variant */
176
+ literal: MixedTypesUnion;
177
+
178
+ /** This should be receive/send the int variant */
179
+ int: MixedTypesUnion;
180
+
181
+ /** This should be receive/send the boolean variant */
182
+ boolean: MixedTypesUnion;
183
+
184
+ /** This should be receive/send 4 element with Cat, "a", int, and boolean */
185
+ array: MixedTypesUnion[];
186
+ }
187
+
188
+ /**
189
+ * Describe union of floats "a" | 2 | 3.3
190
+ */
191
+ @route("/mixed-types")
192
+ @operationGroup
193
+ interface MixedTypes
194
+ extends GetAndSend<
195
+ MixedTypesUnion,
196
+ """
197
+ {
198
+ "model": {
199
+ "name": "test"
200
+ },
201
+ "literal": "a",
202
+ "int": 2,
203
+ "boolean": true,
204
+ "array": [
205
+ {
206
+ "name": "test"
207
+ },
208
+ "a",
209
+ 2,
210
+ true
211
+ ]
212
+ }
213
+ """,
214
+ MixedTypesCases
215
+ > {}
216
+
217
+ /**
218
+ * Helper interface to describe a test involving getting and sending a specific data
219
+ */
220
+ interface GetAndSend<Union, Payload extends string, Cases = Union> {
221
+ @scenario
222
+ @scenarioDoc(
223
+ """
224
+ Verify a union can be processed in a response:
225
+ ```tsp
226
+ {type}
227
+ ```
228
+
229
+ Expected response body:
230
+ ```json
231
+ { "prop": {value}}
232
+ ```
233
+ """,
234
+ {
235
+ type: Union,
236
+ value: Payload,
237
+ }
238
+ )
239
+ get(): {
240
+ prop: Cases;
241
+ };
242
+
243
+ @scenario
244
+ @scenarioDoc(
245
+ """
246
+ Verify a union can be processed in a response:
247
+ ```tsp
248
+ {type}
249
+ ```
250
+
251
+ Expected request to send body:
252
+ ```json
253
+ { "prop": {value}}
254
+ ```
255
+ """,
256
+ {
257
+ type: Union,
258
+ value: Payload,
259
+ }
260
+ )
261
+ send(prop: Cases): void;
262
+ }
@@ -0,0 +1,137 @@
1
+ import { json, MockRequest, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
2
+
3
+ export const Scenarios: Record<string, ScenarioMockApi> = {};
4
+
5
+ function createGetServerTests(url: string, value: unknown) {
6
+ return passOnSuccess({
7
+ uri: url,
8
+ method: `get`,
9
+ request: {},
10
+ response: {
11
+ status: 200,
12
+ body: json({ prop: value }),
13
+ },
14
+ handler: (req: MockRequest) => {
15
+ return { status: 200, body: json({ prop: value }) };
16
+ },
17
+ kind: "MockApiDefinition",
18
+ });
19
+ }
20
+
21
+ function createPostServerTests(url: string, value: unknown) {
22
+ return passOnSuccess({
23
+ uri: url,
24
+ method: `post`,
25
+ request: {
26
+ body: {
27
+ prop: value,
28
+ },
29
+ },
30
+ response: {
31
+ status: 204,
32
+ },
33
+ handler: (req: MockRequest) => {
34
+ req.expect.bodyEquals({ prop: value });
35
+ return { status: 204 };
36
+ },
37
+ kind: "MockApiDefinition",
38
+ });
39
+ }
40
+
41
+ Scenarios.Type_Union_StringsOnly_get = createGetServerTests(`/type/union/strings-only`, "b");
42
+ Scenarios.Type_Union_StringsOnly_send = createPostServerTests(`/type/union/strings-only`, "b");
43
+
44
+ Scenarios.Type_Union_StringExtensible_get = createGetServerTests(
45
+ `/type/union/string-extensible`,
46
+ "custom",
47
+ );
48
+ Scenarios.Type_Union_StringExtensible_send = createPostServerTests(
49
+ `/type/union/string-extensible`,
50
+ "custom",
51
+ );
52
+
53
+ Scenarios.Type_Union_StringExtensibleNamed_get = createGetServerTests(
54
+ `/type/union/string-extensible-named`,
55
+ "custom",
56
+ );
57
+ Scenarios.Type_Union_StringExtensibleNamed_send = createPostServerTests(
58
+ `/type/union/string-extensible-named`,
59
+ "custom",
60
+ );
61
+
62
+ Scenarios.Type_Union_IntsOnly_get = createGetServerTests(`/type/union/ints-only`, 2);
63
+ Scenarios.Type_Union_IntsOnly_send = createPostServerTests(`/type/union/ints-only`, 2);
64
+
65
+ Scenarios.Type_Union_FloatsOnly_get = createGetServerTests(`/type/union/floats-only`, 2.2);
66
+ Scenarios.Type_Union_FloatsOnly_send = createPostServerTests(`/type/union/floats-only`, 2.2);
67
+
68
+ Scenarios.Type_Union_ModelsOnly_get = createGetServerTests(`/type/union/models-only`, {
69
+ name: "test",
70
+ });
71
+ Scenarios.Type_Union_ModelsOnly_send = createPostServerTests(`/type/union/models-only`, {
72
+ name: "test",
73
+ });
74
+
75
+ Scenarios.Type_Union_EnumsOnly_get = createGetServerTests(`/type/union/enums-only`, {
76
+ lr: "right",
77
+ ud: "up",
78
+ });
79
+ Scenarios.Type_Union_EnumsOnly_send = createPostServerTests(`/type/union/enums-only`, {
80
+ lr: "right",
81
+ ud: "up",
82
+ });
83
+
84
+ Scenarios.Type_Union_StringAndArray_get = createGetServerTests(`/type/union/string-and-array`, {
85
+ string: "test",
86
+ array: ["test1", "test2"],
87
+ });
88
+ Scenarios.Type_Union_StringAndArray_send = createPostServerTests(`/type/union/string-and-array`, {
89
+ string: "test",
90
+ array: ["test1", "test2"],
91
+ });
92
+
93
+ Scenarios.Type_Union_MixedLiterals_get = createGetServerTests(`/type/union/mixed-literals`, {
94
+ stringLiteral: "a",
95
+ intLiteral: 2,
96
+ floatLiteral: 3.3,
97
+ booleanLiteral: true,
98
+ });
99
+ Scenarios.Type_Union_MixedLiterals_send = createPostServerTests(`/type/union/mixed-literals`, {
100
+ stringLiteral: "a",
101
+ intLiteral: 2,
102
+ floatLiteral: 3.3,
103
+ booleanLiteral: true,
104
+ });
105
+
106
+ Scenarios.Type_Union_MixedTypes_get = createGetServerTests(`/type/union/mixed-types`, {
107
+ model: {
108
+ name: "test",
109
+ },
110
+ literal: "a",
111
+ int: 2,
112
+ boolean: true,
113
+ array: [
114
+ {
115
+ name: "test",
116
+ },
117
+ "a",
118
+ 2,
119
+ true,
120
+ ],
121
+ });
122
+ Scenarios.Type_Union_MixedTypes_send = createPostServerTests(`/type/union/mixed-types`, {
123
+ model: {
124
+ name: "test",
125
+ },
126
+ literal: "a",
127
+ int: 2,
128
+ boolean: true,
129
+ array: [
130
+ {
131
+ name: "test",
132
+ },
133
+ "a",
134
+ 2,
135
+ true,
136
+ ],
137
+ });