@typespec/http-specs 0.1.0-alpha.9-dev.5 → 0.1.0-dev.0

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 (224) hide show
  1. package/CHANGELOG.md +256 -2
  2. package/README.md +11 -3
  3. package/dist/specs/authentication/noauth/union/mockapi.d.ts +3 -0
  4. package/dist/specs/authentication/noauth/union/mockapi.d.ts.map +1 -0
  5. package/dist/specs/authentication/noauth/union/mockapi.js +25 -0
  6. package/dist/specs/authentication/noauth/union/mockapi.js.map +1 -0
  7. package/dist/specs/documentation/mockapi.d.ts +3 -0
  8. package/dist/specs/documentation/mockapi.d.ts.map +1 -0
  9. package/dist/specs/documentation/mockapi.js +40 -0
  10. package/dist/specs/documentation/mockapi.js.map +1 -0
  11. package/dist/specs/encode/array/mockapi.d.ts +3 -0
  12. package/dist/specs/encode/array/mockapi.d.ts.map +1 -0
  13. package/dist/specs/encode/array/mockapi.js +33 -0
  14. package/dist/specs/encode/array/mockapi.js.map +1 -0
  15. package/dist/specs/encode/bytes/mockapi.js +16 -24
  16. package/dist/specs/encode/bytes/mockapi.js.map +1 -1
  17. package/dist/specs/encode/datetime/mockapi.js +2 -2
  18. package/dist/specs/encode/datetime/mockapi.js.map +1 -1
  19. package/dist/specs/encode/duration/mockapi.d.ts.map +1 -1
  20. package/dist/specs/encode/duration/mockapi.js +110 -3
  21. package/dist/specs/encode/duration/mockapi.js.map +1 -1
  22. package/dist/specs/encode/numeric/mockapi.js +2 -2
  23. package/dist/specs/encode/numeric/mockapi.js.map +1 -1
  24. package/dist/specs/helper.d.ts +2 -2
  25. package/dist/specs/helper.d.ts.map +1 -1
  26. package/dist/specs/parameters/basic/mockapi.d.ts.map +1 -1
  27. package/dist/specs/parameters/basic/mockapi.js +3 -3
  28. package/dist/specs/parameters/basic/mockapi.js.map +1 -1
  29. package/dist/specs/parameters/body-optionality/mockapi.d.ts.map +1 -1
  30. package/dist/specs/parameters/body-optionality/mockapi.js +14 -4
  31. package/dist/specs/parameters/body-optionality/mockapi.js.map +1 -1
  32. package/dist/specs/parameters/collection-format/mockapi.js +4 -15
  33. package/dist/specs/parameters/collection-format/mockapi.js.map +1 -1
  34. package/dist/specs/parameters/path/mockapi.d.ts +3 -0
  35. package/dist/specs/parameters/path/mockapi.d.ts.map +1 -0
  36. package/dist/specs/parameters/path/mockapi.js +29 -0
  37. package/dist/specs/parameters/path/mockapi.js.map +1 -0
  38. package/dist/specs/parameters/query/mockapi.d.ts +3 -0
  39. package/dist/specs/parameters/query/mockapi.d.ts.map +1 -0
  40. package/dist/specs/parameters/query/mockapi.js +14 -0
  41. package/dist/specs/parameters/query/mockapi.js.map +1 -0
  42. package/dist/specs/parameters/spread/mockapi.d.ts.map +1 -1
  43. package/dist/specs/parameters/spread/mockapi.js +19 -19
  44. package/dist/specs/parameters/spread/mockapi.js.map +1 -1
  45. package/dist/specs/payload/json-merge-patch/mockapi.js +4 -4
  46. package/dist/specs/payload/json-merge-patch/mockapi.js.map +1 -1
  47. package/dist/specs/payload/media-type/mockapi.js +2 -2
  48. package/dist/specs/payload/media-type/mockapi.js.map +1 -1
  49. package/dist/specs/payload/multipart/mockapi.d.ts.map +1 -1
  50. package/dist/specs/payload/multipart/mockapi.js +189 -60
  51. package/dist/specs/payload/multipart/mockapi.js.map +1 -1
  52. package/dist/specs/payload/pageable/mockapi.d.ts.map +1 -1
  53. package/dist/specs/payload/pageable/mockapi.js +594 -14
  54. package/dist/specs/payload/pageable/mockapi.js.map +1 -1
  55. package/dist/specs/payload/xml/mockapi.d.ts +3 -0
  56. package/dist/specs/payload/xml/mockapi.d.ts.map +1 -1
  57. package/dist/specs/payload/xml/mockapi.js +35 -5
  58. package/dist/specs/payload/xml/mockapi.js.map +1 -1
  59. package/dist/specs/response/status-code-range/mockapi.d.ts.map +1 -1
  60. package/dist/specs/response/status-code-range/mockapi.js +5 -9
  61. package/dist/specs/response/status-code-range/mockapi.js.map +1 -1
  62. package/dist/specs/routes/mockapi.js +16 -16
  63. package/dist/specs/routes/mockapi.js.map +1 -1
  64. package/dist/specs/serialization/encoded-name/json/mockapi.js +1 -1
  65. package/dist/specs/serialization/encoded-name/json/mockapi.js.map +1 -1
  66. package/dist/specs/server/versions/not-versioned/mockapi.js +1 -1
  67. package/dist/specs/server/versions/not-versioned/mockapi.js.map +1 -1
  68. package/dist/specs/server/versions/versioned/mockapi.js +8 -12
  69. package/dist/specs/server/versions/versioned/mockapi.js.map +1 -1
  70. package/dist/specs/special-words/mockapi.d.ts.map +1 -1
  71. package/dist/specs/special-words/mockapi.js +59 -6
  72. package/dist/specs/special-words/mockapi.js.map +1 -1
  73. package/dist/specs/streaming/jsonl/mockapi.d.ts +3 -0
  74. package/dist/specs/streaming/jsonl/mockapi.d.ts.map +1 -0
  75. package/dist/specs/streaming/jsonl/mockapi.js +30 -0
  76. package/dist/specs/streaming/jsonl/mockapi.js.map +1 -0
  77. package/dist/specs/type/array/mockapi.js +1 -1
  78. package/dist/specs/type/array/mockapi.js.map +1 -1
  79. package/dist/specs/type/dictionary/mockapi.js +1 -1
  80. package/dist/specs/type/dictionary/mockapi.js.map +1 -1
  81. package/dist/specs/type/enum/extensible/mockapi.js +1 -1
  82. package/dist/specs/type/enum/extensible/mockapi.js.map +1 -1
  83. package/dist/specs/type/enum/fixed/mockapi.js +2 -2
  84. package/dist/specs/type/enum/fixed/mockapi.js.map +1 -1
  85. package/dist/specs/type/file/mockapi.d.ts +3 -0
  86. package/dist/specs/type/file/mockapi.d.ts.map +1 -0
  87. package/dist/specs/type/file/mockapi.js +187 -0
  88. package/dist/specs/type/file/mockapi.js.map +1 -0
  89. package/dist/specs/type/model/empty/mockapi.js +2 -2
  90. package/dist/specs/type/model/empty/mockapi.js.map +1 -1
  91. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js +1 -1
  92. package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js.map +1 -1
  93. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js +2 -2
  94. package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js.map +1 -1
  95. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js +2 -2
  96. package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js.map +1 -1
  97. package/dist/specs/type/model/inheritance/recursive/mockapi.js +1 -1
  98. package/dist/specs/type/model/inheritance/recursive/mockapi.js.map +1 -1
  99. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js +2 -2
  100. package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js.map +1 -1
  101. package/dist/specs/type/model/usage/mockapi.js +4 -4
  102. package/dist/specs/type/model/usage/mockapi.js.map +1 -1
  103. package/dist/specs/type/model/visibility/mockapi.js +9 -10
  104. package/dist/specs/type/model/visibility/mockapi.js.map +1 -1
  105. package/dist/specs/type/property/additional-properties/mockapi.js +9 -6
  106. package/dist/specs/type/property/additional-properties/mockapi.js.map +1 -1
  107. package/dist/specs/type/property/nullable/mockapi.js +2 -6
  108. package/dist/specs/type/property/nullable/mockapi.js.map +1 -1
  109. package/dist/specs/type/property/optionality/mockapi.js +1 -1
  110. package/dist/specs/type/property/optionality/mockapi.js.map +1 -1
  111. package/dist/specs/type/property/value-types/mockapi.js +3 -3
  112. package/dist/specs/type/property/value-types/mockapi.js.map +1 -1
  113. package/dist/specs/type/scalar/mockapi.js +9 -9
  114. package/dist/specs/type/scalar/mockapi.js.map +1 -1
  115. package/dist/specs/type/union/discriminated/mockapi.d.ts +3 -0
  116. package/dist/specs/type/union/discriminated/mockapi.d.ts.map +1 -0
  117. package/dist/specs/type/union/discriminated/mockapi.js +212 -0
  118. package/dist/specs/type/union/discriminated/mockapi.js.map +1 -0
  119. package/dist/specs/type/union/mockapi.js +2 -2
  120. package/dist/specs/type/union/mockapi.js.map +1 -1
  121. package/dist/specs/versioning/added/mockapi.js +6 -6
  122. package/dist/specs/versioning/added/mockapi.js.map +1 -1
  123. package/dist/specs/versioning/madeOptional/mockapi.js +2 -2
  124. package/dist/specs/versioning/madeOptional/mockapi.js.map +1 -1
  125. package/dist/specs/versioning/removed/mockapi.js +11 -11
  126. package/dist/specs/versioning/removed/mockapi.js.map +1 -1
  127. package/dist/specs/versioning/renamedFrom/mockapi.js +5 -5
  128. package/dist/specs/versioning/renamedFrom/mockapi.js.map +1 -1
  129. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js +1 -1
  130. package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js.map +1 -1
  131. package/dist/specs/versioning/typeChangedFrom/mockapi.js +3 -3
  132. package/dist/specs/versioning/typeChangedFrom/mockapi.js.map +1 -1
  133. package/manifest.json +11200 -0
  134. package/package.json +30 -19
  135. package/smoke/petstore/main.tsp +96 -0
  136. package/smoke/todoapp/main.tsp +293 -0
  137. package/spec-summary.md +1745 -121
  138. package/specs/authentication/noauth/union/main.tsp +30 -0
  139. package/specs/authentication/noauth/union/mockapi.ts +27 -0
  140. package/specs/documentation/main.tsp +158 -0
  141. package/specs/documentation/mockapi.ts +59 -0
  142. package/specs/encode/array/main.tsp +339 -0
  143. package/specs/encode/array/mockapi.ts +83 -0
  144. package/specs/encode/bytes/main.tsp +29 -20
  145. package/specs/encode/bytes/mockapi.ts +13 -31
  146. package/specs/encode/datetime/main.tsp +2 -7
  147. package/specs/encode/datetime/mockapi.ts +2 -2
  148. package/specs/encode/duration/main.tsp +420 -7
  149. package/specs/encode/duration/mockapi.ts +216 -2
  150. package/specs/encode/numeric/mockapi.ts +2 -2
  151. package/specs/parameters/basic/mockapi.ts +3 -3
  152. package/specs/parameters/body-optionality/main.tsp +2 -0
  153. package/specs/parameters/body-optionality/mockapi.ts +24 -4
  154. package/specs/parameters/collection-format/main.tsp +5 -25
  155. package/specs/parameters/collection-format/mockapi.ts +4 -16
  156. package/specs/parameters/path/main.tsp +48 -0
  157. package/specs/parameters/path/mockapi.ts +34 -0
  158. package/specs/parameters/query/main.tsp +22 -0
  159. package/specs/parameters/query/mockapi.ts +15 -0
  160. package/specs/parameters/spread/mockapi.ts +19 -19
  161. package/specs/payload/json-merge-patch/main.tsp +2 -2
  162. package/specs/payload/json-merge-patch/mockapi.ts +4 -4
  163. package/specs/payload/media-type/mockapi.ts +2 -2
  164. package/specs/payload/multipart/main.tsp +230 -32
  165. package/specs/payload/multipart/mockapi.ts +200 -59
  166. package/specs/payload/pageable/main.tsp +601 -0
  167. package/specs/payload/pageable/mockapi.ts +656 -14
  168. package/specs/payload/xml/main.tsp +89 -0
  169. package/specs/payload/xml/mockapi.ts +44 -5
  170. package/specs/response/status-code-range/main.tsp +2 -2
  171. package/specs/response/status-code-range/mockapi.ts +5 -9
  172. package/specs/routes/main.tsp +29 -29
  173. package/specs/routes/mockapi.ts +16 -16
  174. package/specs/serialization/encoded-name/json/main.tsp +1 -1
  175. package/specs/serialization/encoded-name/json/mockapi.ts +1 -1
  176. package/specs/server/endpoint/not-defined/main.tsp +1 -3
  177. package/specs/server/path/multiple/main.tsp +3 -5
  178. package/specs/server/versions/not-versioned/mockapi.ts +1 -1
  179. package/specs/server/versions/versioned/main.tsp +1 -1
  180. package/specs/server/versions/versioned/mockapi.ts +6 -12
  181. package/specs/special-headers/conditional-request/main.tsp +1 -1
  182. package/specs/special-headers/repeatability/main.tsp +2 -2
  183. package/specs/special-words/main.tsp +118 -6
  184. package/specs/special-words/mockapi.ts +62 -6
  185. package/specs/streaming/jsonl/main.tsp +33 -0
  186. package/specs/streaming/jsonl/mockapi.ts +32 -0
  187. package/specs/type/array/mockapi.ts +1 -1
  188. package/specs/type/dictionary/mockapi.ts +1 -1
  189. package/specs/type/enum/extensible/main.tsp +18 -2
  190. package/specs/type/enum/extensible/mockapi.ts +1 -1
  191. package/specs/type/enum/fixed/main.tsp +15 -3
  192. package/specs/type/enum/fixed/mockapi.ts +2 -2
  193. package/specs/type/file/main.tsp +109 -0
  194. package/specs/type/file/mockapi.ts +200 -0
  195. package/specs/type/model/empty/mockapi.ts +2 -2
  196. package/specs/type/model/inheritance/enum-discriminator/mockapi.ts +1 -1
  197. package/specs/type/model/inheritance/nested-discriminator/mockapi.ts +2 -2
  198. package/specs/type/model/inheritance/not-discriminated/mockapi.ts +2 -2
  199. package/specs/type/model/inheritance/recursive/mockapi.ts +1 -1
  200. package/specs/type/model/inheritance/single-discriminator/mockapi.ts +2 -2
  201. package/specs/type/model/usage/mockapi.ts +4 -4
  202. package/specs/type/model/visibility/main.tsp +9 -17
  203. package/specs/type/model/visibility/mockapi.ts +9 -10
  204. package/specs/type/property/additional-properties/main.tsp +17 -17
  205. package/specs/type/property/additional-properties/mockapi.ts +10 -10
  206. package/specs/type/property/nullable/mockapi.ts +7 -8
  207. package/specs/type/property/optionality/mockapi.ts +1 -1
  208. package/specs/type/property/value-types/mockapi.ts +3 -3
  209. package/specs/type/scalar/main.tsp +58 -9
  210. package/specs/type/scalar/mockapi.ts +9 -9
  211. package/specs/type/union/discriminated/main.tsp +251 -0
  212. package/specs/type/union/discriminated/mockapi.ts +230 -0
  213. package/specs/type/union/mockapi.ts +2 -2
  214. package/specs/versioning/added/mockapi.ts +6 -6
  215. package/specs/versioning/madeOptional/mockapi.ts +2 -2
  216. package/specs/versioning/removed/main.tsp +5 -5
  217. package/specs/versioning/removed/mockapi.ts +11 -11
  218. package/specs/versioning/renamedFrom/mockapi.ts +5 -5
  219. package/specs/versioning/returnTypeChangedFrom/main.tsp +17 -2
  220. package/specs/versioning/returnTypeChangedFrom/mockapi.ts +1 -1
  221. package/specs/versioning/typeChangedFrom/mockapi.ts +3 -3
  222. package/temp/.tsbuildinfo +1 -1
  223. package/tsconfig.build.json +0 -4
  224. package/tspconfig.yaml +0 -2
