@typespec/http-specs 0.38.0-dev.3 → 0.38.0-dev.5
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/dist/specs/encode/duration/mockapi.js +6 -0
- package/dist/specs/encode/duration/mockapi.js.map +1 -1
- package/dist/specs/payload/content-negotiation/mockapi.d.ts +3 -0
- package/dist/specs/payload/content-negotiation/mockapi.d.ts.map +1 -0
- package/dist/specs/payload/content-negotiation/mockapi.js +169 -0
- package/dist/specs/payload/content-negotiation/mockapi.js.map +1 -0
- package/dist/specs/special-words/mockapi.js +1 -1
- package/dist/specs/special-words/mockapi.js.map +1 -1
- package/package.json +8 -7
- package/specs/authentication/api-key/main.tsp +2 -1
- package/specs/authentication/http/custom/main.tsp +1 -0
- package/specs/authentication/oauth2/main.tsp +2 -1
- package/specs/authentication/union/main.tsp +2 -1
- package/specs/encode/bytes/main.tsp +2 -8
- package/specs/encode/datetime/main.tsp +2 -7
- package/specs/encode/duration/main.tsp +2 -6
- package/specs/encode/duration/mockapi.ts +14 -0
- package/specs/encode/numeric/main.tsp +2 -4
- package/specs/parameters/basic/main.tsp +2 -5
- package/specs/parameters/body-optionality/main.tsp +2 -4
- package/specs/parameters/collection-format/main.tsp +2 -5
- package/specs/parameters/spread/main.tsp +2 -5
- package/specs/payload/content-negotiation/main.tsp +61 -0
- package/specs/payload/content-negotiation/mockapi.ts +188 -0
- package/specs/payload/json-merge-patch/main.tsp +2 -1
- package/specs/payload/media-type/main.tsp +2 -4
- package/specs/payload/multipart/main.tsp +2 -1
- package/specs/payload/xml/main.tsp +15 -25
- package/specs/routes/main.tsp +2 -1
- package/specs/serialization/encoded-name/json/main.tsp +2 -2
- package/specs/server/endpoint/not-defined/main.tsp +2 -1
- package/specs/server/path/multiple/main.tsp +2 -1
- package/specs/server/path/single/main.tsp +2 -1
- package/specs/server/versions/not-versioned/main.tsp +2 -1
- package/specs/server/versions/versioned/main.tsp +2 -3
- package/specs/special-headers/conditional-request/main.tsp +2 -2
- package/specs/special-headers/repeatability/main.tsp +2 -2
- package/specs/special-words/main.tsp +2 -6
- package/specs/special-words/mockapi.ts +1 -1
- package/specs/type/array/main.tsp +15 -39
- package/specs/type/dictionary/main.tsp +15 -36
- package/specs/type/enum/extensible/main.tsp +2 -1
- package/specs/type/enum/fixed/main.tsp +2 -2
- package/specs/type/model/empty/main.tsp +2 -1
- package/specs/type/model/inheritance/enum-discriminator/main.tsp +2 -2
- package/specs/type/model/inheritance/nested-discriminator/main.tsp +2 -1
- package/specs/type/model/inheritance/not-discriminated/main.tsp +2 -1
- package/specs/type/model/inheritance/recursive/main.tsp +2 -1
- package/specs/type/model/inheritance/single-discriminator/main.tsp +2 -1
- package/specs/type/model/templated/main.tsp +2 -2
- package/specs/type/model/usage/main.tsp +2 -1
- package/specs/type/model/visibility/main.tsp +2 -1
- package/specs/type/property/additional-properties/main.tsp +15 -57
- package/specs/type/property/nullable/main.tsp +31 -54
- package/specs/type/property/optionality/main.tsp +31 -63
- package/specs/type/property/value-types/main.tsp +15 -56
- package/specs/type/scalar/main.tsp +34 -62
- package/specs/type/union/main.tsp +5 -18
- package/specs/versioning/added/main.tsp +2 -1
- package/specs/versioning/madeOptional/main.tsp +2 -1
- package/specs/versioning/removed/main.tsp +2 -1
- package/specs/versioning/renamedFrom/main.tsp +2 -1
- package/specs/versioning/returnTypeChangedFrom/main.tsp +2 -1
- package/specs/versioning/typeChangedFrom/main.tsp +2 -1
- package/temp/.tsbuildinfo +1 -1
- package/specs/type/property/nullable/client.tsp +0 -21
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import "@typespec/http";
|
|
2
2
|
import "@typespec/spec-lib";
|
|
3
3
|
|
|
4
|
-
using
|
|
5
|
-
using
|
|
4
|
+
using Http;
|
|
5
|
+
using SpecLib;
|
|
6
6
|
|
|
7
7
|
@scenarioService("/type/scalar")
|
|
8
8
|
namespace Type.Scalar;
|
|
9
9
|
|
|
10
|
-
@operationGroup
|
|
11
10
|
@route("/string")
|
|
12
11
|
interface String {
|
|
13
12
|
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
|
|
@@ -25,7 +24,6 @@ interface String {
|
|
|
25
24
|
put(@body @doc("_") body: string): void;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
@operationGroup
|
|
29
27
|
@route("/boolean")
|
|
30
28
|
interface Boolean {
|
|
31
29
|
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
|
|
@@ -43,7 +41,6 @@ interface Boolean {
|
|
|
43
41
|
put(@body @doc("_") body: boolean): void;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
@operationGroup
|
|
47
44
|
@route("/unknown")
|
|
48
45
|
interface Unknown {
|
|
49
46
|
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
|
|
@@ -62,49 +59,34 @@ interface Unknown {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
@doc("Template to have scalar types operations")
|
|
65
|
-
interface ScalarTypesOperations<T, TDoc extends string> {
|
|
62
|
+
interface ScalarTypesOperations<T, TDoc extends valueof string> {
|
|
66
63
|
@scenario
|
|
67
|
-
@scenarioDoc(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
""",
|
|
74
|
-
{
|
|
75
|
-
doc: TDoc,
|
|
76
|
-
}
|
|
77
|
-
)
|
|
64
|
+
@scenarioDoc("""
|
|
65
|
+
Expected response body:
|
|
66
|
+
```json
|
|
67
|
+
${TDoc}
|
|
68
|
+
```
|
|
69
|
+
""")
|
|
78
70
|
@get
|
|
79
71
|
@route("/response_body")
|
|
80
72
|
responseBody(): T;
|
|
81
73
|
|
|
82
74
|
@scenario
|
|
83
|
-
@scenarioDoc(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
""",
|
|
90
|
-
{
|
|
91
|
-
doc: TDoc,
|
|
92
|
-
}
|
|
93
|
-
)
|
|
75
|
+
@scenarioDoc("""
|
|
76
|
+
Expected input body:
|
|
77
|
+
```json
|
|
78
|
+
${TDoc}
|
|
79
|
+
```
|
|
80
|
+
""")
|
|
94
81
|
@put
|
|
95
82
|
@route("/resquest_body")
|
|
96
83
|
requestBody(@body body: T): void;
|
|
97
84
|
|
|
98
85
|
@scenario
|
|
99
|
-
@scenarioDoc(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
""",
|
|
104
|
-
{
|
|
105
|
-
doc: TDoc,
|
|
106
|
-
}
|
|
107
|
-
)
|
|
86
|
+
@scenarioDoc("""
|
|
87
|
+
Expected request parameter:
|
|
88
|
+
value=${TDoc}
|
|
89
|
+
""")
|
|
108
90
|
@get
|
|
109
91
|
@route("/request_parameter")
|
|
110
92
|
requestParameter(@query value: T): void;
|
|
@@ -112,42 +94,34 @@ interface ScalarTypesOperations<T, TDoc extends string> {
|
|
|
112
94
|
|
|
113
95
|
@doc("Decimal type")
|
|
114
96
|
@route("/decimal")
|
|
115
|
-
@operationGroup
|
|
116
97
|
interface DecimalType extends ScalarTypesOperations<decimal, "0.33333"> {}
|
|
117
98
|
|
|
118
99
|
@doc("Decimal128 type")
|
|
119
100
|
@route("/decimal128")
|
|
120
|
-
@operationGroup
|
|
121
101
|
interface Decimal128Type extends ScalarTypesOperations<decimal128, "0.33333"> {}
|
|
122
102
|
|
|
123
103
|
@doc("Template to verify number types")
|
|
124
|
-
interface NumberTypesVerifyOperations<
|
|
104
|
+
interface NumberTypesVerifyOperations<
|
|
105
|
+
T,
|
|
106
|
+
VerifyValues extends valueof string,
|
|
107
|
+
ResultValue extends valueof string
|
|
108
|
+
> {
|
|
125
109
|
@scenario
|
|
126
|
-
@scenarioDoc(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
""",
|
|
131
|
-
{
|
|
132
|
-
doc: VerifyValues,
|
|
133
|
-
}
|
|
134
|
-
)
|
|
110
|
+
@scenarioDoc("""
|
|
111
|
+
Get verify values:
|
|
112
|
+
${VerifyValues}
|
|
113
|
+
""")
|
|
135
114
|
@get
|
|
136
115
|
@route("/prepare_verify")
|
|
137
116
|
prepareVerify(): T[];
|
|
138
117
|
|
|
139
118
|
@scenario
|
|
140
|
-
@scenarioDoc(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
""",
|
|
147
|
-
{
|
|
148
|
-
doc: ResultValue,
|
|
149
|
-
}
|
|
150
|
-
)
|
|
119
|
+
@scenarioDoc("""
|
|
120
|
+
Expected input body:
|
|
121
|
+
```json
|
|
122
|
+
${ResultValue}
|
|
123
|
+
```
|
|
124
|
+
""")
|
|
151
125
|
@post
|
|
152
126
|
@route("/verify")
|
|
153
127
|
verify(@body body: T): void;
|
|
@@ -155,10 +129,8 @@ interface NumberTypesVerifyOperations<T, VerifyValues extends string, ResultValu
|
|
|
155
129
|
|
|
156
130
|
@doc("Decimal type verification")
|
|
157
131
|
@route("/decimal")
|
|
158
|
-
@operationGroup
|
|
159
132
|
interface DecimalVerify extends NumberTypesVerifyOperations<decimal, "[0.1, 0.1, 0.1]", "0.3"> {}
|
|
160
133
|
|
|
161
134
|
@doc("Decimal128 type verification")
|
|
162
135
|
@route("/decimal128")
|
|
163
|
-
@operationGroup
|
|
164
136
|
interface Decimal128Verify extends NumberTypesVerifyOperations<decimal, "[0.1, 0.1, 0.1]", "0.3"> {}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import "@typespec/http";
|
|
2
2
|
import "@typespec/spec-lib";
|
|
3
3
|
|
|
4
|
-
using
|
|
5
|
-
using
|
|
4
|
+
using Http;
|
|
5
|
+
using SpecLib;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Describe scenarios for various combinations of unions.
|
|
9
9
|
*/
|
|
10
|
-
@supportedBy("dpg")
|
|
11
10
|
@scenarioService("/type/union")
|
|
12
11
|
namespace Type.Union;
|
|
13
12
|
|
|
@@ -32,14 +31,12 @@ enum UD {
|
|
|
32
31
|
* Describe union of string "a" | "b" | "c"
|
|
33
32
|
*/
|
|
34
33
|
@route("/strings-only")
|
|
35
|
-
@operationGroup
|
|
36
34
|
interface StringsOnly extends GetAndSend<"a" | "b" | "c", "\"b\""> {}
|
|
37
35
|
|
|
38
36
|
/**
|
|
39
37
|
* Describe union of string string | "b" | "c"
|
|
40
38
|
*/
|
|
41
39
|
@route("/string-extensible")
|
|
42
|
-
@operationGroup
|
|
43
40
|
interface StringExtensible extends GetAndSend<string | "b" | "c", "\"custom\""> {}
|
|
44
41
|
|
|
45
42
|
union StringExtensibleNamedUnion {
|
|
@@ -51,28 +48,24 @@ union StringExtensibleNamedUnion {
|
|
|
51
48
|
* Describe union of string string | "b" | "c" but where the union is named and some of the variants are named
|
|
52
49
|
*/
|
|
53
50
|
@route("/string-extensible-named")
|
|
54
|
-
@operationGroup
|
|
55
51
|
interface StringExtensibleNamed extends GetAndSend<StringExtensibleNamedUnion, "\"custom\""> {}
|
|
56
52
|
|
|
57
53
|
/**
|
|
58
54
|
* Describe union of integer 1 | 2 | 3
|
|
59
55
|
*/
|
|
60
56
|
@route("/ints-only")
|
|
61
|
-
@operationGroup
|
|
62
57
|
interface IntsOnly extends GetAndSend<1 | 2 | 3, "2"> {}
|
|
63
58
|
|
|
64
59
|
/**
|
|
65
60
|
* Describe union of floats 1.1 | 2.2 | 3.3
|
|
66
61
|
*/
|
|
67
62
|
@route("/floats-only")
|
|
68
|
-
@operationGroup
|
|
69
63
|
interface FloatsOnly extends GetAndSend<1.1 | 2.2 | 3.3, "2.2"> {}
|
|
70
64
|
|
|
71
65
|
/**
|
|
72
66
|
* Describe union of models
|
|
73
67
|
*/
|
|
74
68
|
@route("/models-only")
|
|
75
|
-
@operationGroup
|
|
76
69
|
interface ModelsOnly
|
|
77
70
|
extends GetAndSend<
|
|
78
71
|
Cat | Dog,
|
|
@@ -95,7 +88,6 @@ model EnumsOnlyCases {
|
|
|
95
88
|
* Describe union of 2 different enums
|
|
96
89
|
*/
|
|
97
90
|
@route("/enums-only")
|
|
98
|
-
@operationGroup
|
|
99
91
|
interface EnumsOnly
|
|
100
92
|
extends GetAndSend<
|
|
101
93
|
LR | UD,
|
|
@@ -120,7 +112,6 @@ model StringAndArrayCases {
|
|
|
120
112
|
* Describe union of a string and an array of strings
|
|
121
113
|
*/
|
|
122
114
|
@route("/string-and-array")
|
|
123
|
-
@operationGroup
|
|
124
115
|
interface StringAndArray
|
|
125
116
|
extends GetAndSend<
|
|
126
117
|
string | string[],
|
|
@@ -152,7 +143,6 @@ model MixedLiteralsCases {
|
|
|
152
143
|
* Describe union of floats "a" | 2 | 3.3
|
|
153
144
|
*/
|
|
154
145
|
@route("/mixed-literals")
|
|
155
|
-
@operationGroup
|
|
156
146
|
interface MixedLiterals
|
|
157
147
|
extends GetAndSend<
|
|
158
148
|
MixedLiteralsUnion,
|
|
@@ -189,7 +179,6 @@ model MixedTypesCases {
|
|
|
189
179
|
* Describe union of floats "a" | 2 | 3.3
|
|
190
180
|
*/
|
|
191
181
|
@route("/mixed-types")
|
|
192
|
-
@operationGroup
|
|
193
182
|
interface MixedTypes
|
|
194
183
|
extends GetAndSend<
|
|
195
184
|
MixedTypesUnion,
|
|
@@ -217,7 +206,7 @@ interface MixedTypes
|
|
|
217
206
|
/**
|
|
218
207
|
* Helper interface to describe a test involving getting and sending a specific data
|
|
219
208
|
*/
|
|
220
|
-
interface GetAndSend<Union, Payload extends string, Cases = Union> {
|
|
209
|
+
interface GetAndSend<Union, Payload extends valueof string, Cases = Union> {
|
|
221
210
|
@scenario
|
|
222
211
|
@scenarioDoc(
|
|
223
212
|
"""
|
|
@@ -228,12 +217,11 @@ interface GetAndSend<Union, Payload extends string, Cases = Union> {
|
|
|
228
217
|
|
|
229
218
|
Expected response body:
|
|
230
219
|
```json
|
|
231
|
-
{ "prop": {
|
|
220
|
+
{ "prop": ${Payload}}
|
|
232
221
|
```
|
|
233
222
|
""",
|
|
234
223
|
{
|
|
235
224
|
type: Union,
|
|
236
|
-
value: Payload,
|
|
237
225
|
}
|
|
238
226
|
)
|
|
239
227
|
get(): {
|
|
@@ -250,12 +238,11 @@ interface GetAndSend<Union, Payload extends string, Cases = Union> {
|
|
|
250
238
|
|
|
251
239
|
Expected request to send body:
|
|
252
240
|
```json
|
|
253
|
-
{ "prop": {
|
|
241
|
+
{ "prop": ${Payload}}
|
|
254
242
|
```
|
|
255
243
|
""",
|
|
256
244
|
{
|
|
257
245
|
type: Union,
|
|
258
|
-
value: Payload,
|
|
259
246
|
}
|
|
260
247
|
)
|
|
261
248
|
send(prop: Cases): void;
|