@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,8 +1,8 @@
|
|
|
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
|
@doc("Illustrates models with nullable properties.")
|
|
8
8
|
@scenarioService("/type/property/nullable")
|
|
@@ -18,54 +18,43 @@ model ModelTemplate<TProperty> {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
@doc("Operations associated with getting and putting models with nullable properties.")
|
|
21
|
-
interface OperationsTemplate<
|
|
21
|
+
interface OperationsTemplate<
|
|
22
|
+
TModel,
|
|
23
|
+
TDoc extends valueof string,
|
|
24
|
+
TDefaultDoc extends valueof string = "null"
|
|
25
|
+
> {
|
|
22
26
|
@doc("Get models that will return all properties in the model")
|
|
23
27
|
@scenario
|
|
24
|
-
@scenarioDoc(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
""",
|
|
31
|
-
{
|
|
32
|
-
allDoc: TDoc,
|
|
33
|
-
}
|
|
34
|
-
)
|
|
28
|
+
@scenarioDoc("""
|
|
29
|
+
Expected response body:
|
|
30
|
+
```json
|
|
31
|
+
{ "requiredProperty": "foo", "nullableProperty": ${TDoc}}
|
|
32
|
+
```
|
|
33
|
+
""")
|
|
35
34
|
@route("/non-null")
|
|
36
35
|
@get
|
|
37
36
|
getNonNull(): TModel;
|
|
38
37
|
|
|
39
38
|
@doc("Get models that will return the default object")
|
|
40
39
|
@scenario
|
|
41
|
-
@scenarioDoc(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
""",
|
|
48
|
-
{
|
|
49
|
-
defaultDoc: TDefaultDoc,
|
|
50
|
-
}
|
|
51
|
-
)
|
|
40
|
+
@scenarioDoc("""
|
|
41
|
+
Expected response body:
|
|
42
|
+
```json
|
|
43
|
+
{ "requiredProperty": "foo", "nullableProperty": ${TDefaultDoc}}
|
|
44
|
+
```
|
|
45
|
+
""")
|
|
52
46
|
@route("/null")
|
|
53
47
|
@get
|
|
54
48
|
getNull(): TModel;
|
|
55
49
|
|
|
56
50
|
@doc("Put a body with all properties present.")
|
|
57
51
|
@scenario
|
|
58
|
-
@scenarioDoc(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
""",
|
|
65
|
-
{
|
|
66
|
-
allDoc: TDoc,
|
|
67
|
-
}
|
|
68
|
-
)
|
|
52
|
+
@scenarioDoc("""
|
|
53
|
+
Expected request body:
|
|
54
|
+
```json
|
|
55
|
+
{ "requiredProperty": "foo", "nullableProperty": ${TDoc}}
|
|
56
|
+
```
|
|
57
|
+
""")
|
|
69
58
|
@route("/non-null")
|
|
70
59
|
@patch
|
|
71
60
|
patchNonNull(
|
|
@@ -78,17 +67,12 @@ interface OperationsTemplate<TModel, TDoc extends string, TDefaultDoc extends st
|
|
|
78
67
|
|
|
79
68
|
@doc("Put a body with default properties.")
|
|
80
69
|
@scenario
|
|
81
|
-
@scenarioDoc(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
""",
|
|
88
|
-
{
|
|
89
|
-
defaultDoc: TDefaultDoc,
|
|
90
|
-
}
|
|
91
|
-
)
|
|
70
|
+
@scenarioDoc("""
|
|
71
|
+
Expected request body:
|
|
72
|
+
```json
|
|
73
|
+
{ "requiredProperty": "foo", "nullableProperty": ${TDefaultDoc}}
|
|
74
|
+
```
|
|
75
|
+
""")
|
|
92
76
|
@route("/null")
|
|
93
77
|
@patch
|
|
94
78
|
patchNull(
|
|
@@ -103,34 +87,29 @@ interface OperationsTemplate<TModel, TDoc extends string, TDefaultDoc extends st
|
|
|
103
87
|
// Model with nullable string property
|
|
104
88
|
model StringProperty is ModelTemplate<string>;
|
|
105
89
|
@route("/string")
|
|
106
|
-
@operationGroup
|
|
107
90
|
interface String extends OperationsTemplate<StringProperty, "hello"> {}
|
|
108
91
|
|
|
109
92
|
// Model with nullable bytes property
|
|
110
93
|
model BytesProperty is ModelTemplate<bytes>;
|
|
111
94
|
@route("/bytes")
|
|
112
|
-
@operationGroup
|
|
113
95
|
interface Bytes extends OperationsTemplate<BytesProperty, "aGVsbG8sIHdvcmxkIQ=="> {}
|
|
114
96
|
|
|
115
97
|
// Model with nullable datetime property
|
|
116
98
|
@doc("Model with a datetime property")
|
|
117
99
|
model DatetimeProperty is ModelTemplate<utcDateTime>;
|
|
118
100
|
@route("/datetime")
|
|
119
|
-
@operationGroup
|
|
120
101
|
interface Datetime extends OperationsTemplate<DatetimeProperty, "2022-08-26T18:38:00Z"> {}
|
|
121
102
|
|
|
122
103
|
// Model with nullable duration property
|
|
123
104
|
@doc("Model with a duration property")
|
|
124
105
|
model DurationProperty is ModelTemplate<duration>;
|
|
125
106
|
@route("/duration")
|
|
126
|
-
@operationGroup
|
|
127
107
|
interface Duration extends OperationsTemplate<DurationProperty, "P123DT22H14M12.011S"> {}
|
|
128
108
|
|
|
129
109
|
// Model with nullable collection bytes property
|
|
130
110
|
@doc("Model with collection bytes properties")
|
|
131
111
|
model CollectionsByteProperty is ModelTemplate<bytes[]>;
|
|
132
112
|
@route("/collections/bytes")
|
|
133
|
-
@operationGroup
|
|
134
113
|
interface CollectionsByte
|
|
135
114
|
extends OperationsTemplate<
|
|
136
115
|
CollectionsByteProperty,
|
|
@@ -146,7 +125,6 @@ model InnerModel {
|
|
|
146
125
|
@doc("Model with collection models properties")
|
|
147
126
|
model CollectionsModelProperty is ModelTemplate<InnerModel[]>;
|
|
148
127
|
@route("/collections/model")
|
|
149
|
-
@operationGroup
|
|
150
128
|
interface CollectionsModel
|
|
151
129
|
extends OperationsTemplate<
|
|
152
130
|
CollectionsModelProperty,
|
|
@@ -157,6 +135,5 @@ interface CollectionsModel
|
|
|
157
135
|
@doc("Model with collection string properties")
|
|
158
136
|
model CollectionsStringProperty is ModelTemplate<string[]>;
|
|
159
137
|
@route("/collections/string")
|
|
160
|
-
@operationGroup
|
|
161
138
|
interface CollectionsString
|
|
162
139
|
extends OperationsTemplate<CollectionsStringProperty, "['hello', 'world']"> {}
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
@doc("Illustrates models with optional properties.")
|
|
8
8
|
@scenarioService("/type/property/optional")
|
|
@@ -15,71 +15,55 @@ model ModelTemplate<TProperty> {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
@doc("Operations associated with getting and putting models with optional properties.")
|
|
18
|
-
interface OperationsTemplate<
|
|
18
|
+
interface OperationsTemplate<
|
|
19
|
+
TModel,
|
|
20
|
+
TDoc extends valueof string,
|
|
21
|
+
TDefaultDoc extends valueof string = "{}"
|
|
22
|
+
> {
|
|
19
23
|
@doc("Get models that will return all properties in the model")
|
|
20
24
|
@scenario
|
|
21
|
-
@scenarioDoc(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
""",
|
|
28
|
-
{
|
|
29
|
-
allDoc: TDoc,
|
|
30
|
-
}
|
|
31
|
-
)
|
|
25
|
+
@scenarioDoc("""
|
|
26
|
+
Expected response body:
|
|
27
|
+
```json
|
|
28
|
+
{"property": ${TDoc}}
|
|
29
|
+
```
|
|
30
|
+
""")
|
|
32
31
|
@route("/all")
|
|
33
32
|
@get
|
|
34
33
|
getAll(): TModel;
|
|
35
34
|
|
|
36
35
|
@doc("Get models that will return the default object")
|
|
37
36
|
@scenario
|
|
38
|
-
@scenarioDoc(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
""",
|
|
45
|
-
{
|
|
46
|
-
defaultDoc: TDefaultDoc,
|
|
47
|
-
}
|
|
48
|
-
)
|
|
37
|
+
@scenarioDoc("""
|
|
38
|
+
Expected response body:
|
|
39
|
+
```json
|
|
40
|
+
${TDefaultDoc}
|
|
41
|
+
```
|
|
42
|
+
""")
|
|
49
43
|
@route("/default")
|
|
50
44
|
@get
|
|
51
45
|
getDefault(): TModel;
|
|
52
46
|
|
|
53
47
|
@doc("Put a body with all properties present.")
|
|
54
48
|
@scenario
|
|
55
|
-
@scenarioDoc(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
""",
|
|
62
|
-
{
|
|
63
|
-
allDoc: TDoc,
|
|
64
|
-
}
|
|
65
|
-
)
|
|
49
|
+
@scenarioDoc("""
|
|
50
|
+
Expected request body:
|
|
51
|
+
```json
|
|
52
|
+
{"property": ${TDoc}}
|
|
53
|
+
```
|
|
54
|
+
""")
|
|
66
55
|
@route("/all")
|
|
67
56
|
@put
|
|
68
57
|
putAll(@body body: TModel): void;
|
|
69
58
|
|
|
70
59
|
@doc("Put a body with default properties.")
|
|
71
60
|
@scenario
|
|
72
|
-
@scenarioDoc(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
""",
|
|
79
|
-
{
|
|
80
|
-
defaultDoc: TDefaultDoc,
|
|
81
|
-
}
|
|
82
|
-
)
|
|
61
|
+
@scenarioDoc("""
|
|
62
|
+
Expected request body:
|
|
63
|
+
```json
|
|
64
|
+
${TDefaultDoc}
|
|
65
|
+
```
|
|
66
|
+
""")
|
|
83
67
|
@route("/default")
|
|
84
68
|
@put
|
|
85
69
|
putDefault(@body body: TModel): void;
|
|
@@ -88,48 +72,41 @@ interface OperationsTemplate<TModel, TDoc extends string, TDefaultDoc extends st
|
|
|
88
72
|
// Model with optional string property
|
|
89
73
|
model StringProperty is ModelTemplate<string>;
|
|
90
74
|
@route("/string")
|
|
91
|
-
@operationGroup
|
|
92
75
|
interface String extends OperationsTemplate<StringProperty, "\"hello\""> {}
|
|
93
76
|
|
|
94
77
|
// Model with optional bytes property
|
|
95
78
|
model BytesProperty is ModelTemplate<bytes>;
|
|
96
79
|
@route("/bytes")
|
|
97
|
-
@operationGroup
|
|
98
80
|
interface Bytes extends OperationsTemplate<BytesProperty, "\"aGVsbG8sIHdvcmxkIQ==\""> {}
|
|
99
81
|
|
|
100
82
|
// Model with optional datetime property
|
|
101
83
|
@doc("Model with a datetime property")
|
|
102
84
|
model DatetimeProperty is ModelTemplate<utcDateTime>;
|
|
103
85
|
@route("/datetime")
|
|
104
|
-
@operationGroup
|
|
105
86
|
interface Datetime extends OperationsTemplate<DatetimeProperty, "\"2022-08-26T18:38:00Z\""> {}
|
|
106
87
|
|
|
107
88
|
// Model with optional duration property
|
|
108
89
|
@doc("Model with a duration property")
|
|
109
90
|
model DurationProperty is ModelTemplate<duration>;
|
|
110
91
|
@route("/duration")
|
|
111
|
-
@operationGroup
|
|
112
92
|
interface Duration extends OperationsTemplate<DurationProperty, "\"P123DT22H14M12.011S\""> {}
|
|
113
93
|
|
|
114
94
|
// Model with optional plainDate property
|
|
115
95
|
@doc("Model with a plainDate property")
|
|
116
96
|
model PlainDateProperty is ModelTemplate<plainDate>;
|
|
117
97
|
@route("/plainDate")
|
|
118
|
-
@operationGroup
|
|
119
98
|
interface PlainDate extends OperationsTemplate<PlainDateProperty, "\"2022-12-12\""> {}
|
|
120
99
|
|
|
121
100
|
// Model with optional property
|
|
122
101
|
@doc("Model with a plainTime property")
|
|
123
102
|
model PlainTimeProperty is ModelTemplate<plainTime>;
|
|
124
103
|
@route("/plainTime")
|
|
125
|
-
@operationGroup
|
|
126
104
|
interface PlainTime extends OperationsTemplate<PlainTimeProperty, "\"13:06:12\""> {}
|
|
127
105
|
|
|
128
106
|
// Model with optional collection bytes property
|
|
129
107
|
@doc("Model with collection bytes properties")
|
|
130
108
|
model CollectionsByteProperty is ModelTemplate<bytes[]>;
|
|
131
109
|
@route("/collections/bytes")
|
|
132
|
-
@operationGroup
|
|
133
110
|
interface CollectionsByte
|
|
134
111
|
extends OperationsTemplate<
|
|
135
112
|
CollectionsByteProperty,
|
|
@@ -140,7 +117,6 @@ interface CollectionsByte
|
|
|
140
117
|
@doc("Model with collection models properties")
|
|
141
118
|
model CollectionsModelProperty is ModelTemplate<StringProperty[]>;
|
|
142
119
|
@route("/collections/model")
|
|
143
|
-
@operationGroup
|
|
144
120
|
interface CollectionsModel
|
|
145
121
|
extends OperationsTemplate<
|
|
146
122
|
CollectionsModelProperty,
|
|
@@ -151,49 +127,42 @@ interface CollectionsModel
|
|
|
151
127
|
@doc("Model with string literal property")
|
|
152
128
|
model StringLiteralProperty is ModelTemplate<"hello">;
|
|
153
129
|
@route("/string/literal")
|
|
154
|
-
@operationGroup
|
|
155
130
|
interface StringLiteral extends OperationsTemplate<StringLiteralProperty, "\"hello\""> {}
|
|
156
131
|
|
|
157
132
|
// Model with optional int literal property
|
|
158
133
|
@doc("Model with int literal property")
|
|
159
134
|
model IntLiteralProperty is ModelTemplate<1>;
|
|
160
135
|
@route("/int/literal")
|
|
161
|
-
@operationGroup
|
|
162
136
|
interface IntLiteral extends OperationsTemplate<IntLiteralProperty, "1"> {}
|
|
163
137
|
|
|
164
138
|
// Model with optional float literal property
|
|
165
139
|
@doc("Model with float literal property")
|
|
166
140
|
model FloatLiteralProperty is ModelTemplate<1.25>;
|
|
167
141
|
@route("/float/literal")
|
|
168
|
-
@operationGroup
|
|
169
142
|
interface FloatLiteral extends OperationsTemplate<FloatLiteralProperty, "1.25"> {}
|
|
170
143
|
|
|
171
144
|
// Model with optional boolean literal property
|
|
172
145
|
@doc("Model with boolean literal property")
|
|
173
146
|
model BooleanLiteralProperty is ModelTemplate<true>;
|
|
174
147
|
@route("/boolean/literal")
|
|
175
|
-
@operationGroup
|
|
176
148
|
interface BooleanLiteral extends OperationsTemplate<BooleanLiteralProperty, "true"> {}
|
|
177
149
|
|
|
178
150
|
// Model with union of string literal property
|
|
179
151
|
@doc("Model with union of string literal property")
|
|
180
152
|
model UnionStringLiteralProperty is ModelTemplate<"hello" | "world">;
|
|
181
153
|
@route("/union/string/literal")
|
|
182
|
-
@operationGroup
|
|
183
154
|
interface UnionStringLiteral extends OperationsTemplate<UnionStringLiteralProperty, "\"world\""> {}
|
|
184
155
|
|
|
185
156
|
// Model with union of int literal property
|
|
186
157
|
@doc("Model with union of int literal property")
|
|
187
158
|
model UnionIntLiteralProperty is ModelTemplate<1 | 2>;
|
|
188
159
|
@route("/union/int/literal")
|
|
189
|
-
@operationGroup
|
|
190
160
|
interface UnionIntLiteral extends OperationsTemplate<UnionIntLiteralProperty, "2"> {}
|
|
191
161
|
|
|
192
162
|
// Model with union of float literal property
|
|
193
163
|
@doc("Model with union of float literal property")
|
|
194
164
|
model UnionFloatLiteralProperty is ModelTemplate<1.25 | 2.375>;
|
|
195
165
|
@route("/union/float/literal")
|
|
196
|
-
@operationGroup
|
|
197
166
|
interface UnionFloatLiteral extends OperationsTemplate<UnionFloatLiteralProperty, "2.375"> {}
|
|
198
167
|
|
|
199
168
|
@doc("Model with required and optional properties")
|
|
@@ -206,7 +175,6 @@ model RequiredAndOptionalProperty {
|
|
|
206
175
|
}
|
|
207
176
|
@doc("Test optional and required properties")
|
|
208
177
|
@route("/requiredAndOptional")
|
|
209
|
-
@operationGroup
|
|
210
178
|
interface RequiredAndOptional {
|
|
211
179
|
@doc("Get models that will return all properties in the model")
|
|
212
180
|
@scenario
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
@doc("Illustrates various property types for models")
|
|
8
8
|
@scenarioService("/type/property/value-types")
|
|
@@ -16,37 +16,27 @@ model ModelTemplate<TProperty> {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@doc("Template to have models operations")
|
|
19
|
-
interface ModelOperations<TModel, TDoc extends string> {
|
|
19
|
+
interface ModelOperations<TModel, TDoc extends valueof string> {
|
|
20
20
|
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
|
|
21
21
|
@scenario
|
|
22
|
-
@scenarioDoc(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
""",
|
|
29
|
-
{
|
|
30
|
-
doc: TDoc,
|
|
31
|
-
}
|
|
32
|
-
)
|
|
22
|
+
@scenarioDoc("""
|
|
23
|
+
Expected response body:
|
|
24
|
+
```json
|
|
25
|
+
{"property": ${TDoc}}
|
|
26
|
+
```
|
|
27
|
+
""")
|
|
33
28
|
@get
|
|
34
29
|
@doc("Get call")
|
|
35
30
|
get(): TModel;
|
|
36
31
|
|
|
37
32
|
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "For testing"
|
|
38
33
|
@scenario
|
|
39
|
-
@scenarioDoc(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
""",
|
|
46
|
-
{
|
|
47
|
-
doc: TDoc,
|
|
48
|
-
}
|
|
49
|
-
)
|
|
34
|
+
@scenarioDoc("""
|
|
35
|
+
Expected input body:
|
|
36
|
+
```json
|
|
37
|
+
{"property": ${TDoc}}
|
|
38
|
+
```
|
|
39
|
+
""")
|
|
50
40
|
@put
|
|
51
41
|
@doc("Put operation")
|
|
52
42
|
put(@body @doc("body") body: TModel): void;
|
|
@@ -56,63 +46,54 @@ interface ModelOperations<TModel, TDoc extends string> {
|
|
|
56
46
|
@doc("Model with a boolean property")
|
|
57
47
|
model BooleanProperty is ModelTemplate<boolean>;
|
|
58
48
|
@route("/boolean")
|
|
59
|
-
@operationGroup
|
|
60
49
|
interface Boolean extends ModelOperations<BooleanProperty, "true"> {}
|
|
61
50
|
|
|
62
51
|
// Test a model with a string property
|
|
63
52
|
@doc("Model with a string property")
|
|
64
53
|
model StringProperty is ModelTemplate<string>;
|
|
65
54
|
@route("/string")
|
|
66
|
-
@operationGroup
|
|
67
55
|
interface String extends ModelOperations<StringProperty, "\"hello\""> {}
|
|
68
56
|
|
|
69
57
|
// Test a model with a bytes property
|
|
70
58
|
@doc("Model with a bytes property")
|
|
71
59
|
model BytesProperty is ModelTemplate<bytes>;
|
|
72
60
|
@route("/bytes")
|
|
73
|
-
@operationGroup
|
|
74
61
|
interface Bytes extends ModelOperations<BytesProperty, "aGVsbG8sIHdvcmxkIQ=="> {}
|
|
75
62
|
|
|
76
63
|
// Test a model with an int property
|
|
77
64
|
@doc("Model with a int property")
|
|
78
65
|
model IntProperty is ModelTemplate<int32>;
|
|
79
66
|
@route("/int")
|
|
80
|
-
@operationGroup
|
|
81
67
|
interface Int extends ModelOperations<IntProperty, "42"> {}
|
|
82
68
|
|
|
83
69
|
// Test a model with a float property
|
|
84
70
|
@doc("Model with a float property")
|
|
85
71
|
model FloatProperty is ModelTemplate<float32>;
|
|
86
72
|
@route("/float")
|
|
87
|
-
@operationGroup
|
|
88
73
|
interface Float extends ModelOperations<FloatProperty, "43.125"> {}
|
|
89
74
|
|
|
90
75
|
// Test a model with a decimal property
|
|
91
76
|
@doc("Model with a decimal property")
|
|
92
77
|
model DecimalProperty is ModelTemplate<decimal>;
|
|
93
78
|
@route("/decimal")
|
|
94
|
-
@operationGroup
|
|
95
79
|
interface Decimal extends ModelOperations<DecimalProperty, "0.33333"> {}
|
|
96
80
|
|
|
97
81
|
// Test a model with a decimal128 property
|
|
98
82
|
@doc("Model with a decimal128 property")
|
|
99
83
|
model Decimal128Property is ModelTemplate<decimal128>;
|
|
100
84
|
@route("/decimal128")
|
|
101
|
-
@operationGroup
|
|
102
85
|
interface Decimal128 extends ModelOperations<Decimal128Property, "0.33333"> {}
|
|
103
86
|
|
|
104
87
|
// Test a model with a datetime property
|
|
105
88
|
@doc("Model with a datetime property")
|
|
106
89
|
model DatetimeProperty is ModelTemplate<utcDateTime>;
|
|
107
90
|
@route("/datetime")
|
|
108
|
-
@operationGroup
|
|
109
91
|
interface Datetime extends ModelOperations<DatetimeProperty, "2022-08-26T18:38:00Z"> {}
|
|
110
92
|
|
|
111
93
|
// Test a model with a duration property
|
|
112
94
|
@doc("Model with a duration property")
|
|
113
95
|
model DurationProperty is ModelTemplate<duration>;
|
|
114
96
|
@route("/duration")
|
|
115
|
-
@operationGroup
|
|
116
97
|
interface Duration extends ModelOperations<DurationProperty, "P123DT22H14M12.011S"> {}
|
|
117
98
|
|
|
118
99
|
// Test a model with an enum property
|
|
@@ -127,9 +108,7 @@ union InnerEnum {
|
|
|
127
108
|
ValueTwo: "ValueTwo",
|
|
128
109
|
}
|
|
129
110
|
|
|
130
|
-
#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "For testing"
|
|
131
111
|
@doc("Enum that will be used as a property for model EnumProperty. Non-extensible.")
|
|
132
|
-
@Azure.Core.fixed
|
|
133
112
|
enum FixedInnerEnum {
|
|
134
113
|
@doc("First value.")
|
|
135
114
|
ValueOne,
|
|
@@ -141,13 +120,11 @@ enum FixedInnerEnum {
|
|
|
141
120
|
@doc("Model with enum properties")
|
|
142
121
|
model EnumProperty is ModelTemplate<FixedInnerEnum>;
|
|
143
122
|
@route("/enum")
|
|
144
|
-
@operationGroup
|
|
145
123
|
interface Enum extends ModelOperations<EnumProperty, "\"ValueOne\""> {}
|
|
146
124
|
|
|
147
125
|
@doc("Model with extensible enum properties")
|
|
148
126
|
model ExtensibleEnumProperty is ModelTemplate<InnerEnum>;
|
|
149
127
|
@route("/extensible-enum")
|
|
150
|
-
@operationGroup
|
|
151
128
|
interface ExtensibleEnum extends ModelOperations<ExtensibleEnumProperty, "\"UnknownValue\""> {}
|
|
152
129
|
|
|
153
130
|
// Test a model with a model property
|
|
@@ -159,14 +136,12 @@ model InnerModel {
|
|
|
159
136
|
@doc("Model with model properties")
|
|
160
137
|
model ModelProperty is ModelTemplate<InnerModel>;
|
|
161
138
|
@route("/model")
|
|
162
|
-
@operationGroup
|
|
163
139
|
interface Model extends ModelOperations<ModelProperty, "{'property': 'hello'}"> {}
|
|
164
140
|
|
|
165
141
|
// Test a model with a string collection property
|
|
166
142
|
@doc("Model with collection string properties")
|
|
167
143
|
model CollectionsStringProperty is ModelTemplate<string[]>;
|
|
168
144
|
@route("/collections/string")
|
|
169
|
-
@operationGroup
|
|
170
145
|
interface CollectionsString
|
|
171
146
|
extends ModelOperations<CollectionsStringProperty, "['hello', 'world']"> {}
|
|
172
147
|
|
|
@@ -174,14 +149,12 @@ interface CollectionsString
|
|
|
174
149
|
@doc("Model with collection int properties")
|
|
175
150
|
model CollectionsIntProperty is ModelTemplate<int32[]>;
|
|
176
151
|
@route("/collections/int")
|
|
177
|
-
@operationGroup
|
|
178
152
|
interface CollectionsInt extends ModelOperations<CollectionsIntProperty, "[1, 2]"> {}
|
|
179
153
|
|
|
180
154
|
// Test a model with a model collection property
|
|
181
155
|
@doc("Model with collection model properties")
|
|
182
156
|
model CollectionsModelProperty is ModelTemplate<InnerModel[]>;
|
|
183
157
|
@route("/collections/model")
|
|
184
|
-
@operationGroup
|
|
185
158
|
interface CollectionsModel
|
|
186
159
|
extends ModelOperations<
|
|
187
160
|
CollectionsModelProperty,
|
|
@@ -192,7 +165,6 @@ interface CollectionsModel
|
|
|
192
165
|
@doc("Model with dictionary string properties")
|
|
193
166
|
model DictionaryStringProperty is ModelTemplate<Record<string>>;
|
|
194
167
|
@route("/dictionary/string")
|
|
195
|
-
@operationGroup
|
|
196
168
|
interface DictionaryString
|
|
197
169
|
extends ModelOperations<DictionaryStringProperty, "{'k1': 'hello', 'k2': 'world'}"> {}
|
|
198
170
|
|
|
@@ -200,77 +172,65 @@ interface DictionaryString
|
|
|
200
172
|
@doc("Model with a property never. (This property should not be included).")
|
|
201
173
|
model NeverProperty is ModelTemplate<never>;
|
|
202
174
|
@route("/never")
|
|
203
|
-
@operationGroup
|
|
204
175
|
interface Never extends ModelOperations<NeverProperty, "<don't include this property>"> {}
|
|
205
176
|
|
|
206
177
|
// Test a model with unknown and string
|
|
207
178
|
@doc("Model with a property unknown, and the data is a string.")
|
|
208
179
|
model UnknownStringProperty is ModelTemplate<unknown>;
|
|
209
180
|
@route("/unknown/string")
|
|
210
|
-
@operationGroup
|
|
211
181
|
interface UnknownString extends ModelOperations<UnknownStringProperty, "\"hello\""> {}
|
|
212
182
|
|
|
213
183
|
// Test a model with unknown and int
|
|
214
184
|
@doc("Model with a property unknown, and the data is a int32.")
|
|
215
185
|
model UnknownIntProperty is ModelTemplate<unknown>;
|
|
216
186
|
@route("/unknown/int")
|
|
217
|
-
@operationGroup
|
|
218
187
|
interface UnknownInt extends ModelOperations<UnknownIntProperty, "42"> {}
|
|
219
188
|
|
|
220
189
|
// Test a model with unknown and a dictionnary
|
|
221
190
|
@doc("Model with a property unknown, and the data is a dictionnary.")
|
|
222
191
|
model UnknownDictProperty is ModelTemplate<unknown>;
|
|
223
192
|
@route("/unknown/dict")
|
|
224
|
-
@operationGroup
|
|
225
193
|
interface UnknownDict extends ModelOperations<UnknownDictProperty, "{'k1': 'hello', 'k2': 42}"> {}
|
|
226
194
|
|
|
227
195
|
// Test a model with unknown and an array
|
|
228
196
|
@doc("Model with a property unknown, and the data is an array.")
|
|
229
197
|
model UnknownArrayProperty is ModelTemplate<unknown>;
|
|
230
198
|
@route("/unknown/array")
|
|
231
|
-
@operationGroup
|
|
232
199
|
interface UnknownArray extends ModelOperations<UnknownArrayProperty, "['hello', 'world']"> {}
|
|
233
200
|
|
|
234
201
|
@doc("Model with a string literal property.")
|
|
235
202
|
model StringLiteralProperty is ModelTemplate<"hello">;
|
|
236
203
|
@route("/string/literal")
|
|
237
|
-
@operationGroup
|
|
238
204
|
interface StringLiteral extends ModelOperations<StringLiteralProperty, "\"hello\""> {}
|
|
239
205
|
|
|
240
206
|
@doc("Model with a int literal property.")
|
|
241
207
|
model IntLiteralProperty is ModelTemplate<42>;
|
|
242
208
|
@route("/int/literal")
|
|
243
|
-
@operationGroup
|
|
244
209
|
interface IntLiteral extends ModelOperations<IntLiteralProperty, "42"> {}
|
|
245
210
|
|
|
246
211
|
@doc("Model with a float literal property.")
|
|
247
212
|
model FloatLiteralProperty is ModelTemplate<43.125>;
|
|
248
213
|
@route("/float/literal")
|
|
249
|
-
@operationGroup
|
|
250
214
|
interface FloatLiteral extends ModelOperations<FloatLiteralProperty, "43.125"> {}
|
|
251
215
|
|
|
252
216
|
@doc("Model with a boolean literal property.")
|
|
253
217
|
model BooleanLiteralProperty is ModelTemplate<true>;
|
|
254
218
|
@route("/boolean/literal")
|
|
255
|
-
@operationGroup
|
|
256
219
|
interface BooleanLiteral extends ModelOperations<BooleanLiteralProperty, "true"> {}
|
|
257
220
|
|
|
258
221
|
@doc("Model with a union of string literal as property.")
|
|
259
222
|
model UnionStringLiteralProperty is ModelTemplate<"hello" | "world">;
|
|
260
223
|
@route("/union/string/literal")
|
|
261
|
-
@operationGroup
|
|
262
224
|
interface UnionStringLiteral extends ModelOperations<UnionStringLiteralProperty, "\"world\""> {}
|
|
263
225
|
|
|
264
226
|
@doc("Model with a union of int literal as property.")
|
|
265
227
|
model UnionIntLiteralProperty is ModelTemplate<42 | 43>;
|
|
266
228
|
@route("/union/int/literal")
|
|
267
|
-
@operationGroup
|
|
268
229
|
interface UnionIntLiteral extends ModelOperations<UnionIntLiteralProperty, "42"> {}
|
|
269
230
|
|
|
270
231
|
@doc("Model with a union of float literal as property.")
|
|
271
232
|
model UnionFloatLiteralProperty is ModelTemplate<43.125 | 46.875>;
|
|
272
233
|
@route("/union/float/literal")
|
|
273
|
-
@operationGroup
|
|
274
234
|
interface UnionFloatLiteral extends ModelOperations<UnionFloatLiteralProperty, "46.875"> {}
|
|
275
235
|
|
|
276
236
|
union ExtendedEnum {
|
|
@@ -281,5 +241,4 @@ union ExtendedEnum {
|
|
|
281
241
|
model UnionEnumValueProperty is ModelTemplate<ExtendedEnum.EnumValue2>;
|
|
282
242
|
|
|
283
243
|
@route("/union-enum-value")
|
|
284
|
-
@operationGroup
|
|
285
244
|
interface UnionEnumValue extends ModelOperations<UnionEnumValueProperty, "\"value2\""> {}
|