@@ -0,0 +1,30 @@
1
+ import "@typespec/http";
2
+ import "@typespec/spector";
3
+
4
+ using Http;
5
+ using Spector;
6
+
7
+ @scenarioService("/authentication/noauth/union")
8
+ @doc("Illustrates clients generated with NoAuth and OAuth2 authentication union.")
9
+ @useAuth(NoAuth | OAuth2Auth<[MyFlow]>)
10
+ namespace Authentication.Noauth.Union;
11
+
12
+ model MyFlow {
13
+ type: OAuth2FlowType.implicit;
14
+ authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize";
15
+ scopes: ["https://security.microsoft.com/.default"];
16
+ }
17
+
18
+ @scenario
19
+ @scenarioDoc("Expects no authentication. The server accepts requests without any authentication header.")
20
+ @doc("Check whether client can make a request without authentication")
21
+ @get
22
+ @route("/valid")
23
+ op validNoAuth(): NoContentResponse;
24
+
25
+ @scenario
26
+ @scenarioDoc("Expects header 'authorization': 'Bearer https://security.microsoft.com/.default'")
27
+ @doc("Check whether client is authenticated with OAuth2 token")
28
+ @get
29
+ @route("/validtoken")
30
+ op validToken(): NoContentResponse;
@@ -0,0 +1,27 @@
1
+ import { passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
2
+
3
+ export const Scenarios: Record<string, ScenarioMockApi> = {};
4
+
5
+ Scenarios.Authentication_Noauth_Union_validNoAuth = passOnSuccess({
6
+ uri: `/authentication/noauth/union/valid`,
7
+ method: "get",
8
+ request: {},
9
+ response: {
10
+ status: 204,
11
+ },
12
+ kind: "MockApiDefinition",
13
+ });
14
+
15
+ Scenarios.Authentication_Noauth_Union_validToken = passOnSuccess({
16
+ uri: `/authentication/noauth/union/validtoken`,
17
+ method: "get",
18
+ request: {
19
+ headers: {
20
+ authorization: "Bearer https://security.microsoft.com/.default",
21
+ },
22
+ },
23
+ response: {
24
+ status: 204,
25
+ },
26
+ kind: "MockApiDefinition",
27
+ });
@@ -0,0 +1,158 @@
1
+ import "@typespec/http";
2
+ import "@typespec/spector";
3
+
4
+ using Http;
5
+ using Spector;
6
+
7
+ @scenarioService("/documentation")
8
+ @doc("Illustrates documentation generation and formatting features")
9
+ namespace Documentation;
10
+
11
+ @route("/lists")
12
+ namespace Lists {
13
+ /**
14
+ * This tests:
15
+ * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.
16
+ * - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.
17
+ * - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.
18
+ * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.
19
+ * - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.
20
+ * - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.
21
+ */
22
+ @scenario
23
+ @scenarioDoc("""
24
+ Test simple bullet points in documentation.
25
+ Expected behavior: Should render properly formatted bullet lists.
26
+ """)
27
+ @get
28
+ @route("/bullet-points/op")
29
+ op bulletPointsOp(): NoContentResponse;
30
+
31
+ /**
32
+ * This tests:
33
+ * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.
34
+ * - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.
35
+ * - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.
36
+ * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.
37
+ * - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.
38
+ * - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.
39
+ */
40
+ model BulletPointsModel {
41
+ /**
42
+ * This property uses an enum with bullet point documentation. The enum documentation includes various formatting styles to test rendering. The styles are:
43
+ * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.
44
+ * - Bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple
45
+ * - Bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.
46
+ * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.
47
+ * - **Bold bullet point**
48
+ * - *Italic bullet point*
49
+ */
50
+ prop: BulletPointsEnum;
51
+ }
52
+
53
+ /**
54
+ * This tests really long bullet points in enum documentation to see how wrapping and formatting are handled. This should wrap around correctly and maintain proper indentation for each line.
55
+ * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.
56
+ * - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.
57
+ * - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.
58
+ * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.
59
+ * - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.
60
+ * - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.
61
+ */
62
+ enum BulletPointsEnum {
63
+ /**
64
+ * Simple bullet point. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
65
+ * - One: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
66
+ * - Two: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
67
+ */
68
+ Simple: "Simple",
69
+
70
+ /**
71
+ * Bullet point with **bold text**. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
72
+ * - **One**: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
73
+ * - **Two**: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
74
+ */
75
+ Bold: "Bold",
76
+
77
+ /**
78
+ * Bullet point with *italic text*. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
79
+ * - *One*: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
80
+ * - *Two*: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines.
81
+ */
82
+ Italic: "Italic",
83
+ }
84
+
85
+ @scenarioDoc("""
86
+ Test bullet points in model and enum documentation.
87
+ Expected input:
88
+ ```json
89
+ {
90
+ "input": {"prop": "Simple"}
91
+ }
92
+ ```
93
+ """)
94
+ @post
95
+ @route("/bullet-points/model")
96
+ op bulletPointsModel(input: BulletPointsModel): OkResponse;
97
+
98
+ /**
99
+ * Steps to follow:
100
+ * 1. First step with **important** note
101
+ * 2. Second step with *emphasis*
102
+ * 3. Third step combining **bold** and *italic*
103
+ * 4. **Final step**: Review all steps for *accuracy*.
104
+ */
105
+ @scenario
106
+ @scenarioDoc("""
107
+ Test numbered lists.
108
+ Expected behavior: Should render numbered list properly.
109
+ """)
110
+ @route("/numbered")
111
+ @get
112
+ op numbered(): NoContentResponse;
113
+ }
114
+
115
+ @route("/text-formatting")
116
+ namespace TextFormatting {
117
+ /**
118
+ * This is **bold text** in the middle of a sentence.
119
+ * This is a sentence with **multiple bold** sections and **another bold** section.
120
+ * **This entire sentence is bold.**
121
+ */
122
+ @scenario
123
+ @scenarioDoc("""
124
+ Expected behavior: Text between ** should render as bold.
125
+ """)
126
+ @route("/bold")
127
+ @get
128
+ op boldText(): NoContentResponse;
129
+
130
+ /**
131
+ * This is *italic text* in the middle of a sentence.
132
+ * This is a sentence with *multiple italic* sections and *another italic* section.
133
+ * *This entire sentence is italic.*
134
+ * */
135
+ @scenario
136
+ @scenarioDoc("""
137
+ Test italic text formatting using *single asterisks*.
138
+ Expected behavior: Text between * should render as italic.
139
+ """)
140
+ @route("/italic")
141
+ @get
142
+ op italicText(): NoContentResponse;
143
+
144
+ /**
145
+ * This sentence has **bold**, *italic*, and ***bold italic*** text.
146
+ * You can also combine them like **bold with *italic inside* bold**.
147
+ * Or *italic with **bold inside** italic*.
148
+ * This is a sentence with **bold**, *italic*, and ***bold italic*** text.
149
+ */
150
+ @scenario
151
+ @scenarioDoc("""
152
+ Test combined bold and italic formatting.
153
+ Expected behavior: Should handle nested and combined formatting.
154
+ """)
155
+ @route("/combined")
156
+ @get
157
+ op combinedFormatting(): NoContentResponse;
158
+ }
@@ -0,0 +1,59 @@
1
+ import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
2
+
3
+ export const Scenarios: Record<string, ScenarioMockApi> = {};
4
+
5
+ function createGetServerTests(uri: string) {
6
+ return passOnSuccess({
7
+ uri,
8
+ method: "get",
9
+ request: {},
10
+ response: {
11
+ status: 204,
12
+ },
13
+ kind: "MockApiDefinition",
14
+ });
15
+ }
16
+
17
+ function createPostServerTests(uri: string, requestBody: unknown, responseBody?: unknown) {
18
+ return passOnSuccess({
19
+ uri,
20
+ method: "post",
21
+ request: {
22
+ body: json(requestBody),
23
+ },
24
+ response: {
25
+ status: 200,
26
+ body: responseBody ? json(responseBody) : undefined,
27
+ },
28
+ kind: "MockApiDefinition",
29
+ });
30
+ }
31
+
32
+ // Lists namespace tests
33
+ Scenarios.Documentation_Lists_bulletPointsOp = createGetServerTests(
34
+ "/documentation/lists/bullet-points/op",
35
+ );
36
+
37
+ Scenarios.Documentation_Lists_bulletPointsModel = createPostServerTests(
38
+ "/documentation/lists/bullet-points/model",
39
+ {
40
+ input: {
41
+ prop: "Simple",
42
+ },
43
+ },
44
+ );
45
+
46
+ Scenarios.Documentation_Lists_numbered = createGetServerTests("/documentation/lists/numbered");
47
+
48
+ // TextFormatting namespace tests
49
+ Scenarios.Documentation_TextFormatting_boldText = createGetServerTests(
50
+ "/documentation/text-formatting/bold",
51
+ );
52
+
53
+ Scenarios.Documentation_TextFormatting_italicText = createGetServerTests(
54
+ "/documentation/text-formatting/italic",
55
+ );
56
+
57
+ Scenarios.Documentation_TextFormatting_combinedFormatting = createGetServerTests(
58
+ "/documentation/text-formatting/combined",
59
+ );
@@ -0,0 +1,339 @@
1
+ import "@typespec/http";
2
+ import "@typespec/spector";
3
+
4
+ using Http;
5
+ using Spector;
6
+
7
+ @doc("Test for encode decorator on array.")
8
+ @scenarioService("/encode/array")
9
+ namespace Encode.Array;
10
+
11
+ enum Colors {
12
+ Blue: "blue",
13
+ Red: "red",
14
+ Green: "green",
15
+ }
16
+
17
+ union ColorsExtensibleEnum {
18
+ string,
19
+ Blue: "blue",
20
+ Red: "red",
21
+ Green: "green",
22
+ }
23
+
24
+ model CommaDelimitedArrayProperty {
25
+ @encode(ArrayEncoding.commaDelimited)
26
+ value: string[];
27
+ }
28
+
29
+ model SpaceDelimitedArrayProperty {
30
+ @encode(ArrayEncoding.spaceDelimited)
31
+ value: string[];
32
+ }
33
+
34
+ model PipeDelimitedArrayProperty {
35
+ @encode(ArrayEncoding.pipeDelimited)
36
+ value: string[];
37
+ }
38
+
39
+ model NewlineDelimitedArrayProperty {
40
+ @encode(ArrayEncoding.newlineDelimited)
41
+ value: string[];
42
+ }
43
+
44
+ model CommaDelimitedEnumArrayProperty {
45
+ @encode(ArrayEncoding.commaDelimited)
46
+ value: Colors[];
47
+ }
48
+
49
+ model SpaceDelimitedEnumArrayProperty {
50
+ @encode(ArrayEncoding.spaceDelimited)
51
+ value: Colors[];
52
+ }
53
+
54
+ model PipeDelimitedEnumArrayProperty {
55
+ @encode(ArrayEncoding.pipeDelimited)
56
+ value: Colors[];
57
+ }
58
+
59
+ model NewlineDelimitedEnumArrayProperty {
60
+ @encode(ArrayEncoding.newlineDelimited)
61
+ value: Colors[];
62
+ }
63
+
64
+ model CommaDelimitedExtensibleEnumArrayProperty {
65
+ @encode(ArrayEncoding.commaDelimited)
66
+ value: ColorsExtensibleEnum[];
67
+ }
68
+
69
+ model SpaceDelimitedExtensibleEnumArrayProperty {
70
+ @encode(ArrayEncoding.spaceDelimited)
71
+ value: ColorsExtensibleEnum[];
72
+ }
73
+
74
+ model PipeDelimitedExtensibleEnumArrayProperty {
75
+ @encode(ArrayEncoding.pipeDelimited)
76
+ value: ColorsExtensibleEnum[];
77
+ }
78
+
79
+ model NewlineDelimitedExtensibleEnumArrayProperty {
80
+ @encode(ArrayEncoding.newlineDelimited)
81
+ value: ColorsExtensibleEnum[];
82
+ }
83
+
84
+ @route("/property")
85
+ namespace Property {
86
+ @route("/comma-delimited")
87
+ @scenario
88
+ @scenarioDoc("""
89
+ Test operation with request and response model contains a string array property with commaDelimited encode.
90
+ Expected request body:
91
+ ```json
92
+ {
93
+ "value": "blue,red,green"
94
+ }
95
+ ```
96
+ Expected response body:
97
+ ```json
98
+ {
99
+ "value": "blue,red,green"
100
+ }
101
+ ```
102
+ """)
103
+ @post
104
+ op commaDelimited(@body body: CommaDelimitedArrayProperty): CommaDelimitedArrayProperty;
105
+
106
+ @route("/space-delimited")
107
+ @scenario
108
+ @scenarioDoc("""
109
+ Test operation with request and response model contains a string array property with spaceDelimited encode.
110
+ Expected request body:
111
+ ```json
112
+ {
113
+ "value": "blue red green"
114
+ }
115
+ ```
116
+ Expected response body:
117
+ ```json
118
+ {
119
+ "value": "blue red green"
120
+ }
121
+ ```
122
+ """)
123
+ @post
124
+ op spaceDelimited(@body body: SpaceDelimitedArrayProperty): SpaceDelimitedArrayProperty;
125
+
126
+ @route("/pipe-delimited")
127
+ @scenario
128
+ @scenarioDoc("""
129
+ Test operation with request and response model contains a string array property with pipeDelimited encode.
130
+ Expected request body:
131
+ ```json
132
+ {
133
+ "value": "blue|red|green"
134
+ }
135
+ ```
136
+ Expected response body:
137
+ ```json
138
+ {
139
+ "value": "blue|red|green"
140
+ }
141
+ ```
142
+ """)
143
+ @post
144
+ op pipeDelimited(@body body: PipeDelimitedArrayProperty): PipeDelimitedArrayProperty;
145
+
146
+ @route("/newline-delimited")
147
+ @scenario
148
+ @scenarioDoc("""
149
+ Test operation with request and response model contains a string array property with newlineDelimited encode.
150
+ Expected request body:
151
+ ```json
152
+ {
153
+ "value": "blue\\nred\\ngreen"
154
+ }
155
+ ```
156
+ Expected response body:
157
+ ```json
158
+ {
159
+ "value": "blue\\nred\\ngreen"
160
+ }
161
+ ```
162
+ """)
163
+ @post
164
+ op newlineDelimited(@body body: NewlineDelimitedArrayProperty): NewlineDelimitedArrayProperty;
165
+
166
+ @route("/enum/comma-delimited")
167
+ @scenario
168
+ @scenarioDoc("""
169
+ Test operation with request and response model contains an enum array property with commaDelimited encode.
170
+ Expected request body:
171
+ ```json
172
+ {
173
+ "value": "blue,red,green"
174
+ }
175
+ ```
176
+ Expected response body:
177
+ ```json
178
+ {
179
+ "value": "blue,red,green"
180
+ }
181
+ ```
182
+ """)
183
+ @post
184
+ op enumCommaDelimited(
185
+ @body body: CommaDelimitedEnumArrayProperty,
186
+ ): CommaDelimitedEnumArrayProperty;
187
+
188
+ @route("/enum/space-delimited")
189
+ @scenario
190
+ @scenarioDoc("""
191
+ Test operation with request and response model contains an enum array property with spaceDelimited encode.
192
+ Expected request body:
193
+ ```json
194
+ {
195
+ "value": "blue red green"
196
+ }
197
+ ```
198
+ Expected response body:
199
+ ```json
200
+ {
201
+ "value": "blue red green"
202
+ }
203
+ ```
204
+ """)
205
+ @post
206
+ op enumSpaceDelimited(
207
+ @body body: SpaceDelimitedEnumArrayProperty,
208
+ ): SpaceDelimitedEnumArrayProperty;
209
+
210
+ @route("/enum/pipe-delimited")
211
+ @scenario
212
+ @scenarioDoc("""
213
+ Test operation with request and response model contains an enum array property with pipeDelimited encode.
214
+ Expected request body:
215
+ ```json
216
+ {
217
+ "value": "blue|red|green"
218
+ }
219
+ ```
220
+ Expected response body:
221
+ ```json
222
+ {
223
+ "value": "blue|red|green"
224
+ }
225
+ ```
226
+ """)
227
+ @post
228
+ op enumPipeDelimited(@body body: PipeDelimitedEnumArrayProperty): PipeDelimitedEnumArrayProperty;
229
+
230
+ @route("/enum/newline-delimited")
231
+ @scenario
232
+ @scenarioDoc("""
233
+ Test operation with request and response model contains an enum array property with newlineDelimited encode.
234
+ Expected request body:
235
+ ```json
236
+ {
237
+ "value": "blue\\nred\\ngreen"
238
+ }
239
+ ```
240
+ Expected response body:
241
+ ```json
242
+ {
243
+ "value": "blue\\nred\\ngreen"
244
+ }
245
+ ```
246
+ """)
247
+ @post
248
+ op enumNewlineDelimited(
249
+ @body body: NewlineDelimitedEnumArrayProperty,
250
+ ): NewlineDelimitedEnumArrayProperty;
251
+
252
+ @route("/extensible-enum/comma-delimited")
253
+ @scenario
254
+ @scenarioDoc("""
255
+ Test operation with request and response model contains an extensible enum (union) array property with commaDelimited encode.
256
+ Expected request body:
257
+ ```json
258
+ {
259
+ "value": "blue,red,green"
260
+ }
261
+ ```
262
+ Expected response body:
263
+ ```json
264
+ {
265
+ "value": "blue,red,green"
266
+ }
267
+ ```
268
+ """)
269
+ @post
270
+ op extensibleEnumCommaDelimited(
271
+ @body body: CommaDelimitedExtensibleEnumArrayProperty,
272
+ ): CommaDelimitedExtensibleEnumArrayProperty;
273
+
274
+ @route("/extensible-enum/space-delimited")
275
+ @scenario
276
+ @scenarioDoc("""
277
+ Test operation with request and response model contains an extensible enum (union) array property with spaceDelimited encode.
278
+ Expected request body:
279
+ ```json
280
+ {
281
+ "value": "blue red green"
282
+ }
283
+ ```
284
+ Expected response body:
285
+ ```json
286
+ {
287
+ "value": "blue red green"
288
+ }
289
+ ```
290
+ """)
291
+ @post
292
+ op extensibleEnumSpaceDelimited(
293
+ @body body: SpaceDelimitedExtensibleEnumArrayProperty,
294
+ ): SpaceDelimitedExtensibleEnumArrayProperty;
295
+
296
+ @route("/extensible-enum/pipe-delimited")
297
+ @scenario
298
+ @scenarioDoc("""
299
+ Test operation with request and response model contains an extensible enum (union) array property with pipeDelimited encode.
300
+ Expected request body:
301
+ ```json
302
+ {
303
+ "value": "blue|red|green"
304
+ }
305
+ ```
306
+ Expected response body:
307
+ ```json
308
+ {
309
+ "value": "blue|red|green"
310
+ }
311
+ ```
312
+ """)
313
+ @post
314
+ op extensibleEnumPipeDelimited(
315
+ @body body: PipeDelimitedExtensibleEnumArrayProperty,
316
+ ): PipeDelimitedExtensibleEnumArrayProperty;
317
+
318
+ @route("/extensible-enum/newline-delimited")
319
+ @scenario
320
+ @scenarioDoc("""
321
+ Test operation with request and response model contains an extensible enum (union) array property with newlineDelimited encode.
322
+ Expected request body:
323
+ ```json
324
+ {
325
+ "value": "blue\\nred\\ngreen"
326
+ }
327
+ ```
328
+ Expected response body:
329
+ ```json
330
+ {
331
+ "value": "blue\\nred\\ngreen"
332
+ }
333
+ ```
334
+ """)
335
+ @post
336
+ op extensibleEnumNewlineDelimited(
337
+ @body body: NewlineDelimitedExtensibleEnumArrayProperty,
338
+ ): NewlineDelimitedExtensibleEnumArrayProperty;
339
+ }
@@ -0,0 +1,83 @@
1
+ import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
2
+
3
+ export const Scenarios: Record<string, ScenarioMockApi> = {};
4
+
5
+ const colors = ["blue", "red", "green"];
6
+
7
+ function createPropertyServerTests(uri: string, delimiter: string) {
8
+ const encodedValue = colors.join(delimiter);
9
+ return passOnSuccess({
10
+ uri,
11
+ method: "post",
12
+ request: {
13
+ body: json({
14
+ value: encodedValue,
15
+ }),
16
+ },
17
+ response: {
18
+ status: 200,
19
+ body: json({ value: encodedValue }),
20
+ },
21
+ kind: "MockApiDefinition",
22
+ });
23
+ }
24
+
25
+ Scenarios.Encode_Array_Property_commaDelimited = createPropertyServerTests(
26
+ "/encode/array/property/comma-delimited",
27
+ ",",
28
+ );
29
+
30
+ Scenarios.Encode_Array_Property_spaceDelimited = createPropertyServerTests(
31
+ "/encode/array/property/space-delimited",
32
+ " ",
33
+ );
34
+
35
+ Scenarios.Encode_Array_Property_pipeDelimited = createPropertyServerTests(
36
+ "/encode/array/property/pipe-delimited",
37
+ "|",
38
+ );
39
+
40
+ Scenarios.Encode_Array_Property_newlineDelimited = createPropertyServerTests(
41
+ "/encode/array/property/newline-delimited",
42
+ "\n",
43
+ );
44
+
45
+ Scenarios.Encode_Array_Property_enumCommaDelimited = createPropertyServerTests(
46
+ "/encode/array/property/enum/comma-delimited",
47
+ ",",
48
+ );
49
+
50
+ Scenarios.Encode_Array_Property_enumSpaceDelimited = createPropertyServerTests(
51
+ "/encode/array/property/enum/space-delimited",
52
+ " ",
53
+ );
54
+
55
+ Scenarios.Encode_Array_Property_enumPipeDelimited = createPropertyServerTests(
56
+ "/encode/array/property/enum/pipe-delimited",
57
+ "|",
58
+ );
59
+
60
+ Scenarios.Encode_Array_Property_enumNewlineDelimited = createPropertyServerTests(
61
+ "/encode/array/property/enum/newline-delimited",
62
+ "\n",
63
+ );
64
+
65
+ Scenarios.Encode_Array_Property_extensibleEnumCommaDelimited = createPropertyServerTests(
66
+ "/encode/array/property/extensible-enum/comma-delimited",
67
+ ",",
68
+ );
69
+
70
+ Scenarios.Encode_Array_Property_extensibleEnumSpaceDelimited = createPropertyServerTests(
71
+ "/encode/array/property/extensible-enum/space-delimited",
72
+ " ",
73
+ );
74
+
75
+ Scenarios.Encode_Array_Property_extensibleEnumPipeDelimited = createPropertyServerTests(
76
+ "/encode/array/property/extensible-enum/pipe-delimited",
77
+ "|",
78
+ );
79
+
80
+ Scenarios.Encode_Array_Property_extensibleEnumNewlineDelimited = createPropertyServerTests(
81
+ "/encode/array/property/extensible-enum/newline-delimited",
82
+ "\n",
83
+ );