-
Notifications
You must be signed in to change notification settings - Fork 219
/
http-labels.smithy
278 lines (245 loc) · 7.18 KB
/
http-labels.smithy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
// This file defines test cases that test HTTP URI label bindings.
// See: https://awslabs.github.io/smithy/1.0/spec/http.html#httplabel-trait
$version: "2.0"
namespace aws.protocoltests.restjson
use aws.protocols#restJson1
use aws.protocoltests.shared#DateTime
use aws.protocoltests.shared#EpochSeconds
use aws.protocoltests.shared#HttpDate
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests
/// The example tests how requests are serialized when there's no input
/// payload but there are HTTP labels.
@readonly
@http(method: "GET", uri: "/HttpRequestWithLabels/{string}/{short}/{integer}/{long}/{float}/{double}/{boolean}/{timestamp}")
operation HttpRequestWithLabels {
input: HttpRequestWithLabelsInput
}
apply HttpRequestWithLabels @httpRequestTests([
{
id: "RestJsonInputWithHeadersAndAllParams",
documentation: "Sends a GET request that uses URI label bindings",
protocol: restJson1,
method: "GET",
uri: "/HttpRequestWithLabels/string/1/2/3/4.1/5.1/true/2019-12-16T23%3A48%3A18Z",
body: "",
params: {
string: "string",
short: 1,
integer: 2,
long: 3,
float: 4.1,
double: 5.1,
boolean: true,
timestamp: 1576540098
}
},
{
id: "RestJsonHttpRequestLabelEscaping",
documentation: "Sends a GET request that uses URI label bindings",
protocol: restJson1,
method: "GET",
uri: "/HttpRequestWithLabels/%25%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%F0%9F%98%B9/1/2/3/4.1/5.1/true/2019-12-16T23%3A48%3A18Z",
body: "",
params: {
string: "%:/?#[]@!$&'()*+,;=😹",
short: 1,
integer: 2,
long: 3,
float: 4.1,
double: 5.1,
boolean: true,
timestamp: 1576540098
}
},
])
structure HttpRequestWithLabelsInput {
@httpLabel
@required
string: String,
@httpLabel
@required
short: Short,
@httpLabel
@required
integer: Integer,
@httpLabel
@required
long: Long,
@httpLabel
@required
float: Float,
@httpLabel
@required
double: Double,
/// Serialized in the path as true or false.
@httpLabel
@required
boolean: Boolean,
/// Note that this member has no format, so it's serialized as an RFC 3399 date-time.
@httpLabel
@required
timestamp: Timestamp,
}
/// The example tests how requests serialize different timestamp formats in the
/// URI path.
@readonly
@http(method: "GET", uri: "/HttpRequestWithLabelsAndTimestampFormat/{memberEpochSeconds}/{memberHttpDate}/{memberDateTime}/{defaultFormat}/{targetEpochSeconds}/{targetHttpDate}/{targetDateTime}")
operation HttpRequestWithLabelsAndTimestampFormat {
input: HttpRequestWithLabelsAndTimestampFormatInput
}
apply HttpRequestWithLabelsAndTimestampFormat @httpRequestTests([
{
id: "RestJsonHttpRequestWithLabelsAndTimestampFormat",
documentation: "Serializes different timestamp formats in URI labels",
protocol: restJson1,
method: "GET",
uri: """
/HttpRequestWithLabelsAndTimestampFormat\
/1576540098\
/Mon%2C%2016%20Dec%202019%2023%3A48%3A18%20GMT\
/2019-12-16T23%3A48%3A18Z\
/2019-12-16T23%3A48%3A18Z\
/1576540098\
/Mon%2C%2016%20Dec%202019%2023%3A48%3A18%20GMT\
/2019-12-16T23%3A48%3A18Z""",
body: "",
params: {
memberEpochSeconds: 1576540098,
memberHttpDate: 1576540098,
memberDateTime: 1576540098,
defaultFormat: 1576540098,
targetEpochSeconds: 1576540098,
targetHttpDate: 1576540098,
targetDateTime: 1576540098,
}
},
])
structure HttpRequestWithLabelsAndTimestampFormatInput {
@httpLabel
@required
@timestampFormat("epoch-seconds")
memberEpochSeconds: Timestamp,
@httpLabel
@required
@timestampFormat("http-date")
memberHttpDate: Timestamp,
@httpLabel
@required
@timestampFormat("date-time")
memberDateTime: Timestamp,
@httpLabel
@required
defaultFormat: Timestamp,
@httpLabel
@required
targetEpochSeconds: EpochSeconds,
@httpLabel
@required
targetHttpDate: HttpDate,
@httpLabel
@required
targetDateTime: DateTime,
}
// This example uses a greedy label and a normal label.
@readonly
@http(method: "GET", uri: "/HttpRequestWithGreedyLabelInPath/foo/{foo}/baz/{baz+}")
operation HttpRequestWithGreedyLabelInPath {
input: HttpRequestWithGreedyLabelInPathInput
}
apply HttpRequestWithGreedyLabelInPath @httpRequestTests([
{
id: "RestJsonHttpRequestWithGreedyLabelInPath",
documentation: "Serializes greedy labels and normal labels",
protocol: restJson1,
method: "GET",
uri: "/HttpRequestWithGreedyLabelInPath/foo/hello%2Fescape/baz/there/guy",
body: "",
params: {
foo: "hello/escape",
baz: "there/guy",
}
},
])
structure HttpRequestWithGreedyLabelInPathInput {
@httpLabel
@required
foo: String,
@httpLabel
@required
baz: String,
}
apply HttpRequestWithFloatLabels @httpRequestTests([
{
id: "RestJsonSupportsNaNFloatLabels",
documentation: "Supports handling NaN float label values.",
protocol: restJson1,
method: "GET",
uri: "/FloatHttpLabels/NaN/NaN",
body: "",
params: {
float: "NaN",
double: "NaN",
}
},
{
id: "RestJsonSupportsInfinityFloatLabels",
documentation: "Supports handling Infinity float label values.",
protocol: restJson1,
method: "GET",
uri: "/FloatHttpLabels/Infinity/Infinity",
body: "",
params: {
float: "Infinity",
double: "Infinity",
}
},
{
id: "RestJsonSupportsNegativeInfinityFloatLabels",
documentation: "Supports handling -Infinity float label values.",
protocol: restJson1,
method: "GET",
uri: "/FloatHttpLabels/-Infinity/-Infinity",
body: "",
params: {
float: "-Infinity",
double: "-Infinity",
}
},
])
@readonly
@http(method: "GET", uri: "/FloatHttpLabels/{float}/{double}")
operation HttpRequestWithFloatLabels {
input: HttpRequestWithFloatLabelsInput
}
structure HttpRequestWithFloatLabelsInput {
@httpLabel
@required
float: Float,
@httpLabel
@required
double: Double,
}
apply HttpRequestWithRegexLiteral @httpRequestTests([
{
id: "RestJsonToleratesRegexCharsInSegments",
documentation: "Path matching is not broken by regex expressions in literal segments",
protocol: restJson1,
method: "GET",
uri: "/ReDosLiteral/abc/(a+)+",
body: "",
params: {
str: "abc"
}
},
])
@readonly
@http(method: "GET", uri: "/ReDosLiteral/{str}/(a+)+")
operation HttpRequestWithRegexLiteral {
input: HttpRequestWithRegexLiteralInput
}
structure HttpRequestWithRegexLiteralInput {
@httpLabel
@required
str: String
}