@typespec/http-specs 0.1.0-alpha.3-dev.6 → 0.1.0-alpha.30-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.
- package/CHANGELOG.md +238 -0
- package/README.md +11 -3
- package/dist/specs/documentation/mockapi.d.ts.map +1 -0
- package/dist/specs/documentation/mockapi.js +38 -0
- package/dist/specs/documentation/mockapi.js.map +1 -0
- package/dist/specs/encode/array/mockapi.d.ts +3 -0
- package/dist/specs/encode/array/mockapi.d.ts.map +1 -0
- package/dist/specs/encode/array/mockapi.js +25 -0
- package/dist/specs/encode/array/mockapi.js.map +1 -0
- package/dist/specs/encode/bytes/mockapi.js +16 -24
- package/dist/specs/encode/bytes/mockapi.js.map +1 -1
- package/dist/specs/encode/datetime/mockapi.js +2 -2
- package/dist/specs/encode/datetime/mockapi.js.map +1 -1
- package/dist/specs/encode/duration/mockapi.js +74 -2
- package/dist/specs/encode/duration/mockapi.js.map +1 -1
- package/dist/specs/encode/numeric/mockapi.js +2 -2
- package/dist/specs/encode/numeric/mockapi.js.map +1 -1
- package/dist/specs/helper.d.ts +2 -2
- package/dist/specs/helper.d.ts.map +1 -1
- package/dist/specs/parameters/basic/mockapi.d.ts.map +1 -1
- package/dist/specs/parameters/basic/mockapi.js +3 -3
- package/dist/specs/parameters/basic/mockapi.js.map +1 -1
- package/dist/specs/parameters/body-optionality/mockapi.d.ts.map +1 -1
- package/dist/specs/parameters/body-optionality/mockapi.js +14 -4
- package/dist/specs/parameters/body-optionality/mockapi.js.map +1 -1
- package/dist/specs/parameters/collection-format/mockapi.js +4 -15
- package/dist/specs/parameters/collection-format/mockapi.js.map +1 -1
- package/dist/specs/parameters/path/mockapi.d.ts +3 -0
- package/dist/specs/parameters/path/mockapi.d.ts.map +1 -0
- package/dist/specs/parameters/path/mockapi.js +29 -0
- package/dist/specs/parameters/path/mockapi.js.map +1 -0
- package/dist/specs/parameters/spread/mockapi.d.ts.map +1 -1
- package/dist/specs/parameters/spread/mockapi.js +19 -19
- package/dist/specs/parameters/spread/mockapi.js.map +1 -1
- package/dist/specs/payload/json-merge-patch/mockapi.js +4 -4
- package/dist/specs/payload/json-merge-patch/mockapi.js.map +1 -1
- package/dist/specs/payload/media-type/mockapi.js +2 -2
- package/dist/specs/payload/media-type/mockapi.js.map +1 -1
- package/dist/specs/payload/multipart/mockapi.d.ts.map +1 -1
- package/dist/specs/payload/multipart/mockapi.js +42 -60
- package/dist/specs/payload/multipart/mockapi.js.map +1 -1
- package/dist/specs/payload/pageable/mockapi.d.ts.map +1 -1
- package/dist/specs/payload/pageable/mockapi.js +425 -18
- package/dist/specs/payload/pageable/mockapi.js.map +1 -1
- package/dist/specs/payload/xml/mockapi.js +1 -4
- package/dist/specs/payload/xml/mockapi.js.map +1 -1
- package/dist/specs/response/status-code-range/mockapi.d.ts +3 -0
- package/dist/specs/response/status-code-range/mockapi.d.ts.map +1 -0
- package/dist/specs/response/status-code-range/mockapi.js +29 -0
- package/dist/specs/response/status-code-range/mockapi.js.map +1 -0
- package/dist/specs/routes/mockapi.js +25 -25
- package/dist/specs/routes/mockapi.js.map +1 -1
- package/dist/specs/serialization/encoded-name/json/mockapi.js +1 -1
- package/dist/specs/serialization/encoded-name/json/mockapi.js.map +1 -1
- package/dist/specs/server/versions/not-versioned/mockapi.js +1 -1
- package/dist/specs/server/versions/not-versioned/mockapi.js.map +1 -1
- package/dist/specs/server/versions/versioned/mockapi.js +8 -12
- package/dist/specs/server/versions/versioned/mockapi.js.map +1 -1
- package/dist/specs/special-words/mockapi.d.ts.map +1 -1
- package/dist/specs/special-words/mockapi.js +28 -6
- package/dist/specs/special-words/mockapi.js.map +1 -1
- package/dist/specs/streaming/jsonl/mockapi.d.ts +3 -0
- package/dist/specs/streaming/jsonl/mockapi.d.ts.map +1 -0
- package/dist/specs/streaming/jsonl/mockapi.js +30 -0
- package/dist/specs/streaming/jsonl/mockapi.js.map +1 -0
- package/dist/specs/type/array/mockapi.js +1 -1
- package/dist/specs/type/array/mockapi.js.map +1 -1
- package/dist/specs/type/dictionary/mockapi.js +1 -1
- package/dist/specs/type/dictionary/mockapi.js.map +1 -1
- package/dist/specs/type/enum/extensible/mockapi.js +1 -1
- package/dist/specs/type/enum/extensible/mockapi.js.map +1 -1
- package/dist/specs/type/enum/fixed/mockapi.js +2 -2
- package/dist/specs/type/enum/fixed/mockapi.js.map +1 -1
- package/dist/specs/type/model/empty/mockapi.js +2 -2
- package/dist/specs/type/model/empty/mockapi.js.map +1 -1
- package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js +1 -1
- package/dist/specs/type/model/inheritance/enum-discriminator/mockapi.js.map +1 -1
- package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js +2 -2
- package/dist/specs/type/model/inheritance/nested-discriminator/mockapi.js.map +1 -1
- package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js +2 -2
- package/dist/specs/type/model/inheritance/not-discriminated/mockapi.js.map +1 -1
- package/dist/specs/type/model/inheritance/recursive/mockapi.js +1 -1
- package/dist/specs/type/model/inheritance/recursive/mockapi.js.map +1 -1
- package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js +2 -2
- package/dist/specs/type/model/inheritance/single-discriminator/mockapi.js.map +1 -1
- package/dist/specs/type/model/usage/mockapi.js +4 -4
- package/dist/specs/type/model/usage/mockapi.js.map +1 -1
- package/dist/specs/type/model/visibility/mockapi.js +9 -10
- package/dist/specs/type/model/visibility/mockapi.js.map +1 -1
- package/dist/specs/type/property/additional-properties/mockapi.js +9 -6
- package/dist/specs/type/property/additional-properties/mockapi.js.map +1 -1
- package/dist/specs/type/property/nullable/mockapi.js +2 -6
- package/dist/specs/type/property/nullable/mockapi.js.map +1 -1
- package/dist/specs/type/property/optionality/mockapi.js +1 -1
- package/dist/specs/type/property/optionality/mockapi.js.map +1 -1
- package/dist/specs/type/property/value-types/mockapi.js +3 -3
- package/dist/specs/type/property/value-types/mockapi.js.map +1 -1
- package/dist/specs/type/scalar/mockapi.js +9 -9
- package/dist/specs/type/scalar/mockapi.js.map +1 -1
- package/dist/specs/type/union/discriminated/mockapi.d.ts +3 -0
- package/dist/specs/type/union/discriminated/mockapi.d.ts.map +1 -0
- package/dist/specs/type/union/discriminated/mockapi.js +212 -0
- package/dist/specs/type/union/discriminated/mockapi.js.map +1 -0
- package/dist/specs/type/union/mockapi.js +2 -2
- package/dist/specs/type/union/mockapi.js.map +1 -1
- package/dist/specs/versioning/added/mockapi.js +6 -6
- package/dist/specs/versioning/added/mockapi.js.map +1 -1
- package/dist/specs/versioning/madeOptional/mockapi.js +2 -2
- package/dist/specs/versioning/madeOptional/mockapi.js.map +1 -1
- package/dist/specs/versioning/removed/mockapi.js +46 -2
- package/dist/specs/versioning/removed/mockapi.js.map +1 -1
- package/dist/specs/versioning/renamedFrom/mockapi.js +5 -5
- package/dist/specs/versioning/renamedFrom/mockapi.js.map +1 -1
- package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js +1 -1
- package/dist/specs/versioning/returnTypeChangedFrom/mockapi.js.map +1 -1
- package/dist/specs/versioning/typeChangedFrom/mockapi.js +3 -3
- package/dist/specs/versioning/typeChangedFrom/mockapi.js.map +1 -1
- package/package.json +32 -19
- package/smoke/petstore/main.tsp +96 -0
- package/smoke/todoapp/main.tsp +293 -0
- package/spec-summary.md +1289 -265
- package/specs/documentation/main.tsp +158 -0
- package/specs/documentation/mockapi.ts +57 -0
- package/specs/encode/array/main.tsp +112 -0
- package/specs/encode/array/mockapi.ts +43 -0
- package/specs/encode/bytes/main.tsp +29 -20
- package/specs/encode/bytes/mockapi.ts +13 -31
- package/specs/encode/datetime/main.tsp +2 -7
- package/specs/encode/datetime/mockapi.ts +2 -2
- package/specs/encode/duration/main.tsp +420 -7
- package/specs/encode/duration/mockapi.ts +174 -2
- package/specs/encode/numeric/mockapi.ts +2 -2
- package/specs/parameters/basic/mockapi.ts +3 -3
- package/specs/parameters/body-optionality/main.tsp +2 -0
- package/specs/parameters/body-optionality/mockapi.ts +24 -4
- package/specs/parameters/collection-format/main.tsp +5 -25
- package/specs/parameters/collection-format/mockapi.ts +4 -16
- package/specs/parameters/path/main.tsp +48 -0
- package/specs/parameters/path/mockapi.ts +34 -0
- package/specs/parameters/spread/mockapi.ts +19 -19
- package/specs/payload/json-merge-patch/main.tsp +2 -2
- package/specs/payload/json-merge-patch/mockapi.ts +4 -4
- package/specs/payload/media-type/mockapi.ts +2 -2
- package/specs/payload/multipart/main.tsp +34 -32
- package/specs/payload/multipart/mockapi.ts +42 -59
- package/specs/payload/pageable/main.tsp +462 -7
- package/specs/payload/pageable/mockapi.ts +478 -18
- package/specs/payload/xml/mockapi.ts +1 -4
- package/specs/response/status-code-range/main.tsp +82 -0
- package/specs/response/status-code-range/mockapi.ts +31 -0
- package/specs/routes/main.tsp +48 -48
- package/specs/routes/mockapi.ts +25 -25
- package/specs/serialization/encoded-name/json/main.tsp +1 -1
- package/specs/serialization/encoded-name/json/mockapi.ts +1 -1
- package/specs/server/endpoint/not-defined/main.tsp +1 -3
- package/specs/server/path/multiple/main.tsp +3 -5
- package/specs/server/versions/not-versioned/mockapi.ts +1 -1
- package/specs/server/versions/versioned/main.tsp +1 -1
- package/specs/server/versions/versioned/mockapi.ts +6 -12
- package/specs/special-headers/conditional-request/main.tsp +1 -1
- package/specs/special-headers/repeatability/main.tsp +2 -2
- package/specs/special-words/main.tsp +44 -6
- package/specs/special-words/mockapi.ts +29 -6
- package/specs/streaming/jsonl/main.tsp +33 -0
- package/specs/streaming/jsonl/mockapi.ts +32 -0
- package/specs/type/array/mockapi.ts +1 -1
- package/specs/type/dictionary/mockapi.ts +1 -1
- package/specs/type/enum/extensible/main.tsp +18 -2
- package/specs/type/enum/extensible/mockapi.ts +1 -1
- package/specs/type/enum/fixed/main.tsp +15 -3
- package/specs/type/enum/fixed/mockapi.ts +2 -2
- package/specs/type/model/empty/mockapi.ts +2 -2
- package/specs/type/model/inheritance/enum-discriminator/mockapi.ts +1 -1
- package/specs/type/model/inheritance/nested-discriminator/mockapi.ts +2 -2
- package/specs/type/model/inheritance/not-discriminated/mockapi.ts +2 -2
- package/specs/type/model/inheritance/recursive/mockapi.ts +1 -1
- package/specs/type/model/inheritance/single-discriminator/mockapi.ts +2 -2
- package/specs/type/model/usage/mockapi.ts +4 -4
- package/specs/type/model/visibility/main.tsp +15 -23
- package/specs/type/model/visibility/mockapi.ts +9 -10
- package/specs/type/property/additional-properties/main.tsp +17 -17
- package/specs/type/property/additional-properties/mockapi.ts +10 -10
- package/specs/type/property/nullable/mockapi.ts +7 -8
- package/specs/type/property/optionality/mockapi.ts +1 -1
- package/specs/type/property/value-types/mockapi.ts +3 -3
- package/specs/type/scalar/main.tsp +58 -9
- package/specs/type/scalar/mockapi.ts +9 -9
- package/specs/type/union/discriminated/main.tsp +251 -0
- package/specs/type/union/discriminated/mockapi.ts +230 -0
- package/specs/type/union/mockapi.ts +2 -2
- package/specs/versioning/added/mockapi.ts +6 -6
- package/specs/versioning/madeOptional/mockapi.ts +2 -2
- package/specs/versioning/removed/main.tsp +65 -3
- package/specs/versioning/removed/mockapi.ts +49 -2
- package/specs/versioning/renamedFrom/mockapi.ts +5 -5
- package/specs/versioning/returnTypeChangedFrom/main.tsp +17 -2
- package/specs/versioning/returnTypeChangedFrom/mockapi.ts +1 -1
- package/specs/versioning/typeChangedFrom/mockapi.ts +3 -3
- package/temp/.tsbuildinfo +1 -1
- package/tspconfig.yaml +0 -2
- package/dist/specs/type/model/templated/mockapi.d.ts.map +0 -1
- package/dist/specs/type/model/templated/mockapi.js +0 -63
- package/dist/specs/type/model/templated/mockapi.js.map +0 -1
- package/specs/type/model/templated/main.tsp +0 -130
- package/specs/type/model/templated/mockapi.ts +0 -66
- /package/dist/specs/{type/model/templated → documentation}/mockapi.d.ts +0 -0
|
@@ -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
|
+
"prop": "Simple"
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
""")
|
|
94
|
+
@post
|
|
95
|
+
@route("/bullet-points/model")
|
|
96
|
+
op bulletPointsModel(input: BulletPointsModel): NoContentResponse;
|
|
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,57 @@
|
|
|
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
|
+
prop: "Simple",
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
Scenarios.Documentation_Lists_numbered = createGetServerTests("/documentation/lists/numbered");
|
|
45
|
+
|
|
46
|
+
// TextFormatting namespace tests
|
|
47
|
+
Scenarios.Documentation_TextFormatting_boldText = createGetServerTests(
|
|
48
|
+
"/documentation/text-formatting/bold",
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
Scenarios.Documentation_TextFormatting_italicText = createGetServerTests(
|
|
52
|
+
"/documentation/text-formatting/italic",
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
Scenarios.Documentation_TextFormatting_combinedFormatting = createGetServerTests(
|
|
56
|
+
"/documentation/text-formatting/combined",
|
|
57
|
+
);
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
model CommaDelimitedArrayProperty {
|
|
12
|
+
@encode(ArrayEncoding.commaDelimited)
|
|
13
|
+
value: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
model SpaceDelimitedArrayProperty {
|
|
17
|
+
@encode(ArrayEncoding.spaceDelimited)
|
|
18
|
+
value: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
model PipeDelimitedArrayProperty {
|
|
22
|
+
@encode(ArrayEncoding.pipeDelimited)
|
|
23
|
+
value: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
model NewlineDelimitedArrayProperty {
|
|
27
|
+
@encode(ArrayEncoding.newlineDelimited)
|
|
28
|
+
value: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@route("/property")
|
|
32
|
+
namespace Property {
|
|
33
|
+
@route("/comma-delimited")
|
|
34
|
+
@scenario
|
|
35
|
+
@scenarioDoc("""
|
|
36
|
+
Test operation with request and response model contains a string array property with commaDelimited encode.
|
|
37
|
+
Expected request body:
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"value": "blue,red,green"
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
Expected response body:
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"value": "blue,red,green"
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
""")
|
|
50
|
+
@post
|
|
51
|
+
op commaDelimited(@body body: CommaDelimitedArrayProperty): CommaDelimitedArrayProperty;
|
|
52
|
+
|
|
53
|
+
@route("/space-delimited")
|
|
54
|
+
@scenario
|
|
55
|
+
@scenarioDoc("""
|
|
56
|
+
Test operation with request and response model contains a string array property with spaceDelimited encode.
|
|
57
|
+
Expected request body:
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"value": "blue red green"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
Expected response body:
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"value": "blue red green"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
""")
|
|
70
|
+
@post
|
|
71
|
+
op spaceDelimited(@body body: SpaceDelimitedArrayProperty): SpaceDelimitedArrayProperty;
|
|
72
|
+
|
|
73
|
+
@route("/pipe-delimited")
|
|
74
|
+
@scenario
|
|
75
|
+
@scenarioDoc("""
|
|
76
|
+
Test operation with request and response model contains a string array property with pipeDelimited encode.
|
|
77
|
+
Expected request body:
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"value": "blue|red|green"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
Expected response body:
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"value": "blue|red|green"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
""")
|
|
90
|
+
@post
|
|
91
|
+
op pipeDelimited(@body body: PipeDelimitedArrayProperty): PipeDelimitedArrayProperty;
|
|
92
|
+
|
|
93
|
+
@route("/newline-delimited")
|
|
94
|
+
@scenario
|
|
95
|
+
@scenarioDoc("""
|
|
96
|
+
Test operation with request and response model contains a string array property with newlineDelimited encode.
|
|
97
|
+
Expected request body:
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"value": "blue\\nred\\ngreen"
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
Expected response body:
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"value": "blue\\nred\\ngreen"
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
""")
|
|
110
|
+
@post
|
|
111
|
+
op newlineDelimited(@body body: NewlineDelimitedArrayProperty): NewlineDelimitedArrayProperty;
|
|
112
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
);
|
|
@@ -59,10 +59,7 @@ namespace Query {
|
|
|
59
59
|
value=dGVzdA, dGVzdA
|
|
60
60
|
""")
|
|
61
61
|
op base64urlArray(
|
|
62
|
-
|
|
63
|
-
@query({
|
|
64
|
-
format: "csv",
|
|
65
|
-
})
|
|
62
|
+
@query
|
|
66
63
|
value: base64urlBytes[],
|
|
67
64
|
): NoContentResponse;
|
|
68
65
|
}
|
|
@@ -216,9 +213,7 @@ namespace Header {
|
|
|
216
213
|
value=dGVzdA,dGVzdA
|
|
217
214
|
""")
|
|
218
215
|
op base64urlArray(
|
|
219
|
-
@header
|
|
220
|
-
format: "csv",
|
|
221
|
-
})
|
|
216
|
+
@header
|
|
222
217
|
value: base64urlBytes[],
|
|
223
218
|
): NoContentResponse;
|
|
224
219
|
}
|
|
@@ -228,9 +223,8 @@ namespace RequestBody {
|
|
|
228
223
|
@route("/default")
|
|
229
224
|
@scenario
|
|
230
225
|
@scenarioDoc("""
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
"dGVzdA==" (base64 encode of test, in JSON string)
|
|
226
|
+
When content type is not defined and body is `bytes` the payload is a binary stream.
|
|
227
|
+
Stream should match packages/http-specs/assets/image.png file.
|
|
234
228
|
""")
|
|
235
229
|
@post
|
|
236
230
|
op default(
|
|
@@ -241,8 +235,8 @@ namespace RequestBody {
|
|
|
241
235
|
@route("/octet-stream")
|
|
242
236
|
@scenario
|
|
243
237
|
@scenarioDoc("""
|
|
244
|
-
When content type is application/octet-stream and body is `bytes` the payload is a binary
|
|
245
|
-
|
|
238
|
+
When content type is application/octet-stream and body is `bytes` the payload is a binary stream.
|
|
239
|
+
Stream should match packages/http-specs/assets/image.png file.
|
|
246
240
|
""")
|
|
247
241
|
@post
|
|
248
242
|
op octetStream(
|
|
@@ -257,7 +251,7 @@ namespace RequestBody {
|
|
|
257
251
|
@scenario
|
|
258
252
|
@scenarioDoc("""
|
|
259
253
|
When content type is a custom type(image/png here) and body is `bytes` the payload is a binary file.
|
|
260
|
-
File should match packages/
|
|
254
|
+
File should match packages/http-specs/assets/image.png.
|
|
261
255
|
""")
|
|
262
256
|
@post
|
|
263
257
|
op customContentType(
|
|
@@ -277,6 +271,9 @@ namespace RequestBody {
|
|
|
277
271
|
""")
|
|
278
272
|
@post
|
|
279
273
|
op base64(
|
|
274
|
+
@header
|
|
275
|
+
contentType: "application/json",
|
|
276
|
+
|
|
280
277
|
@body
|
|
281
278
|
@encode(BytesKnownEncoding.base64)
|
|
282
279
|
value: bytes,
|
|
@@ -291,6 +288,9 @@ namespace RequestBody {
|
|
|
291
288
|
""")
|
|
292
289
|
@post
|
|
293
290
|
op base64url(
|
|
291
|
+
@header
|
|
292
|
+
contentType: "application/json",
|
|
293
|
+
|
|
294
294
|
@body
|
|
295
295
|
@encode(BytesKnownEncoding.base64url)
|
|
296
296
|
value: bytes,
|
|
@@ -302,9 +302,8 @@ namespace ResponseBody {
|
|
|
302
302
|
@route("/default")
|
|
303
303
|
@scenario
|
|
304
304
|
@scenarioDoc("""
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
"dGVzdA==" (base64 encode of test, in JSON string)
|
|
305
|
+
When content type is not defined and body is `bytes` the payload is a binary stream.
|
|
306
|
+
Stream should match packages/http-specs/assets/image.png file.
|
|
308
307
|
""")
|
|
309
308
|
op default(): {
|
|
310
309
|
@body
|
|
@@ -314,8 +313,8 @@ namespace ResponseBody {
|
|
|
314
313
|
@route("/octet-stream")
|
|
315
314
|
@scenario
|
|
316
315
|
@scenarioDoc("""
|
|
317
|
-
When content type is application/octet-stream and body is `bytes` the payload is a binary
|
|
318
|
-
|
|
316
|
+
When content type is application/octet-stream and body is `bytes` the payload is a binary stream.
|
|
317
|
+
Stream should match packages/http-specs/assets/image.png file.
|
|
319
318
|
""")
|
|
320
319
|
op octetStream(): {
|
|
321
320
|
@header
|
|
@@ -329,7 +328,7 @@ namespace ResponseBody {
|
|
|
329
328
|
@scenario
|
|
330
329
|
@scenarioDoc("""
|
|
331
330
|
When content type is a custom type(image/png here) and body is `bytes` the payload is a binary file.
|
|
332
|
-
File should match packages/
|
|
331
|
+
File should match packages/http-specs/assets/image.png
|
|
333
332
|
""")
|
|
334
333
|
op customContentType(): {
|
|
335
334
|
@header
|
|
@@ -347,6 +346,9 @@ namespace ResponseBody {
|
|
|
347
346
|
"dGVzdA==" (base64 encode of test, in JSON string)
|
|
348
347
|
""")
|
|
349
348
|
op base64(): {
|
|
349
|
+
@header
|
|
350
|
+
contentType: "application/json";
|
|
351
|
+
|
|
350
352
|
@body
|
|
351
353
|
@encode(BytesKnownEncoding.base64)
|
|
352
354
|
value: bytes;
|
|
@@ -359,5 +361,12 @@ namespace ResponseBody {
|
|
|
359
361
|
Expected body:
|
|
360
362
|
"dGVzdA" (base64url encode of test, in JSON string)
|
|
361
363
|
""")
|
|
362
|
-
op base64url():
|
|
364
|
+
op base64url(): {
|
|
365
|
+
@header
|
|
366
|
+
contentType: "application/json";
|
|
367
|
+
|
|
368
|
+
@body
|
|
369
|
+
@encode(BytesKnownEncoding.base64url)
|
|
370
|
+
body: base64urlBytes;
|
|
371
|
+
};
|
|
363
372
|
}
|
|
@@ -25,7 +25,7 @@ function createQueryServerTests(
|
|
|
25
25
|
uri,
|
|
26
26
|
method: "get",
|
|
27
27
|
request: {
|
|
28
|
-
|
|
28
|
+
query: data,
|
|
29
29
|
},
|
|
30
30
|
response: {
|
|
31
31
|
status: 204,
|
|
@@ -73,7 +73,7 @@ function createPropertyServerTests(uri: string, data: any, value: any) {
|
|
|
73
73
|
uri,
|
|
74
74
|
method: "post",
|
|
75
75
|
request: {
|
|
76
|
-
body: data,
|
|
76
|
+
body: json(data),
|
|
77
77
|
},
|
|
78
78
|
response: {
|
|
79
79
|
status: 200,
|
|
@@ -154,23 +154,23 @@ Scenarios.Encode_Bytes_Header_base64urlArray = createHeaderServerTests(
|
|
|
154
154
|
function createRequestBodyServerTests(
|
|
155
155
|
uri: string,
|
|
156
156
|
data: any,
|
|
157
|
-
headersData: any,
|
|
158
|
-
value: any,
|
|
159
157
|
contentType: string = "application/json",
|
|
160
158
|
) {
|
|
161
159
|
return passOnSuccess({
|
|
162
160
|
uri,
|
|
163
161
|
method: "post",
|
|
164
162
|
request: {
|
|
165
|
-
body:
|
|
166
|
-
|
|
163
|
+
body: {
|
|
164
|
+
contentType: contentType,
|
|
165
|
+
rawContent: data,
|
|
166
|
+
},
|
|
167
167
|
},
|
|
168
168
|
response: {
|
|
169
169
|
status: 204,
|
|
170
170
|
},
|
|
171
171
|
handler(req: MockRequest) {
|
|
172
172
|
req.expect.containsHeader("content-type", contentType);
|
|
173
|
-
req.expect.rawBodyEquals(
|
|
173
|
+
req.expect.rawBodyEquals(data);
|
|
174
174
|
return {
|
|
175
175
|
status: 204,
|
|
176
176
|
};
|
|
@@ -180,45 +180,26 @@ function createRequestBodyServerTests(
|
|
|
180
180
|
}
|
|
181
181
|
Scenarios.Encode_Bytes_RequestBody_default = createRequestBodyServerTests(
|
|
182
182
|
"/encode/bytes/body/request/default",
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
"Content-Type": "application/json",
|
|
186
|
-
},
|
|
187
|
-
'"dGVzdA=="',
|
|
183
|
+
pngFile,
|
|
184
|
+
"application/octet-stream",
|
|
188
185
|
);
|
|
189
186
|
Scenarios.Encode_Bytes_RequestBody_base64 = createRequestBodyServerTests(
|
|
190
187
|
"/encode/bytes/body/request/base64",
|
|
191
188
|
'"dGVzdA=="',
|
|
192
|
-
{
|
|
193
|
-
"Content-Type": "application/json",
|
|
194
|
-
},
|
|
195
|
-
'"dGVzdA=="',
|
|
196
189
|
);
|
|
197
190
|
Scenarios.Encode_Bytes_RequestBody_base64url = createRequestBodyServerTests(
|
|
198
191
|
"/encode/bytes/body/request/base64url",
|
|
199
192
|
'"dGVzdA"',
|
|
200
|
-
{
|
|
201
|
-
"Content-Type": "application/json",
|
|
202
|
-
},
|
|
203
|
-
'"dGVzdA"',
|
|
204
193
|
);
|
|
205
194
|
|
|
206
195
|
Scenarios.Encode_Bytes_RequestBody_customContentType = createRequestBodyServerTests(
|
|
207
196
|
"/encode/bytes/body/request/custom-content-type",
|
|
208
197
|
pngFile,
|
|
209
|
-
{
|
|
210
|
-
"Content-Type": "image/png",
|
|
211
|
-
},
|
|
212
|
-
pngFile,
|
|
213
198
|
"image/png",
|
|
214
199
|
);
|
|
215
200
|
Scenarios.Encode_Bytes_RequestBody_octetStream = createRequestBodyServerTests(
|
|
216
201
|
"/encode/bytes/body/request/octet-stream",
|
|
217
202
|
pngFile,
|
|
218
|
-
{
|
|
219
|
-
"Content-Type": "application/octet-stream",
|
|
220
|
-
},
|
|
221
|
-
pngFile,
|
|
222
203
|
"application/octet-stream",
|
|
223
204
|
);
|
|
224
205
|
function createResponseBodyServerTests(
|
|
@@ -255,11 +236,12 @@ function createResponseBodyServerTests(
|
|
|
255
236
|
}
|
|
256
237
|
Scenarios.Encode_Bytes_ResponseBody_default = createResponseBodyServerTests(
|
|
257
238
|
"/encode/bytes/body/response/default",
|
|
258
|
-
|
|
239
|
+
pngFile,
|
|
259
240
|
{
|
|
260
|
-
"Content-Type": "application/
|
|
241
|
+
"Content-Type": "application/octet-stream",
|
|
261
242
|
},
|
|
262
|
-
|
|
243
|
+
pngFile,
|
|
244
|
+
"application/octet-stream",
|
|
263
245
|
);
|
|
264
246
|
Scenarios.Encode_Bytes_ResponseBody_base64 = createResponseBodyServerTests(
|
|
265
247
|
"/encode/bytes/body/response/base64",
|
|
@@ -72,10 +72,7 @@ namespace Query {
|
|
|
72
72
|
value=1686566864, 1686734256
|
|
73
73
|
""")
|
|
74
74
|
op unixTimestampArray(
|
|
75
|
-
|
|
76
|
-
@query({
|
|
77
|
-
format: "csv",
|
|
78
|
-
})
|
|
75
|
+
@query
|
|
79
76
|
value: unixTimestampDatetime[],
|
|
80
77
|
): NoContentResponse;
|
|
81
78
|
}
|
|
@@ -269,9 +266,7 @@ namespace Header {
|
|
|
269
266
|
value=1686566864,1686734256
|
|
270
267
|
""")
|
|
271
268
|
op unixTimestampArray(
|
|
272
|
-
@header
|
|
273
|
-
format: "csv",
|
|
274
|
-
})
|
|
269
|
+
@header
|
|
275
270
|
value: unixTimestampDatetime[],
|
|
276
271
|
): NoContentResponse;
|
|
277
272
|
}
|
|
@@ -21,7 +21,7 @@ function createQueryServerTests(
|
|
|
21
21
|
uri,
|
|
22
22
|
method: "get",
|
|
23
23
|
request: {
|
|
24
|
-
|
|
24
|
+
query: paramData,
|
|
25
25
|
},
|
|
26
26
|
response: {
|
|
27
27
|
status: 204,
|
|
@@ -93,7 +93,7 @@ function createPropertyServerTests(
|
|
|
93
93
|
uri,
|
|
94
94
|
method: "post",
|
|
95
95
|
request: {
|
|
96
|
-
body: data,
|
|
96
|
+
body: json(data),
|
|
97
97
|
},
|
|
98
98
|
response: {
|
|
99
99
|
status: 200,
|