1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | ::pin_project_lite::pin_project! {
|
3 3 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 - | /// [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput) using modelled bindings.
|
5 - | pub struct ContentTypeParametersInputFuture {
|
6 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ContentTypeParametersInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
4 + | /// [`EmptyOperationInput`](crate::input::EmptyOperationInput) using modelled bindings.
|
5 + | pub struct EmptyOperationInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
7 7 | }
|
8 8 | }
|
9 9 |
|
10 - | impl std::future::Future for ContentTypeParametersInputFuture {
|
10 + | impl std::future::Future for EmptyOperationInputFuture {
|
11 11 | type Output = Result<
|
12 - | crate::input::ContentTypeParametersInput,
|
12 + | crate::input::EmptyOperationInput,
|
13 13 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
14 14 | >;
|
15 15 |
|
16 16 | fn poll(
|
17 17 | self: std::pin::Pin<&mut Self>,
|
18 18 | cx: &mut std::task::Context<'_>,
|
19 19 | ) -> std::task::Poll<Self::Output> {
|
20 20 | let this = self.project();
|
21 21 | this.inner.as_mut().poll(cx)
|
22 22 | }
|
23 23 | }
|
24 24 |
|
25 25 | impl<B>
|
26 26 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
27 27 | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
28 28 | B,
|
29 - | > for crate::input::ContentTypeParametersInput
|
29 + | > for crate::input::EmptyOperationInput
|
30 30 | where
|
31 31 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
32 32 | B: 'static,
|
33 33 |
|
34 34 | B::Data: Send,
|
35 35 | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
36 36 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
37 37 | {
|
38 38 | type Rejection =
|
39 39 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
40 - | type Future = ContentTypeParametersInputFuture;
|
40 + | type Future = EmptyOperationInputFuture;
|
41 41 |
|
42 42 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
43 43 | let fut = async move {
|
44 44 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
45 45 | request.headers(),
|
46 46 | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
47 47 | ) {
|
48 48 | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
49 49 | }
|
50 - | crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters_http_request(request)
|
50 + | crate::protocol_serde::shape_empty_operation::de_empty_operation_http_request(request)
|
51 51 | .await
|
52 52 | };
|
53 53 | use ::futures_util::future::TryFutureExt;
|
54 54 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
55 55 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
56 56 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
57 57 | });
|
58 - | ContentTypeParametersInputFuture {
|
58 + | EmptyOperationInputFuture {
|
59 59 | inner: Box::pin(fut),
|
60 60 | }
|
61 61 | }
|
62 62 | }
|
63 63 | impl
|
64 64 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
65 65 | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
66 - | > for crate::output::ContentTypeParametersOutput
|
66 + | > for crate::output::EmptyOperationOutput
|
67 67 | {
|
68 68 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
69 - | match crate::protocol_serde::shape_content_type_parameters::ser_content_type_parameters_http_response(self) {
|
69 + | match crate::protocol_serde::shape_empty_operation::ser_empty_operation_http_response(self)
|
70 + | {
|
70 71 | Ok(response) => response,
|
71 72 | Err(e) => {
|
72 73 | ::tracing::error!(error = %e, "failed to serialize response");
|
73 74 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
74 75 | }
|
75 76 | }
|
76 77 | }
|
77 78 | }
|
78 79 |
|
79 80 | #[allow(unreachable_code, unused_variables)]
|
80 81 | #[cfg(test)]
|
81 - | mod content_type_parameters_test {
|
82 + | mod empty_operation_test {
|
82 83 |
|
83 - | /// A server should ignore parameters added to the content type
|
84 - | /// Test ID: AwsJson11MustSupportParametersInContentType
|
84 + | /// Sends requests to /
|
85 + | /// Test ID: sends_requests_to_slash
|
85 86 | #[::tokio::test]
|
86 87 | #[::tracing_test::traced_test]
|
87 - | async fn aws_json11_must_support_parameters_in_content_type_request() {
|
88 + | async fn sends_requests_to_slash_request() {
|
88 89 | #[allow(unused_mut)]
|
89 90 | let mut http_request = ::http::Request::builder()
|
90 91 | .uri("/")
|
91 92 | .method("POST")
|
92 - | .header("Content-Type", "application/x-amz-json-1.1; charset=utf-8")
|
93 - | .header("X-Amz-Target", "JsonProtocol.ContentTypeParameters")
|
93 + | .header("Content-Type", "application/x-amz-json-1.1")
|
94 + | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
95 + | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
96 + | .unwrap();
|
97 + | #[allow(unused_mut)]
|
98 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
99 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
100 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
101 + | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
102 + | let sender = sender.clone();
|
103 + | async move {
|
104 + | let result = {
|
105 + | let expected = crate::input::EmptyOperationInput {};
|
106 + | ::pretty_assertions::assert_eq!(input, expected);
|
107 + | let output = crate::output::EmptyOperationOutput {};
|
108 + | output
|
109 + | };
|
110 + | sender.send(()).await.expect("receiver dropped early");
|
111 + | result
|
112 + | }
|
113 + | })
|
114 + | .build_unchecked();
|
115 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
116 + | .await
|
117 + | .expect("unable to make an HTTP request");
|
118 + | assert!(
|
119 + | receiver.recv().await.is_some(),
|
120 + | "we expected operation handler to be invoked but it was not entered"
|
121 + | );
|
122 + | }
|
123 + |
|
124 + | /// Includes X-Amz-Target header and Content-Type
|
125 + | /// Test ID: includes_x_amz_target_and_content_type
|
126 + | #[::tokio::test]
|
127 + | #[::tracing_test::traced_test]
|
128 + | async fn includes_x_amz_target_and_content_type_request() {
|
129 + | #[allow(unused_mut)]
|
130 + | let mut http_request = ::http::Request::builder()
|
131 + | .uri("/")
|
132 + | .method("POST")
|
133 + | .header("Content-Type", "application/x-amz-json-1.1")
|
134 + | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
135 + | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
136 + | .unwrap();
|
137 + | #[allow(unused_mut)]
|
138 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
139 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
140 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
141 + | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
142 + | let sender = sender.clone();
|
143 + | async move {
|
144 + | let result = {
|
145 + | let expected = crate::input::EmptyOperationInput {};
|
146 + | ::pretty_assertions::assert_eq!(input, expected);
|
147 + | let output = crate::output::EmptyOperationOutput {};
|
148 + | output
|
149 + | };
|
150 + | sender.send(()).await.expect("receiver dropped early");
|
151 + | result
|
152 + | }
|
153 + | })
|
154 + | .build_unchecked();
|
155 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
156 + | .await
|
157 + | .expect("unable to make an HTTP request");
|
158 + | assert!(
|
159 + | receiver.recv().await.is_some(),
|
160 + | "we expected operation handler to be invoked but it was not entered"
|
161 + | );
|
162 + | }
|
163 + |
|
164 + | /// Clients must always send an empty JSON object payload for
|
165 + | /// operations with no input (that is, `{}`). While AWS service
|
166 + | /// implementations support requests with no payload or requests
|
167 + | /// that send `{}`, always sending `{}` from the client is
|
168 + | /// preferred for forward compatibility in case input is ever
|
169 + | /// added to an operation.
|
170 + | /// Test ID: json_1_1_client_sends_empty_payload_for_no_input_shape
|
171 + | #[::tokio::test]
|
172 + | #[::tracing_test::traced_test]
|
173 + | async fn json_1_1_client_sends_empty_payload_for_no_input_shape_request() {
|
174 + | #[allow(unused_mut)]
|
175 + | let mut http_request = ::http::Request::builder()
|
176 + | .uri("/")
|
177 + | .method("POST")
|
178 + | .header("Content-Type", "application/x-amz-json-1.1")
|
179 + | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
94 180 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
95 181 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
96 - | "{\"value\":5}".as_bytes(),
|
182 + | "{}".as_bytes(),
|
97 183 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
98 184 | )),
|
99 185 | ))
|
100 186 | .unwrap();
|
101 187 | #[allow(unused_mut)]
|
102 188 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
103 189 | let config = crate::service::JsonProtocolConfig::builder().build();
|
104 190 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
105 - | .content_type_parameters(move |input: crate::input::ContentTypeParametersInput| {
|
191 + | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
106 192 | let sender = sender.clone();
|
107 193 | async move {
|
108 194 | let result = {
|
109 - | let expected = crate::input::ContentTypeParametersInput {
|
110 - | value: ::std::option::Option::Some(5),
|
195 + | let expected = crate::input::EmptyOperationInput {};
|
196 + | ::pretty_assertions::assert_eq!(input, expected);
|
197 + | let output = crate::output::EmptyOperationOutput {};
|
198 + | output
|
111 199 | };
|
200 + | sender.send(()).await.expect("receiver dropped early");
|
201 + | result
|
202 + | }
|
203 + | })
|
204 + | .build_unchecked();
|
205 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
206 + | .await
|
207 + | .expect("unable to make an HTTP request");
|
208 + | assert!(
|
209 + | receiver.recv().await.is_some(),
|
210 + | "we expected operation handler to be invoked but it was not entered"
|
211 + | );
|
212 + | }
|
213 + |
|
214 + | /// Service implementations must support no payload or an empty
|
215 + | /// object payload for operations that define no input. However,
|
216 + | /// despite the lack of a payload, a Content-Type header is still
|
217 + | /// required in order for the service to properly detect the
|
218 + | /// protocol.
|
219 + | /// Test ID: json_1_1_service_supports_empty_payload_for_no_input_shape
|
220 + | #[::tokio::test]
|
221 + | #[::tracing_test::traced_test]
|
222 + | async fn json_1_1_service_supports_empty_payload_for_no_input_shape_request() {
|
223 + | #[allow(unused_mut)]
|
224 + | let mut http_request = ::http::Request::builder()
|
225 + | .uri("/")
|
226 + | .method("POST")
|
227 + | .header("Content-Type", "application/x-amz-json-1.1")
|
228 + | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
229 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
230 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
231 + | "".as_bytes(),
|
232 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
233 + | )),
|
234 + | ))
|
235 + | .unwrap();
|
236 + | #[allow(unused_mut)]
|
237 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
238 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
239 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
240 + | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
241 + | let sender = sender.clone();
|
242 + | async move {
|
243 + | let result = {
|
244 + | let expected = crate::input::EmptyOperationInput {};
|
112 245 | ::pretty_assertions::assert_eq!(input, expected);
|
113 - | let output = crate::output::ContentTypeParametersOutput {};
|
246 + | let output = crate::output::EmptyOperationOutput {};
|
114 247 | output
|
115 248 | };
|
116 249 | sender.send(()).await.expect("receiver dropped early");
|
117 250 | result
|
118 251 | }
|
119 252 | })
|
120 253 | .build_unchecked();
|
121 254 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
122 255 | .await
|
123 256 | .expect("unable to make an HTTP request");
|
124 257 | assert!(
|
125 258 | receiver.recv().await.is_some(),
|
126 259 | "we expected operation handler to be invoked but it was not entered"
|
127 260 | );
|
128 261 | }
|
262 + |
|
263 + | /// When no output is defined, the service is expected to return
|
264 + | /// an empty payload. Despite the lack of a payload, the service
|
265 + | /// is expected to always send a Content-Type header. Clients must
|
266 + | /// handle cases where a service returns a JSON object and where
|
267 + | /// a service returns no JSON at all.
|
268 + | /// Test ID: json_1_1_service_responds_with_no_payload
|
269 + | #[::tokio::test]
|
270 + | #[::tracing_test::traced_test]
|
271 + | async fn json_1_1_service_responds_with_no_payload_response() {
|
272 + | let output = crate::output::EmptyOperationOutput {};
|
273 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
274 + | let http_response = output.into_response();
|
275 + | ::pretty_assertions::assert_eq!(
|
276 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
277 + | http_response.status()
|
278 + | );
|
279 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
280 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
281 + | http_response.headers(),
|
282 + | expected_headers,
|
283 + | ));
|
284 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
285 + | .await
|
286 + | .expect("unable to extract body to bytes");
|
287 + | // No body.
|
288 + | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
289 + | }
|
129 290 | }
|
130 291 |
|
131 292 | ::pin_project_lite::pin_project! {
|
132 293 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
133 - | /// [`PutWithContentEncodingInput`](crate::input::PutWithContentEncodingInput) using modelled bindings.
|
134 - | pub struct PutWithContentEncodingInputFuture {
|
135 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PutWithContentEncodingInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
294 + | /// [`KitchenSinkOperationInput`](crate::input::KitchenSinkOperationInput) using modelled bindings.
|
295 + | pub struct KitchenSinkOperationInputFuture {
|
296 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::KitchenSinkOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
136 297 | }
|
137 298 | }
|
138 299 |
|
139 - | impl std::future::Future for PutWithContentEncodingInputFuture {
|
300 + | impl std::future::Future for KitchenSinkOperationInputFuture {
|
140 301 | type Output = Result<
|
141 - | crate::input::PutWithContentEncodingInput,
|
302 + | crate::input::KitchenSinkOperationInput,
|
142 303 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
143 304 | >;
|
144 305 |
|
145 306 | fn poll(
|
146 307 | self: std::pin::Pin<&mut Self>,
|
147 308 | cx: &mut std::task::Context<'_>,
|
148 309 | ) -> std::task::Poll<Self::Output> {
|
149 310 | let this = self.project();
|
150 311 | this.inner.as_mut().poll(cx)
|
151 312 | }
|
152 313 | }
|
153 314 |
|
154 315 | impl<B>
|
155 316 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
156 317 | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
157 318 | B,
|
158 - | > for crate::input::PutWithContentEncodingInput
|
319 + | > for crate::input::KitchenSinkOperationInput
|
159 320 | where
|
160 321 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
161 322 | B: 'static,
|
162 323 |
|
163 324 | B::Data: Send,
|
164 325 | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
165 326 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
166 327 | {
|
167 328 | type Rejection =
|
168 329 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
169 - | type Future = PutWithContentEncodingInputFuture;
|
330 + | type Future = KitchenSinkOperationInputFuture;
|
170 331 |
|
171 332 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
172 333 | let fut = async move {
|
173 334 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
174 335 | request.headers(),
|
175 336 | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
176 337 | ) {
|
177 338 | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
178 339 | }
|
179 - | crate::protocol_serde::shape_put_with_content_encoding::de_put_with_content_encoding_http_request(request)
|
340 + | crate::protocol_serde::shape_kitchen_sink_operation::de_kitchen_sink_operation_http_request(request)
|
180 341 | .await
|
181 342 | };
|
182 343 | use ::futures_util::future::TryFutureExt;
|
183 344 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
184 345 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
185 346 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
186 347 | });
|
187 - | PutWithContentEncodingInputFuture {
|
348 + | KitchenSinkOperationInputFuture {
|
188 349 | inner: Box::pin(fut),
|
189 350 | }
|
190 351 | }
|
191 352 | }
|
192 353 | impl
|
193 354 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
194 355 | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
195 - | > for crate::output::PutWithContentEncodingOutput
|
356 + | > for crate::output::KitchenSinkOperationOutput
|
196 357 | {
|
197 358 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
198 - | match crate::protocol_serde::shape_put_with_content_encoding::ser_put_with_content_encoding_http_response(self) {
|
359 + | match crate::protocol_serde::shape_kitchen_sink_operation::ser_kitchen_sink_operation_http_response(self) {
|
199 360 | Ok(response) => response,
|
200 361 | Err(e) => {
|
201 362 | ::tracing::error!(error = %e, "failed to serialize response");
|
202 363 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
203 364 | }
|
204 365 | }
|
205 366 | }
|
206 367 | }
|
207 - |
|
208 - | ::pin_project_lite::pin_project! {
|
209 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
210 - | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
211 - | pub struct FractionalSecondsInputFuture {
|
212 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
213 - | }
|
214 - | }
|
215 - |
|
216 - | impl std::future::Future for FractionalSecondsInputFuture {
|
217 - | type Output = Result<
|
218 - | crate::input::FractionalSecondsInput,
|
219 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
220 - | >;
|
221 - |
|
222 - | fn poll(
|
223 - | self: std::pin::Pin<&mut Self>,
|
224 - | cx: &mut std::task::Context<'_>,
|
225 - | ) -> std::task::Poll<Self::Output> {
|
226 - | let this = self.project();
|
227 - | this.inner.as_mut().poll(cx)
|
228 - | }
|
229 - | }
|
230 - |
|
231 - | impl<B>
|
232 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
233 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
234 - | B,
|
235 - | > for crate::input::FractionalSecondsInput
|
236 - | where
|
237 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
238 - | B: 'static,
|
239 - |
|
240 - | B::Data: Send,
|
241 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
242 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
243 - | {
|
244 - | type Rejection =
|
245 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
246 - | type Future = FractionalSecondsInputFuture;
|
247 - |
|
248 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
249 - | let fut = async move {
|
250 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
251 - | request.headers(),
|
252 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
253 - | ) {
|
254 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
255 - | }
|
256 - | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
257 - | request,
|
258 - | )
|
259 - | .await
|
260 - | };
|
261 - | use ::futures_util::future::TryFutureExt;
|
262 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
263 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
264 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
265 - | });
|
266 - | FractionalSecondsInputFuture {
|
267 - | inner: Box::pin(fut),
|
268 - | }
|
269 - | }
|
270 - | }
|
271 - | impl
|
272 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
273 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
274 - | > for crate::output::FractionalSecondsOutput
|
275 - | {
|
276 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
277 - | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
278 - | self,
|
279 - | ) {
|
280 - | Ok(response) => response,
|
281 - | Err(e) => {
|
282 - | ::tracing::error!(error = %e, "failed to serialize response");
|
283 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
284 - | }
|
285 - | }
|
286 - | }
|
287 - | }
|
288 - |
|
289 - | ::pin_project_lite::pin_project! {
|
290 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
291 - | /// [`DatetimeOffsetsInput`](crate::input::DatetimeOffsetsInput) using modelled bindings.
|
292 - | pub struct DatetimeOffsetsInputFuture {
|
293 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::DatetimeOffsetsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
294 - | }
|
295 - | }
|
296 - |
|
297 - | impl std::future::Future for DatetimeOffsetsInputFuture {
|
298 - | type Output = Result<
|
299 - | crate::input::DatetimeOffsetsInput,
|
300 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
301 - | >;
|
302 - |
|
303 - | fn poll(
|
304 - | self: std::pin::Pin<&mut Self>,
|
305 - | cx: &mut std::task::Context<'_>,
|
306 - | ) -> std::task::Poll<Self::Output> {
|
307 - | let this = self.project();
|
308 - | this.inner.as_mut().poll(cx)
|
309 - | }
|
310 - | }
|
311 - |
|
312 - | impl<B>
|
313 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
314 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
315 - | B,
|
316 - | > for crate::input::DatetimeOffsetsInput
|
317 - | where
|
318 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
319 - | B: 'static,
|
320 - |
|
321 - | B::Data: Send,
|
322 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
323 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
324 - | {
|
325 - | type Rejection =
|
326 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
327 - | type Future = DatetimeOffsetsInputFuture;
|
328 - |
|
329 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
330 - | let fut = async move {
|
331 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
332 - | request.headers(),
|
333 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
334 - | ) {
|
335 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
336 - | }
|
337 - | crate::protocol_serde::shape_datetime_offsets::de_datetime_offsets_http_request(request)
|
338 - | .await
|
339 - | };
|
340 - | use ::futures_util::future::TryFutureExt;
|
341 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
342 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
343 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
344 - | });
|
345 - | DatetimeOffsetsInputFuture {
|
346 - | inner: Box::pin(fut),
|
347 - | }
|
348 - | }
|
349 - | }
|
350 - | impl
|
351 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
352 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
353 - | > for crate::output::DatetimeOffsetsOutput
|
354 - | {
|
355 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
356 - | match crate::protocol_serde::shape_datetime_offsets::ser_datetime_offsets_http_response(
|
357 - | self,
|
358 - | ) {
|
359 - | Ok(response) => response,
|
360 - | Err(e) => {
|
361 - | ::tracing::error!(error = %e, "failed to serialize response");
|
362 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
363 - | }
|
364 - | }
|
365 - | }
|
366 - | }
|
367 - |
|
368 - | ::pin_project_lite::pin_project! {
|
369 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
370 - | /// [`HostWithPathOperationInput`](crate::input::HostWithPathOperationInput) using modelled bindings.
|
371 - | pub struct HostWithPathOperationInputFuture {
|
372 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HostWithPathOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
373 - | }
|
374 - | }
|
375 - |
|
376 - | impl std::future::Future for HostWithPathOperationInputFuture {
|
377 - | type Output = Result<
|
378 - | crate::input::HostWithPathOperationInput,
|
379 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
380 - | >;
|
381 - |
|
382 - | fn poll(
|
383 - | self: std::pin::Pin<&mut Self>,
|
384 - | cx: &mut std::task::Context<'_>,
|
385 - | ) -> std::task::Poll<Self::Output> {
|
386 - | let this = self.project();
|
387 - | this.inner.as_mut().poll(cx)
|
388 - | }
|
389 - | }
|
390 - |
|
391 - | impl<B>
|
392 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
393 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
394 - | B,
|
395 - | > for crate::input::HostWithPathOperationInput
|
396 - | where
|
397 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
398 - | B: 'static,
|
399 - |
|
400 - | B::Data: Send,
|
401 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
402 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
403 - | {
|
404 - | type Rejection =
|
405 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
406 - | type Future = HostWithPathOperationInputFuture;
|
407 - |
|
408 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
409 - | let fut = async move {
|
410 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
411 - | request.headers(),
|
412 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
413 - | ) {
|
414 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
415 - | }
|
416 - | crate::protocol_serde::shape_host_with_path_operation::de_host_with_path_operation_http_request(request)
|
417 - | .await
|
418 - | };
|
419 - | use ::futures_util::future::TryFutureExt;
|
420 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
421 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
422 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
423 - | });
|
424 - | HostWithPathOperationInputFuture {
|
425 - | inner: Box::pin(fut),
|
426 - | }
|
427 - | }
|
428 - | }
|
429 - | impl
|
430 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
431 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
432 - | > for crate::output::HostWithPathOperationOutput
|
433 - | {
|
434 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
435 - | match crate::protocol_serde::shape_host_with_path_operation::ser_host_with_path_operation_http_response(self) {
|
436 - | Ok(response) => response,
|
437 - | Err(e) => {
|
438 - | ::tracing::error!(error = %e, "failed to serialize response");
|
439 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
440 - | }
|
441 - | }
|
442 - | }
|
443 - | }
|
444 - |
|
445 - | ::pin_project_lite::pin_project! {
|
446 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
447 - | /// [`EndpointWithHostLabelOperationInput`](crate::input::EndpointWithHostLabelOperationInput) using modelled bindings.
|
448 - | pub struct EndpointWithHostLabelOperationInputFuture {
|
449 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EndpointWithHostLabelOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
450 - | }
|
451 - | }
|
452 - |
|
453 - | impl std::future::Future for EndpointWithHostLabelOperationInputFuture {
|
454 - | type Output = Result<
|
455 - | crate::input::EndpointWithHostLabelOperationInput,
|
456 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
457 - | >;
|
458 - |
|
459 - | fn poll(
|
460 - | self: std::pin::Pin<&mut Self>,
|
461 - | cx: &mut std::task::Context<'_>,
|
462 - | ) -> std::task::Poll<Self::Output> {
|
463 - | let this = self.project();
|
464 - | this.inner.as_mut().poll(cx)
|
465 - | }
|
466 - | }
|
467 - |
|
468 - | impl<B>
|
469 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
470 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
471 - | B,
|
472 - | > for crate::input::EndpointWithHostLabelOperationInput
|
473 - | where
|
474 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
475 - | B: 'static,
|
476 - |
|
477 - | B::Data: Send,
|
478 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
479 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
480 - | {
|
481 - | type Rejection =
|
482 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
483 - | type Future = EndpointWithHostLabelOperationInputFuture;
|
484 - |
|
485 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
486 - | let fut = async move {
|
487 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
488 - | request.headers(),
|
489 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
490 - | ) {
|
491 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
492 - | }
|
493 - | crate::protocol_serde::shape_endpoint_with_host_label_operation::de_endpoint_with_host_label_operation_http_request(request)
|
494 - | .await
|
495 - | };
|
496 - | use ::futures_util::future::TryFutureExt;
|
497 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
498 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
499 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
500 - | });
|
501 - | EndpointWithHostLabelOperationInputFuture {
|
502 - | inner: Box::pin(fut),
|
503 - | }
|
504 - | }
|
505 - | }
|
506 - | impl
|
507 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
508 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
509 - | > for crate::output::EndpointWithHostLabelOperationOutput
|
510 - | {
|
511 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
512 - | match crate::protocol_serde::shape_endpoint_with_host_label_operation::ser_endpoint_with_host_label_operation_http_response(self) {
|
513 - | Ok(response) => response,
|
514 - | Err(e) => {
|
515 - | ::tracing::error!(error = %e, "failed to serialize response");
|
516 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
517 - | }
|
518 - | }
|
519 - | }
|
520 - | }
|
521 - | impl
|
522 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
523 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
524 - | > for crate::error::EndpointWithHostLabelOperationError
|
525 - | {
|
526 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
527 - | match crate::protocol_serde::shape_endpoint_with_host_label_operation::ser_endpoint_with_host_label_operation_http_error(&self) {
|
528 - | Ok(mut response) => {
|
529 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
530 - | response
|
531 - | },
|
532 - | Err(e) => {
|
533 - | ::tracing::error!(error = %e, "failed to serialize response");
|
534 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
535 - | }
|
536 - | }
|
537 - | }
|
538 - | }
|
539 - |
|
540 - | #[allow(unreachable_code, unused_variables)]
|
541 - | #[cfg(test)]
|
542 - | mod endpoint_with_host_label_operation_test {
|
543 - |
|
544 - | /// Operations can prepend to the given host if they define the
|
545 - | /// endpoint trait, and can use the host label trait to define
|
546 - | /// further customization based on user input.
|
547 - | /// Test ID: AwsJson11EndpointTraitWithHostLabel
|
548 - | #[::tokio::test]
|
549 - | #[::tracing_test::traced_test]
|
550 - | #[should_panic]
|
551 - | async fn aws_json11_endpoint_trait_with_host_label_request() {
|
552 - | #[allow(unused_mut)]
|
553 - | let mut http_request = ::http::Request::builder()
|
554 - | .uri("/")
|
555 - | .method("POST")
|
556 - | .header("Content-Type", "application/x-amz-json-1.1")
|
557 - | .header(
|
558 - | "X-Amz-Target",
|
559 - | "JsonProtocol.EndpointWithHostLabelOperation",
|
560 - | )
|
561 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
562 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
563 - | "{\"label\": \"bar\"}".as_bytes(),
|
564 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
565 - | )),
|
566 - | ))
|
567 - | .unwrap();
|
568 - | todo!("endpoint trait not supported yet");
|
569 - | #[allow(unused_mut)]
|
570 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
571 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
572 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
573 - | .endpoint_with_host_label_operation(
|
574 - | move |input: crate::input::EndpointWithHostLabelOperationInput| {
|
575 - | let sender = sender.clone();
|
576 - | async move {
|
577 - | let result = {
|
578 - | let expected = crate::input::EndpointWithHostLabelOperationInput {
|
579 - | label: "bar".to_owned(),
|
580 - | };
|
581 - | ::pretty_assertions::assert_eq!(input, expected);
|
582 - | let output = crate::output::EndpointWithHostLabelOperationOutput {};
|
583 - | Ok(output)
|
584 - | };
|
585 - | sender.send(()).await.expect("receiver dropped early");
|
586 - | result
|
587 - | }
|
588 - | },
|
589 - | )
|
590 - | .build_unchecked();
|
591 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
592 - | .await
|
593 - | .expect("unable to make an HTTP request");
|
594 - | assert!(
|
595 - | receiver.recv().await.is_some(),
|
596 - | "we expected operation handler to be invoked but it was not entered"
|
597 - | );
|
598 - | }
|
599 - | }
|
600 - |
|
601 - | ::pin_project_lite::pin_project! {
|
602 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
603 - | /// [`EndpointOperationInput`](crate::input::EndpointOperationInput) using modelled bindings.
|
604 - | pub struct EndpointOperationInputFuture {
|
605 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EndpointOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
606 - | }
|
607 - | }
|
608 - |
|
609 - | impl std::future::Future for EndpointOperationInputFuture {
|
610 - | type Output = Result<
|
611 - | crate::input::EndpointOperationInput,
|
612 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
613 - | >;
|
614 - |
|
615 - | fn poll(
|
616 - | self: std::pin::Pin<&mut Self>,
|
617 - | cx: &mut std::task::Context<'_>,
|
618 - | ) -> std::task::Poll<Self::Output> {
|
619 - | let this = self.project();
|
620 - | this.inner.as_mut().poll(cx)
|
621 - | }
|
622 - | }
|
623 - |
|
624 - | impl<B>
|
625 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
626 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
627 - | B,
|
628 - | > for crate::input::EndpointOperationInput
|
629 - | where
|
630 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
631 - | B: 'static,
|
632 - |
|
633 - | B::Data: Send,
|
634 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
635 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
636 - | {
|
637 - | type Rejection =
|
638 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
639 - | type Future = EndpointOperationInputFuture;
|
640 - |
|
641 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
642 - | let fut = async move {
|
643 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
644 - | request.headers(),
|
645 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
646 - | ) {
|
647 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
648 - | }
|
649 - | crate::protocol_serde::shape_endpoint_operation::de_endpoint_operation_http_request(
|
650 - | request,
|
651 - | )
|
652 - | .await
|
653 - | };
|
654 - | use ::futures_util::future::TryFutureExt;
|
655 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
656 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
657 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
658 - | });
|
659 - | EndpointOperationInputFuture {
|
660 - | inner: Box::pin(fut),
|
661 - | }
|
662 - | }
|
663 - | }
|
664 - | impl
|
665 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
666 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
667 - | > for crate::output::EndpointOperationOutput
|
668 - | {
|
669 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
670 - | match crate::protocol_serde::shape_endpoint_operation::ser_endpoint_operation_http_response(
|
671 - | self,
|
672 - | ) {
|
673 - | Ok(response) => response,
|
674 - | Err(e) => {
|
675 - | ::tracing::error!(error = %e, "failed to serialize response");
|
676 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
677 - | }
|
678 - | }
|
679 - | }
|
680 - | }
|
681 - |
|
682 - | #[allow(unreachable_code, unused_variables)]
|
683 - | #[cfg(test)]
|
684 - | mod endpoint_operation_test {
|
685 - |
|
686 - | /// Operations can prepend to the given host if they define the
|
687 - | /// endpoint trait.
|
688 - | /// Test ID: AwsJson11EndpointTrait
|
689 - | #[::tokio::test]
|
690 - | #[::tracing_test::traced_test]
|
691 - | #[should_panic]
|
692 - | async fn aws_json11_endpoint_trait_request() {
|
693 - | #[allow(unused_mut)]
|
694 - | let mut http_request = ::http::Request::builder()
|
695 - | .uri("/")
|
696 - | .method("POST")
|
697 - | .header("Content-Type", "application/x-amz-json-1.1")
|
698 - | .header("X-Amz-Target", "JsonProtocol.EndpointOperation")
|
699 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
700 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
701 - | "{}".as_bytes(),
|
702 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
703 - | )),
|
704 - | ))
|
705 - | .unwrap();
|
706 - | todo!("endpoint trait not supported yet");
|
707 - | #[allow(unused_mut)]
|
708 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
709 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
710 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
711 - | .endpoint_operation(move |input: crate::input::EndpointOperationInput| {
|
712 - | let sender = sender.clone();
|
713 - | async move {
|
714 - | let result = {
|
715 - | let expected = crate::input::EndpointOperationInput {};
|
716 - | ::pretty_assertions::assert_eq!(input, expected);
|
717 - | let output = crate::output::EndpointOperationOutput {};
|
718 - | output
|
719 - | };
|
720 - | sender.send(()).await.expect("receiver dropped early");
|
721 - | result
|
722 - | }
|
723 - | })
|
724 - | .build_unchecked();
|
725 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
726 - | .await
|
727 - | .expect("unable to make an HTTP request");
|
728 - | assert!(
|
729 - | receiver.recv().await.is_some(),
|
730 - | "we expected operation handler to be invoked but it was not entered"
|
731 - | );
|
732 - | }
|
733 - | }
|
734 - |
|
735 - | ::pin_project_lite::pin_project! {
|
736 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
737 - | /// [`JsonUnionsInput`](crate::input::JsonUnionsInput) using modelled bindings.
|
738 - | pub struct JsonUnionsInputFuture {
|
739 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::JsonUnionsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
740 - | }
|
741 - | }
|
742 - |
|
743 - | impl std::future::Future for JsonUnionsInputFuture {
|
744 - | type Output = Result<
|
745 - | crate::input::JsonUnionsInput,
|
746 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
747 - | >;
|
748 - |
|
749 - | fn poll(
|
750 - | self: std::pin::Pin<&mut Self>,
|
751 - | cx: &mut std::task::Context<'_>,
|
752 - | ) -> std::task::Poll<Self::Output> {
|
753 - | let this = self.project();
|
754 - | this.inner.as_mut().poll(cx)
|
755 - | }
|
756 - | }
|
757 - |
|
758 - | impl<B>
|
759 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
760 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
761 - | B,
|
762 - | > for crate::input::JsonUnionsInput
|
763 - | where
|
764 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
765 - | B: 'static,
|
766 - |
|
767 - | B::Data: Send,
|
768 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
769 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
770 - | {
|
771 - | type Rejection =
|
772 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
773 - | type Future = JsonUnionsInputFuture;
|
774 - |
|
775 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
776 - | let fut = async move {
|
777 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
778 - | request.headers(),
|
779 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
780 - | ) {
|
781 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
782 - | }
|
783 - | crate::protocol_serde::shape_json_unions::de_json_unions_http_request(request).await
|
784 - | };
|
785 - | use ::futures_util::future::TryFutureExt;
|
786 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
787 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
788 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
789 - | });
|
790 - | JsonUnionsInputFuture {
|
791 - | inner: Box::pin(fut),
|
792 - | }
|
793 - | }
|
794 - | }
|
795 - | impl
|
796 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
797 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
798 - | > for crate::output::JsonUnionsOutput
|
799 - | {
|
800 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
801 - | match crate::protocol_serde::shape_json_unions::ser_json_unions_http_response(self) {
|
802 - | Ok(response) => response,
|
803 - | Err(e) => {
|
804 - | ::tracing::error!(error = %e, "failed to serialize response");
|
805 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
806 - | }
|
807 - | }
|
808 - | }
|
809 - | }
|
810 - | impl
|
811 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
812 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
813 - | > for crate::error::JsonUnionsError
|
814 - | {
|
815 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
816 - | match crate::protocol_serde::shape_json_unions::ser_json_unions_http_error(&self) {
|
817 - | Ok(mut response) => {
|
818 - | response.extensions_mut().insert(
|
819 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
820 - | self.name(),
|
821 - | ),
|
822 - | );
|
823 - | response
|
824 - | }
|
825 - | Err(e) => {
|
826 - | ::tracing::error!(error = %e, "failed to serialize response");
|
827 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
828 - | }
|
829 - | }
|
830 - | }
|
831 - | }
|
832 - |
|
833 - | #[allow(unreachable_code, unused_variables)]
|
834 - | #[cfg(test)]
|
835 - | mod json_unions_test {
|
836 - |
|
837 - | /// Serializes a string union value
|
838 - | /// Test ID: AwsJson11SerializeStringUnionValue
|
839 - | #[::tokio::test]
|
840 - | #[::tracing_test::traced_test]
|
841 - | async fn aws_json11_serialize_string_union_value_request() {
|
842 - | #[allow(unused_mut)]
|
843 - | let mut http_request = ::http::Request::builder()
|
844 - | .uri("/")
|
845 - | .method("POST")
|
846 - | .header("Content-Type", "application/x-amz-json-1.1")
|
847 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
848 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
849 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
850 - | "{\n \"contents\": {\n \"stringValue\": \"foo\"\n }\n}".as_bytes(),
|
851 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
852 - | )),
|
853 - | ))
|
854 - | .unwrap();
|
855 - | #[allow(unused_mut)]
|
856 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
857 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
858 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
859 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
860 - | let sender = sender.clone();
|
861 - | async move {
|
862 - | let result = {
|
863 - | let expected = crate::input::JsonUnionsInput {
|
864 - | contents: ::std::option::Option::Some(
|
865 - | crate::model::MyUnion::StringValue("foo".to_owned()),
|
866 - | ),
|
867 - | };
|
868 - | ::pretty_assertions::assert_eq!(input, expected);
|
869 - | let output = crate::output::JsonUnionsOutput {
|
870 - | contents: ::std::option::Option::None,
|
871 - | };
|
872 - | Ok(output)
|
873 - | };
|
874 - | sender.send(()).await.expect("receiver dropped early");
|
875 - | result
|
876 - | }
|
877 - | })
|
878 - | .build_unchecked();
|
879 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
880 - | .await
|
881 - | .expect("unable to make an HTTP request");
|
882 - | assert!(
|
883 - | receiver.recv().await.is_some(),
|
884 - | "we expected operation handler to be invoked but it was not entered"
|
885 - | );
|
886 - | }
|
887 - |
|
888 - | /// Serializes a boolean union value
|
889 - | /// Test ID: AwsJson11SerializeBooleanUnionValue
|
890 - | #[::tokio::test]
|
891 - | #[::tracing_test::traced_test]
|
892 - | async fn aws_json11_serialize_boolean_union_value_request() {
|
893 - | #[allow(unused_mut)]
|
894 - | let mut http_request = ::http::Request::builder()
|
895 - | .uri("/")
|
896 - | .method("POST")
|
897 - | .header("Content-Type", "application/x-amz-json-1.1")
|
898 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
899 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
900 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
901 - | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}".as_bytes(),
|
902 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
903 - | )),
|
904 - | ))
|
905 - | .unwrap();
|
906 - | #[allow(unused_mut)]
|
907 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
908 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
909 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
910 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
911 - | let sender = sender.clone();
|
912 - | async move {
|
913 - | let result = {
|
914 - | let expected = crate::input::JsonUnionsInput {
|
915 - | contents: ::std::option::Option::Some(
|
916 - | crate::model::MyUnion::BooleanValue(true),
|
917 - | ),
|
918 - | };
|
919 - | ::pretty_assertions::assert_eq!(input, expected);
|
920 - | let output = crate::output::JsonUnionsOutput {
|
921 - | contents: ::std::option::Option::None,
|
922 - | };
|
923 - | Ok(output)
|
924 - | };
|
925 - | sender.send(()).await.expect("receiver dropped early");
|
926 - | result
|
927 - | }
|
928 - | })
|
929 - | .build_unchecked();
|
930 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
931 - | .await
|
932 - | .expect("unable to make an HTTP request");
|
933 - | assert!(
|
934 - | receiver.recv().await.is_some(),
|
935 - | "we expected operation handler to be invoked but it was not entered"
|
936 - | );
|
937 - | }
|
938 - |
|
939 - | /// Serializes a number union value
|
940 - | /// Test ID: AwsJson11SerializeNumberUnionValue
|
941 - | #[::tokio::test]
|
942 - | #[::tracing_test::traced_test]
|
943 - | async fn aws_json11_serialize_number_union_value_request() {
|
944 - | #[allow(unused_mut)]
|
945 - | let mut http_request = ::http::Request::builder()
|
946 - | .uri("/")
|
947 - | .method("POST")
|
948 - | .header("Content-Type", "application/x-amz-json-1.1")
|
949 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
950 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
951 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
952 - | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}".as_bytes(),
|
953 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
954 - | )),
|
955 - | ))
|
956 - | .unwrap();
|
957 - | #[allow(unused_mut)]
|
958 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
959 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
960 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
961 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
962 - | let sender = sender.clone();
|
963 - | async move {
|
964 - | let result = {
|
965 - | let expected = crate::input::JsonUnionsInput {
|
966 - | contents: ::std::option::Option::Some(
|
967 - | crate::model::MyUnion::NumberValue(1),
|
968 - | ),
|
969 - | };
|
970 - | ::pretty_assertions::assert_eq!(input, expected);
|
971 - | let output = crate::output::JsonUnionsOutput {
|
972 - | contents: ::std::option::Option::None,
|
973 - | };
|
974 - | Ok(output)
|
975 - | };
|
976 - | sender.send(()).await.expect("receiver dropped early");
|
977 - | result
|
978 - | }
|
979 - | })
|
980 - | .build_unchecked();
|
981 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
982 - | .await
|
983 - | .expect("unable to make an HTTP request");
|
984 - | assert!(
|
985 - | receiver.recv().await.is_some(),
|
986 - | "we expected operation handler to be invoked but it was not entered"
|
987 - | );
|
988 - | }
|
989 - |
|
990 - | /// Serializes a blob union value
|
991 - | /// Test ID: AwsJson11SerializeBlobUnionValue
|
992 - | #[::tokio::test]
|
993 - | #[::tracing_test::traced_test]
|
994 - | async fn aws_json11_serialize_blob_union_value_request() {
|
995 - | #[allow(unused_mut)]
|
996 - | let mut http_request = ::http::Request::builder()
|
997 - | .uri("/")
|
998 - | .method("POST")
|
999 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1000 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
1001 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1002 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1003 - | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}".as_bytes(),
|
1004 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1005 - | )),
|
1006 - | ))
|
1007 - | .unwrap();
|
1008 - | #[allow(unused_mut)]
|
1009 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1010 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1011 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1012 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1013 - | let sender = sender.clone();
|
1014 - | async move {
|
1015 - | let result = {
|
1016 - | let expected = crate::input::JsonUnionsInput {
|
1017 - | contents: ::std::option::Option::Some(
|
1018 - | crate::model::MyUnion::BlobValue(::aws_smithy_types::Blob::new(
|
1019 - | "foo",
|
1020 - | )),
|
1021 - | ),
|
1022 - | };
|
1023 - | ::pretty_assertions::assert_eq!(input, expected);
|
1024 - | let output = crate::output::JsonUnionsOutput {
|
1025 - | contents: ::std::option::Option::None,
|
1026 - | };
|
1027 - | Ok(output)
|
1028 - | };
|
1029 - | sender.send(()).await.expect("receiver dropped early");
|
1030 - | result
|
1031 - | }
|
1032 - | })
|
1033 - | .build_unchecked();
|
1034 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1035 - | .await
|
1036 - | .expect("unable to make an HTTP request");
|
1037 - | assert!(
|
1038 - | receiver.recv().await.is_some(),
|
1039 - | "we expected operation handler to be invoked but it was not entered"
|
1040 - | );
|
1041 - | }
|
1042 - |
|
1043 - | /// Serializes a timestamp union value
|
1044 - | /// Test ID: AwsJson11SerializeTimestampUnionValue
|
1045 - | #[::tokio::test]
|
1046 - | #[::tracing_test::traced_test]
|
1047 - | async fn aws_json11_serialize_timestamp_union_value_request() {
|
1048 - | #[allow(unused_mut)]
|
1049 - | let mut http_request = ::http::Request::builder()
|
1050 - | .uri("/")
|
1051 - | .method("POST")
|
1052 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1053 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
1054 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1055 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1056 - | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}"
|
1057 - | .as_bytes(),
|
1058 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1059 - | )),
|
1060 - | ))
|
1061 - | .unwrap();
|
1062 - | #[allow(unused_mut)]
|
1063 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1064 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1065 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1066 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1067 - | let sender = sender.clone();
|
1068 - | async move {
|
1069 - | let result = {
|
1070 - | let expected = crate::input::JsonUnionsInput {
|
1071 - | contents: ::std::option::Option::Some(
|
1072 - | crate::model::MyUnion::TimestampValue(
|
1073 - | ::aws_smithy_types::DateTime::from_fractional_secs(
|
1074 - | 1398796238, 0_f64,
|
1075 - | ),
|
1076 - | ),
|
1077 - | ),
|
1078 - | };
|
1079 - | ::pretty_assertions::assert_eq!(input, expected);
|
1080 - | let output = crate::output::JsonUnionsOutput {
|
1081 - | contents: ::std::option::Option::None,
|
1082 - | };
|
1083 - | Ok(output)
|
1084 - | };
|
1085 - | sender.send(()).await.expect("receiver dropped early");
|
1086 - | result
|
1087 - | }
|
1088 - | })
|
1089 - | .build_unchecked();
|
1090 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1091 - | .await
|
1092 - | .expect("unable to make an HTTP request");
|
1093 - | assert!(
|
1094 - | receiver.recv().await.is_some(),
|
1095 - | "we expected operation handler to be invoked but it was not entered"
|
1096 - | );
|
1097 - | }
|
1098 - |
|
1099 - | /// Serializes an enum union value
|
1100 - | /// Test ID: AwsJson11SerializeEnumUnionValue
|
1101 - | #[::tokio::test]
|
1102 - | #[::tracing_test::traced_test]
|
1103 - | async fn aws_json11_serialize_enum_union_value_request() {
|
1104 - | #[allow(unused_mut)]
|
1105 - | let mut http_request = ::http::Request::builder()
|
1106 - | .uri("/")
|
1107 - | .method("POST")
|
1108 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1109 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
1110 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1111 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1112 - | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}".as_bytes(),
|
1113 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1114 - | )),
|
1115 - | ))
|
1116 - | .unwrap();
|
1117 - | #[allow(unused_mut)]
|
1118 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1119 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1120 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1121 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1122 - | let sender = sender.clone();
|
1123 - | async move {
|
1124 - | let result = {
|
1125 - | let expected = crate::input::JsonUnionsInput {
|
1126 - | contents: ::std::option::Option::Some(
|
1127 - | crate::model::MyUnion::EnumValue(
|
1128 - | "Foo"
|
1129 - | .parse::<crate::model::FooEnum>()
|
1130 - | .expect("static value validated to member"),
|
1131 - | ),
|
1132 - | ),
|
1133 - | };
|
1134 - | ::pretty_assertions::assert_eq!(input, expected);
|
1135 - | let output = crate::output::JsonUnionsOutput {
|
1136 - | contents: ::std::option::Option::None,
|
1137 - | };
|
1138 - | Ok(output)
|
1139 - | };
|
1140 - | sender.send(()).await.expect("receiver dropped early");
|
1141 - | result
|
1142 - | }
|
1143 - | })
|
1144 - | .build_unchecked();
|
1145 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1146 - | .await
|
1147 - | .expect("unable to make an HTTP request");
|
1148 - | assert!(
|
1149 - | receiver.recv().await.is_some(),
|
1150 - | "we expected operation handler to be invoked but it was not entered"
|
1151 - | );
|
1152 - | }
|
1153 - |
|
1154 - | /// Serializes a list union value
|
1155 - | /// Test ID: AwsJson11SerializeListUnionValue
|
1156 - | #[::tokio::test]
|
1157 - | #[::tracing_test::traced_test]
|
1158 - | async fn aws_json11_serialize_list_union_value_request() {
|
1159 - | #[allow(unused_mut)]
|
1160 - | let mut http_request = ::http::Request::builder()
|
1161 - | .uri("/")
|
1162 - | .method("POST")
|
1163 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1164 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
1165 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1166 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1167 - | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}"
|
1168 - | .as_bytes(),
|
1169 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1170 - | )),
|
1171 - | ))
|
1172 - | .unwrap();
|
1173 - | #[allow(unused_mut)]
|
1174 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1175 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1176 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1177 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1178 - | let sender = sender.clone();
|
1179 - | async move {
|
1180 - | let result = {
|
1181 - | let expected = crate::input::JsonUnionsInput {
|
1182 - | contents: ::std::option::Option::Some(
|
1183 - | crate::model::MyUnion::ListValue(vec![
|
1184 - | "foo".to_owned(),
|
1185 - | "bar".to_owned(),
|
1186 - | ]),
|
1187 - | ),
|
1188 - | };
|
1189 - | ::pretty_assertions::assert_eq!(input, expected);
|
1190 - | let output = crate::output::JsonUnionsOutput {
|
1191 - | contents: ::std::option::Option::None,
|
1192 - | };
|
1193 - | Ok(output)
|
1194 - | };
|
1195 - | sender.send(()).await.expect("receiver dropped early");
|
1196 - | result
|
1197 - | }
|
1198 - | })
|
1199 - | .build_unchecked();
|
1200 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1201 - | .await
|
1202 - | .expect("unable to make an HTTP request");
|
1203 - | assert!(
|
1204 - | receiver.recv().await.is_some(),
|
1205 - | "we expected operation handler to be invoked but it was not entered"
|
1206 - | );
|
1207 - | }
|
1208 - |
|
1209 - | /// Serializes a map union value
|
1210 - | /// Test ID: AwsJson11SerializeMapUnionValue
|
1211 - | #[::tokio::test]
|
1212 - | #[::tracing_test::traced_test]
|
1213 - | async fn aws_json11_serialize_map_union_value_request() {
|
1214 - | #[allow(unused_mut)]
|
1215 - | let mut http_request = ::http::Request::builder()
|
1216 - | .uri("/")
|
1217 - | .method("POST")
|
1218 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1219 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
1220 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1221 - | ::bytes::Bytes::copy_from_slice(
|
1222 - | &::aws_smithy_protocol_test::decode_body_data("{\n \"contents\": {\n \"mapValue\": {\n \"foo\": \"bar\",\n \"spam\": \"eggs\"\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1223 - | )
|
1224 - | )).unwrap();
|
1225 - | #[allow(unused_mut)]
|
1226 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1227 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1228 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1229 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1230 - | let sender = sender.clone();
|
1231 - | async move {
|
1232 - | let result = {
|
1233 - | let expected = crate::input::JsonUnionsInput {
|
1234 - | contents: ::std::option::Option::Some(crate::model::MyUnion::MapValue(
|
1235 - | {
|
1236 - | let mut ret = ::std::collections::HashMap::new();
|
1237 - | ret.insert("foo".to_owned(), "bar".to_owned());
|
1238 - | ret.insert("spam".to_owned(), "eggs".to_owned());
|
1239 - | ret
|
1240 - | },
|
1241 - | )),
|
1242 - | };
|
1243 - | ::pretty_assertions::assert_eq!(input, expected);
|
1244 - | let output = crate::output::JsonUnionsOutput {
|
1245 - | contents: ::std::option::Option::None,
|
1246 - | };
|
1247 - | Ok(output)
|
1248 - | };
|
1249 - | sender.send(()).await.expect("receiver dropped early");
|
1250 - | result
|
1251 - | }
|
1252 - | })
|
1253 - | .build_unchecked();
|
1254 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1255 - | .await
|
1256 - | .expect("unable to make an HTTP request");
|
1257 - | assert!(
|
1258 - | receiver.recv().await.is_some(),
|
1259 - | "we expected operation handler to be invoked but it was not entered"
|
1260 - | );
|
1261 - | }
|
1262 - |
|
1263 - | /// Serializes a structure union value
|
1264 - | /// Test ID: AwsJson11SerializeStructureUnionValue
|
1265 - | #[::tokio::test]
|
1266 - | #[::tracing_test::traced_test]
|
1267 - | async fn aws_json11_serialize_structure_union_value_request() {
|
1268 - | #[allow(unused_mut)]
|
1269 - | let mut http_request = ::http::Request::builder()
|
1270 - | .uri("/")
|
1271 - | .method("POST")
|
1272 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1273 - | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
1274 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1275 - | ::bytes::Bytes::copy_from_slice(
|
1276 - | &::aws_smithy_protocol_test::decode_body_data("{\n \"contents\": {\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1277 - | )
|
1278 - | )).unwrap();
|
1279 - | #[allow(unused_mut)]
|
1280 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1281 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1282 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1283 - | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1284 - | let sender = sender.clone();
|
1285 - | async move {
|
1286 - | let result = {
|
1287 - | let expected = crate::input::JsonUnionsInput {
|
1288 - | contents: ::std::option::Option::Some(
|
1289 - | crate::model::MyUnion::StructureValue(
|
1290 - | crate::model::GreetingStruct {
|
1291 - | hi: ::std::option::Option::Some("hello".to_owned()),
|
1292 - | },
|
1293 - | ),
|
1294 - | ),
|
1295 - | };
|
1296 - | ::pretty_assertions::assert_eq!(input, expected);
|
1297 - | let output = crate::output::JsonUnionsOutput {
|
1298 - | contents: ::std::option::Option::None,
|
1299 - | };
|
1300 - | Ok(output)
|
1301 - | };
|
1302 - | sender.send(()).await.expect("receiver dropped early");
|
1303 - | result
|
1304 - | }
|
1305 - | })
|
1306 - | .build_unchecked();
|
1307 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1308 - | .await
|
1309 - | .expect("unable to make an HTTP request");
|
1310 - | assert!(
|
1311 - | receiver.recv().await.is_some(),
|
1312 - | "we expected operation handler to be invoked but it was not entered"
|
1313 - | );
|
1314 - | }
|
1315 - |
|
1316 - | /// Deserializes a string union value
|
1317 - | /// Test ID: AwsJson11DeserializeStringUnionValue
|
1318 - | #[::tokio::test]
|
1319 - | #[::tracing_test::traced_test]
|
1320 - | async fn aws_json11_deserialize_string_union_value_response() {
|
1321 - | let output = crate::output::JsonUnionsOutput {
|
1322 - | contents: ::std::option::Option::Some(crate::model::MyUnion::StringValue(
|
1323 - | "foo".to_owned(),
|
1324 - | )),
|
1325 - | };
|
1326 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1327 - | let http_response = output.into_response();
|
1328 - | ::pretty_assertions::assert_eq!(
|
1329 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1330 - | http_response.status()
|
1331 - | );
|
1332 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1333 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1334 - | http_response.headers(),
|
1335 - | expected_headers,
|
1336 - | ));
|
1337 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1338 - | .await
|
1339 - | .expect("unable to extract body to bytes");
|
1340 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1341 - | &body,
|
1342 - | "{\n \"contents\": {\n \"stringValue\": \"foo\"\n }\n}",
|
1343 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1344 - | ));
|
1345 - | }
|
1346 - |
|
1347 - | /// Deserializes a boolean union value
|
1348 - | /// Test ID: AwsJson11DeserializeBooleanUnionValue
|
1349 - | #[::tokio::test]
|
1350 - | #[::tracing_test::traced_test]
|
1351 - | async fn aws_json11_deserialize_boolean_union_value_response() {
|
1352 - | let output = crate::output::JsonUnionsOutput {
|
1353 - | contents: ::std::option::Option::Some(crate::model::MyUnion::BooleanValue(true)),
|
1354 - | };
|
1355 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1356 - | let http_response = output.into_response();
|
1357 - | ::pretty_assertions::assert_eq!(
|
1358 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1359 - | http_response.status()
|
1360 - | );
|
1361 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1362 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1363 - | http_response.headers(),
|
1364 - | expected_headers,
|
1365 - | ));
|
1366 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1367 - | .await
|
1368 - | .expect("unable to extract body to bytes");
|
1369 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1370 - | &body,
|
1371 - | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}",
|
1372 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1373 - | ));
|
1374 - | }
|
1375 - |
|
1376 - | /// Deserializes a number union value
|
1377 - | /// Test ID: AwsJson11DeserializeNumberUnionValue
|
1378 - | #[::tokio::test]
|
1379 - | #[::tracing_test::traced_test]
|
1380 - | async fn aws_json11_deserialize_number_union_value_response() {
|
1381 - | let output = crate::output::JsonUnionsOutput {
|
1382 - | contents: ::std::option::Option::Some(crate::model::MyUnion::NumberValue(1)),
|
1383 - | };
|
1384 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1385 - | let http_response = output.into_response();
|
1386 - | ::pretty_assertions::assert_eq!(
|
1387 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1388 - | http_response.status()
|
1389 - | );
|
1390 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1391 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1392 - | http_response.headers(),
|
1393 - | expected_headers,
|
1394 - | ));
|
1395 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1396 - | .await
|
1397 - | .expect("unable to extract body to bytes");
|
1398 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1399 - | &body,
|
1400 - | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}",
|
1401 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1402 - | ));
|
1403 - | }
|
1404 - |
|
1405 - | /// Deserializes a blob union value
|
1406 - | /// Test ID: AwsJson11DeserializeBlobUnionValue
|
1407 - | #[::tokio::test]
|
1408 - | #[::tracing_test::traced_test]
|
1409 - | async fn aws_json11_deserialize_blob_union_value_response() {
|
1410 - | let output = crate::output::JsonUnionsOutput {
|
1411 - | contents: ::std::option::Option::Some(crate::model::MyUnion::BlobValue(
|
1412 - | ::aws_smithy_types::Blob::new("foo"),
|
1413 - | )),
|
1414 - | };
|
1415 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1416 - | let http_response = output.into_response();
|
1417 - | ::pretty_assertions::assert_eq!(
|
1418 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1419 - | http_response.status()
|
1420 - | );
|
1421 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1422 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1423 - | http_response.headers(),
|
1424 - | expected_headers,
|
1425 - | ));
|
1426 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1427 - | .await
|
1428 - | .expect("unable to extract body to bytes");
|
1429 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1430 - | &body,
|
1431 - | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}",
|
1432 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1433 - | ));
|
1434 - | }
|
1435 - |
|
1436 - | /// Deserializes a timestamp union value
|
1437 - | /// Test ID: AwsJson11DeserializeTimestampUnionValue
|
1438 - | #[::tokio::test]
|
1439 - | #[::tracing_test::traced_test]
|
1440 - | async fn aws_json11_deserialize_timestamp_union_value_response() {
|
1441 - | let output = crate::output::JsonUnionsOutput {
|
1442 - | contents: ::std::option::Option::Some(crate::model::MyUnion::TimestampValue(
|
1443 - | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
1444 - | )),
|
1445 - | };
|
1446 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1447 - | let http_response = output.into_response();
|
1448 - | ::pretty_assertions::assert_eq!(
|
1449 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1450 - | http_response.status()
|
1451 - | );
|
1452 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1453 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1454 - | http_response.headers(),
|
1455 - | expected_headers,
|
1456 - | ));
|
1457 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1458 - | .await
|
1459 - | .expect("unable to extract body to bytes");
|
1460 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1461 - | &body,
|
1462 - | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}",
|
1463 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1464 - | ));
|
1465 - | }
|
1466 - |
|
1467 - | /// Deserializes an enum union value
|
1468 - | /// Test ID: AwsJson11DeserializeEnumUnionValue
|
1469 - | #[::tokio::test]
|
1470 - | #[::tracing_test::traced_test]
|
1471 - | async fn aws_json11_deserialize_enum_union_value_response() {
|
1472 - | let output = crate::output::JsonUnionsOutput {
|
1473 - | contents: ::std::option::Option::Some(crate::model::MyUnion::EnumValue(
|
1474 - | "Foo"
|
1475 - | .parse::<crate::model::FooEnum>()
|
1476 - | .expect("static value validated to member"),
|
1477 - | )),
|
1478 - | };
|
1479 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1480 - | let http_response = output.into_response();
|
1481 - | ::pretty_assertions::assert_eq!(
|
1482 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1483 - | http_response.status()
|
1484 - | );
|
1485 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1486 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1487 - | http_response.headers(),
|
1488 - | expected_headers,
|
1489 - | ));
|
1490 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1491 - | .await
|
1492 - | .expect("unable to extract body to bytes");
|
1493 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1494 - | &body,
|
1495 - | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}",
|
1496 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1497 - | ));
|
1498 - | }
|
1499 - |
|
1500 - | /// Deserializes a list union value
|
1501 - | /// Test ID: AwsJson11DeserializeListUnionValue
|
1502 - | #[::tokio::test]
|
1503 - | #[::tracing_test::traced_test]
|
1504 - | async fn aws_json11_deserialize_list_union_value_response() {
|
1505 - | let output = crate::output::JsonUnionsOutput {
|
1506 - | contents: ::std::option::Option::Some(crate::model::MyUnion::ListValue(vec![
|
1507 - | "foo".to_owned(),
|
1508 - | "bar".to_owned(),
|
1509 - | ])),
|
1510 - | };
|
1511 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1512 - | let http_response = output.into_response();
|
1513 - | ::pretty_assertions::assert_eq!(
|
1514 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1515 - | http_response.status()
|
1516 - | );
|
1517 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1518 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1519 - | http_response.headers(),
|
1520 - | expected_headers,
|
1521 - | ));
|
1522 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1523 - | .await
|
1524 - | .expect("unable to extract body to bytes");
|
1525 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1526 - | &body,
|
1527 - | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}",
|
1528 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1529 - | ));
|
1530 - | }
|
1531 - |
|
1532 - | /// Deserializes a map union value
|
1533 - | /// Test ID: AwsJson11DeserializeMapUnionValue
|
1534 - | #[::tokio::test]
|
1535 - | #[::tracing_test::traced_test]
|
1536 - | async fn aws_json11_deserialize_map_union_value_response() {
|
1537 - | let output = crate::output::JsonUnionsOutput {
|
1538 - | contents: ::std::option::Option::Some(crate::model::MyUnion::MapValue({
|
1539 - | let mut ret = ::std::collections::HashMap::new();
|
1540 - | ret.insert("foo".to_owned(), "bar".to_owned());
|
1541 - | ret.insert("spam".to_owned(), "eggs".to_owned());
|
1542 - | ret
|
1543 - | })),
|
1544 - | };
|
1545 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1546 - | let http_response = output.into_response();
|
1547 - | ::pretty_assertions::assert_eq!(
|
1548 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1549 - | http_response.status()
|
1550 - | );
|
1551 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1552 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1553 - | http_response.headers(),
|
1554 - | expected_headers,
|
1555 - | ));
|
1556 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1557 - | .await
|
1558 - | .expect("unable to extract body to bytes");
|
1559 - | ::aws_smithy_protocol_test::assert_ok(
|
1560 - | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"contents\": {\n \"mapValue\": {\n \"foo\": \"bar\",\n \"spam\": \"eggs\"\n }\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1561 - | );
|
1562 - | }
|
1563 - |
|
1564 - | /// Deserializes a structure union value
|
1565 - | /// Test ID: AwsJson11DeserializeStructureUnionValue
|
1566 - | #[::tokio::test]
|
1567 - | #[::tracing_test::traced_test]
|
1568 - | async fn aws_json11_deserialize_structure_union_value_response() {
|
1569 - | let output = crate::output::JsonUnionsOutput {
|
1570 - | contents: ::std::option::Option::Some(crate::model::MyUnion::StructureValue(
|
1571 - | crate::model::GreetingStruct {
|
1572 - | hi: ::std::option::Option::Some("hello".to_owned()),
|
1573 - | },
|
1574 - | )),
|
1575 - | };
|
1576 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1577 - | let http_response = output.into_response();
|
1578 - | ::pretty_assertions::assert_eq!(
|
1579 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1580 - | http_response.status()
|
1581 - | );
|
1582 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1583 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1584 - | http_response.headers(),
|
1585 - | expected_headers,
|
1586 - | ));
|
1587 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1588 - | .await
|
1589 - | .expect("unable to extract body to bytes");
|
1590 - | ::aws_smithy_protocol_test::assert_ok(
|
1591 - | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"contents\": {\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1592 - | );
|
1593 - | }
|
1594 - | }
|
1595 - |
|
1596 - | ::pin_project_lite::pin_project! {
|
1597 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1598 - | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
1599 - | pub struct GreetingWithErrorsInputFuture {
|
1600 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
1601 - | }
|
1602 - | }
|
1603 - |
|
1604 - | impl std::future::Future for GreetingWithErrorsInputFuture {
|
1605 - | type Output = Result<
|
1606 - | crate::input::GreetingWithErrorsInput,
|
1607 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1608 - | >;
|
1609 - |
|
1610 - | fn poll(
|
1611 - | self: std::pin::Pin<&mut Self>,
|
1612 - | cx: &mut std::task::Context<'_>,
|
1613 - | ) -> std::task::Poll<Self::Output> {
|
1614 - | let this = self.project();
|
1615 - | this.inner.as_mut().poll(cx)
|
1616 - | }
|
1617 - | }
|
1618 - |
|
1619 - | impl<B>
|
1620 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1621 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
1622 - | B,
|
1623 - | > for crate::input::GreetingWithErrorsInput
|
1624 - | where
|
1625 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1626 - | B: 'static,
|
1627 - |
|
1628 - | B::Data: Send,
|
1629 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1630 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1631 - | {
|
1632 - | type Rejection =
|
1633 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1634 - | type Future = GreetingWithErrorsInputFuture;
|
1635 - |
|
1636 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1637 - | let fut = async move {
|
1638 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1639 - | request.headers(),
|
1640 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
1641 - | ) {
|
1642 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1643 - | }
|
1644 - | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
1645 - | request,
|
1646 - | )
|
1647 - | .await
|
1648 - | };
|
1649 - | use ::futures_util::future::TryFutureExt;
|
1650 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1651 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1652 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1653 - | });
|
1654 - | GreetingWithErrorsInputFuture {
|
1655 - | inner: Box::pin(fut),
|
1656 - | }
|
1657 - | }
|
1658 - | }
|
1659 - | impl
|
1660 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1661 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
1662 - | > for crate::output::GreetingWithErrorsOutput
|
1663 - | {
|
1664 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1665 - | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
1666 - | Ok(response) => response,
|
1667 - | Err(e) => {
|
1668 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1669 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1670 - | }
|
1671 - | }
|
1672 - | }
|
1673 - | }
|
1674 - | impl
|
1675 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1676 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
1677 - | > for crate::error::GreetingWithErrorsError
|
1678 - | {
|
1679 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1680 - | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
1681 - | &self,
|
1682 - | ) {
|
1683 - | Ok(mut response) => {
|
1684 - | response.extensions_mut().insert(
|
1685 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1686 - | self.name(),
|
1687 - | ),
|
1688 - | );
|
1689 - | response
|
1690 - | }
|
1691 - | Err(e) => {
|
1692 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1693 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1694 - | }
|
1695 - | }
|
1696 - | }
|
1697 - | }
|
1698 - |
|
1699 - | #[allow(unreachable_code, unused_variables)]
|
1700 - | #[cfg(test)]
|
1701 - | mod greeting_with_errors_test {
|
1702 - |
|
1703 - | /// Parses simple JSON errors
|
1704 - | /// Test ID: AwsJson11InvalidGreetingError
|
1705 - | #[::tokio::test]
|
1706 - | #[::tracing_test::traced_test]
|
1707 - | async fn aws_json11_invalid_greeting_error_response() {
|
1708 - | let output = crate::error::InvalidGreeting {
|
1709 - | message: ::std::option::Option::Some("Hi".to_owned()),
|
1710 - | };
|
1711 - | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
1712 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1713 - | let http_response = output.into_response();
|
1714 - | ::pretty_assertions::assert_eq!(
|
1715 - | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1716 - | http_response.status()
|
1717 - | );
|
1718 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1719 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1720 - | http_response.headers(),
|
1721 - | expected_headers,
|
1722 - | ));
|
1723 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1724 - | .await
|
1725 - | .expect("unable to extract body to bytes");
|
1726 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1727 - | &body,
|
1728 - | "{\n \"__type\": \"InvalidGreeting\",\n \"Message\": \"Hi\"\n}",
|
1729 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1730 - | ));
|
1731 - | }
|
1732 - |
|
1733 - | /// Parses a complex error with no message member
|
1734 - | /// Test ID: AwsJson11ComplexError
|
1735 - | #[::tokio::test]
|
1736 - | #[::tracing_test::traced_test]
|
1737 - | async fn aws_json11_complex_error_response() {
|
1738 - | let output = crate::error::ComplexError {
|
1739 - | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
1740 - | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
1741 - | foo: ::std::option::Option::Some("bar".to_owned()),
|
1742 - | }),
|
1743 - | };
|
1744 - | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
1745 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1746 - | let http_response = output.into_response();
|
1747 - | ::pretty_assertions::assert_eq!(
|
1748 - | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1749 - | http_response.status()
|
1750 - | );
|
1751 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1752 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1753 - | http_response.headers(),
|
1754 - | expected_headers,
|
1755 - | ));
|
1756 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1757 - | .await
|
1758 - | .expect("unable to extract body to bytes");
|
1759 - | ::aws_smithy_protocol_test::assert_ok(
|
1760 - | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"__type\": \"ComplexError\",\n \"TopLevel\": \"Top level\",\n \"Nested\": {\n \"Foo\": \"bar\"\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1761 - | );
|
1762 - | }
|
1763 - | /// Test ID: AwsJson11EmptyComplexError
|
1764 - | #[::tokio::test]
|
1765 - | #[::tracing_test::traced_test]
|
1766 - | async fn aws_json11_empty_complex_error_response() {
|
1767 - | let output = crate::error::ComplexError {
|
1768 - | top_level: ::std::option::Option::None,
|
1769 - | nested: ::std::option::Option::None,
|
1770 - | };
|
1771 - | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
1772 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1773 - | let http_response = output.into_response();
|
1774 - | ::pretty_assertions::assert_eq!(
|
1775 - | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1776 - | http_response.status()
|
1777 - | );
|
1778 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
1779 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1780 - | http_response.headers(),
|
1781 - | expected_headers,
|
1782 - | ));
|
1783 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1784 - | .await
|
1785 - | .expect("unable to extract body to bytes");
|
1786 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1787 - | &body,
|
1788 - | "{\n \"__type\": \"ComplexError\"\n}",
|
1789 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1790 - | ));
|
1791 - | }
|
1792 - | }
|
1793 - |
|
1794 - | ::pin_project_lite::pin_project! {
|
1795 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1796 - | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
1797 - | pub struct SparseNullsOperationInputFuture {
|
1798 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
1799 - | }
|
1800 - | }
|
1801 - |
|
1802 - | impl std::future::Future for SparseNullsOperationInputFuture {
|
1803 - | type Output = Result<
|
1804 - | crate::input::SparseNullsOperationInput,
|
1805 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1806 - | >;
|
1807 - |
|
1808 - | fn poll(
|
1809 - | self: std::pin::Pin<&mut Self>,
|
1810 - | cx: &mut std::task::Context<'_>,
|
1811 - | ) -> std::task::Poll<Self::Output> {
|
1812 - | let this = self.project();
|
1813 - | this.inner.as_mut().poll(cx)
|
1814 - | }
|
1815 - | }
|
1816 - |
|
1817 - | impl<B>
|
1818 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1819 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
1820 - | B,
|
1821 - | > for crate::input::SparseNullsOperationInput
|
1822 - | where
|
1823 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1824 - | B: 'static,
|
1825 - |
|
1826 - | B::Data: Send,
|
1827 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1828 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1829 - | {
|
1830 - | type Rejection =
|
1831 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1832 - | type Future = SparseNullsOperationInputFuture;
|
1833 - |
|
1834 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1835 - | let fut = async move {
|
1836 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1837 - | request.headers(),
|
1838 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
1839 - | ) {
|
1840 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1841 - | }
|
1842 - | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
1843 - | .await
|
1844 - | };
|
1845 - | use ::futures_util::future::TryFutureExt;
|
1846 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1847 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1848 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1849 - | });
|
1850 - | SparseNullsOperationInputFuture {
|
1851 - | inner: Box::pin(fut),
|
1852 - | }
|
1853 - | }
|
1854 - | }
|
1855 - | impl
|
1856 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1857 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
1858 - | > for crate::output::SparseNullsOperationOutput
|
1859 - | {
|
1860 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1861 - | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
1862 - | Ok(response) => response,
|
1863 - | Err(e) => {
|
1864 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1865 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1866 - | }
|
1867 - | }
|
1868 - | }
|
1869 - | }
|
1870 - |
|
1871 - | #[allow(unreachable_code, unused_variables)]
|
1872 - | #[cfg(test)]
|
1873 - | mod sparse_nulls_operation_test {
|
1874 - |
|
1875 - | /// Serializes null values in maps
|
1876 - | /// Test ID: AwsJson11SparseMapsSerializeNullValues
|
1877 - | #[::tokio::test]
|
1878 - | #[::tracing_test::traced_test]
|
1879 - | async fn aws_json11_sparse_maps_serialize_null_values_request() {
|
1880 - | #[allow(unused_mut)]
|
1881 - | let mut http_request = ::http::Request::builder()
|
1882 - | .uri("/")
|
1883 - | .method("POST")
|
1884 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1885 - | .header("X-Amz-Target", "JsonProtocol.SparseNullsOperation")
|
1886 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1887 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1888 - | "{\n \"sparseStringMap\": {\n \"foo\": null\n }\n}".as_bytes(),
|
1889 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1890 - | )),
|
1891 - | ))
|
1892 - | .unwrap();
|
1893 - | #[allow(unused_mut)]
|
1894 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1895 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1896 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1897 - | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
1898 - | let sender = sender.clone();
|
1899 - | async move {
|
1900 - | let result = {
|
1901 - | let expected = crate::input::SparseNullsOperationInput {
|
1902 - | sparse_string_map: ::std::option::Option::Some({
|
1903 - | let mut ret = ::std::collections::HashMap::new();
|
1904 - | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
1905 - | ret
|
1906 - | }),
|
1907 - | sparse_string_list: ::std::option::Option::None,
|
1908 - | };
|
1909 - | ::pretty_assertions::assert_eq!(input, expected);
|
1910 - | let output = crate::output::SparseNullsOperationOutput {
|
1911 - | sparse_string_list: ::std::option::Option::None,
|
1912 - | sparse_string_map: ::std::option::Option::None,
|
1913 - | };
|
1914 - | output
|
1915 - | };
|
1916 - | sender.send(()).await.expect("receiver dropped early");
|
1917 - | result
|
1918 - | }
|
1919 - | })
|
1920 - | .build_unchecked();
|
1921 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1922 - | .await
|
1923 - | .expect("unable to make an HTTP request");
|
1924 - | assert!(
|
1925 - | receiver.recv().await.is_some(),
|
1926 - | "we expected operation handler to be invoked but it was not entered"
|
1927 - | );
|
1928 - | }
|
1929 - |
|
1930 - | /// Serializes null values in lists
|
1931 - | /// Test ID: AwsJson11SparseListsSerializeNull
|
1932 - | #[::tokio::test]
|
1933 - | #[::tracing_test::traced_test]
|
1934 - | async fn aws_json11_sparse_lists_serialize_null_request() {
|
1935 - | #[allow(unused_mut)]
|
1936 - | let mut http_request = ::http::Request::builder()
|
1937 - | .uri("/")
|
1938 - | .method("POST")
|
1939 - | .header("Content-Type", "application/x-amz-json-1.1")
|
1940 - | .header("X-Amz-Target", "JsonProtocol.SparseNullsOperation")
|
1941 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1942 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1943 - | "{\n \"sparseStringList\": [\n null\n ]\n}".as_bytes(),
|
1944 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1945 - | )),
|
1946 - | ))
|
1947 - | .unwrap();
|
1948 - | #[allow(unused_mut)]
|
1949 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1950 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
1951 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1952 - | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
1953 - | let sender = sender.clone();
|
1954 - | async move {
|
1955 - | let result = {
|
1956 - | let expected = crate::input::SparseNullsOperationInput {
|
1957 - | sparse_string_list: ::std::option::Option::Some(vec![
|
1958 - | ::std::option::Option::None,
|
1959 - | ]),
|
1960 - | sparse_string_map: ::std::option::Option::None,
|
1961 - | };
|
1962 - | ::pretty_assertions::assert_eq!(input, expected);
|
1963 - | let output = crate::output::SparseNullsOperationOutput {
|
1964 - | sparse_string_list: ::std::option::Option::None,
|
1965 - | sparse_string_map: ::std::option::Option::None,
|
1966 - | };
|
1967 - | output
|
1968 - | };
|
1969 - | sender.send(()).await.expect("receiver dropped early");
|
1970 - | result
|
1971 - | }
|
1972 - | })
|
1973 - | .build_unchecked();
|
1974 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1975 - | .await
|
1976 - | .expect("unable to make an HTTP request");
|
1977 - | assert!(
|
1978 - | receiver.recv().await.is_some(),
|
1979 - | "we expected operation handler to be invoked but it was not entered"
|
1980 - | );
|
1981 - | }
|
1982 - |
|
1983 - | /// Deserializes null values in maps
|
1984 - | /// Test ID: AwsJson11SparseMapsDeserializeNullValues
|
1985 - | #[::tokio::test]
|
1986 - | #[::tracing_test::traced_test]
|
1987 - | async fn aws_json11_sparse_maps_deserialize_null_values_response() {
|
1988 - | let output = crate::output::SparseNullsOperationOutput {
|
1989 - | sparse_string_map: ::std::option::Option::Some({
|
1990 - | let mut ret = ::std::collections::HashMap::new();
|
1991 - | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
1992 - | ret
|
1993 - | }),
|
1994 - | sparse_string_list: ::std::option::Option::None,
|
1995 - | };
|
1996 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1997 - | let http_response = output.into_response();
|
1998 - | ::pretty_assertions::assert_eq!(
|
1999 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2000 - | http_response.status()
|
2001 - | );
|
2002 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
2003 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2004 - | http_response.headers(),
|
2005 - | expected_headers,
|
2006 - | ));
|
2007 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2008 - | .await
|
2009 - | .expect("unable to extract body to bytes");
|
2010 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2011 - | &body,
|
2012 - | "{\n \"sparseStringMap\": {\n \"foo\": null\n }\n}",
|
2013 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2014 - | ));
|
2015 - | }
|
2016 - |
|
2017 - | /// Deserializes null values in lists
|
2018 - | /// Test ID: AwsJson11SparseListsDeserializeNull
|
2019 - | #[::tokio::test]
|
2020 - | #[::tracing_test::traced_test]
|
2021 - | async fn aws_json11_sparse_lists_deserialize_null_response() {
|
2022 - | let output = crate::output::SparseNullsOperationOutput {
|
2023 - | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
2024 - | sparse_string_map: ::std::option::Option::None,
|
2025 - | };
|
2026 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2027 - | let http_response = output.into_response();
|
2028 - | ::pretty_assertions::assert_eq!(
|
2029 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2030 - | http_response.status()
|
2031 - | );
|
2032 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
2033 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2034 - | http_response.headers(),
|
2035 - | expected_headers,
|
2036 - | ));
|
2037 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2038 - | .await
|
2039 - | .expect("unable to extract body to bytes");
|
2040 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2041 - | &body,
|
2042 - | "{\n \"sparseStringList\": [\n null\n ]\n}",
|
2043 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2044 - | ));
|
2045 - | }
|
2046 - | }
|
2047 - |
|
2048 - | ::pin_project_lite::pin_project! {
|
2049 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2050 - | /// [`NullOperationInput`](crate::input::NullOperationInput) using modelled bindings.
|
2051 - | pub struct NullOperationInputFuture {
|
2052 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NullOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
2053 - | }
|
2054 - | }
|
2055 - |
|
2056 - | impl std::future::Future for NullOperationInputFuture {
|
2057 - | type Output = Result<
|
2058 - | crate::input::NullOperationInput,
|
2059 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2060 - | >;
|
2061 - |
|
2062 - | fn poll(
|
2063 - | self: std::pin::Pin<&mut Self>,
|
2064 - | cx: &mut std::task::Context<'_>,
|
2065 - | ) -> std::task::Poll<Self::Output> {
|
2066 - | let this = self.project();
|
2067 - | this.inner.as_mut().poll(cx)
|
2068 - | }
|
2069 - | }
|
2070 - |
|
2071 - | impl<B>
|
2072 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2073 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2074 - | B,
|
2075 - | > for crate::input::NullOperationInput
|
2076 - | where
|
2077 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2078 - | B: 'static,
|
2079 - |
|
2080 - | B::Data: Send,
|
2081 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2082 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2083 - | {
|
2084 - | type Rejection =
|
2085 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2086 - | type Future = NullOperationInputFuture;
|
2087 - |
|
2088 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2089 - | let fut = async move {
|
2090 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2091 - | request.headers(),
|
2092 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
2093 - | ) {
|
2094 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2095 - | }
|
2096 - | crate::protocol_serde::shape_null_operation::de_null_operation_http_request(request)
|
2097 - | .await
|
2098 - | };
|
2099 - | use ::futures_util::future::TryFutureExt;
|
2100 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2101 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2102 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2103 - | });
|
2104 - | NullOperationInputFuture {
|
2105 - | inner: Box::pin(fut),
|
2106 - | }
|
2107 - | }
|
2108 - | }
|
2109 - | impl
|
2110 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2111 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2112 - | > for crate::output::NullOperationOutput
|
2113 - | {
|
2114 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2115 - | match crate::protocol_serde::shape_null_operation::ser_null_operation_http_response(self) {
|
2116 - | Ok(response) => response,
|
2117 - | Err(e) => {
|
2118 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2119 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2120 - | }
|
2121 - | }
|
368 + | impl
|
369 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
370 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
371 + | > for crate::error::KitchenSinkOperationError
|
372 + | {
|
373 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
374 + | match crate::protocol_serde::shape_kitchen_sink_operation::ser_kitchen_sink_operation_http_error(&self) {
|
375 + | Ok(mut response) => {
|
376 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
377 + | response
|
378 + | },
|
379 + | Err(e) => {
|
380 + | ::tracing::error!(error = %e, "failed to serialize response");
|
381 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
382 + | }
|
383 + | }
|
2122 384 | }
|
2123 385 | }
|
2124 386 |
|
2125 387 | #[allow(unreachable_code, unused_variables)]
|
2126 388 | #[cfg(test)]
|
2127 - | mod null_operation_test {
|
389 + | mod kitchen_sink_operation_test {
|
2128 390 |
|
2129 - | /// Null structure values are dropped
|
2130 - | /// Test ID: AwsJson11ServersDontDeserializeNullStructureValues
|
391 + | /// Serializes string shapes
|
392 + | /// Test ID: serializes_string_shapes
|
2131 393 | #[::tokio::test]
|
2132 394 | #[::tracing_test::traced_test]
|
2133 - | async fn aws_json11_servers_dont_deserialize_null_structure_values_request() {
|
395 + | async fn serializes_string_shapes_request() {
|
2134 396 | #[allow(unused_mut)]
|
2135 397 | let mut http_request = ::http::Request::builder()
|
2136 398 | .uri("/")
|
2137 399 | .method("POST")
|
2138 400 | .header("Content-Type", "application/x-amz-json-1.1")
|
2139 - | .header("X-Amz-Target", "JsonProtocol.NullOperation")
|
401 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
2140 402 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2141 403 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2142 - | "{\n \"string\": null\n}".as_bytes(),
|
404 + | "{\"String\":\"abc xyz\"}".as_bytes(),
|
2143 405 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2144 406 | )),
|
2145 407 | ))
|
2146 408 | .unwrap();
|
2147 409 | #[allow(unused_mut)]
|
2148 410 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2149 411 | let config = crate::service::JsonProtocolConfig::builder().build();
|
2150 412 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2151 - | .null_operation(move |input: crate::input::NullOperationInput| {
|
2152 - | let sender = sender.clone();
|
2153 - | async move {
|
2154 - | let result = {
|
2155 - | let expected = crate::input::NullOperationInput {
|
2156 - | string: ::std::option::Option::None,
|
2157 - | };
|
2158 - | ::pretty_assertions::assert_eq!(input, expected);
|
2159 - | let output = crate::output::NullOperationOutput {
|
2160 - | string: ::std::option::Option::None,
|
2161 - | };
|
2162 - | output
|
2163 - | };
|
2164 - | sender.send(()).await.expect("receiver dropped early");
|
2165 - | result
|
2166 - | }
|
2167 - | })
|
2168 - | .build_unchecked();
|
2169 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2170 - | .await
|
2171 - | .expect("unable to make an HTTP request");
|
2172 - | assert!(
|
2173 - | receiver.recv().await.is_some(),
|
2174 - | "we expected operation handler to be invoked but it was not entered"
|
2175 - | );
|
2176 - | }
|
2177 - |
|
2178 - | /// Null structure values are dropped
|
2179 - | /// Test ID: AwsJson11ServersDontSerializeNullStructureValues
|
2180 - | #[::tokio::test]
|
2181 - | #[::tracing_test::traced_test]
|
2182 - | async fn aws_json11_servers_dont_serialize_null_structure_values_response() {
|
2183 - | let output = crate::output::NullOperationOutput {
|
2184 - | string: ::std::option::Option::None,
|
2185 - | };
|
2186 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2187 - | let http_response = output.into_response();
|
2188 - | ::pretty_assertions::assert_eq!(
|
2189 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2190 - | http_response.status()
|
2191 - | );
|
2192 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
2193 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2194 - | http_response.headers(),
|
2195 - | expected_headers,
|
2196 - | ));
|
2197 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2198 - | .await
|
2199 - | .expect("unable to extract body to bytes");
|
2200 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2201 - | &body,
|
2202 - | "{}",
|
2203 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2204 - | ));
|
2205 - | }
|
2206 - | }
|
2207 - |
|
2208 - | ::pin_project_lite::pin_project! {
|
2209 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2210 - | /// [`JsonIntEnumsInput`](crate::input::JsonIntEnumsInput) using modelled bindings.
|
2211 - | pub struct JsonIntEnumsInputFuture {
|
2212 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::JsonIntEnumsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
2213 - | }
|
2214 - | }
|
2215 - |
|
2216 - | impl std::future::Future for JsonIntEnumsInputFuture {
|
2217 - | type Output = Result<
|
2218 - | crate::input::JsonIntEnumsInput,
|
2219 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2220 - | >;
|
2221 - |
|
2222 - | fn poll(
|
2223 - | self: std::pin::Pin<&mut Self>,
|
2224 - | cx: &mut std::task::Context<'_>,
|
2225 - | ) -> std::task::Poll<Self::Output> {
|
2226 - | let this = self.project();
|
2227 - | this.inner.as_mut().poll(cx)
|
2228 - | }
|
2229 - | }
|
2230 - |
|
2231 - | impl<B>
|
2232 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2233 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2234 - | B,
|
2235 - | > for crate::input::JsonIntEnumsInput
|
2236 - | where
|
2237 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2238 - | B: 'static,
|
2239 - |
|
2240 - | B::Data: Send,
|
2241 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2242 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2243 - | {
|
2244 - | type Rejection =
|
2245 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2246 - | type Future = JsonIntEnumsInputFuture;
|
2247 - |
|
2248 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2249 - | let fut = async move {
|
2250 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2251 - | request.headers(),
|
2252 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
2253 - | ) {
|
2254 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2255 - | }
|
2256 - | crate::protocol_serde::shape_json_int_enums::de_json_int_enums_http_request(request)
|
2257 - | .await
|
2258 - | };
|
2259 - | use ::futures_util::future::TryFutureExt;
|
2260 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2261 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2262 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2263 - | });
|
2264 - | JsonIntEnumsInputFuture {
|
2265 - | inner: Box::pin(fut),
|
2266 - | }
|
2267 - | }
|
2268 - | }
|
2269 - | impl
|
2270 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2271 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2272 - | > for crate::output::JsonIntEnumsOutput
|
2273 - | {
|
2274 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2275 - | match crate::protocol_serde::shape_json_int_enums::ser_json_int_enums_http_response(self) {
|
2276 - | Ok(response) => response,
|
2277 - | Err(e) => {
|
2278 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2279 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2280 - | }
|
2281 - | }
|
2282 - | }
|
2283 - | }
|
2284 - | impl
|
2285 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2286 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2287 - | > for crate::error::JsonIntEnumsError
|
2288 - | {
|
2289 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2290 - | match crate::protocol_serde::shape_json_int_enums::ser_json_int_enums_http_error(&self) {
|
2291 - | Ok(mut response) => {
|
2292 - | response.extensions_mut().insert(
|
2293 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
2294 - | self.name(),
|
2295 - | ),
|
2296 - | );
|
2297 - | response
|
2298 - | }
|
2299 - | Err(e) => {
|
2300 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2301 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2302 - | }
|
2303 - | }
|
2304 - | }
|
2305 - | }
|
2306 - |
|
2307 - | #[allow(unreachable_code, unused_variables)]
|
2308 - | #[cfg(test)]
|
2309 - | mod json_int_enums_test {
|
2310 - |
|
2311 - | /// Serializes simple scalar properties
|
2312 - | /// Test ID: AwsJson11IntEnums
|
2313 - | #[::tokio::test]
|
2314 - | #[::tracing_test::traced_test]
|
2315 - | async fn aws_json11_int_enums_request() {
|
2316 - | #[allow(unused_mut)]
|
2317 - | let mut http_request = ::http::Request::builder()
|
2318 - | .uri("/")
|
2319 - | .method("POST")
|
2320 - | .header("Content-Type", "application/x-amz-json-1.1")
|
2321 - | .header("X-Amz-Target", "JsonProtocol.JsonIntEnums")
|
2322 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2323 - | ::bytes::Bytes::copy_from_slice(
|
2324 - | &::aws_smithy_protocol_test::decode_body_data("{\n \"intEnum1\": 1,\n \"intEnum2\": 2,\n \"intEnum3\": 3,\n \"intEnumList\": [\n 1,\n 2\n ],\n \"intEnumSet\": [\n 1,\n 2\n ],\n \"intEnumMap\": {\n \"a\": 1,\n \"b\": 2\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2325 - | )
|
2326 - | )).unwrap();
|
2327 - | #[allow(unused_mut)]
|
2328 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2329 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
2330 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2331 - | .json_int_enums(move |input: crate::input::JsonIntEnumsInput| {
|
413 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
2332 414 | let sender = sender.clone();
|
2333 415 | async move {
|
2334 416 | let result = {
|
2335 - | let expected = crate::input::JsonIntEnumsInput {
|
2336 - | int_enum1: ::std::option::Option::Some(1),
|
2337 - | int_enum2: ::std::option::Option::Some(2),
|
2338 - | int_enum3: ::std::option::Option::Some(3),
|
2339 - | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2340 - | int_enum_set: ::std::option::Option::Some(
|
2341 - | vec![1, 2].try_into().expect("this is only used in tests"),
|
2342 - | ),
|
2343 - | int_enum_map: ::std::option::Option::Some({
|
2344 - | let mut ret = ::std::collections::HashMap::new();
|
2345 - | ret.insert("a".to_owned(), 1);
|
2346 - | ret.insert("b".to_owned(), 2);
|
2347 - | ret
|
2348 - | }),
|
2349 - | };
|
2350 - | ::pretty_assertions::assert_eq!(input, expected);
|
2351 - | let output = crate::output::JsonIntEnumsOutput {
|
2352 - | int_enum1: ::std::option::Option::None,
|
2353 - | int_enum2: ::std::option::Option::None,
|
2354 - | int_enum3: ::std::option::Option::None,
|
2355 - | int_enum_list: ::std::option::Option::None,
|
2356 - | int_enum_set: ::std::option::Option::None,
|
2357 - | int_enum_map: ::std::option::Option::None,
|
2358 - | };
|
2359 - | Ok(output)
|
417 + | use ::aws_smithy_protocol_test::FloatEquals;
|
418 + | let expected = crate::input::KitchenSinkOperationInput {
|
419 + | string: ::std::option::Option::Some("abc xyz".to_owned()),
|
420 + | blob: ::std::option::Option::None,
|
421 + | boolean: ::std::option::Option::None,
|
422 + | double: ::std::option::Option::None,
|
423 + | empty_struct: ::std::option::Option::None,
|
424 + | float: ::std::option::Option::None,
|
425 + | httpdate_timestamp: ::std::option::Option::None,
|
426 + | integer: ::std::option::Option::None,
|
427 + | iso8601_timestamp: ::std::option::Option::None,
|
428 + | json_value: ::std::option::Option::None,
|
429 + | list_of_lists: ::std::option::Option::None,
|
430 + | list_of_maps_of_strings: ::std::option::Option::None,
|
431 + | list_of_strings: ::std::option::Option::None,
|
432 + | list_of_structs: ::std::option::Option::None,
|
433 + | long: ::std::option::Option::None,
|
434 + | map_of_lists_of_strings: ::std::option::Option::None,
|
435 + | map_of_maps: ::std::option::Option::None,
|
436 + | map_of_strings: ::std::option::Option::None,
|
437 + | map_of_structs: ::std::option::Option::None,
|
438 + | recursive_list: ::std::option::Option::None,
|
439 + | recursive_map: ::std::option::Option::None,
|
440 + | recursive_struct: ::std::option::Option::None,
|
441 + | simple_struct: ::std::option::Option::None,
|
442 + | struct_with_json_name: ::std::option::Option::None,
|
443 + | timestamp: ::std::option::Option::None,
|
444 + | unix_timestamp: ::std::option::Option::None,
|
2360 445 | };
|
2361 - | sender.send(()).await.expect("receiver dropped early");
|
2362 - | result
|
2363 - | }
|
2364 - | })
|
2365 - | .build_unchecked();
|
2366 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2367 - | .await
|
2368 - | .expect("unable to make an HTTP request");
|
446 + | ::pretty_assertions::assert_eq!(
|
447 + | input.blob,
|
448 + | expected.blob,
|
449 + | "Unexpected value for `blob`"
|
450 + | );
|
451 + | ::pretty_assertions::assert_eq!(
|
452 + | input.boolean,
|
453 + | expected.boolean,
|
454 + | "Unexpected value for `boolean`"
|
455 + | );
|
2369 456 | assert!(
|
2370 - | receiver.recv().await.is_some(),
|
2371 - | "we expected operation handler to be invoked but it was not entered"
|
457 + | input.double.float_equals(&expected.double),
|
458 + | "Unexpected value for `double` {:?} vs. {:?}",
|
459 + | expected.double,
|
460 + | input.double
|
2372 461 | );
|
2373 - | }
|
2374 - |
|
2375 - | /// Serializes simple scalar properties
|
2376 - | /// Test ID: AwsJson11IntEnums
|
2377 - | #[::tokio::test]
|
2378 - | #[::tracing_test::traced_test]
|
2379 - | #[should_panic]
|
2380 - | async fn aws_json11_int_enums_response() {
|
2381 - | let output = crate::output::JsonIntEnumsOutput {
|
2382 - | int_enum1: ::std::option::Option::Some(1),
|
2383 - | int_enum2: ::std::option::Option::Some(2),
|
2384 - | int_enum3: ::std::option::Option::Some(3),
|
2385 - | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2386 - | int_enum_set: ::std::option::Option::Some(
|
2387 - | vec![1, 2].try_into().expect("this is only used in tests"),
|
2388 - | ),
|
2389 - | int_enum_map: ::std::option::Option::Some({
|
2390 - | let mut ret = ::std::collections::HashMap::new();
|
2391 - | ret.insert("a".to_owned(), 1);
|
2392 - | ret.insert("b".to_owned(), 2);
|
2393 - | ret
|
2394 - | }),
|
2395 - | };
|
2396 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2397 - | let http_response = output.into_response();
|
2398 462 | ::pretty_assertions::assert_eq!(
|
2399 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2400 - | http_response.status()
|
463 + | input.empty_struct,
|
464 + | expected.empty_struct,
|
465 + | "Unexpected value for `empty_struct`"
|
2401 466 | );
|
2402 - | let expected_headers = [
|
2403 - | ("Content-Type", "application/x-amz-json-1.1"),
|
2404 - | ("X-Amz-Target", "JsonProtocol.JsonIntEnums"),
|
2405 - | ];
|
2406 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2407 - | http_response.headers(),
|
2408 - | expected_headers,
|
2409 - | ));
|
2410 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2411 - | .await
|
2412 - | .expect("unable to extract body to bytes");
|
2413 - | ::aws_smithy_protocol_test::assert_ok(
|
2414 - | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"intEnum1\": 1,\n \"intEnum2\": 2,\n \"intEnum3\": 3,\n \"intEnumList\": [\n 1,\n 2\n ],\n \"intEnumSet\": [\n 1,\n 2\n ],\n \"intEnumMap\": {\n \"a\": 1,\n \"b\": 2\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
467 + | assert!(
|
468 + | input.float.float_equals(&expected.float),
|
469 + | "Unexpected value for `float` {:?} vs. {:?}",
|
470 + | expected.float,
|
471 + | input.float
|
2415 472 | );
|
2416 - | }
|
2417 - | }
|
2418 - |
|
2419 - | ::pin_project_lite::pin_project! {
|
2420 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2421 - | /// [`JsonEnumsInput`](crate::input::JsonEnumsInput) using modelled bindings.
|
2422 - | pub struct JsonEnumsInputFuture {
|
2423 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::JsonEnumsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
2424 - | }
|
2425 - | }
|
2426 - |
|
2427 - | impl std::future::Future for JsonEnumsInputFuture {
|
2428 - | type Output = Result<
|
2429 - | crate::input::JsonEnumsInput,
|
2430 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2431 - | >;
|
2432 - |
|
2433 - | fn poll(
|
2434 - | self: std::pin::Pin<&mut Self>,
|
2435 - | cx: &mut std::task::Context<'_>,
|
2436 - | ) -> std::task::Poll<Self::Output> {
|
2437 - | let this = self.project();
|
2438 - | this.inner.as_mut().poll(cx)
|
2439 - | }
|
2440 - | }
|
2441 - |
|
2442 - | impl<B>
|
2443 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2444 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2445 - | B,
|
2446 - | > for crate::input::JsonEnumsInput
|
2447 - | where
|
2448 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2449 - | B: 'static,
|
2450 - |
|
2451 - | B::Data: Send,
|
2452 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2453 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2454 - | {
|
2455 - | type Rejection =
|
2456 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2457 - | type Future = JsonEnumsInputFuture;
|
2458 - |
|
2459 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2460 - | let fut = async move {
|
2461 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2462 - | request.headers(),
|
2463 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
2464 - | ) {
|
2465 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2466 - | }
|
2467 - | crate::protocol_serde::shape_json_enums::de_json_enums_http_request(request).await
|
473 + | ::pretty_assertions::assert_eq!(
|
474 + | input.httpdate_timestamp,
|
475 + | expected.httpdate_timestamp,
|
476 + | "Unexpected value for `httpdate_timestamp`"
|
477 + | );
|
478 + | ::pretty_assertions::assert_eq!(
|
479 + | input.integer,
|
480 + | expected.integer,
|
481 + | "Unexpected value for `integer`"
|
482 + | );
|
483 + | ::pretty_assertions::assert_eq!(
|
484 + | input.iso8601_timestamp,
|
485 + | expected.iso8601_timestamp,
|
486 + | "Unexpected value for `iso8601_timestamp`"
|
487 + | );
|
488 + | ::pretty_assertions::assert_eq!(
|
489 + | input.json_value,
|
490 + | expected.json_value,
|
491 + | "Unexpected value for `json_value`"
|
492 + | );
|
493 + | ::pretty_assertions::assert_eq!(
|
494 + | input.list_of_lists,
|
495 + | expected.list_of_lists,
|
496 + | "Unexpected value for `list_of_lists`"
|
497 + | );
|
498 + | ::pretty_assertions::assert_eq!(
|
499 + | input.list_of_maps_of_strings,
|
500 + | expected.list_of_maps_of_strings,
|
501 + | "Unexpected value for `list_of_maps_of_strings`"
|
502 + | );
|
503 + | ::pretty_assertions::assert_eq!(
|
504 + | input.list_of_strings,
|
505 + | expected.list_of_strings,
|
506 + | "Unexpected value for `list_of_strings`"
|
507 + | );
|
508 + | ::pretty_assertions::assert_eq!(
|
509 + | input.list_of_structs,
|
510 + | expected.list_of_structs,
|
511 + | "Unexpected value for `list_of_structs`"
|
512 + | );
|
513 + | ::pretty_assertions::assert_eq!(
|
514 + | input.long,
|
515 + | expected.long,
|
516 + | "Unexpected value for `long`"
|
517 + | );
|
518 + | ::pretty_assertions::assert_eq!(
|
519 + | input.map_of_lists_of_strings,
|
520 + | expected.map_of_lists_of_strings,
|
521 + | "Unexpected value for `map_of_lists_of_strings`"
|
522 + | );
|
523 + | ::pretty_assertions::assert_eq!(
|
524 + | input.map_of_maps,
|
525 + | expected.map_of_maps,
|
526 + | "Unexpected value for `map_of_maps`"
|
527 + | );
|
528 + | ::pretty_assertions::assert_eq!(
|
529 + | input.map_of_strings,
|
530 + | expected.map_of_strings,
|
531 + | "Unexpected value for `map_of_strings`"
|
532 + | );
|
533 + | ::pretty_assertions::assert_eq!(
|
534 + | input.map_of_structs,
|
535 + | expected.map_of_structs,
|
536 + | "Unexpected value for `map_of_structs`"
|
537 + | );
|
538 + | ::pretty_assertions::assert_eq!(
|
539 + | input.recursive_list,
|
540 + | expected.recursive_list,
|
541 + | "Unexpected value for `recursive_list`"
|
542 + | );
|
543 + | ::pretty_assertions::assert_eq!(
|
544 + | input.recursive_map,
|
545 + | expected.recursive_map,
|
546 + | "Unexpected value for `recursive_map`"
|
547 + | );
|
548 + | ::pretty_assertions::assert_eq!(
|
549 + | input.recursive_struct,
|
550 + | expected.recursive_struct,
|
551 + | "Unexpected value for `recursive_struct`"
|
552 + | );
|
553 + | ::pretty_assertions::assert_eq!(
|
554 + | input.simple_struct,
|
555 + | expected.simple_struct,
|
556 + | "Unexpected value for `simple_struct`"
|
557 + | );
|
558 + | ::pretty_assertions::assert_eq!(
|
559 + | input.string,
|
560 + | expected.string,
|
561 + | "Unexpected value for `string`"
|
562 + | );
|
563 + | ::pretty_assertions::assert_eq!(
|
564 + | input.struct_with_json_name,
|
565 + | expected.struct_with_json_name,
|
566 + | "Unexpected value for `struct_with_json_name`"
|
567 + | );
|
568 + | ::pretty_assertions::assert_eq!(
|
569 + | input.timestamp,
|
570 + | expected.timestamp,
|
571 + | "Unexpected value for `timestamp`"
|
572 + | );
|
573 + | ::pretty_assertions::assert_eq!(
|
574 + | input.unix_timestamp,
|
575 + | expected.unix_timestamp,
|
576 + | "Unexpected value for `unix_timestamp`"
|
577 + | );
|
578 + | let output = crate::output::KitchenSinkOperationOutput {
|
579 + | blob: ::std::option::Option::None,
|
580 + | boolean: ::std::option::Option::None,
|
581 + | double: ::std::option::Option::None,
|
582 + | empty_struct: ::std::option::Option::None,
|
583 + | float: ::std::option::Option::None,
|
584 + | httpdate_timestamp: ::std::option::Option::None,
|
585 + | integer: ::std::option::Option::None,
|
586 + | iso8601_timestamp: ::std::option::Option::None,
|
587 + | json_value: ::std::option::Option::None,
|
588 + | list_of_lists: ::std::option::Option::None,
|
589 + | list_of_maps_of_strings: ::std::option::Option::None,
|
590 + | list_of_strings: ::std::option::Option::None,
|
591 + | list_of_structs: ::std::option::Option::None,
|
592 + | long: ::std::option::Option::None,
|
593 + | map_of_lists_of_strings: ::std::option::Option::None,
|
594 + | map_of_maps: ::std::option::Option::None,
|
595 + | map_of_strings: ::std::option::Option::None,
|
596 + | map_of_structs: ::std::option::Option::None,
|
597 + | recursive_list: ::std::option::Option::None,
|
598 + | recursive_map: ::std::option::Option::None,
|
599 + | recursive_struct: ::std::option::Option::None,
|
600 + | simple_struct: ::std::option::Option::None,
|
601 + | string: ::std::option::Option::None,
|
602 + | struct_with_json_name: ::std::option::Option::None,
|
603 + | timestamp: ::std::option::Option::None,
|
604 + | unix_timestamp: ::std::option::Option::None,
|
2468 605 | };
|
2469 - | use ::futures_util::future::TryFutureExt;
|
2470 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2471 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2472 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2473 - | });
|
2474 - | JsonEnumsInputFuture {
|
2475 - | inner: Box::pin(fut),
|
2476 - | }
|
2477 - | }
|
2478 - | }
|
2479 - | impl
|
2480 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2481 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2482 - | > for crate::output::JsonEnumsOutput
|
2483 - | {
|
2484 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2485 - | match crate::protocol_serde::shape_json_enums::ser_json_enums_http_response(self) {
|
2486 - | Ok(response) => response,
|
2487 - | Err(e) => {
|
2488 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2489 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2490 - | }
|
2491 - | }
|
606 + | Ok(output)
|
607 + | };
|
608 + | sender.send(()).await.expect("receiver dropped early");
|
609 + | result
|
2492 610 | }
|
2493 - | }
|
2494 - | impl
|
2495 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2496 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2497 - | > for crate::error::JsonEnumsError
|
2498 - | {
|
2499 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2500 - | match crate::protocol_serde::shape_json_enums::ser_json_enums_http_error(&self) {
|
2501 - | Ok(mut response) => {
|
2502 - | response.extensions_mut().insert(
|
2503 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
2504 - | self.name(),
|
2505 - | ),
|
611 + | })
|
612 + | .build_unchecked();
|
613 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
614 + | .await
|
615 + | .expect("unable to make an HTTP request");
|
616 + | assert!(
|
617 + | receiver.recv().await.is_some(),
|
618 + | "we expected operation handler to be invoked but it was not entered"
|
2506 619 | );
|
2507 - | response
|
2508 620 | }
|
2509 - | Err(e) => {
|
2510 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2511 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
621 + |
|
622 + | /// Serializes string shapes with jsonvalue trait
|
623 + | /// Test ID: serializes_string_shapes_with_jsonvalue_trait
|
624 + | #[::tokio::test]
|
625 + | #[::tracing_test::traced_test]
|
626 + | async fn serializes_string_shapes_with_jsonvalue_trait_request() {
|
627 + | #[allow(unused_mut)]
|
628 + | let mut http_request = ::http::Request::builder()
|
629 + | .uri("/")
|
630 + | .method("POST")
|
631 + | .header("Content-Type", "application/x-amz-json-1.1")
|
632 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
633 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
634 + | ::bytes::Bytes::copy_from_slice(
|
635 + | &::aws_smithy_protocol_test::decode_body_data("{\"JsonValue\":\"{\\\"string\\\":\\\"value\\\",\\\"number\\\":1234.5,\\\"boolTrue\\\":true,\\\"boolFalse\\\":false,\\\"array\\\":[1,2,3,4],\\\"object\\\":{\\\"key\\\":\\\"value\\\"},\\\"null\\\":null}\"}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
636 + | )
|
637 + | )).unwrap();
|
638 + | #[allow(unused_mut)]
|
639 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
640 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
641 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
642 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
643 + | let sender = sender.clone();
|
644 + | async move {
|
645 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
646 + | let expected =
|
647 + | crate::input::KitchenSinkOperationInput {
|
648 + | json_value:
|
649 + | ::std::option::Option::Some(
|
650 + | "{\"string\":\"value\",\"number\":1234.5,\"boolTrue\":true,\"boolFalse\":false,\"array\":[1,2,3,4],\"object\":{\"key\":\"value\"},\"null\":null}".to_owned()
|
651 + | )
|
652 + | ,
|
653 + | blob:
|
654 + | ::std::option::Option::None
|
655 + | ,
|
656 + | boolean:
|
657 + | ::std::option::Option::None
|
658 + | ,
|
659 + | double:
|
660 + | ::std::option::Option::None
|
661 + | ,
|
662 + | empty_struct:
|
663 + | ::std::option::Option::None
|
664 + | ,
|
665 + | float:
|
666 + | ::std::option::Option::None
|
667 + | ,
|
668 + | httpdate_timestamp:
|
669 + | ::std::option::Option::None
|
670 + | ,
|
671 + | integer:
|
672 + | ::std::option::Option::None
|
673 + | ,
|
674 + | iso8601_timestamp:
|
675 + | ::std::option::Option::None
|
676 + | ,
|
677 + | list_of_lists:
|
678 + | ::std::option::Option::None
|
679 + | ,
|
680 + | list_of_maps_of_strings:
|
681 + | ::std::option::Option::None
|
682 + | ,
|
683 + | list_of_strings:
|
684 + | ::std::option::Option::None
|
685 + | ,
|
686 + | list_of_structs:
|
687 + | ::std::option::Option::None
|
688 + | ,
|
689 + | long:
|
690 + | ::std::option::Option::None
|
691 + | ,
|
692 + | map_of_lists_of_strings:
|
693 + | ::std::option::Option::None
|
694 + | ,
|
695 + | map_of_maps:
|
696 + | ::std::option::Option::None
|
697 + | ,
|
698 + | map_of_strings:
|
699 + | ::std::option::Option::None
|
700 + | ,
|
701 + | map_of_structs:
|
702 + | ::std::option::Option::None
|
703 + | ,
|
704 + | recursive_list:
|
705 + | ::std::option::Option::None
|
706 + | ,
|
707 + | recursive_map:
|
708 + | ::std::option::Option::None
|
709 + | ,
|
710 + | recursive_struct:
|
711 + | ::std::option::Option::None
|
712 + | ,
|
713 + | simple_struct:
|
714 + | ::std::option::Option::None
|
715 + | ,
|
716 + | string:
|
717 + | ::std::option::Option::None
|
718 + | ,
|
719 + | struct_with_json_name:
|
720 + | ::std::option::Option::None
|
721 + | ,
|
722 + | timestamp:
|
723 + | ::std::option::Option::None
|
724 + | ,
|
725 + | unix_timestamp:
|
726 + | ::std::option::Option::None
|
727 + | ,
|
728 + | }
|
729 + | ;
|
730 + | ::pretty_assertions::assert_eq!(input.blob, expected.blob, "Unexpected value for `blob`");
|
731 + | ::pretty_assertions::assert_eq!(input.boolean, expected.boolean, "Unexpected value for `boolean`");
|
732 + | assert!(input.double.float_equals(&expected.double),
|
733 + | "Unexpected value for `double` {:?} vs. {:?}", expected.double, input.double);
|
734 + | ::pretty_assertions::assert_eq!(input.empty_struct, expected.empty_struct, "Unexpected value for `empty_struct`");
|
735 + | assert!(input.float.float_equals(&expected.float),
|
736 + | "Unexpected value for `float` {:?} vs. {:?}", expected.float, input.float);
|
737 + | ::pretty_assertions::assert_eq!(input.httpdate_timestamp, expected.httpdate_timestamp, "Unexpected value for `httpdate_timestamp`");
|
738 + | ::pretty_assertions::assert_eq!(input.integer, expected.integer, "Unexpected value for `integer`");
|
739 + | ::pretty_assertions::assert_eq!(input.iso8601_timestamp, expected.iso8601_timestamp, "Unexpected value for `iso8601_timestamp`");
|
740 + | ::pretty_assertions::assert_eq!(input.json_value, expected.json_value, "Unexpected value for `json_value`");
|
741 + | ::pretty_assertions::assert_eq!(input.list_of_lists, expected.list_of_lists, "Unexpected value for `list_of_lists`");
|
742 + | ::pretty_assertions::assert_eq!(input.list_of_maps_of_strings, expected.list_of_maps_of_strings, "Unexpected value for `list_of_maps_of_strings`");
|
743 + | ::pretty_assertions::assert_eq!(input.list_of_strings, expected.list_of_strings, "Unexpected value for `list_of_strings`");
|
744 + | ::pretty_assertions::assert_eq!(input.list_of_structs, expected.list_of_structs, "Unexpected value for `list_of_structs`");
|
745 + | ::pretty_assertions::assert_eq!(input.long, expected.long, "Unexpected value for `long`");
|
746 + | ::pretty_assertions::assert_eq!(input.map_of_lists_of_strings, expected.map_of_lists_of_strings, "Unexpected value for `map_of_lists_of_strings`");
|
747 + | ::pretty_assertions::assert_eq!(input.map_of_maps, expected.map_of_maps, "Unexpected value for `map_of_maps`");
|
748 + | ::pretty_assertions::assert_eq!(input.map_of_strings, expected.map_of_strings, "Unexpected value for `map_of_strings`");
|
749 + | ::pretty_assertions::assert_eq!(input.map_of_structs, expected.map_of_structs, "Unexpected value for `map_of_structs`");
|
750 + | ::pretty_assertions::assert_eq!(input.recursive_list, expected.recursive_list, "Unexpected value for `recursive_list`");
|
751 + | ::pretty_assertions::assert_eq!(input.recursive_map, expected.recursive_map, "Unexpected value for `recursive_map`");
|
752 + | ::pretty_assertions::assert_eq!(input.recursive_struct, expected.recursive_struct, "Unexpected value for `recursive_struct`");
|
753 + | ::pretty_assertions::assert_eq!(input.simple_struct, expected.simple_struct, "Unexpected value for `simple_struct`");
|
754 + | ::pretty_assertions::assert_eq!(input.string, expected.string, "Unexpected value for `string`");
|
755 + | ::pretty_assertions::assert_eq!(input.struct_with_json_name, expected.struct_with_json_name, "Unexpected value for `struct_with_json_name`");
|
756 + | ::pretty_assertions::assert_eq!(input.timestamp, expected.timestamp, "Unexpected value for `timestamp`");
|
757 + | ::pretty_assertions::assert_eq!(input.unix_timestamp, expected.unix_timestamp, "Unexpected value for `unix_timestamp`");
|
758 + | let output =
|
759 + | crate::output::KitchenSinkOperationOutput {
|
760 + | blob:
|
761 + | ::std::option::Option::None
|
762 + | ,
|
763 + | boolean:
|
764 + | ::std::option::Option::None
|
765 + | ,
|
766 + | double:
|
767 + | ::std::option::Option::None
|
768 + | ,
|
769 + | empty_struct:
|
770 + | ::std::option::Option::None
|
771 + | ,
|
772 + | float:
|
773 + | ::std::option::Option::None
|
774 + | ,
|
775 + | httpdate_timestamp:
|
776 + | ::std::option::Option::None
|
777 + | ,
|
778 + | integer:
|
779 + | ::std::option::Option::None
|
780 + | ,
|
781 + | iso8601_timestamp:
|
782 + | ::std::option::Option::None
|
783 + | ,
|
784 + | json_value:
|
785 + | ::std::option::Option::None
|
786 + | ,
|
787 + | list_of_lists:
|
788 + | ::std::option::Option::None
|
789 + | ,
|
790 + | list_of_maps_of_strings:
|
791 + | ::std::option::Option::None
|
792 + | ,
|
793 + | list_of_strings:
|
794 + | ::std::option::Option::None
|
795 + | ,
|
796 + | list_of_structs:
|
797 + | ::std::option::Option::None
|
798 + | ,
|
799 + | long:
|
800 + | ::std::option::Option::None
|
801 + | ,
|
802 + | map_of_lists_of_strings:
|
803 + | ::std::option::Option::None
|
804 + | ,
|
805 + | map_of_maps:
|
806 + | ::std::option::Option::None
|
807 + | ,
|
808 + | map_of_strings:
|
809 + | ::std::option::Option::None
|
810 + | ,
|
811 + | map_of_structs:
|
812 + | ::std::option::Option::None
|
813 + | ,
|
814 + | recursive_list:
|
815 + | ::std::option::Option::None
|
816 + | ,
|
817 + | recursive_map:
|
818 + | ::std::option::Option::None
|
819 + | ,
|
820 + | recursive_struct:
|
821 + | ::std::option::Option::None
|
822 + | ,
|
823 + | simple_struct:
|
824 + | ::std::option::Option::None
|
825 + | ,
|
826 + | string:
|
827 + | ::std::option::Option::None
|
828 + | ,
|
829 + | struct_with_json_name:
|
830 + | ::std::option::Option::None
|
831 + | ,
|
832 + | timestamp:
|
833 + | ::std::option::Option::None
|
834 + | ,
|
835 + | unix_timestamp:
|
836 + | ::std::option::Option::None
|
837 + | ,
|
2512 838 | }
|
839 + | ;
|
840 + | Ok(output) };
|
841 + | sender.send(()).await.expect("receiver dropped early");
|
842 + | result
|
2513 843 | }
|
844 + | })
|
845 + | .build_unchecked();
|
846 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
847 + | .await
|
848 + | .expect("unable to make an HTTP request");
|
849 + | assert!(
|
850 + | receiver.recv().await.is_some(),
|
851 + | "we expected operation handler to be invoked but it was not entered"
|
852 + | );
|
2514 853 | }
|
2515 - | }
|
2516 - |
|
2517 - | #[allow(unreachable_code, unused_variables)]
|
2518 - | #[cfg(test)]
|
2519 - | mod json_enums_test {
|
2520 854 |
|
2521 - | /// Serializes simple scalar properties
|
2522 - | /// Test ID: AwsJson11Enums
|
855 + | /// Serializes integer shapes
|
856 + | /// Test ID: serializes_integer_shapes
|
2523 857 | #[::tokio::test]
|
2524 858 | #[::tracing_test::traced_test]
|
2525 - | async fn aws_json11_enums_request() {
|
859 + | async fn serializes_integer_shapes_request() {
|
2526 860 | #[allow(unused_mut)]
|
2527 861 | let mut http_request = ::http::Request::builder()
|
2528 862 | .uri("/")
|
2529 863 | .method("POST")
|
2530 864 | .header("Content-Type", "application/x-amz-json-1.1")
|
2531 - | .header("X-Amz-Target", "JsonProtocol.JsonEnums")
|
865 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
2532 866 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2533 - | ::bytes::Bytes::copy_from_slice(
|
2534 - | &::aws_smithy_protocol_test::decode_body_data("{\n \"fooEnum1\": \"Foo\",\n \"fooEnum2\": \"0\",\n \"fooEnum3\": \"1\",\n \"fooEnumList\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumSet\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumMap\": {\n \"hi\": \"Foo\",\n \"zero\": \"0\"\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2535 - | )
|
2536 - | )).unwrap();
|
867 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
868 + | "{\"Integer\":1234}".as_bytes(),
|
869 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
870 + | )),
|
871 + | ))
|
872 + | .unwrap();
|
2537 873 | #[allow(unused_mut)]
|
2538 874 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2539 875 | let config = crate::service::JsonProtocolConfig::builder().build();
|
2540 876 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2541 - | .json_enums(move |input: crate::input::JsonEnumsInput| {
|
877 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
2542 878 | let sender = sender.clone();
|
2543 879 | async move {
|
2544 880 | let result = {
|
2545 - | let expected = crate::input::JsonEnumsInput {
|
2546 - | foo_enum1: ::std::option::Option::Some(
|
2547 - | "Foo"
|
2548 - | .parse::<crate::model::FooEnum>()
|
2549 - | .expect("static value validated to member"),
|
2550 - | ),
|
2551 - | foo_enum2: ::std::option::Option::Some(
|
2552 - | "0".parse::<crate::model::FooEnum>()
|
2553 - | .expect("static value validated to member"),
|
2554 - | ),
|
2555 - | foo_enum3: ::std::option::Option::Some(
|
2556 - | "1".parse::<crate::model::FooEnum>()
|
2557 - | .expect("static value validated to member"),
|
2558 - | ),
|
2559 - | foo_enum_list: ::std::option::Option::Some(vec![
|
2560 - | "Foo"
|
2561 - | .parse::<crate::model::FooEnum>()
|
2562 - | .expect("static value validated to member"),
|
2563 - | "0".parse::<crate::model::FooEnum>()
|
2564 - | .expect("static value validated to member"),
|
2565 - | ]),
|
2566 - | foo_enum_set: ::std::option::Option::Some(
|
2567 - | vec![
|
2568 - | "Foo"
|
2569 - | .parse::<crate::model::FooEnum>()
|
2570 - | .expect("static value validated to member"),
|
2571 - | "0".parse::<crate::model::FooEnum>()
|
2572 - | .expect("static value validated to member"),
|
2573 - | ]
|
2574 - | .try_into()
|
2575 - | .expect("this is only used in tests"),
|
2576 - | ),
|
2577 - | foo_enum_map: ::std::option::Option::Some({
|
2578 - | let mut ret = ::std::collections::HashMap::new();
|
2579 - | ret.insert(
|
2580 - | "hi".to_owned(),
|
2581 - | "Foo"
|
2582 - | .parse::<crate::model::FooEnum>()
|
2583 - | .expect("static value validated to member"),
|
881 + | use ::aws_smithy_protocol_test::FloatEquals;
|
882 + | let expected = crate::input::KitchenSinkOperationInput {
|
883 + | integer: ::std::option::Option::Some(1234),
|
884 + | blob: ::std::option::Option::None,
|
885 + | boolean: ::std::option::Option::None,
|
886 + | double: ::std::option::Option::None,
|
887 + | empty_struct: ::std::option::Option::None,
|
888 + | float: ::std::option::Option::None,
|
889 + | httpdate_timestamp: ::std::option::Option::None,
|
890 + | iso8601_timestamp: ::std::option::Option::None,
|
891 + | json_value: ::std::option::Option::None,
|
892 + | list_of_lists: ::std::option::Option::None,
|
893 + | list_of_maps_of_strings: ::std::option::Option::None,
|
894 + | list_of_strings: ::std::option::Option::None,
|
895 + | list_of_structs: ::std::option::Option::None,
|
896 + | long: ::std::option::Option::None,
|
897 + | map_of_lists_of_strings: ::std::option::Option::None,
|
898 + | map_of_maps: ::std::option::Option::None,
|
899 + | map_of_strings: ::std::option::Option::None,
|
900 + | map_of_structs: ::std::option::Option::None,
|
901 + | recursive_list: ::std::option::Option::None,
|
902 + | recursive_map: ::std::option::Option::None,
|
903 + | recursive_struct: ::std::option::Option::None,
|
904 + | simple_struct: ::std::option::Option::None,
|
905 + | string: ::std::option::Option::None,
|
906 + | struct_with_json_name: ::std::option::Option::None,
|
907 + | timestamp: ::std::option::Option::None,
|
908 + | unix_timestamp: ::std::option::Option::None,
|
909 + | };
|
910 + | ::pretty_assertions::assert_eq!(
|
911 + | input.blob,
|
912 + | expected.blob,
|
913 + | "Unexpected value for `blob`"
|
2584 914 | );
|
2585 - | ret.insert(
|
2586 - | "zero".to_owned(),
|
2587 - | "0".parse::<crate::model::FooEnum>()
|
2588 - | .expect("static value validated to member"),
|
915 + | ::pretty_assertions::assert_eq!(
|
916 + | input.boolean,
|
917 + | expected.boolean,
|
918 + | "Unexpected value for `boolean`"
|
919 + | );
|
920 + | assert!(
|
921 + | input.double.float_equals(&expected.double),
|
922 + | "Unexpected value for `double` {:?} vs. {:?}",
|
923 + | expected.double,
|
924 + | input.double
|
925 + | );
|
926 + | ::pretty_assertions::assert_eq!(
|
927 + | input.empty_struct,
|
928 + | expected.empty_struct,
|
929 + | "Unexpected value for `empty_struct`"
|
930 + | );
|
931 + | assert!(
|
932 + | input.float.float_equals(&expected.float),
|
933 + | "Unexpected value for `float` {:?} vs. {:?}",
|
934 + | expected.float,
|
935 + | input.float
|
936 + | );
|
937 + | ::pretty_assertions::assert_eq!(
|
938 + | input.httpdate_timestamp,
|
939 + | expected.httpdate_timestamp,
|
940 + | "Unexpected value for `httpdate_timestamp`"
|
941 + | );
|
942 + | ::pretty_assertions::assert_eq!(
|
943 + | input.integer,
|
944 + | expected.integer,
|
945 + | "Unexpected value for `integer`"
|
946 + | );
|
947 + | ::pretty_assertions::assert_eq!(
|
948 + | input.iso8601_timestamp,
|
949 + | expected.iso8601_timestamp,
|
950 + | "Unexpected value for `iso8601_timestamp`"
|
951 + | );
|
952 + | ::pretty_assertions::assert_eq!(
|
953 + | input.json_value,
|
954 + | expected.json_value,
|
955 + | "Unexpected value for `json_value`"
|
956 + | );
|
957 + | ::pretty_assertions::assert_eq!(
|
958 + | input.list_of_lists,
|
959 + | expected.list_of_lists,
|
960 + | "Unexpected value for `list_of_lists`"
|
961 + | );
|
962 + | ::pretty_assertions::assert_eq!(
|
963 + | input.list_of_maps_of_strings,
|
964 + | expected.list_of_maps_of_strings,
|
965 + | "Unexpected value for `list_of_maps_of_strings`"
|
966 + | );
|
967 + | ::pretty_assertions::assert_eq!(
|
968 + | input.list_of_strings,
|
969 + | expected.list_of_strings,
|
970 + | "Unexpected value for `list_of_strings`"
|
971 + | );
|
972 + | ::pretty_assertions::assert_eq!(
|
973 + | input.list_of_structs,
|
974 + | expected.list_of_structs,
|
975 + | "Unexpected value for `list_of_structs`"
|
976 + | );
|
977 + | ::pretty_assertions::assert_eq!(
|
978 + | input.long,
|
979 + | expected.long,
|
980 + | "Unexpected value for `long`"
|
981 + | );
|
982 + | ::pretty_assertions::assert_eq!(
|
983 + | input.map_of_lists_of_strings,
|
984 + | expected.map_of_lists_of_strings,
|
985 + | "Unexpected value for `map_of_lists_of_strings`"
|
986 + | );
|
987 + | ::pretty_assertions::assert_eq!(
|
988 + | input.map_of_maps,
|
989 + | expected.map_of_maps,
|
990 + | "Unexpected value for `map_of_maps`"
|
991 + | );
|
992 + | ::pretty_assertions::assert_eq!(
|
993 + | input.map_of_strings,
|
994 + | expected.map_of_strings,
|
995 + | "Unexpected value for `map_of_strings`"
|
996 + | );
|
997 + | ::pretty_assertions::assert_eq!(
|
998 + | input.map_of_structs,
|
999 + | expected.map_of_structs,
|
1000 + | "Unexpected value for `map_of_structs`"
|
1001 + | );
|
1002 + | ::pretty_assertions::assert_eq!(
|
1003 + | input.recursive_list,
|
1004 + | expected.recursive_list,
|
1005 + | "Unexpected value for `recursive_list`"
|
1006 + | );
|
1007 + | ::pretty_assertions::assert_eq!(
|
1008 + | input.recursive_map,
|
1009 + | expected.recursive_map,
|
1010 + | "Unexpected value for `recursive_map`"
|
1011 + | );
|
1012 + | ::pretty_assertions::assert_eq!(
|
1013 + | input.recursive_struct,
|
1014 + | expected.recursive_struct,
|
1015 + | "Unexpected value for `recursive_struct`"
|
1016 + | );
|
1017 + | ::pretty_assertions::assert_eq!(
|
1018 + | input.simple_struct,
|
1019 + | expected.simple_struct,
|
1020 + | "Unexpected value for `simple_struct`"
|
1021 + | );
|
1022 + | ::pretty_assertions::assert_eq!(
|
1023 + | input.string,
|
1024 + | expected.string,
|
1025 + | "Unexpected value for `string`"
|
1026 + | );
|
1027 + | ::pretty_assertions::assert_eq!(
|
1028 + | input.struct_with_json_name,
|
1029 + | expected.struct_with_json_name,
|
1030 + | "Unexpected value for `struct_with_json_name`"
|
1031 + | );
|
1032 + | ::pretty_assertions::assert_eq!(
|
1033 + | input.timestamp,
|
1034 + | expected.timestamp,
|
1035 + | "Unexpected value for `timestamp`"
|
1036 + | );
|
1037 + | ::pretty_assertions::assert_eq!(
|
1038 + | input.unix_timestamp,
|
1039 + | expected.unix_timestamp,
|
1040 + | "Unexpected value for `unix_timestamp`"
|
2589 1041 | );
|
2590 - | ret
|
2591 - | }),
|
2592 - | };
|
2593 - | ::pretty_assertions::assert_eq!(input, expected);
|
2594 - | let output = crate::output::JsonEnumsOutput {
|
2595 - | foo_enum1: ::std::option::Option::None,
|
2596 - | foo_enum2: ::std::option::Option::None,
|
2597 - | foo_enum3: ::std::option::Option::None,
|
2598 - | foo_enum_list: ::std::option::Option::None,
|
2599 - | foo_enum_set: ::std::option::Option::None,
|
2600 - | foo_enum_map: ::std::option::Option::None,
|
1042 + | let output = crate::output::KitchenSinkOperationOutput {
|
1043 + | blob: ::std::option::Option::None,
|
1044 + | boolean: ::std::option::Option::None,
|
1045 + | double: ::std::option::Option::None,
|
1046 + | empty_struct: ::std::option::Option::None,
|
1047 + | float: ::std::option::Option::None,
|
1048 + | httpdate_timestamp: ::std::option::Option::None,
|
1049 + | integer: ::std::option::Option::None,
|
1050 + | iso8601_timestamp: ::std::option::Option::None,
|
1051 + | json_value: ::std::option::Option::None,
|
1052 + | list_of_lists: ::std::option::Option::None,
|
1053 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1054 + | list_of_strings: ::std::option::Option::None,
|
1055 + | list_of_structs: ::std::option::Option::None,
|
1056 + | long: ::std::option::Option::None,
|
1057 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1058 + | map_of_maps: ::std::option::Option::None,
|
1059 + | map_of_strings: ::std::option::Option::None,
|
1060 + | map_of_structs: ::std::option::Option::None,
|
1061 + | recursive_list: ::std::option::Option::None,
|
1062 + | recursive_map: ::std::option::Option::None,
|
1063 + | recursive_struct: ::std::option::Option::None,
|
1064 + | simple_struct: ::std::option::Option::None,
|
1065 + | string: ::std::option::Option::None,
|
1066 + | struct_with_json_name: ::std::option::Option::None,
|
1067 + | timestamp: ::std::option::Option::None,
|
1068 + | unix_timestamp: ::std::option::Option::None,
|
2601 1069 | };
|
2602 1070 | Ok(output)
|
2603 1071 | };
|
2604 1072 | sender.send(()).await.expect("receiver dropped early");
|
2605 1073 | result
|
2606 1074 | }
|
2607 1075 | })
|
2608 1076 | .build_unchecked();
|
2609 1077 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2610 1078 | .await
|
2611 1079 | .expect("unable to make an HTTP request");
|
2612 1080 | assert!(
|
2613 1081 | receiver.recv().await.is_some(),
|
2614 1082 | "we expected operation handler to be invoked but it was not entered"
|
2615 1083 | );
|
2616 1084 | }
|
2617 1085 |
|
2618 - | /// Serializes simple scalar properties
|
2619 - | /// Test ID: AwsJson11Enums
|
2620 - | #[::tokio::test]
|
2621 - | #[::tracing_test::traced_test]
|
2622 - | async fn aws_json11_enums_response() {
|
2623 - | let output = crate::output::JsonEnumsOutput {
|
2624 - | foo_enum1: ::std::option::Option::Some(
|
2625 - | "Foo"
|
2626 - | .parse::<crate::model::FooEnum>()
|
2627 - | .expect("static value validated to member"),
|
2628 - | ),
|
2629 - | foo_enum2: ::std::option::Option::Some(
|
2630 - | "0".parse::<crate::model::FooEnum>()
|
2631 - | .expect("static value validated to member"),
|
2632 - | ),
|
2633 - | foo_enum3: ::std::option::Option::Some(
|
2634 - | "1".parse::<crate::model::FooEnum>()
|
2635 - | .expect("static value validated to member"),
|
2636 - | ),
|
2637 - | foo_enum_list: ::std::option::Option::Some(vec![
|
2638 - | "Foo"
|
2639 - | .parse::<crate::model::FooEnum>()
|
2640 - | .expect("static value validated to member"),
|
2641 - | "0".parse::<crate::model::FooEnum>()
|
2642 - | .expect("static value validated to member"),
|
2643 - | ]),
|
2644 - | foo_enum_set: ::std::option::Option::Some(
|
2645 - | vec![
|
2646 - | "Foo"
|
2647 - | .parse::<crate::model::FooEnum>()
|
2648 - | .expect("static value validated to member"),
|
2649 - | "0".parse::<crate::model::FooEnum>()
|
2650 - | .expect("static value validated to member"),
|
2651 - | ]
|
2652 - | .try_into()
|
2653 - | .expect("this is only used in tests"),
|
2654 - | ),
|
2655 - | foo_enum_map: ::std::option::Option::Some({
|
2656 - | let mut ret = ::std::collections::HashMap::new();
|
2657 - | ret.insert(
|
2658 - | "hi".to_owned(),
|
2659 - | "Foo"
|
2660 - | .parse::<crate::model::FooEnum>()
|
2661 - | .expect("static value validated to member"),
|
2662 - | );
|
2663 - | ret.insert(
|
2664 - | "zero".to_owned(),
|
2665 - | "0".parse::<crate::model::FooEnum>()
|
2666 - | .expect("static value validated to member"),
|
2667 - | );
|
2668 - | ret
|
2669 - | }),
|
2670 - | };
|
2671 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2672 - | let http_response = output.into_response();
|
2673 - | ::pretty_assertions::assert_eq!(
|
2674 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2675 - | http_response.status()
|
2676 - | );
|
2677 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
2678 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2679 - | http_response.headers(),
|
2680 - | expected_headers,
|
2681 - | ));
|
2682 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2683 - | .await
|
2684 - | .expect("unable to extract body to bytes");
|
2685 - | ::aws_smithy_protocol_test::assert_ok(
|
2686 - | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"fooEnum1\": \"Foo\",\n \"fooEnum2\": \"0\",\n \"fooEnum3\": \"1\",\n \"fooEnumList\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumSet\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumMap\": {\n \"hi\": \"Foo\",\n \"zero\": \"0\"\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2687 - | );
|
2688 - | }
|
2689 - | }
|
2690 - |
|
2691 - | ::pin_project_lite::pin_project! {
|
2692 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2693 - | /// [`PutAndGetInlineDocumentsInput`](crate::input::PutAndGetInlineDocumentsInput) using modelled bindings.
|
2694 - | pub struct PutAndGetInlineDocumentsInputFuture {
|
2695 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PutAndGetInlineDocumentsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
2696 - | }
|
2697 - | }
|
2698 - |
|
2699 - | impl std::future::Future for PutAndGetInlineDocumentsInputFuture {
|
2700 - | type Output = Result<
|
2701 - | crate::input::PutAndGetInlineDocumentsInput,
|
2702 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2703 - | >;
|
2704 - |
|
2705 - | fn poll(
|
2706 - | self: std::pin::Pin<&mut Self>,
|
2707 - | cx: &mut std::task::Context<'_>,
|
2708 - | ) -> std::task::Poll<Self::Output> {
|
2709 - | let this = self.project();
|
2710 - | this.inner.as_mut().poll(cx)
|
2711 - | }
|
2712 - | }
|
2713 - |
|
2714 - | impl<B>
|
2715 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2716 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2717 - | B,
|
2718 - | > for crate::input::PutAndGetInlineDocumentsInput
|
2719 - | where
|
2720 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2721 - | B: 'static,
|
2722 - |
|
2723 - | B::Data: Send,
|
2724 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2725 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2726 - | {
|
2727 - | type Rejection =
|
2728 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2729 - | type Future = PutAndGetInlineDocumentsInputFuture;
|
2730 - |
|
2731 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2732 - | let fut = async move {
|
2733 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2734 - | request.headers(),
|
2735 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
2736 - | ) {
|
2737 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2738 - | }
|
2739 - | crate::protocol_serde::shape_put_and_get_inline_documents::de_put_and_get_inline_documents_http_request(request)
|
2740 - | .await
|
2741 - | };
|
2742 - | use ::futures_util::future::TryFutureExt;
|
2743 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2744 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2745 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2746 - | });
|
2747 - | PutAndGetInlineDocumentsInputFuture {
|
2748 - | inner: Box::pin(fut),
|
2749 - | }
|
2750 - | }
|
2751 - | }
|
2752 - | impl
|
2753 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2754 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2755 - | > for crate::output::PutAndGetInlineDocumentsOutput
|
2756 - | {
|
2757 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2758 - | match crate::protocol_serde::shape_put_and_get_inline_documents::ser_put_and_get_inline_documents_http_response(self) {
|
2759 - | Ok(response) => response,
|
2760 - | Err(e) => {
|
2761 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2762 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2763 - | }
|
2764 - | }
|
2765 - | }
|
2766 - | }
|
2767 - |
|
2768 - | #[allow(unreachable_code, unused_variables)]
|
2769 - | #[cfg(test)]
|
2770 - | mod put_and_get_inline_documents_test {
|
2771 - |
|
2772 - | /// Serializes inline documents in a JSON request.
|
2773 - | /// Test ID: PutAndGetInlineDocumentsInput
|
1086 + | /// Serializes long shapes
|
1087 + | /// Test ID: serializes_long_shapes
|
2774 1088 | #[::tokio::test]
|
2775 1089 | #[::tracing_test::traced_test]
|
2776 - | async fn put_and_get_inline_documents_input_request() {
|
1090 + | async fn serializes_long_shapes_request() {
|
2777 1091 | #[allow(unused_mut)]
|
2778 1092 | let mut http_request = ::http::Request::builder()
|
2779 1093 | .uri("/")
|
2780 1094 | .method("POST")
|
2781 1095 | .header("Content-Type", "application/x-amz-json-1.1")
|
2782 - | .header("X-Amz-Target", "JsonProtocol.PutAndGetInlineDocuments")
|
1096 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
2783 1097 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2784 1098 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2785 - | "{\n \"inlineDocument\": {\"foo\": \"bar\"}\n}".as_bytes(),
|
1099 + | "{\"Long\":999999999999}".as_bytes(),
|
2786 1100 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2787 1101 | )),
|
2788 1102 | ))
|
2789 1103 | .unwrap();
|
2790 1104 | #[allow(unused_mut)]
|
2791 1105 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2792 1106 | let config = crate::service::JsonProtocolConfig::builder().build();
|
2793 1107 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2794 - | .put_and_get_inline_documents(
|
2795 - | move |input: crate::input::PutAndGetInlineDocumentsInput| {
|
1108 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
2796 1109 | let sender = sender.clone();
|
2797 1110 | async move {
|
2798 1111 | let result = {
|
2799 - | let expected = crate::input::PutAndGetInlineDocumentsInput {
|
2800 - | inline_document: ::std::option::Option::Some({
|
2801 - | let json_bytes = br#"{
|
2802 - | "foo": "bar"
|
2803 - | }"#;
|
2804 - | let mut tokens =
|
2805 - | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
2806 - | .peekable();
|
2807 - | ::aws_smithy_json::deserialize::token::expect_document(
|
2808 - | &mut tokens,
|
2809 - | )
|
2810 - | .expect("well formed json")
|
2811 - | }),
|
2812 - | };
|
2813 - | ::pretty_assertions::assert_eq!(input, expected);
|
2814 - | let output = crate::output::PutAndGetInlineDocumentsOutput {
|
2815 - | inline_document: ::std::option::Option::Some({
|
2816 - | let json_bytes = br#"null"#;
|
2817 - | let mut tokens =
|
2818 - | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
2819 - | .peekable();
|
2820 - | ::aws_smithy_json::deserialize::token::expect_document(
|
2821 - | &mut tokens,
|
2822 - | )
|
2823 - | .expect("well formed json")
|
2824 - | }),
|
2825 - | };
|
2826 - | output
|
1112 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1113 + | let expected = crate::input::KitchenSinkOperationInput {
|
1114 + | long: ::std::option::Option::Some(999999999999),
|
1115 + | blob: ::std::option::Option::None,
|
1116 + | boolean: ::std::option::Option::None,
|
1117 + | double: ::std::option::Option::None,
|
1118 + | empty_struct: ::std::option::Option::None,
|
1119 + | float: ::std::option::Option::None,
|
1120 + | httpdate_timestamp: ::std::option::Option::None,
|
1121 + | integer: ::std::option::Option::None,
|
1122 + | iso8601_timestamp: ::std::option::Option::None,
|
1123 + | json_value: ::std::option::Option::None,
|
1124 + | list_of_lists: ::std::option::Option::None,
|
1125 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1126 + | list_of_strings: ::std::option::Option::None,
|
1127 + | list_of_structs: ::std::option::Option::None,
|
1128 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1129 + | map_of_maps: ::std::option::Option::None,
|
1130 + | map_of_strings: ::std::option::Option::None,
|
1131 + | map_of_structs: ::std::option::Option::None,
|
1132 + | recursive_list: ::std::option::Option::None,
|
1133 + | recursive_map: ::std::option::Option::None,
|
1134 + | recursive_struct: ::std::option::Option::None,
|
1135 + | simple_struct: ::std::option::Option::None,
|
1136 + | string: ::std::option::Option::None,
|
1137 + | struct_with_json_name: ::std::option::Option::None,
|
1138 + | timestamp: ::std::option::Option::None,
|
1139 + | unix_timestamp: ::std::option::Option::None,
|
2827 1140 | };
|
2828 - | sender.send(()).await.expect("receiver dropped early");
|
2829 - | result
|
2830 - | }
|
2831 - | },
|
2832 - | )
|
2833 - | .build_unchecked();
|
2834 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2835 - | .await
|
2836 - | .expect("unable to make an HTTP request");
|
1141 + | ::pretty_assertions::assert_eq!(
|
1142 + | input.blob,
|
1143 + | expected.blob,
|
1144 + | "Unexpected value for `blob`"
|
1145 + | );
|
1146 + | ::pretty_assertions::assert_eq!(
|
1147 + | input.boolean,
|
1148 + | expected.boolean,
|
1149 + | "Unexpected value for `boolean`"
|
1150 + | );
|
2837 1151 | assert!(
|
2838 - | receiver.recv().await.is_some(),
|
2839 - | "we expected operation handler to be invoked but it was not entered"
|
1152 + | input.double.float_equals(&expected.double),
|
1153 + | "Unexpected value for `double` {:?} vs. {:?}",
|
1154 + | expected.double,
|
1155 + | input.double
|
2840 1156 | );
|
2841 - | }
|
2842 - |
|
2843 - | /// Serializes inline documents in a JSON response.
|
2844 - | /// Test ID: PutAndGetInlineDocumentsInput
|
2845 - | #[::tokio::test]
|
2846 - | #[::tracing_test::traced_test]
|
2847 - | async fn put_and_get_inline_documents_input_response() {
|
2848 - | let output = crate::output::PutAndGetInlineDocumentsOutput {
|
2849 - | inline_document: ::std::option::Option::Some({
|
2850 - | let json_bytes = br#"{
|
2851 - | "foo": "bar"
|
2852 - | }"#;
|
2853 - | let mut tokens =
|
2854 - | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
2855 - | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
2856 - | .expect("well formed json")
|
2857 - | }),
|
2858 - | };
|
2859 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2860 - | let http_response = output.into_response();
|
2861 1157 | ::pretty_assertions::assert_eq!(
|
2862 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2863 - | http_response.status()
|
1158 + | input.empty_struct,
|
1159 + | expected.empty_struct,
|
1160 + | "Unexpected value for `empty_struct`"
|
2864 1161 | );
|
2865 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
2866 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2867 - | http_response.headers(),
|
2868 - | expected_headers,
|
2869 - | ));
|
2870 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2871 - | .await
|
2872 - | .expect("unable to extract body to bytes");
|
2873 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2874 - | &body,
|
2875 - | "{\n \"inlineDocument\": {\"foo\": \"bar\"}\n}",
|
2876 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2877 - | ));
|
2878 - | }
|
2879 - | }
|
2880 - |
|
2881 - | ::pin_project_lite::pin_project! {
|
2882 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2883 - | /// [`OperationWithOptionalInputOutputInput`](crate::input::OperationWithOptionalInputOutputInput) using modelled bindings.
|
2884 - | pub struct OperationWithOptionalInputOutputInputFuture {
|
2885 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithOptionalInputOutputInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
2886 - | }
|
2887 - | }
|
2888 - |
|
2889 - | impl std::future::Future for OperationWithOptionalInputOutputInputFuture {
|
2890 - | type Output = Result<
|
2891 - | crate::input::OperationWithOptionalInputOutputInput,
|
2892 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2893 - | >;
|
2894 - |
|
2895 - | fn poll(
|
2896 - | self: std::pin::Pin<&mut Self>,
|
2897 - | cx: &mut std::task::Context<'_>,
|
2898 - | ) -> std::task::Poll<Self::Output> {
|
2899 - | let this = self.project();
|
2900 - | this.inner.as_mut().poll(cx)
|
2901 - | }
|
2902 - | }
|
2903 - |
|
2904 - | impl<B>
|
2905 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2906 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2907 - | B,
|
2908 - | > for crate::input::OperationWithOptionalInputOutputInput
|
2909 - | where
|
2910 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2911 - | B: 'static,
|
2912 - |
|
2913 - | B::Data: Send,
|
2914 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2915 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2916 - | {
|
2917 - | type Rejection =
|
2918 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2919 - | type Future = OperationWithOptionalInputOutputInputFuture;
|
2920 - |
|
2921 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2922 - | let fut = async move {
|
2923 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2924 - | request.headers(),
|
2925 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
2926 - | ) {
|
2927 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2928 - | }
|
2929 - | crate::protocol_serde::shape_operation_with_optional_input_output::de_operation_with_optional_input_output_http_request(request)
|
2930 - | .await
|
1162 + | assert!(
|
1163 + | input.float.float_equals(&expected.float),
|
1164 + | "Unexpected value for `float` {:?} vs. {:?}",
|
1165 + | expected.float,
|
1166 + | input.float
|
1167 + | );
|
1168 + | ::pretty_assertions::assert_eq!(
|
1169 + | input.httpdate_timestamp,
|
1170 + | expected.httpdate_timestamp,
|
1171 + | "Unexpected value for `httpdate_timestamp`"
|
1172 + | );
|
1173 + | ::pretty_assertions::assert_eq!(
|
1174 + | input.integer,
|
1175 + | expected.integer,
|
1176 + | "Unexpected value for `integer`"
|
1177 + | );
|
1178 + | ::pretty_assertions::assert_eq!(
|
1179 + | input.iso8601_timestamp,
|
1180 + | expected.iso8601_timestamp,
|
1181 + | "Unexpected value for `iso8601_timestamp`"
|
1182 + | );
|
1183 + | ::pretty_assertions::assert_eq!(
|
1184 + | input.json_value,
|
1185 + | expected.json_value,
|
1186 + | "Unexpected value for `json_value`"
|
1187 + | );
|
1188 + | ::pretty_assertions::assert_eq!(
|
1189 + | input.list_of_lists,
|
1190 + | expected.list_of_lists,
|
1191 + | "Unexpected value for `list_of_lists`"
|
1192 + | );
|
1193 + | ::pretty_assertions::assert_eq!(
|
1194 + | input.list_of_maps_of_strings,
|
1195 + | expected.list_of_maps_of_strings,
|
1196 + | "Unexpected value for `list_of_maps_of_strings`"
|
1197 + | );
|
1198 + | ::pretty_assertions::assert_eq!(
|
1199 + | input.list_of_strings,
|
1200 + | expected.list_of_strings,
|
1201 + | "Unexpected value for `list_of_strings`"
|
1202 + | );
|
1203 + | ::pretty_assertions::assert_eq!(
|
1204 + | input.list_of_structs,
|
1205 + | expected.list_of_structs,
|
1206 + | "Unexpected value for `list_of_structs`"
|
1207 + | );
|
1208 + | ::pretty_assertions::assert_eq!(
|
1209 + | input.long,
|
1210 + | expected.long,
|
1211 + | "Unexpected value for `long`"
|
1212 + | );
|
1213 + | ::pretty_assertions::assert_eq!(
|
1214 + | input.map_of_lists_of_strings,
|
1215 + | expected.map_of_lists_of_strings,
|
1216 + | "Unexpected value for `map_of_lists_of_strings`"
|
1217 + | );
|
1218 + | ::pretty_assertions::assert_eq!(
|
1219 + | input.map_of_maps,
|
1220 + | expected.map_of_maps,
|
1221 + | "Unexpected value for `map_of_maps`"
|
1222 + | );
|
1223 + | ::pretty_assertions::assert_eq!(
|
1224 + | input.map_of_strings,
|
1225 + | expected.map_of_strings,
|
1226 + | "Unexpected value for `map_of_strings`"
|
1227 + | );
|
1228 + | ::pretty_assertions::assert_eq!(
|
1229 + | input.map_of_structs,
|
1230 + | expected.map_of_structs,
|
1231 + | "Unexpected value for `map_of_structs`"
|
1232 + | );
|
1233 + | ::pretty_assertions::assert_eq!(
|
1234 + | input.recursive_list,
|
1235 + | expected.recursive_list,
|
1236 + | "Unexpected value for `recursive_list`"
|
1237 + | );
|
1238 + | ::pretty_assertions::assert_eq!(
|
1239 + | input.recursive_map,
|
1240 + | expected.recursive_map,
|
1241 + | "Unexpected value for `recursive_map`"
|
1242 + | );
|
1243 + | ::pretty_assertions::assert_eq!(
|
1244 + | input.recursive_struct,
|
1245 + | expected.recursive_struct,
|
1246 + | "Unexpected value for `recursive_struct`"
|
1247 + | );
|
1248 + | ::pretty_assertions::assert_eq!(
|
1249 + | input.simple_struct,
|
1250 + | expected.simple_struct,
|
1251 + | "Unexpected value for `simple_struct`"
|
1252 + | );
|
1253 + | ::pretty_assertions::assert_eq!(
|
1254 + | input.string,
|
1255 + | expected.string,
|
1256 + | "Unexpected value for `string`"
|
1257 + | );
|
1258 + | ::pretty_assertions::assert_eq!(
|
1259 + | input.struct_with_json_name,
|
1260 + | expected.struct_with_json_name,
|
1261 + | "Unexpected value for `struct_with_json_name`"
|
1262 + | );
|
1263 + | ::pretty_assertions::assert_eq!(
|
1264 + | input.timestamp,
|
1265 + | expected.timestamp,
|
1266 + | "Unexpected value for `timestamp`"
|
1267 + | );
|
1268 + | ::pretty_assertions::assert_eq!(
|
1269 + | input.unix_timestamp,
|
1270 + | expected.unix_timestamp,
|
1271 + | "Unexpected value for `unix_timestamp`"
|
1272 + | );
|
1273 + | let output = crate::output::KitchenSinkOperationOutput {
|
1274 + | blob: ::std::option::Option::None,
|
1275 + | boolean: ::std::option::Option::None,
|
1276 + | double: ::std::option::Option::None,
|
1277 + | empty_struct: ::std::option::Option::None,
|
1278 + | float: ::std::option::Option::None,
|
1279 + | httpdate_timestamp: ::std::option::Option::None,
|
1280 + | integer: ::std::option::Option::None,
|
1281 + | iso8601_timestamp: ::std::option::Option::None,
|
1282 + | json_value: ::std::option::Option::None,
|
1283 + | list_of_lists: ::std::option::Option::None,
|
1284 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1285 + | list_of_strings: ::std::option::Option::None,
|
1286 + | list_of_structs: ::std::option::Option::None,
|
1287 + | long: ::std::option::Option::None,
|
1288 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1289 + | map_of_maps: ::std::option::Option::None,
|
1290 + | map_of_strings: ::std::option::Option::None,
|
1291 + | map_of_structs: ::std::option::Option::None,
|
1292 + | recursive_list: ::std::option::Option::None,
|
1293 + | recursive_map: ::std::option::Option::None,
|
1294 + | recursive_struct: ::std::option::Option::None,
|
1295 + | simple_struct: ::std::option::Option::None,
|
1296 + | string: ::std::option::Option::None,
|
1297 + | struct_with_json_name: ::std::option::Option::None,
|
1298 + | timestamp: ::std::option::Option::None,
|
1299 + | unix_timestamp: ::std::option::Option::None,
|
2931 1300 | };
|
2932 - | use ::futures_util::future::TryFutureExt;
|
2933 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2934 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2935 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2936 - | });
|
2937 - | OperationWithOptionalInputOutputInputFuture {
|
2938 - | inner: Box::pin(fut),
|
2939 - | }
|
2940 - | }
|
2941 - | }
|
2942 - | impl
|
2943 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2944 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
2945 - | > for crate::output::OperationWithOptionalInputOutputOutput
|
2946 - | {
|
2947 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2948 - | match crate::protocol_serde::shape_operation_with_optional_input_output::ser_operation_with_optional_input_output_http_response(self) {
|
2949 - | Ok(response) => response,
|
2950 - | Err(e) => {
|
2951 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2952 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2953 - | }
|
1301 + | Ok(output)
|
1302 + | };
|
1303 + | sender.send(()).await.expect("receiver dropped early");
|
1304 + | result
|
2954 1305 | }
|
1306 + | })
|
1307 + | .build_unchecked();
|
1308 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1309 + | .await
|
1310 + | .expect("unable to make an HTTP request");
|
1311 + | assert!(
|
1312 + | receiver.recv().await.is_some(),
|
1313 + | "we expected operation handler to be invoked but it was not entered"
|
1314 + | );
|
2955 1315 | }
|
2956 - | }
|
2957 - |
|
2958 - | #[allow(unreachable_code, unused_variables)]
|
2959 - | #[cfg(test)]
|
2960 - | mod operation_with_optional_input_output_test {
|
2961 1316 |
|
2962 - | /// Can call operations with no input or output
|
2963 - | /// Test ID: can_call_operation_with_no_input_or_output
|
1317 + | /// Serializes float shapes
|
1318 + | /// Test ID: serializes_float_shapes
|
2964 1319 | #[::tokio::test]
|
2965 1320 | #[::tracing_test::traced_test]
|
2966 - | async fn can_call_operation_with_no_input_or_output_request() {
|
1321 + | async fn serializes_float_shapes_request() {
|
2967 1322 | #[allow(unused_mut)]
|
2968 1323 | let mut http_request = ::http::Request::builder()
|
2969 1324 | .uri("/")
|
2970 1325 | .method("POST")
|
2971 1326 | .header("Content-Type", "application/x-amz-json-1.1")
|
2972 - | .header(
|
2973 - | "X-Amz-Target",
|
2974 - | "JsonProtocol.OperationWithOptionalInputOutput",
|
2975 - | )
|
1327 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
2976 1328 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2977 1329 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2978 - | "{}".as_bytes(),
|
1330 + | "{\"Float\":1234.5}".as_bytes(),
|
2979 1331 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2980 1332 | )),
|
2981 1333 | ))
|
2982 1334 | .unwrap();
|
2983 1335 | #[allow(unused_mut)]
|
2984 1336 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2985 1337 | let config = crate::service::JsonProtocolConfig::builder().build();
|
2986 1338 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2987 - | .operation_with_optional_input_output(
|
2988 - | move |input: crate::input::OperationWithOptionalInputOutputInput| {
|
1339 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
2989 1340 | let sender = sender.clone();
|
2990 1341 | async move {
|
2991 1342 | let result = {
|
2992 - | let expected = crate::input::OperationWithOptionalInputOutputInput {
|
2993 - | value: ::std::option::Option::None,
|
1343 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1344 + | let expected = crate::input::KitchenSinkOperationInput {
|
1345 + | float: ::std::option::Option::Some(1234.5_f32),
|
1346 + | blob: ::std::option::Option::None,
|
1347 + | boolean: ::std::option::Option::None,
|
1348 + | double: ::std::option::Option::None,
|
1349 + | empty_struct: ::std::option::Option::None,
|
1350 + | httpdate_timestamp: ::std::option::Option::None,
|
1351 + | integer: ::std::option::Option::None,
|
1352 + | iso8601_timestamp: ::std::option::Option::None,
|
1353 + | json_value: ::std::option::Option::None,
|
1354 + | list_of_lists: ::std::option::Option::None,
|
1355 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1356 + | list_of_strings: ::std::option::Option::None,
|
1357 + | list_of_structs: ::std::option::Option::None,
|
1358 + | long: ::std::option::Option::None,
|
1359 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1360 + | map_of_maps: ::std::option::Option::None,
|
1361 + | map_of_strings: ::std::option::Option::None,
|
1362 + | map_of_structs: ::std::option::Option::None,
|
1363 + | recursive_list: ::std::option::Option::None,
|
1364 + | recursive_map: ::std::option::Option::None,
|
1365 + | recursive_struct: ::std::option::Option::None,
|
1366 + | simple_struct: ::std::option::Option::None,
|
1367 + | string: ::std::option::Option::None,
|
1368 + | struct_with_json_name: ::std::option::Option::None,
|
1369 + | timestamp: ::std::option::Option::None,
|
1370 + | unix_timestamp: ::std::option::Option::None,
|
2994 1371 | };
|
2995 - | ::pretty_assertions::assert_eq!(input, expected);
|
2996 - | let output = crate::output::OperationWithOptionalInputOutputOutput {
|
2997 - | value: ::std::option::Option::None,
|
1372 + | ::pretty_assertions::assert_eq!(
|
1373 + | input.blob,
|
1374 + | expected.blob,
|
1375 + | "Unexpected value for `blob`"
|
1376 + | );
|
1377 + | ::pretty_assertions::assert_eq!(
|
1378 + | input.boolean,
|
1379 + | expected.boolean,
|
1380 + | "Unexpected value for `boolean`"
|
1381 + | );
|
1382 + | assert!(
|
1383 + | input.double.float_equals(&expected.double),
|
1384 + | "Unexpected value for `double` {:?} vs. {:?}",
|
1385 + | expected.double,
|
1386 + | input.double
|
1387 + | );
|
1388 + | ::pretty_assertions::assert_eq!(
|
1389 + | input.empty_struct,
|
1390 + | expected.empty_struct,
|
1391 + | "Unexpected value for `empty_struct`"
|
1392 + | );
|
1393 + | assert!(
|
1394 + | input.float.float_equals(&expected.float),
|
1395 + | "Unexpected value for `float` {:?} vs. {:?}",
|
1396 + | expected.float,
|
1397 + | input.float
|
1398 + | );
|
1399 + | ::pretty_assertions::assert_eq!(
|
1400 + | input.httpdate_timestamp,
|
1401 + | expected.httpdate_timestamp,
|
1402 + | "Unexpected value for `httpdate_timestamp`"
|
1403 + | );
|
1404 + | ::pretty_assertions::assert_eq!(
|
1405 + | input.integer,
|
1406 + | expected.integer,
|
1407 + | "Unexpected value for `integer`"
|
1408 + | );
|
1409 + | ::pretty_assertions::assert_eq!(
|
1410 + | input.iso8601_timestamp,
|
1411 + | expected.iso8601_timestamp,
|
1412 + | "Unexpected value for `iso8601_timestamp`"
|
1413 + | );
|
1414 + | ::pretty_assertions::assert_eq!(
|
1415 + | input.json_value,
|
1416 + | expected.json_value,
|
1417 + | "Unexpected value for `json_value`"
|
1418 + | );
|
1419 + | ::pretty_assertions::assert_eq!(
|
1420 + | input.list_of_lists,
|
1421 + | expected.list_of_lists,
|
1422 + | "Unexpected value for `list_of_lists`"
|
1423 + | );
|
1424 + | ::pretty_assertions::assert_eq!(
|
1425 + | input.list_of_maps_of_strings,
|
1426 + | expected.list_of_maps_of_strings,
|
1427 + | "Unexpected value for `list_of_maps_of_strings`"
|
1428 + | );
|
1429 + | ::pretty_assertions::assert_eq!(
|
1430 + | input.list_of_strings,
|
1431 + | expected.list_of_strings,
|
1432 + | "Unexpected value for `list_of_strings`"
|
1433 + | );
|
1434 + | ::pretty_assertions::assert_eq!(
|
1435 + | input.list_of_structs,
|
1436 + | expected.list_of_structs,
|
1437 + | "Unexpected value for `list_of_structs`"
|
1438 + | );
|
1439 + | ::pretty_assertions::assert_eq!(
|
1440 + | input.long,
|
1441 + | expected.long,
|
1442 + | "Unexpected value for `long`"
|
1443 + | );
|
1444 + | ::pretty_assertions::assert_eq!(
|
1445 + | input.map_of_lists_of_strings,
|
1446 + | expected.map_of_lists_of_strings,
|
1447 + | "Unexpected value for `map_of_lists_of_strings`"
|
1448 + | );
|
1449 + | ::pretty_assertions::assert_eq!(
|
1450 + | input.map_of_maps,
|
1451 + | expected.map_of_maps,
|
1452 + | "Unexpected value for `map_of_maps`"
|
1453 + | );
|
1454 + | ::pretty_assertions::assert_eq!(
|
1455 + | input.map_of_strings,
|
1456 + | expected.map_of_strings,
|
1457 + | "Unexpected value for `map_of_strings`"
|
1458 + | );
|
1459 + | ::pretty_assertions::assert_eq!(
|
1460 + | input.map_of_structs,
|
1461 + | expected.map_of_structs,
|
1462 + | "Unexpected value for `map_of_structs`"
|
1463 + | );
|
1464 + | ::pretty_assertions::assert_eq!(
|
1465 + | input.recursive_list,
|
1466 + | expected.recursive_list,
|
1467 + | "Unexpected value for `recursive_list`"
|
1468 + | );
|
1469 + | ::pretty_assertions::assert_eq!(
|
1470 + | input.recursive_map,
|
1471 + | expected.recursive_map,
|
1472 + | "Unexpected value for `recursive_map`"
|
1473 + | );
|
1474 + | ::pretty_assertions::assert_eq!(
|
1475 + | input.recursive_struct,
|
1476 + | expected.recursive_struct,
|
1477 + | "Unexpected value for `recursive_struct`"
|
1478 + | );
|
1479 + | ::pretty_assertions::assert_eq!(
|
1480 + | input.simple_struct,
|
1481 + | expected.simple_struct,
|
1482 + | "Unexpected value for `simple_struct`"
|
1483 + | );
|
1484 + | ::pretty_assertions::assert_eq!(
|
1485 + | input.string,
|
1486 + | expected.string,
|
1487 + | "Unexpected value for `string`"
|
1488 + | );
|
1489 + | ::pretty_assertions::assert_eq!(
|
1490 + | input.struct_with_json_name,
|
1491 + | expected.struct_with_json_name,
|
1492 + | "Unexpected value for `struct_with_json_name`"
|
1493 + | );
|
1494 + | ::pretty_assertions::assert_eq!(
|
1495 + | input.timestamp,
|
1496 + | expected.timestamp,
|
1497 + | "Unexpected value for `timestamp`"
|
1498 + | );
|
1499 + | ::pretty_assertions::assert_eq!(
|
1500 + | input.unix_timestamp,
|
1501 + | expected.unix_timestamp,
|
1502 + | "Unexpected value for `unix_timestamp`"
|
1503 + | );
|
1504 + | let output = crate::output::KitchenSinkOperationOutput {
|
1505 + | blob: ::std::option::Option::None,
|
1506 + | boolean: ::std::option::Option::None,
|
1507 + | double: ::std::option::Option::None,
|
1508 + | empty_struct: ::std::option::Option::None,
|
1509 + | float: ::std::option::Option::None,
|
1510 + | httpdate_timestamp: ::std::option::Option::None,
|
1511 + | integer: ::std::option::Option::None,
|
1512 + | iso8601_timestamp: ::std::option::Option::None,
|
1513 + | json_value: ::std::option::Option::None,
|
1514 + | list_of_lists: ::std::option::Option::None,
|
1515 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1516 + | list_of_strings: ::std::option::Option::None,
|
1517 + | list_of_structs: ::std::option::Option::None,
|
1518 + | long: ::std::option::Option::None,
|
1519 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1520 + | map_of_maps: ::std::option::Option::None,
|
1521 + | map_of_strings: ::std::option::Option::None,
|
1522 + | map_of_structs: ::std::option::Option::None,
|
1523 + | recursive_list: ::std::option::Option::None,
|
1524 + | recursive_map: ::std::option::Option::None,
|
1525 + | recursive_struct: ::std::option::Option::None,
|
1526 + | simple_struct: ::std::option::Option::None,
|
1527 + | string: ::std::option::Option::None,
|
1528 + | struct_with_json_name: ::std::option::Option::None,
|
1529 + | timestamp: ::std::option::Option::None,
|
1530 + | unix_timestamp: ::std::option::Option::None,
|
2998 1531 | };
|
2999 - | output
|
1532 + | Ok(output)
|
3000 1533 | };
|
3001 1534 | sender.send(()).await.expect("receiver dropped early");
|
3002 1535 | result
|
3003 1536 | }
|
3004 - | },
|
3005 - | )
|
1537 + | })
|
3006 1538 | .build_unchecked();
|
3007 1539 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3008 1540 | .await
|
3009 1541 | .expect("unable to make an HTTP request");
|
3010 1542 | assert!(
|
3011 1543 | receiver.recv().await.is_some(),
|
3012 1544 | "we expected operation handler to be invoked but it was not entered"
|
3013 1545 | );
|
3014 1546 | }
|
3015 1547 |
|
3016 - | /// Can invoke operations with optional input
|
3017 - | /// Test ID: can_call_operation_with_optional_input
|
1548 + | /// Serializes double shapes
|
1549 + | /// Test ID: serializes_double_shapes
|
3018 1550 | #[::tokio::test]
|
3019 1551 | #[::tracing_test::traced_test]
|
3020 - | async fn can_call_operation_with_optional_input_request() {
|
1552 + | async fn serializes_double_shapes_request() {
|
3021 1553 | #[allow(unused_mut)]
|
3022 1554 | let mut http_request = ::http::Request::builder()
|
3023 1555 | .uri("/")
|
3024 1556 | .method("POST")
|
3025 1557 | .header("Content-Type", "application/x-amz-json-1.1")
|
3026 - | .header(
|
3027 - | "X-Amz-Target",
|
3028 - | "JsonProtocol.OperationWithOptionalInputOutput",
|
3029 - | )
|
1558 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
3030 1559 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3031 1560 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3032 - | "{\"Value\":\"Hi\"}".as_bytes(),
|
1561 + | "{\"Double\":1234.5}".as_bytes(),
|
3033 1562 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3034 1563 | )),
|
3035 1564 | ))
|
3036 1565 | .unwrap();
|
3037 1566 | #[allow(unused_mut)]
|
3038 1567 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3039 1568 | let config = crate::service::JsonProtocolConfig::builder().build();
|
3040 1569 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3041 - | .operation_with_optional_input_output(
|
3042 - | move |input: crate::input::OperationWithOptionalInputOutputInput| {
|
1570 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
3043 1571 | let sender = sender.clone();
|
3044 1572 | async move {
|
3045 1573 | let result = {
|
3046 - | let expected = crate::input::OperationWithOptionalInputOutputInput {
|
3047 - | value: ::std::option::Option::Some("Hi".to_owned()),
|
3048 - | };
|
3049 - | ::pretty_assertions::assert_eq!(input, expected);
|
3050 - | let output = crate::output::OperationWithOptionalInputOutputOutput {
|
3051 - | value: ::std::option::Option::None,
|
3052 - | };
|
3053 - | output
|
1574 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1575 + | let expected = crate::input::KitchenSinkOperationInput {
|
1576 + | double: ::std::option::Option::Some(1234.5_f64),
|
1577 + | blob: ::std::option::Option::None,
|
1578 + | boolean: ::std::option::Option::None,
|
1579 + | empty_struct: ::std::option::Option::None,
|
1580 + | float: ::std::option::Option::None,
|
1581 + | httpdate_timestamp: ::std::option::Option::None,
|
1582 + | integer: ::std::option::Option::None,
|
1583 + | iso8601_timestamp: ::std::option::Option::None,
|
1584 + | json_value: ::std::option::Option::None,
|
1585 + | list_of_lists: ::std::option::Option::None,
|
1586 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1587 + | list_of_strings: ::std::option::Option::None,
|
1588 + | list_of_structs: ::std::option::Option::None,
|
1589 + | long: ::std::option::Option::None,
|
1590 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1591 + | map_of_maps: ::std::option::Option::None,
|
1592 + | map_of_strings: ::std::option::Option::None,
|
1593 + | map_of_structs: ::std::option::Option::None,
|
1594 + | recursive_list: ::std::option::Option::None,
|
1595 + | recursive_map: ::std::option::Option::None,
|
1596 + | recursive_struct: ::std::option::Option::None,
|
1597 + | simple_struct: ::std::option::Option::None,
|
1598 + | string: ::std::option::Option::None,
|
1599 + | struct_with_json_name: ::std::option::Option::None,
|
1600 + | timestamp: ::std::option::Option::None,
|
1601 + | unix_timestamp: ::std::option::Option::None,
|
3054 1602 | };
|
3055 - | sender.send(()).await.expect("receiver dropped early");
|
3056 - | result
|
3057 - | }
|
3058 - | },
|
3059 - | )
|
3060 - | .build_unchecked();
|
3061 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3062 - | .await
|
3063 - | .expect("unable to make an HTTP request");
|
1603 + | ::pretty_assertions::assert_eq!(
|
1604 + | input.blob,
|
1605 + | expected.blob,
|
1606 + | "Unexpected value for `blob`"
|
1607 + | );
|
1608 + | ::pretty_assertions::assert_eq!(
|
1609 + | input.boolean,
|
1610 + | expected.boolean,
|
1611 + | "Unexpected value for `boolean`"
|
1612 + | );
|
3064 1613 | assert!(
|
3065 - | receiver.recv().await.is_some(),
|
3066 - | "we expected operation handler to be invoked but it was not entered"
|
1614 + | input.double.float_equals(&expected.double),
|
1615 + | "Unexpected value for `double` {:?} vs. {:?}",
|
1616 + | expected.double,
|
1617 + | input.double
|
3067 1618 | );
|
3068 - | }
|
3069 - | }
|
3070 - |
|
3071 - | ::pin_project_lite::pin_project! {
|
3072 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3073 - | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
3074 - | pub struct SimpleScalarPropertiesInputFuture {
|
3075 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
3076 - | }
|
3077 - | }
|
3078 - |
|
3079 - | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
3080 - | type Output = Result<
|
3081 - | crate::input::SimpleScalarPropertiesInput,
|
3082 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
3083 - | >;
|
3084 - |
|
3085 - | fn poll(
|
3086 - | self: std::pin::Pin<&mut Self>,
|
3087 - | cx: &mut std::task::Context<'_>,
|
3088 - | ) -> std::task::Poll<Self::Output> {
|
3089 - | let this = self.project();
|
3090 - | this.inner.as_mut().poll(cx)
|
3091 - | }
|
3092 - | }
|
3093 - |
|
3094 - | impl<B>
|
3095 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
3096 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
3097 - | B,
|
3098 - | > for crate::input::SimpleScalarPropertiesInput
|
3099 - | where
|
3100 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
3101 - | B: 'static,
|
3102 - |
|
3103 - | B::Data: Send,
|
3104 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
3105 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
3106 - | {
|
3107 - | type Rejection =
|
3108 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
3109 - | type Future = SimpleScalarPropertiesInputFuture;
|
3110 - |
|
3111 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3112 - | let fut = async move {
|
3113 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
3114 - | request.headers(),
|
3115 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
3116 - | ) {
|
3117 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
3118 - | }
|
3119 - | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
3120 - | .await
|
1619 + | ::pretty_assertions::assert_eq!(
|
1620 + | input.empty_struct,
|
1621 + | expected.empty_struct,
|
1622 + | "Unexpected value for `empty_struct`"
|
1623 + | );
|
1624 + | assert!(
|
1625 + | input.float.float_equals(&expected.float),
|
1626 + | "Unexpected value for `float` {:?} vs. {:?}",
|
1627 + | expected.float,
|
1628 + | input.float
|
1629 + | );
|
1630 + | ::pretty_assertions::assert_eq!(
|
1631 + | input.httpdate_timestamp,
|
1632 + | expected.httpdate_timestamp,
|
1633 + | "Unexpected value for `httpdate_timestamp`"
|
1634 + | );
|
1635 + | ::pretty_assertions::assert_eq!(
|
1636 + | input.integer,
|
1637 + | expected.integer,
|
1638 + | "Unexpected value for `integer`"
|
1639 + | );
|
1640 + | ::pretty_assertions::assert_eq!(
|
1641 + | input.iso8601_timestamp,
|
1642 + | expected.iso8601_timestamp,
|
1643 + | "Unexpected value for `iso8601_timestamp`"
|
1644 + | );
|
1645 + | ::pretty_assertions::assert_eq!(
|
1646 + | input.json_value,
|
1647 + | expected.json_value,
|
1648 + | "Unexpected value for `json_value`"
|
1649 + | );
|
1650 + | ::pretty_assertions::assert_eq!(
|
1651 + | input.list_of_lists,
|
1652 + | expected.list_of_lists,
|
1653 + | "Unexpected value for `list_of_lists`"
|
1654 + | );
|
1655 + | ::pretty_assertions::assert_eq!(
|
1656 + | input.list_of_maps_of_strings,
|
1657 + | expected.list_of_maps_of_strings,
|
1658 + | "Unexpected value for `list_of_maps_of_strings`"
|
1659 + | );
|
1660 + | ::pretty_assertions::assert_eq!(
|
1661 + | input.list_of_strings,
|
1662 + | expected.list_of_strings,
|
1663 + | "Unexpected value for `list_of_strings`"
|
1664 + | );
|
1665 + | ::pretty_assertions::assert_eq!(
|
1666 + | input.list_of_structs,
|
1667 + | expected.list_of_structs,
|
1668 + | "Unexpected value for `list_of_structs`"
|
1669 + | );
|
1670 + | ::pretty_assertions::assert_eq!(
|
1671 + | input.long,
|
1672 + | expected.long,
|
1673 + | "Unexpected value for `long`"
|
1674 + | );
|
1675 + | ::pretty_assertions::assert_eq!(
|
1676 + | input.map_of_lists_of_strings,
|
1677 + | expected.map_of_lists_of_strings,
|
1678 + | "Unexpected value for `map_of_lists_of_strings`"
|
1679 + | );
|
1680 + | ::pretty_assertions::assert_eq!(
|
1681 + | input.map_of_maps,
|
1682 + | expected.map_of_maps,
|
1683 + | "Unexpected value for `map_of_maps`"
|
1684 + | );
|
1685 + | ::pretty_assertions::assert_eq!(
|
1686 + | input.map_of_strings,
|
1687 + | expected.map_of_strings,
|
1688 + | "Unexpected value for `map_of_strings`"
|
1689 + | );
|
1690 + | ::pretty_assertions::assert_eq!(
|
1691 + | input.map_of_structs,
|
1692 + | expected.map_of_structs,
|
1693 + | "Unexpected value for `map_of_structs`"
|
1694 + | );
|
1695 + | ::pretty_assertions::assert_eq!(
|
1696 + | input.recursive_list,
|
1697 + | expected.recursive_list,
|
1698 + | "Unexpected value for `recursive_list`"
|
1699 + | );
|
1700 + | ::pretty_assertions::assert_eq!(
|
1701 + | input.recursive_map,
|
1702 + | expected.recursive_map,
|
1703 + | "Unexpected value for `recursive_map`"
|
1704 + | );
|
1705 + | ::pretty_assertions::assert_eq!(
|
1706 + | input.recursive_struct,
|
1707 + | expected.recursive_struct,
|
1708 + | "Unexpected value for `recursive_struct`"
|
1709 + | );
|
1710 + | ::pretty_assertions::assert_eq!(
|
1711 + | input.simple_struct,
|
1712 + | expected.simple_struct,
|
1713 + | "Unexpected value for `simple_struct`"
|
1714 + | );
|
1715 + | ::pretty_assertions::assert_eq!(
|
1716 + | input.string,
|
1717 + | expected.string,
|
1718 + | "Unexpected value for `string`"
|
1719 + | );
|
1720 + | ::pretty_assertions::assert_eq!(
|
1721 + | input.struct_with_json_name,
|
1722 + | expected.struct_with_json_name,
|
1723 + | "Unexpected value for `struct_with_json_name`"
|
1724 + | );
|
1725 + | ::pretty_assertions::assert_eq!(
|
1726 + | input.timestamp,
|
1727 + | expected.timestamp,
|
1728 + | "Unexpected value for `timestamp`"
|
1729 + | );
|
1730 + | ::pretty_assertions::assert_eq!(
|
1731 + | input.unix_timestamp,
|
1732 + | expected.unix_timestamp,
|
1733 + | "Unexpected value for `unix_timestamp`"
|
1734 + | );
|
1735 + | let output = crate::output::KitchenSinkOperationOutput {
|
1736 + | blob: ::std::option::Option::None,
|
1737 + | boolean: ::std::option::Option::None,
|
1738 + | double: ::std::option::Option::None,
|
1739 + | empty_struct: ::std::option::Option::None,
|
1740 + | float: ::std::option::Option::None,
|
1741 + | httpdate_timestamp: ::std::option::Option::None,
|
1742 + | integer: ::std::option::Option::None,
|
1743 + | iso8601_timestamp: ::std::option::Option::None,
|
1744 + | json_value: ::std::option::Option::None,
|
1745 + | list_of_lists: ::std::option::Option::None,
|
1746 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1747 + | list_of_strings: ::std::option::Option::None,
|
1748 + | list_of_structs: ::std::option::Option::None,
|
1749 + | long: ::std::option::Option::None,
|
1750 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1751 + | map_of_maps: ::std::option::Option::None,
|
1752 + | map_of_strings: ::std::option::Option::None,
|
1753 + | map_of_structs: ::std::option::Option::None,
|
1754 + | recursive_list: ::std::option::Option::None,
|
1755 + | recursive_map: ::std::option::Option::None,
|
1756 + | recursive_struct: ::std::option::Option::None,
|
1757 + | simple_struct: ::std::option::Option::None,
|
1758 + | string: ::std::option::Option::None,
|
1759 + | struct_with_json_name: ::std::option::Option::None,
|
1760 + | timestamp: ::std::option::Option::None,
|
1761 + | unix_timestamp: ::std::option::Option::None,
|
3121 1762 | };
|
3122 - | use ::futures_util::future::TryFutureExt;
|
3123 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
3124 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3125 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
3126 - | });
|
3127 - | SimpleScalarPropertiesInputFuture {
|
3128 - | inner: Box::pin(fut),
|
3129 - | }
|
1763 + | Ok(output)
|
1764 + | };
|
1765 + | sender.send(()).await.expect("receiver dropped early");
|
1766 + | result
|
3130 1767 | }
|
3131 - | }
|
3132 - | impl
|
3133 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3134 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
3135 - | > for crate::output::SimpleScalarPropertiesOutput
|
3136 - | {
|
3137 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3138 - | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
3139 - | Ok(response) => response,
|
3140 - | Err(e) => {
|
3141 - | ::tracing::error!(error = %e, "failed to serialize response");
|
3142 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1768 + | })
|
1769 + | .build_unchecked();
|
1770 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1771 + | .await
|
1772 + | .expect("unable to make an HTTP request");
|
1773 + | assert!(
|
1774 + | receiver.recv().await.is_some(),
|
1775 + | "we expected operation handler to be invoked but it was not entered"
|
1776 + | );
|
3143 1777 | }
|
1778 + |
|
1779 + | /// Serializes blob shapes
|
1780 + | /// Test ID: serializes_blob_shapes
|
1781 + | #[::tokio::test]
|
1782 + | #[::tracing_test::traced_test]
|
1783 + | async fn serializes_blob_shapes_request() {
|
1784 + | #[allow(unused_mut)]
|
1785 + | let mut http_request = ::http::Request::builder()
|
1786 + | .uri("/")
|
1787 + | .method("POST")
|
1788 + | .header("Content-Type", "application/x-amz-json-1.1")
|
1789 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
1790 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1791 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1792 + | "{\"Blob\":\"YmluYXJ5LXZhbHVl\"}".as_bytes(),
|
1793 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1794 + | )),
|
1795 + | ))
|
1796 + | .unwrap();
|
1797 + | #[allow(unused_mut)]
|
1798 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1799 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
1800 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1801 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
1802 + | let sender = sender.clone();
|
1803 + | async move {
|
1804 + | let result = {
|
1805 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1806 + | let expected = crate::input::KitchenSinkOperationInput {
|
1807 + | blob: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
1808 + | "binary-value",
|
1809 + | )),
|
1810 + | boolean: ::std::option::Option::None,
|
1811 + | double: ::std::option::Option::None,
|
1812 + | empty_struct: ::std::option::Option::None,
|
1813 + | float: ::std::option::Option::None,
|
1814 + | httpdate_timestamp: ::std::option::Option::None,
|
1815 + | integer: ::std::option::Option::None,
|
1816 + | iso8601_timestamp: ::std::option::Option::None,
|
1817 + | json_value: ::std::option::Option::None,
|
1818 + | list_of_lists: ::std::option::Option::None,
|
1819 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1820 + | list_of_strings: ::std::option::Option::None,
|
1821 + | list_of_structs: ::std::option::Option::None,
|
1822 + | long: ::std::option::Option::None,
|
1823 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1824 + | map_of_maps: ::std::option::Option::None,
|
1825 + | map_of_strings: ::std::option::Option::None,
|
1826 + | map_of_structs: ::std::option::Option::None,
|
1827 + | recursive_list: ::std::option::Option::None,
|
1828 + | recursive_map: ::std::option::Option::None,
|
1829 + | recursive_struct: ::std::option::Option::None,
|
1830 + | simple_struct: ::std::option::Option::None,
|
1831 + | string: ::std::option::Option::None,
|
1832 + | struct_with_json_name: ::std::option::Option::None,
|
1833 + | timestamp: ::std::option::Option::None,
|
1834 + | unix_timestamp: ::std::option::Option::None,
|
1835 + | };
|
1836 + | ::pretty_assertions::assert_eq!(
|
1837 + | input.blob,
|
1838 + | expected.blob,
|
1839 + | "Unexpected value for `blob`"
|
1840 + | );
|
1841 + | ::pretty_assertions::assert_eq!(
|
1842 + | input.boolean,
|
1843 + | expected.boolean,
|
1844 + | "Unexpected value for `boolean`"
|
1845 + | );
|
1846 + | assert!(
|
1847 + | input.double.float_equals(&expected.double),
|
1848 + | "Unexpected value for `double` {:?} vs. {:?}",
|
1849 + | expected.double,
|
1850 + | input.double
|
1851 + | );
|
1852 + | ::pretty_assertions::assert_eq!(
|
1853 + | input.empty_struct,
|
1854 + | expected.empty_struct,
|
1855 + | "Unexpected value for `empty_struct`"
|
1856 + | );
|
1857 + | assert!(
|
1858 + | input.float.float_equals(&expected.float),
|
1859 + | "Unexpected value for `float` {:?} vs. {:?}",
|
1860 + | expected.float,
|
1861 + | input.float
|
1862 + | );
|
1863 + | ::pretty_assertions::assert_eq!(
|
1864 + | input.httpdate_timestamp,
|
1865 + | expected.httpdate_timestamp,
|
1866 + | "Unexpected value for `httpdate_timestamp`"
|
1867 + | );
|
1868 + | ::pretty_assertions::assert_eq!(
|
1869 + | input.integer,
|
1870 + | expected.integer,
|
1871 + | "Unexpected value for `integer`"
|
1872 + | );
|
1873 + | ::pretty_assertions::assert_eq!(
|
1874 + | input.iso8601_timestamp,
|
1875 + | expected.iso8601_timestamp,
|
1876 + | "Unexpected value for `iso8601_timestamp`"
|
1877 + | );
|
1878 + | ::pretty_assertions::assert_eq!(
|
1879 + | input.json_value,
|
1880 + | expected.json_value,
|
1881 + | "Unexpected value for `json_value`"
|
1882 + | );
|
1883 + | ::pretty_assertions::assert_eq!(
|
1884 + | input.list_of_lists,
|
1885 + | expected.list_of_lists,
|
1886 + | "Unexpected value for `list_of_lists`"
|
1887 + | );
|
1888 + | ::pretty_assertions::assert_eq!(
|
1889 + | input.list_of_maps_of_strings,
|
1890 + | expected.list_of_maps_of_strings,
|
1891 + | "Unexpected value for `list_of_maps_of_strings`"
|
1892 + | );
|
1893 + | ::pretty_assertions::assert_eq!(
|
1894 + | input.list_of_strings,
|
1895 + | expected.list_of_strings,
|
1896 + | "Unexpected value for `list_of_strings`"
|
1897 + | );
|
1898 + | ::pretty_assertions::assert_eq!(
|
1899 + | input.list_of_structs,
|
1900 + | expected.list_of_structs,
|
1901 + | "Unexpected value for `list_of_structs`"
|
1902 + | );
|
1903 + | ::pretty_assertions::assert_eq!(
|
1904 + | input.long,
|
1905 + | expected.long,
|
1906 + | "Unexpected value for `long`"
|
1907 + | );
|
1908 + | ::pretty_assertions::assert_eq!(
|
1909 + | input.map_of_lists_of_strings,
|
1910 + | expected.map_of_lists_of_strings,
|
1911 + | "Unexpected value for `map_of_lists_of_strings`"
|
1912 + | );
|
1913 + | ::pretty_assertions::assert_eq!(
|
1914 + | input.map_of_maps,
|
1915 + | expected.map_of_maps,
|
1916 + | "Unexpected value for `map_of_maps`"
|
1917 + | );
|
1918 + | ::pretty_assertions::assert_eq!(
|
1919 + | input.map_of_strings,
|
1920 + | expected.map_of_strings,
|
1921 + | "Unexpected value for `map_of_strings`"
|
1922 + | );
|
1923 + | ::pretty_assertions::assert_eq!(
|
1924 + | input.map_of_structs,
|
1925 + | expected.map_of_structs,
|
1926 + | "Unexpected value for `map_of_structs`"
|
1927 + | );
|
1928 + | ::pretty_assertions::assert_eq!(
|
1929 + | input.recursive_list,
|
1930 + | expected.recursive_list,
|
1931 + | "Unexpected value for `recursive_list`"
|
1932 + | );
|
1933 + | ::pretty_assertions::assert_eq!(
|
1934 + | input.recursive_map,
|
1935 + | expected.recursive_map,
|
1936 + | "Unexpected value for `recursive_map`"
|
1937 + | );
|
1938 + | ::pretty_assertions::assert_eq!(
|
1939 + | input.recursive_struct,
|
1940 + | expected.recursive_struct,
|
1941 + | "Unexpected value for `recursive_struct`"
|
1942 + | );
|
1943 + | ::pretty_assertions::assert_eq!(
|
1944 + | input.simple_struct,
|
1945 + | expected.simple_struct,
|
1946 + | "Unexpected value for `simple_struct`"
|
1947 + | );
|
1948 + | ::pretty_assertions::assert_eq!(
|
1949 + | input.string,
|
1950 + | expected.string,
|
1951 + | "Unexpected value for `string`"
|
1952 + | );
|
1953 + | ::pretty_assertions::assert_eq!(
|
1954 + | input.struct_with_json_name,
|
1955 + | expected.struct_with_json_name,
|
1956 + | "Unexpected value for `struct_with_json_name`"
|
1957 + | );
|
1958 + | ::pretty_assertions::assert_eq!(
|
1959 + | input.timestamp,
|
1960 + | expected.timestamp,
|
1961 + | "Unexpected value for `timestamp`"
|
1962 + | );
|
1963 + | ::pretty_assertions::assert_eq!(
|
1964 + | input.unix_timestamp,
|
1965 + | expected.unix_timestamp,
|
1966 + | "Unexpected value for `unix_timestamp`"
|
1967 + | );
|
1968 + | let output = crate::output::KitchenSinkOperationOutput {
|
1969 + | blob: ::std::option::Option::None,
|
1970 + | boolean: ::std::option::Option::None,
|
1971 + | double: ::std::option::Option::None,
|
1972 + | empty_struct: ::std::option::Option::None,
|
1973 + | float: ::std::option::Option::None,
|
1974 + | httpdate_timestamp: ::std::option::Option::None,
|
1975 + | integer: ::std::option::Option::None,
|
1976 + | iso8601_timestamp: ::std::option::Option::None,
|
1977 + | json_value: ::std::option::Option::None,
|
1978 + | list_of_lists: ::std::option::Option::None,
|
1979 + | list_of_maps_of_strings: ::std::option::Option::None,
|
1980 + | list_of_strings: ::std::option::Option::None,
|
1981 + | list_of_structs: ::std::option::Option::None,
|
1982 + | long: ::std::option::Option::None,
|
1983 + | map_of_lists_of_strings: ::std::option::Option::None,
|
1984 + | map_of_maps: ::std::option::Option::None,
|
1985 + | map_of_strings: ::std::option::Option::None,
|
1986 + | map_of_structs: ::std::option::Option::None,
|
1987 + | recursive_list: ::std::option::Option::None,
|
1988 + | recursive_map: ::std::option::Option::None,
|
1989 + | recursive_struct: ::std::option::Option::None,
|
1990 + | simple_struct: ::std::option::Option::None,
|
1991 + | string: ::std::option::Option::None,
|
1992 + | struct_with_json_name: ::std::option::Option::None,
|
1993 + | timestamp: ::std::option::Option::None,
|
1994 + | unix_timestamp: ::std::option::Option::None,
|
1995 + | };
|
1996 + | Ok(output)
|
1997 + | };
|
1998 + | sender.send(()).await.expect("receiver dropped early");
|
1999 + | result
|
3144 2000 | }
|
2001 + | })
|
2002 + | .build_unchecked();
|
2003 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2004 + | .await
|
2005 + | .expect("unable to make an HTTP request");
|
2006 + | assert!(
|
2007 + | receiver.recv().await.is_some(),
|
2008 + | "we expected operation handler to be invoked but it was not entered"
|
2009 + | );
|
3145 2010 | }
|
3146 - | }
|
3147 - |
|
3148 - | #[allow(unreachable_code, unused_variables)]
|
3149 - | #[cfg(test)]
|
3150 - | mod simple_scalar_properties_test {
|
3151 2011 |
|
3152 - | /// Supports handling NaN float values.
|
3153 - | /// Test ID: AwsJson11SupportsNaNFloatInputs
|
2012 + | /// Serializes boolean shapes (true)
|
2013 + | /// Test ID: serializes_boolean_shapes_true
|
3154 2014 | #[::tokio::test]
|
3155 2015 | #[::tracing_test::traced_test]
|
3156 - | async fn aws_json11_supports_na_n_float_inputs_request() {
|
2016 + | async fn serializes_boolean_shapes_true_request() {
|
3157 2017 | #[allow(unused_mut)]
|
3158 2018 | let mut http_request = ::http::Request::builder()
|
3159 2019 | .uri("/")
|
3160 2020 | .method("POST")
|
3161 2021 | .header("Content-Type", "application/x-amz-json-1.1")
|
3162 - | .header("X-Amz-Target", "JsonProtocol.SimpleScalarProperties")
|
2022 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
3163 2023 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3164 2024 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3165 - | "{\n \"floatValue\": \"NaN\",\n \"doubleValue\": \"NaN\"\n}".as_bytes(),
|
2025 + | "{\"Boolean\":true}".as_bytes(),
|
3166 2026 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3167 2027 | )),
|
3168 2028 | ))
|
3169 2029 | .unwrap();
|
3170 2030 | #[allow(unused_mut)]
|
3171 2031 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3172 2032 | let config = crate::service::JsonProtocolConfig::builder().build();
|
3173 2033 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3174 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2034 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
3175 2035 | let sender = sender.clone();
|
3176 2036 | async move {
|
3177 - | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
3178 - | let expected =
|
3179 - | crate::input::SimpleScalarPropertiesInput {
|
3180 - | float_value:
|
3181 - | ::std::option::Option::Some(
|
3182 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN").expect("invalid string for number")
|
3183 - | )
|
3184 - | ,
|
3185 - | double_value:
|
3186 - | ::std::option::Option::Some(
|
3187 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN").expect("invalid string for number")
|
3188 - | )
|
3189 - | ,
|
3190 - | }
|
3191 - | ;
|
3192 - | assert!(input.float_value.float_equals(&expected.float_value),
|
3193 - | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
3194 - | assert!(input.double_value.float_equals(&expected.double_value),
|
3195 - | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
3196 - | let output =
|
3197 - | crate::output::SimpleScalarPropertiesOutput {
|
3198 - | float_value:
|
3199 - | ::std::option::Option::None
|
3200 - | ,
|
3201 - | double_value:
|
3202 - | ::std::option::Option::None
|
3203 - | ,
|
3204 - | }
|
3205 - | ;
|
3206 - | output };
|
2037 + | let result = {
|
2038 + | use ::aws_smithy_protocol_test::FloatEquals;
|
2039 + | let expected = crate::input::KitchenSinkOperationInput {
|
2040 + | boolean: ::std::option::Option::Some(true),
|
2041 + | blob: ::std::option::Option::None,
|
2042 + | double: ::std::option::Option::None,
|
2043 + | empty_struct: ::std::option::Option::None,
|
2044 + | float: ::std::option::Option::None,
|
2045 + | httpdate_timestamp: ::std::option::Option::None,
|
2046 + | integer: ::std::option::Option::None,
|
2047 + | iso8601_timestamp: ::std::option::Option::None,
|
2048 + | json_value: ::std::option::Option::None,
|
2049 + | list_of_lists: ::std::option::Option::None,
|
2050 + | list_of_maps_of_strings: ::std::option::Option::None,
|
2051 + | list_of_strings: ::std::option::Option::None,
|
2052 + | list_of_structs: ::std::option::Option::None,
|
2053 + | long: ::std::option::Option::None,
|
2054 + | map_of_lists_of_strings: ::std::option::Option::None,
|
2055 + | map_of_maps: ::std::option::Option::None,
|
2056 + | map_of_strings: ::std::option::Option::None,
|
2057 + | map_of_structs: ::std::option::Option::None,
|
2058 + | recursive_list: ::std::option::Option::None,
|
2059 + | recursive_map: ::std::option::Option::None,
|
2060 + | recursive_struct: ::std::option::Option::None,
|
2061 + | simple_struct: ::std::option::Option::None,
|
2062 + | string: ::std::option::Option::None,
|
2063 + | struct_with_json_name: ::std::option::Option::None,
|
2064 + | timestamp: ::std::option::Option::None,
|
2065 + | unix_timestamp: ::std::option::Option::None,
|
2066 + | };
|
2067 + | ::pretty_assertions::assert_eq!(
|
2068 + | input.blob,
|
2069 + | expected.blob,
|
2070 + | "Unexpected value for `blob`"
|
2071 + | );
|
2072 + | ::pretty_assertions::assert_eq!(
|
2073 + | input.boolean,
|
2074 + | expected.boolean,
|
2075 + | "Unexpected value for `boolean`"
|
2076 + | );
|
2077 + | assert!(
|
2078 + | input.double.float_equals(&expected.double),
|
2079 + | "Unexpected value for `double` {:?} vs. {:?}",
|
2080 + | expected.double,
|
2081 + | input.double
|
2082 + | );
|
2083 + | ::pretty_assertions::assert_eq!(
|
2084 + | input.empty_struct,
|
2085 + | expected.empty_struct,
|
2086 + | "Unexpected value for `empty_struct`"
|
2087 + | );
|
2088 + | assert!(
|
2089 + | input.float.float_equals(&expected.float),
|
2090 + | "Unexpected value for `float` {:?} vs. {:?}",
|
2091 + | expected.float,
|
2092 + | input.float
|
2093 + | );
|
2094 + | ::pretty_assertions::assert_eq!(
|
2095 + | input.httpdate_timestamp,
|
2096 + | expected.httpdate_timestamp,
|
2097 + | "Unexpected value for `httpdate_timestamp`"
|
2098 + | );
|
2099 + | ::pretty_assertions::assert_eq!(
|
2100 + | input.integer,
|
2101 + | expected.integer,
|
2102 + | "Unexpected value for `integer`"
|
2103 + | );
|
2104 + | ::pretty_assertions::assert_eq!(
|
2105 + | input.iso8601_timestamp,
|
2106 + | expected.iso8601_timestamp,
|
2107 + | "Unexpected value for `iso8601_timestamp`"
|
2108 + | );
|
2109 + | ::pretty_assertions::assert_eq!(
|
2110 + | input.json_value,
|
2111 + | expected.json_value,
|
2112 + | "Unexpected value for `json_value`"
|
2113 + | );
|
2114 + | ::pretty_assertions::assert_eq!(
|
2115 + | input.list_of_lists,
|
2116 + | expected.list_of_lists,
|
2117 + | "Unexpected value for `list_of_lists`"
|
2118 + | );
|
2119 + | ::pretty_assertions::assert_eq!(
|
2120 + | input.list_of_maps_of_strings,
|
2121 + | expected.list_of_maps_of_strings,
|
2122 + | "Unexpected value for `list_of_maps_of_strings`"
|
2123 + | );
|
2124 + | ::pretty_assertions::assert_eq!(
|
2125 + | input.list_of_strings,
|
2126 + | expected.list_of_strings,
|
2127 + | "Unexpected value for `list_of_strings`"
|
2128 + | );
|
2129 + | ::pretty_assertions::assert_eq!(
|
2130 + | input.list_of_structs,
|
2131 + | expected.list_of_structs,
|
2132 + | "Unexpected value for `list_of_structs`"
|
2133 + | );
|
2134 + | ::pretty_assertions::assert_eq!(
|
2135 + | input.long,
|
2136 + | expected.long,
|
2137 + | "Unexpected value for `long`"
|
2138 + | );
|
2139 + | ::pretty_assertions::assert_eq!(
|
2140 + | input.map_of_lists_of_strings,
|
2141 + | expected.map_of_lists_of_strings,
|
2142 + | "Unexpected value for `map_of_lists_of_strings`"
|
2143 + | );
|
2144 + | ::pretty_assertions::assert_eq!(
|
2145 + | input.map_of_maps,
|
2146 + | expected.map_of_maps,
|
2147 + | "Unexpected value for `map_of_maps`"
|
2148 + | );
|
2149 + | ::pretty_assertions::assert_eq!(
|
2150 + | input.map_of_strings,
|
2151 + | expected.map_of_strings,
|
2152 + | "Unexpected value for `map_of_strings`"
|
2153 + | );
|
2154 + | ::pretty_assertions::assert_eq!(
|
2155 + | input.map_of_structs,
|
2156 + | expected.map_of_structs,
|
2157 + | "Unexpected value for `map_of_structs`"
|
2158 + | );
|
2159 + | ::pretty_assertions::assert_eq!(
|
2160 + | input.recursive_list,
|
2161 + | expected.recursive_list,
|
2162 + | "Unexpected value for `recursive_list`"
|
2163 + | );
|
2164 + | ::pretty_assertions::assert_eq!(
|
2165 + | input.recursive_map,
|
2166 + | expected.recursive_map,
|
2167 + | "Unexpected value for `recursive_map`"
|
2168 + | );
|
2169 + | ::pretty_assertions::assert_eq!(
|
2170 + | input.recursive_struct,
|
2171 + | expected.recursive_struct,
|
2172 + | "Unexpected value for `recursive_struct`"
|
2173 + | );
|
2174 + | ::pretty_assertions::assert_eq!(
|
2175 + | input.simple_struct,
|
2176 + | expected.simple_struct,
|
2177 + | "Unexpected value for `simple_struct`"
|
2178 + | );
|
2179 + | ::pretty_assertions::assert_eq!(
|
2180 + | input.string,
|
2181 + | expected.string,
|
2182 + | "Unexpected value for `string`"
|
2183 + | );
|
2184 + | ::pretty_assertions::assert_eq!(
|
2185 + | input.struct_with_json_name,
|
2186 + | expected.struct_with_json_name,
|
2187 + | "Unexpected value for `struct_with_json_name`"
|
2188 + | );
|
2189 + | ::pretty_assertions::assert_eq!(
|
2190 + | input.timestamp,
|
2191 + | expected.timestamp,
|
2192 + | "Unexpected value for `timestamp`"
|
2193 + | );
|
2194 + | ::pretty_assertions::assert_eq!(
|
2195 + | input.unix_timestamp,
|
2196 + | expected.unix_timestamp,
|
2197 + | "Unexpected value for `unix_timestamp`"
|
2198 + | );
|
2199 + | let output = crate::output::KitchenSinkOperationOutput {
|
2200 + | blob: ::std::option::Option::None,
|
2201 + | boolean: ::std::option::Option::None,
|
2202 + | double: ::std::option::Option::None,
|
2203 + | empty_struct: ::std::option::Option::None,
|
2204 + | float: ::std::option::Option::None,
|
2205 + | httpdate_timestamp: ::std::option::Option::None,
|
2206 + | integer: ::std::option::Option::None,
|
2207 + | iso8601_timestamp: ::std::option::Option::None,
|
2208 + | json_value: ::std::option::Option::None,
|
2209 + | list_of_lists: ::std::option::Option::None,
|
2210 + | list_of_maps_of_strings: ::std::option::Option::None,
|
2211 + | list_of_strings: ::std::option::Option::None,
|
2212 + | list_of_structs: ::std::option::Option::None,
|
2213 + | long: ::std::option::Option::None,
|
2214 + | map_of_lists_of_strings: ::std::option::Option::None,
|
2215 + | map_of_maps: ::std::option::Option::None,
|
2216 + | map_of_strings: ::std::option::Option::None,
|
2217 + | map_of_structs: ::std::option::Option::None,
|
2218 + | recursive_list: ::std::option::Option::None,
|
2219 + | recursive_map: ::std::option::Option::None,
|
2220 + | recursive_struct: ::std::option::Option::None,
|
2221 + | simple_struct: ::std::option::Option::None,
|
2222 + | string: ::std::option::Option::None,
|
2223 + | struct_with_json_name: ::std::option::Option::None,
|
2224 + | timestamp: ::std::option::Option::None,
|
2225 + | unix_timestamp: ::std::option::Option::None,
|
2226 + | };
|
2227 + | Ok(output)
|
2228 + | };
|
3207 2229 | sender.send(()).await.expect("receiver dropped early");
|
3208 2230 | result
|
3209 2231 | }
|
3210 2232 | })
|
3211 2233 | .build_unchecked();
|
3212 2234 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3213 2235 | .await
|
3214 2236 | .expect("unable to make an HTTP request");
|
3215 2237 | assert!(
|
3216 2238 | receiver.recv().await.is_some(),
|
3217 2239 | "we expected operation handler to be invoked but it was not entered"
|
3218 2240 | );
|
3219 2241 | }
|
3220 2242 |
|
3221 - | /// Supports handling Infinity float values.
|
3222 - | /// Test ID: AwsJson11SupportsInfinityFloatInputs
|
2243 + | /// Serializes boolean shapes (false)
|
2244 + | /// Test ID: serializes_boolean_shapes_false
|
3223 2245 | #[::tokio::test]
|
3224 2246 | #[::tracing_test::traced_test]
|
3225 - | async fn aws_json11_supports_infinity_float_inputs_request() {
|
2247 + | async fn serializes_boolean_shapes_false_request() {
|
3226 2248 | #[allow(unused_mut)]
|
3227 2249 | let mut http_request = ::http::Request::builder()
|
3228 2250 | .uri("/")
|
3229 2251 | .method("POST")
|
3230 2252 | .header("Content-Type", "application/x-amz-json-1.1")
|
3231 - | .header("X-Amz-Target", "JsonProtocol.SimpleScalarProperties")
|
2253 + | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
3232 2254 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3233 2255 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3234 - | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}"
|
3235 - | .as_bytes(),
|
2256 + | "{\"Boolean\":false}".as_bytes(),
|
3236 2257 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3237 2258 | )),
|
3238 2259 | ))
|
3239 2260 | .unwrap();
|
3240 2261 | #[allow(unused_mut)]
|
3241 2262 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3242 2263 | let config = crate::service::JsonProtocolConfig::builder().build();
|
3243 2264 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3244 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2265 + | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
3245 2266 | let sender = sender.clone();
|
3246 2267 | async move {
|
3247 - | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
3248 - | let expected =
|
3249 - | crate::input::SimpleScalarPropertiesInput {
|
3250 - | float_value:
|
3251 - | ::std::option::Option::Some(
|
3252 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number")
|
3253 - | )
|
3254 - | ,
|
3255 - | double_value:
|
3256 - | ::std::option::Option::Some(
|
3257 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number")
|
3258 - | )
|
3259 - | ,
|
3260 - | }
|
3261 - | ;
|
3262 - | assert!(input.float_value.float_equals(&expected.float_value),
|
3263 - | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
3264 - | assert!(input.double_value.float_equals(&expected.double_value),
|
3265 - | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
3266 - | let output =
|
3267 - | crate::output::SimpleScalarPropertiesOutput {
|
3268 - | float_value:
|
3269 - | ::std::option::Option::None
|
3270 - | ,
|
3271 - | double_value:
|
3272 - | ::std::option::Option::None
|
3273 - | ,
|
3274 - | }
|
3275 - | ;
|
3276 - | output };
|
3277 - | sender.send(()).await.expect("receiver dropped early");
|
3278 - | result
|
3279 - | }
|
3280 - | })
|
3281 - | .build_unchecked();
|
3282 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3283 - | .await
|
3284 - | .expect("unable to make an HTTP request");
|
2268 + | let result = {
|
2269 + | use ::aws_smithy_protocol_test::FloatEquals;
|
2270 + | let expected = crate::input::KitchenSinkOperationInput {
|
2271 + | boolean: ::std::option::Option::Some(false),
|
2272 + | blob: ::std::option::Option::None,
|
2273 + | double: ::std::option::Option::None,
|
2274 + | empty_struct: ::std::option::Option::None,
|
2275 + | float: ::std::option::Option::None,
|
2276 + | httpdate_timestamp: ::std::option::Option::None,
|
2277 + | integer: ::std::option::Option::None,
|
2278 + | iso8601_timestamp: ::std::option::Option::None,
|
2279 + | json_value: ::std::option::Option::None,
|
2280 + | list_of_lists: ::std::option::Option::None,
|
2281 + | list_of_maps_of_strings: ::std::option::Option::None,
|
2282 + | list_of_strings: ::std::option::Option::None,
|
2283 + | list_of_structs: ::std::option::Option::None,
|
2284 + | long: ::std::option::Option::None,
|
2285 + | map_of_lists_of_strings: ::std::option::Option::None,
|
2286 + | map_of_maps: ::std::option::Option::None,
|
2287 + | map_of_strings: ::std::option::Option::None,
|
2288 + | map_of_structs: ::std::option::Option::None,
|
2289 + | recursive_list: ::std::option::Option::None,
|
2290 + | recursive_map: ::std::option::Option::None,
|
2291 + | recursive_struct: ::std::option::Option::None,
|
2292 + | simple_struct: ::std::option::Option::None,
|
2293 + | string: ::std::option::Option::None,
|
2294 + | struct_with_json_name: ::std::option::Option::None,
|
2295 + | timestamp: ::std::option::Option::None,
|
2296 + | unix_timestamp: ::std::option::Option::None,
|
2297 + | };
|
2298 + | ::pretty_assertions::assert_eq!(
|
2299 + | input.blob,
|
2300 + | expected.blob,
|
2301 + | "Unexpected value for `blob`"
|
2302 + | );
|
2303 + | ::pretty_assertions::assert_eq!(
|
2304 + | input.boolean,
|
2305 + | expected.boolean,
|
2306 + | "Unexpected value for `boolean`"
|
2307 + | );
|
3285 2308 | assert!(
|
3286 - | receiver.recv().await.is_some(),
|
3287 - | "we expected operation handler to be invoked but it was not entered"
|
2309 + | input.double.float_equals(&expected.double),
|
2310 + | "Unexpected value for `double` {:?} vs. {:?}",
|
2311 + | expected.double,
|
2312 + | input.double
|
3288 2313 | );
|
3289 - | }
|
3290 - |
|
3291 - | /// Supports handling -Infinity float values.
|
3292 - | /// Test ID: AwsJson11SupportsNegativeInfinityFloatInputs
|
3293 - | #[::tokio::test]
|
3294 - | #[::tracing_test::traced_test]
|
3295 - | async fn aws_json11_supports_negative_infinity_float_inputs_request() {
|
3296 - | #[allow(unused_mut)]
|
3297 - | let mut http_request = ::http::Request::builder()
|
3298 - | .uri("/")
|
3299 - | .method("POST")
|
3300 - | .header("Content-Type", "application/x-amz-json-1.1")
|
3301 - | .header("X-Amz-Target", "JsonProtocol.SimpleScalarProperties")
|
3302 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3303 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3304 - | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}"
|
3305 - | .as_bytes(),
|
3306 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3307 - | )),
|
3308 - | ))
|
3309 - | .unwrap();
|
3310 - | #[allow(unused_mut)]
|
3311 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3312 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
3313 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3314 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3315 - | let sender = sender.clone();
|
3316 - | async move {
|
3317 - | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
3318 - | let expected =
|
3319 - | crate::input::SimpleScalarPropertiesInput {
|
3320 - | float_value:
|
3321 - | ::std::option::Option::Some(
|
3322 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number")
|
3323 - | )
|
3324 - | ,
|
3325 - | double_value:
|
3326 - | ::std::option::Option::Some(
|
3327 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number")
|
3328 - | )
|
3329 - | ,
|
3330 - | }
|
3331 - | ;
|
3332 - | assert!(input.float_value.float_equals(&expected.float_value),
|
3333 - | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
3334 - | assert!(input.double_value.float_equals(&expected.double_value),
|
3335 - | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
3336 - | let output =
|
3337 - | crate::output::SimpleScalarPropertiesOutput {
|
3338 - | float_value:
|
3339 - | ::std::option::Option::None
|
3340 - | ,
|
3341 - | double_value:
|
3342 - | ::std::option::Option::None
|
3343 - | ,
|
3344 - | }
|
3345 - | ;
|
3346 - | output };
|
2314 + | ::pretty_assertions::assert_eq!(
|
2315 + | input.empty_struct,
|
2316 + | expected.empty_struct,
|
2317 + | "Unexpected value for `empty_struct`"
|
2318 + | );
|
2319 + | assert!(
|
2320 + | input.float.float_equals(&expected.float),
|
2321 + | "Unexpected value for `float` {:?} vs. {:?}",
|
2322 + | expected.float,
|
2323 + | input.float
|
2324 + | );
|
2325 + | ::pretty_assertions::assert_eq!(
|
2326 + | input.httpdate_timestamp,
|
2327 + | expected.httpdate_timestamp,
|
2328 + | "Unexpected value for `httpdate_timestamp`"
|
2329 + | );
|
2330 + | ::pretty_assertions::assert_eq!(
|
2331 + | input.integer,
|
2332 + | expected.integer,
|
2333 + | "Unexpected value for `integer`"
|
2334 + | );
|
2335 + | ::pretty_assertions::assert_eq!(
|
2336 + | input.iso8601_timestamp,
|
2337 + | expected.iso8601_timestamp,
|
2338 + | "Unexpected value for `iso8601_timestamp`"
|
2339 + | );
|
2340 + | ::pretty_assertions::assert_eq!(
|
2341 + | input.json_value,
|
2342 + | expected.json_value,
|
2343 + | "Unexpected value for `json_value`"
|
2344 + | );
|
2345 + | ::pretty_assertions::assert_eq!(
|
2346 + | input.list_of_lists,
|
2347 + | expected.list_of_lists,
|
2348 + | "Unexpected value for `list_of_lists`"
|
2349 + | );
|
2350 + | ::pretty_assertions::assert_eq!(
|
2351 + | input.list_of_maps_of_strings,
|
2352 + | expected.list_of_maps_of_strings,
|
2353 + | "Unexpected value for `list_of_maps_of_strings`"
|
2354 + | );
|
2355 + | ::pretty_assertions::assert_eq!(
|
2356 + | input.list_of_strings,
|
2357 + | expected.list_of_strings,
|
2358 + | "Unexpected value for `list_of_strings`"
|
2359 + | );
|
2360 + | ::pretty_assertions::assert_eq!(
|
2361 + | input.list_of_structs,
|
2362 + | expected.list_of_structs,
|
2363 + | "Unexpected value for `list_of_structs`"
|
2364 + | );
|
2365 + | ::pretty_assertions::assert_eq!(
|
2366 + | input.long,
|
2367 + | expected.long,
|
2368 + | "Unexpected value for `long`"
|
2369 + | );
|
2370 + | ::pretty_assertions::assert_eq!(
|
2371 + | input.map_of_lists_of_strings,
|
2372 + | expected.map_of_lists_of_strings,
|
2373 + | "Unexpected value for `map_of_lists_of_strings`"
|
2374 + | );
|
2375 + | ::pretty_assertions::assert_eq!(
|
2376 + | input.map_of_maps,
|
2377 + | expected.map_of_maps,
|
2378 + | "Unexpected value for `map_of_maps`"
|
2379 + | );
|
2380 + | ::pretty_assertions::assert_eq!(
|
2381 + | input.map_of_strings,
|
2382 + | expected.map_of_strings,
|
2383 + | "Unexpected value for `map_of_strings`"
|
2384 + | );
|
2385 + | ::pretty_assertions::assert_eq!(
|
2386 + | input.map_of_structs,
|
2387 + | expected.map_of_structs,
|
2388 + | "Unexpected value for `map_of_structs`"
|
2389 + | );
|
2390 + | ::pretty_assertions::assert_eq!(
|
2391 + | input.recursive_list,
|
2392 + | expected.recursive_list,
|
2393 + | "Unexpected value for `recursive_list`"
|
2394 + | );
|
2395 + | ::pretty_assertions::assert_eq!(
|
2396 + | input.recursive_map,
|
2397 + | expected.recursive_map,
|
2398 + | "Unexpected value for `recursive_map`"
|
2399 + | );
|
2400 + | ::pretty_assertions::assert_eq!(
|
2401 + | input.recursive_struct,
|
2402 + | expected.recursive_struct,
|
2403 + | "Unexpected value for `recursive_struct`"
|
2404 + | );
|
2405 + | ::pretty_assertions::assert_eq!(
|
2406 + | input.simple_struct,
|
2407 + | expected.simple_struct,
|
2408 + | "Unexpected value for `simple_struct`"
|
2409 + | );
|
2410 + | ::pretty_assertions::assert_eq!(
|
2411 + | input.string,
|
2412 + | expected.string,
|
2413 + | "Unexpected value for `string`"
|
2414 + | );
|
2415 + | ::pretty_assertions::assert_eq!(
|
2416 + | input.struct_with_json_name,
|
2417 + | expected.struct_with_json_name,
|
2418 + | "Unexpected value for `struct_with_json_name`"
|
2419 + | );
|
2420 + | ::pretty_assertions::assert_eq!(
|
2421 + | input.timestamp,
|
2422 + | expected.timestamp,
|
2423 + | "Unexpected value for `timestamp`"
|
2424 + | );
|
2425 + | ::pretty_assertions::assert_eq!(
|
2426 + | input.unix_timestamp,
|
2427 + | expected.unix_timestamp,
|
2428 + | "Unexpected value for `unix_timestamp`"
|
2429 + | );
|
2430 + | let output = crate::output::KitchenSinkOperationOutput {
|
2431 + | blob: ::std::option::Option::None,
|
2432 + | boolean: ::std::option::Option::None,
|
2433 + | double: ::std::option::Option::None,
|
2434 + | empty_struct: ::std::option::Option::None,
|
2435 + | float: ::std::option::Option::None,
|
2436 + | httpdate_timestamp: ::std::option::Option::None,
|
2437 + | integer: ::std::option::Option::None,
|
2438 + | iso8601_timestamp: ::std::option::Option::None,
|
2439 + | json_value: ::std::option::Option::None,
|
2440 + | list_of_lists: ::std::option::Option::None,
|
2441 + | list_of_maps_of_strings: ::std::option::Option::None,
|
2442 + | list_of_strings: ::std::option::Option::None,
|
2443 + | list_of_structs: ::std::option::Option::None,
|
2444 + | long: ::std::option::Option::None,
|
2445 + | map_of_lists_of_strings: ::std::option::Option::None,
|
2446 + | map_of_maps: ::std::option::Option::None,
|
2447 + | map_of_strings: ::std::option::Option::None,
|
2448 + | map_of_structs: ::std::option::Option::None,
|
2449 + | recursive_list: ::std::option::Option::None,
|
2450 + | recursive_map: ::std::option::Option::None,
|
2451 + | recursive_struct: ::std::option::Option::None,
|
2452 + | simple_struct: ::std::option::Option::None,
|
2453 + | string: ::std::option::Option::None,
|
2454 + | struct_with_json_name: ::std::option::Option::None,
|
2455 + | timestamp: ::std::option::Option::None,
|
2456 + | unix_timestamp: ::std::option::Option::None,
|
2457 + | };
|
2458 + | Ok(output)
|
2459 + | };
|
3347 2460 | sender.send(()).await.expect("receiver dropped early");
|
3348 2461 | result
|
3349 2462 | }
|
3350 2463 | })
|
3351 2464 | .build_unchecked();
|
3352 2465 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3353 2466 | .await
|
3354 2467 | .expect("unable to make an HTTP request");
|
3355 2468 | assert!(
|
3356 2469 | receiver.recv().await.is_some(),
|
3357 2470 | "we expected operation handler to be invoked but it was not entered"
|
3358 2471 | );
|
3359 2472 | }
|
3360 2473 |
|
3361 - | /// Supports handling NaN float values.
|
3362 - | /// Test ID: AwsJson11SupportsNaNFloatInputs
|
3363 - | #[::tokio::test]
|
3364 - | #[::tracing_test::traced_test]
|
3365 - | async fn aws_json11_supports_na_n_float_inputs_response() {
|
3366 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3367 - | float_value: ::std::option::Option::Some(
|
3368 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
3369 - | .expect("invalid string for number"),
|
3370 - | ),
|
3371 - | double_value: ::std::option::Option::Some(
|
3372 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
3373 - | .expect("invalid string for number"),
|
3374 - | ),
|
3375 - | };
|
3376 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3377 - | let http_response = output.into_response();
|
3378 - | ::pretty_assertions::assert_eq!(
|
3379 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3380 - | http_response.status()
|
3381 - | );
|
3382 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
3383 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3384 - | http_response.headers(),
|
3385 - | expected_headers,
|
3386 - | ));
|
3387 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3388 - | .await
|
3389 - | .expect("unable to extract body to bytes");
|
3390 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3391 - | &body,
|
3392 - | "{\n \"floatValue\": \"NaN\",\n \"doubleValue\": \"NaN\"\n}",
|
3393 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3394 - | ));
|
3395 - | }
|
3396 - |
|
3397 - | /// Supports handling Infinity float values.
|
3398 - | /// Test ID: AwsJson11SupportsInfinityFloatInputs
|
3399 - | #[::tokio::test]
|
3400 - | #[::tracing_test::traced_test]
|
3401 - | async fn aws_json11_supports_infinity_float_inputs_response() {
|
3402 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3403 - | float_value: ::std::option::Option::Some(
|
3404 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
3405 - | .expect("invalid string for number"),
|
3406 - | ),
|
3407 - | double_value: ::std::option::Option::Some(
|
3408 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
3409 - | .expect("invalid string for number"),
|
3410 - | ),
|
3411 - | };
|
3412 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3413 - | let http_response = output.into_response();
|
3414 - | ::pretty_assertions::assert_eq!(
|
3415 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3416 - | http_response.status()
|
3417 - | );
|
3418 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
3419 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3420 - | http_response.headers(),
|
3421 - | expected_headers,
|
3422 - | ));
|
3423 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3424 - | .await
|
3425 - | .expect("unable to extract body to bytes");
|
3426 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3427 - | &body,
|
3428 - | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}",
|
3429 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3430 - | ));
|
3431 - | }
|
3432 - |
|
3433 - | /// Supports handling -Infinity float values.
|
3434 - | /// Test ID: AwsJson11SupportsNegativeInfinityFloatInputs
|
3435 - | #[::tokio::test]
|
3436 - | #[::tracing_test::traced_test]
|
3437 - | async fn aws_json11_supports_negative_infinity_float_inputs_response() {
|
3438 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3439 - | float_value: ::std::option::Option::Some(
|
3440 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
3441 - | .expect("invalid string for number"),
|
3442 - | ),
|
3443 - | double_value: ::std::option::Option::Some(
|
3444 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
3445 - | .expect("invalid string for number"),
|
3446 - | ),
|
3447 - | };
|
3448 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3449 - | let http_response = output.into_response();
|
3450 - | ::pretty_assertions::assert_eq!(
|
3451 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3452 - | http_response.status()
|
3453 - | );
|
3454 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
3455 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3456 - | http_response.headers(),
|
3457 - | expected_headers,
|
3458 - | ));
|
3459 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3460 - | .await
|
3461 - | .expect("unable to extract body to bytes");
|
3462 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3463 - | &body,
|
3464 - | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}",
|
3465 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3466 - | ));
|
3467 - | }
|
3468 - | }
|
3469 - |
|
3470 - | ::pin_project_lite::pin_project! {
|
3471 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3472 - | /// [`KitchenSinkOperationInput`](crate::input::KitchenSinkOperationInput) using modelled bindings.
|
3473 - | pub struct KitchenSinkOperationInputFuture {
|
3474 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::KitchenSinkOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
3475 - | }
|
3476 - | }
|
3477 - |
|
3478 - | impl std::future::Future for KitchenSinkOperationInputFuture {
|
3479 - | type Output = Result<
|
3480 - | crate::input::KitchenSinkOperationInput,
|
3481 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
3482 - | >;
|
3483 - |
|
3484 - | fn poll(
|
3485 - | self: std::pin::Pin<&mut Self>,
|
3486 - | cx: &mut std::task::Context<'_>,
|
3487 - | ) -> std::task::Poll<Self::Output> {
|
3488 - | let this = self.project();
|
3489 - | this.inner.as_mut().poll(cx)
|
3490 - | }
|
3491 - | }
|
3492 - |
|
3493 - | impl<B>
|
3494 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
3495 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
3496 - | B,
|
3497 - | > for crate::input::KitchenSinkOperationInput
|
3498 - | where
|
3499 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
3500 - | B: 'static,
|
3501 - |
|
3502 - | B::Data: Send,
|
3503 - | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
3504 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
3505 - | {
|
3506 - | type Rejection =
|
3507 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
3508 - | type Future = KitchenSinkOperationInputFuture;
|
3509 - |
|
3510 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3511 - | let fut = async move {
|
3512 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
3513 - | request.headers(),
|
3514 - | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
3515 - | ) {
|
3516 - | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
3517 - | }
|
3518 - | crate::protocol_serde::shape_kitchen_sink_operation::de_kitchen_sink_operation_http_request(request)
|
3519 - | .await
|
3520 - | };
|
3521 - | use ::futures_util::future::TryFutureExt;
|
3522 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
3523 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3524 - | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
3525 - | });
|
3526 - | KitchenSinkOperationInputFuture {
|
3527 - | inner: Box::pin(fut),
|
3528 - | }
|
3529 - | }
|
3530 - | }
|
3531 - | impl
|
3532 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3533 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
3534 - | > for crate::output::KitchenSinkOperationOutput
|
3535 - | {
|
3536 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3537 - | match crate::protocol_serde::shape_kitchen_sink_operation::ser_kitchen_sink_operation_http_response(self) {
|
3538 - | Ok(response) => response,
|
3539 - | Err(e) => {
|
3540 - | ::tracing::error!(error = %e, "failed to serialize response");
|
3541 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
3542 - | }
|
3543 - | }
|
3544 - | }
|
3545 - | }
|
3546 - | impl
|
3547 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3548 - | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
3549 - | > for crate::error::KitchenSinkOperationError
|
3550 - | {
|
3551 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3552 - | match crate::protocol_serde::shape_kitchen_sink_operation::ser_kitchen_sink_operation_http_error(&self) {
|
3553 - | Ok(mut response) => {
|
3554 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3555 - | response
|
3556 - | },
|
3557 - | Err(e) => {
|
3558 - | ::tracing::error!(error = %e, "failed to serialize response");
|
3559 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
3560 - | }
|
3561 - | }
|
3562 - | }
|
3563 - | }
|
3564 - |
|
3565 - | #[allow(unreachable_code, unused_variables)]
|
3566 - | #[cfg(test)]
|
3567 - | mod kitchen_sink_operation_test {
|
3568 - |
|
3569 - | /// Serializes string shapes
|
3570 - | /// Test ID: serializes_string_shapes
|
2474 + | /// Serializes timestamp shapes
|
2475 + | /// Test ID: serializes_timestamp_shapes
|
3571 2476 | #[::tokio::test]
|
3572 2477 | #[::tracing_test::traced_test]
|
3573 - | async fn serializes_string_shapes_request() {
|
2478 + | async fn serializes_timestamp_shapes_request() {
|
3574 2479 | #[allow(unused_mut)]
|
3575 2480 | let mut http_request = ::http::Request::builder()
|
3576 2481 | .uri("/")
|
3577 2482 | .method("POST")
|
3578 2483 | .header("Content-Type", "application/x-amz-json-1.1")
|
3579 2484 | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
3580 2485 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3581 2486 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3582 - | "{\"String\":\"abc xyz\"}".as_bytes(),
|
2487 + | "{\"Timestamp\":946845296}".as_bytes(),
|
3583 2488 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3584 2489 | )),
|
3585 2490 | ))
|
3586 2491 | .unwrap();
|
3587 2492 | #[allow(unused_mut)]
|
3588 2493 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3589 2494 | let config = crate::service::JsonProtocolConfig::builder().build();
|
3590 2495 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3591 2496 | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
3592 2497 | let sender = sender.clone();
|
3593 2498 | async move {
|
3594 2499 | let result = {
|
3595 2500 | use ::aws_smithy_protocol_test::FloatEquals;
|
3596 2501 | let expected = crate::input::KitchenSinkOperationInput {
|
3597 - | string: ::std::option::Option::Some("abc xyz".to_owned()),
|
2502 + | timestamp: ::std::option::Option::Some(
|
2503 + | ::aws_smithy_types::DateTime::from_fractional_secs(
|
2504 + | 946845296, 0_f64,
|
2505 + | ),
|
2506 + | ),
|
3598 2507 | blob: ::std::option::Option::None,
|
3599 2508 | boolean: ::std::option::Option::None,
|
3600 2509 | double: ::std::option::Option::None,
|
3601 2510 | empty_struct: ::std::option::Option::None,
|
3602 2511 | float: ::std::option::Option::None,
|
3603 2512 | httpdate_timestamp: ::std::option::Option::None,
|
3604 2513 | integer: ::std::option::Option::None,
|
3605 2514 | iso8601_timestamp: ::std::option::Option::None,
|
3606 2515 | json_value: ::std::option::Option::None,
|
3607 2516 | list_of_lists: ::std::option::Option::None,
|
3608 2517 | list_of_maps_of_strings: ::std::option::Option::None,
|
3609 2518 | list_of_strings: ::std::option::Option::None,
|
3610 2519 | list_of_structs: ::std::option::Option::None,
|
3611 2520 | long: ::std::option::Option::None,
|
3612 2521 | map_of_lists_of_strings: ::std::option::Option::None,
|
3613 2522 | map_of_maps: ::std::option::Option::None,
|
3614 2523 | map_of_strings: ::std::option::Option::None,
|
3615 2524 | map_of_structs: ::std::option::Option::None,
|
3616 2525 | recursive_list: ::std::option::Option::None,
|
3617 2526 | recursive_map: ::std::option::Option::None,
|
3618 2527 | recursive_struct: ::std::option::Option::None,
|
3619 2528 | simple_struct: ::std::option::Option::None,
|
2529 + | string: ::std::option::Option::None,
|
3620 2530 | struct_with_json_name: ::std::option::Option::None,
|
3621 - | timestamp: ::std::option::Option::None,
|
3622 2531 | unix_timestamp: ::std::option::Option::None,
|
3623 2532 | };
|
3624 2533 | ::pretty_assertions::assert_eq!(
|
3625 2534 | input.blob,
|
3626 2535 | expected.blob,
|
3627 2536 | "Unexpected value for `blob`"
|
3628 2537 | );
|
3629 2538 | ::pretty_assertions::assert_eq!(
|
3630 2539 | input.boolean,
|
3631 2540 | expected.boolean,
|
8048 7242 | ::pretty_assertions::assert_eq!(
|
8049 7243 | input.unix_timestamp,
|
8050 7244 | expected.unix_timestamp,
|
8051 7245 | "Unexpected value for `unix_timestamp`"
|
8052 7246 | );
|
8053 7247 | let output = crate::output::KitchenSinkOperationOutput {
|
8054 7248 | blob: ::std::option::Option::None,
|
8055 7249 | boolean: ::std::option::Option::None,
|
8056 7250 | double: ::std::option::Option::None,
|
8057 7251 | empty_struct: ::std::option::Option::None,
|
8058 - | float: ::std::option::Option::None,
|
7252 + | float: ::std::option::Option::None,
|
7253 + | httpdate_timestamp: ::std::option::Option::None,
|
7254 + | integer: ::std::option::Option::None,
|
7255 + | iso8601_timestamp: ::std::option::Option::None,
|
7256 + | json_value: ::std::option::Option::None,
|
7257 + | list_of_lists: ::std::option::Option::None,
|
7258 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7259 + | list_of_strings: ::std::option::Option::None,
|
7260 + | list_of_structs: ::std::option::Option::None,
|
7261 + | long: ::std::option::Option::None,
|
7262 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7263 + | map_of_maps: ::std::option::Option::None,
|
7264 + | map_of_strings: ::std::option::Option::None,
|
7265 + | map_of_structs: ::std::option::Option::None,
|
7266 + | recursive_list: ::std::option::Option::None,
|
7267 + | recursive_map: ::std::option::Option::None,
|
7268 + | recursive_struct: ::std::option::Option::None,
|
7269 + | simple_struct: ::std::option::Option::None,
|
7270 + | string: ::std::option::Option::None,
|
7271 + | struct_with_json_name: ::std::option::Option::None,
|
7272 + | timestamp: ::std::option::Option::None,
|
7273 + | unix_timestamp: ::std::option::Option::None,
|
7274 + | };
|
7275 + | Ok(output)
|
7276 + | };
|
7277 + | sender.send(()).await.expect("receiver dropped early");
|
7278 + | result
|
7279 + | }
|
7280 + | })
|
7281 + | .build_unchecked();
|
7282 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7283 + | .await
|
7284 + | .expect("unable to make an HTTP request");
|
7285 + | assert!(
|
7286 + | receiver.recv().await.is_some(),
|
7287 + | "we expected operation handler to be invoked but it was not entered"
|
7288 + | );
|
7289 + | }
|
7290 + |
|
7291 + | /// Parses operations with empty JSON bodies
|
7292 + | /// Test ID: parses_operations_with_empty_json_bodies
|
7293 + | #[::tokio::test]
|
7294 + | #[::tracing_test::traced_test]
|
7295 + | async fn parses_operations_with_empty_json_bodies_response() {
|
7296 + | let output = crate::output::KitchenSinkOperationOutput {
|
7297 + | blob: ::std::option::Option::None,
|
7298 + | boolean: ::std::option::Option::None,
|
7299 + | double: ::std::option::Option::None,
|
7300 + | empty_struct: ::std::option::Option::None,
|
7301 + | float: ::std::option::Option::None,
|
7302 + | httpdate_timestamp: ::std::option::Option::None,
|
7303 + | integer: ::std::option::Option::None,
|
7304 + | iso8601_timestamp: ::std::option::Option::None,
|
7305 + | json_value: ::std::option::Option::None,
|
7306 + | list_of_lists: ::std::option::Option::None,
|
7307 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7308 + | list_of_strings: ::std::option::Option::None,
|
7309 + | list_of_structs: ::std::option::Option::None,
|
7310 + | long: ::std::option::Option::None,
|
7311 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7312 + | map_of_maps: ::std::option::Option::None,
|
7313 + | map_of_strings: ::std::option::Option::None,
|
7314 + | map_of_structs: ::std::option::Option::None,
|
7315 + | recursive_list: ::std::option::Option::None,
|
7316 + | recursive_map: ::std::option::Option::None,
|
7317 + | recursive_struct: ::std::option::Option::None,
|
7318 + | simple_struct: ::std::option::Option::None,
|
7319 + | string: ::std::option::Option::None,
|
7320 + | struct_with_json_name: ::std::option::Option::None,
|
7321 + | timestamp: ::std::option::Option::None,
|
7322 + | unix_timestamp: ::std::option::Option::None,
|
7323 + | };
|
7324 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7325 + | let http_response = output.into_response();
|
7326 + | ::pretty_assertions::assert_eq!(
|
7327 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7328 + | http_response.status()
|
7329 + | );
|
7330 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7331 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7332 + | http_response.headers(),
|
7333 + | expected_headers,
|
7334 + | ));
|
7335 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7336 + | .await
|
7337 + | .expect("unable to extract body to bytes");
|
7338 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7339 + | &body,
|
7340 + | "{}",
|
7341 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7342 + | ));
|
7343 + | }
|
7344 + |
|
7345 + | /// Parses string shapes
|
7346 + | /// Test ID: parses_string_shapes
|
7347 + | #[::tokio::test]
|
7348 + | #[::tracing_test::traced_test]
|
7349 + | async fn parses_string_shapes_response() {
|
7350 + | let output = crate::output::KitchenSinkOperationOutput {
|
7351 + | string: ::std::option::Option::Some("string-value".to_owned()),
|
7352 + | blob: ::std::option::Option::None,
|
7353 + | boolean: ::std::option::Option::None,
|
7354 + | double: ::std::option::Option::None,
|
7355 + | empty_struct: ::std::option::Option::None,
|
7356 + | float: ::std::option::Option::None,
|
7357 + | httpdate_timestamp: ::std::option::Option::None,
|
7358 + | integer: ::std::option::Option::None,
|
7359 + | iso8601_timestamp: ::std::option::Option::None,
|
7360 + | json_value: ::std::option::Option::None,
|
7361 + | list_of_lists: ::std::option::Option::None,
|
7362 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7363 + | list_of_strings: ::std::option::Option::None,
|
7364 + | list_of_structs: ::std::option::Option::None,
|
7365 + | long: ::std::option::Option::None,
|
7366 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7367 + | map_of_maps: ::std::option::Option::None,
|
7368 + | map_of_strings: ::std::option::Option::None,
|
7369 + | map_of_structs: ::std::option::Option::None,
|
7370 + | recursive_list: ::std::option::Option::None,
|
7371 + | recursive_map: ::std::option::Option::None,
|
7372 + | recursive_struct: ::std::option::Option::None,
|
7373 + | simple_struct: ::std::option::Option::None,
|
7374 + | struct_with_json_name: ::std::option::Option::None,
|
7375 + | timestamp: ::std::option::Option::None,
|
7376 + | unix_timestamp: ::std::option::Option::None,
|
7377 + | };
|
7378 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7379 + | let http_response = output.into_response();
|
7380 + | ::pretty_assertions::assert_eq!(
|
7381 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7382 + | http_response.status()
|
7383 + | );
|
7384 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7385 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7386 + | http_response.headers(),
|
7387 + | expected_headers,
|
7388 + | ));
|
7389 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7390 + | .await
|
7391 + | .expect("unable to extract body to bytes");
|
7392 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7393 + | &body,
|
7394 + | "{\"String\":\"string-value\"}",
|
7395 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7396 + | ));
|
7397 + | }
|
7398 + |
|
7399 + | /// Parses integer shapes
|
7400 + | /// Test ID: parses_integer_shapes
|
7401 + | #[::tokio::test]
|
7402 + | #[::tracing_test::traced_test]
|
7403 + | async fn parses_integer_shapes_response() {
|
7404 + | let output = crate::output::KitchenSinkOperationOutput {
|
7405 + | integer: ::std::option::Option::Some(1234),
|
7406 + | blob: ::std::option::Option::None,
|
7407 + | boolean: ::std::option::Option::None,
|
7408 + | double: ::std::option::Option::None,
|
7409 + | empty_struct: ::std::option::Option::None,
|
7410 + | float: ::std::option::Option::None,
|
7411 + | httpdate_timestamp: ::std::option::Option::None,
|
7412 + | iso8601_timestamp: ::std::option::Option::None,
|
7413 + | json_value: ::std::option::Option::None,
|
7414 + | list_of_lists: ::std::option::Option::None,
|
7415 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7416 + | list_of_strings: ::std::option::Option::None,
|
7417 + | list_of_structs: ::std::option::Option::None,
|
7418 + | long: ::std::option::Option::None,
|
7419 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7420 + | map_of_maps: ::std::option::Option::None,
|
7421 + | map_of_strings: ::std::option::Option::None,
|
7422 + | map_of_structs: ::std::option::Option::None,
|
7423 + | recursive_list: ::std::option::Option::None,
|
7424 + | recursive_map: ::std::option::Option::None,
|
7425 + | recursive_struct: ::std::option::Option::None,
|
7426 + | simple_struct: ::std::option::Option::None,
|
7427 + | string: ::std::option::Option::None,
|
7428 + | struct_with_json_name: ::std::option::Option::None,
|
7429 + | timestamp: ::std::option::Option::None,
|
7430 + | unix_timestamp: ::std::option::Option::None,
|
7431 + | };
|
7432 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7433 + | let http_response = output.into_response();
|
7434 + | ::pretty_assertions::assert_eq!(
|
7435 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7436 + | http_response.status()
|
7437 + | );
|
7438 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7439 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7440 + | http_response.headers(),
|
7441 + | expected_headers,
|
7442 + | ));
|
7443 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7444 + | .await
|
7445 + | .expect("unable to extract body to bytes");
|
7446 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7447 + | &body,
|
7448 + | "{\"Integer\":1234}",
|
7449 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7450 + | ));
|
7451 + | }
|
7452 + |
|
7453 + | /// Parses long shapes
|
7454 + | /// Test ID: parses_long_shapes
|
7455 + | #[::tokio::test]
|
7456 + | #[::tracing_test::traced_test]
|
7457 + | async fn parses_long_shapes_response() {
|
7458 + | let output = crate::output::KitchenSinkOperationOutput {
|
7459 + | long: ::std::option::Option::Some(1234567890123456789),
|
7460 + | blob: ::std::option::Option::None,
|
7461 + | boolean: ::std::option::Option::None,
|
7462 + | double: ::std::option::Option::None,
|
7463 + | empty_struct: ::std::option::Option::None,
|
7464 + | float: ::std::option::Option::None,
|
7465 + | httpdate_timestamp: ::std::option::Option::None,
|
7466 + | integer: ::std::option::Option::None,
|
7467 + | iso8601_timestamp: ::std::option::Option::None,
|
7468 + | json_value: ::std::option::Option::None,
|
7469 + | list_of_lists: ::std::option::Option::None,
|
7470 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7471 + | list_of_strings: ::std::option::Option::None,
|
7472 + | list_of_structs: ::std::option::Option::None,
|
7473 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7474 + | map_of_maps: ::std::option::Option::None,
|
7475 + | map_of_strings: ::std::option::Option::None,
|
7476 + | map_of_structs: ::std::option::Option::None,
|
7477 + | recursive_list: ::std::option::Option::None,
|
7478 + | recursive_map: ::std::option::Option::None,
|
7479 + | recursive_struct: ::std::option::Option::None,
|
7480 + | simple_struct: ::std::option::Option::None,
|
7481 + | string: ::std::option::Option::None,
|
7482 + | struct_with_json_name: ::std::option::Option::None,
|
7483 + | timestamp: ::std::option::Option::None,
|
7484 + | unix_timestamp: ::std::option::Option::None,
|
7485 + | };
|
7486 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7487 + | let http_response = output.into_response();
|
7488 + | ::pretty_assertions::assert_eq!(
|
7489 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7490 + | http_response.status()
|
7491 + | );
|
7492 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7493 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7494 + | http_response.headers(),
|
7495 + | expected_headers,
|
7496 + | ));
|
7497 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7498 + | .await
|
7499 + | .expect("unable to extract body to bytes");
|
7500 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7501 + | &body,
|
7502 + | "{\"Long\":1234567890123456789}",
|
7503 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7504 + | ));
|
7505 + | }
|
7506 + |
|
7507 + | /// Parses float shapes
|
7508 + | /// Test ID: parses_float_shapes
|
7509 + | #[::tokio::test]
|
7510 + | #[::tracing_test::traced_test]
|
7511 + | async fn parses_float_shapes_response() {
|
7512 + | let output = crate::output::KitchenSinkOperationOutput {
|
7513 + | float: ::std::option::Option::Some(1234.5_f32),
|
7514 + | blob: ::std::option::Option::None,
|
7515 + | boolean: ::std::option::Option::None,
|
7516 + | double: ::std::option::Option::None,
|
7517 + | empty_struct: ::std::option::Option::None,
|
8059 7518 | httpdate_timestamp: ::std::option::Option::None,
|
8060 7519 | integer: ::std::option::Option::None,
|
8061 7520 | iso8601_timestamp: ::std::option::Option::None,
|
8062 7521 | json_value: ::std::option::Option::None,
|
8063 7522 | list_of_lists: ::std::option::Option::None,
|
8064 7523 | list_of_maps_of_strings: ::std::option::Option::None,
|
8065 7524 | list_of_strings: ::std::option::Option::None,
|
8066 7525 | list_of_structs: ::std::option::Option::None,
|
8067 7526 | long: ::std::option::Option::None,
|
8068 7527 | map_of_lists_of_strings: ::std::option::Option::None,
|
8069 7528 | map_of_maps: ::std::option::Option::None,
|
8070 7529 | map_of_strings: ::std::option::Option::None,
|
8071 7530 | map_of_structs: ::std::option::Option::None,
|
8072 7531 | recursive_list: ::std::option::Option::None,
|
8073 7532 | recursive_map: ::std::option::Option::None,
|
8074 7533 | recursive_struct: ::std::option::Option::None,
|
8075 7534 | simple_struct: ::std::option::Option::None,
|
8076 7535 | string: ::std::option::Option::None,
|
8077 7536 | struct_with_json_name: ::std::option::Option::None,
|
8078 7537 | timestamp: ::std::option::Option::None,
|
8079 7538 | unix_timestamp: ::std::option::Option::None,
|
8080 7539 | };
|
8081 - | Ok(output)
|
8082 - | };
|
8083 - | sender.send(()).await.expect("receiver dropped early");
|
8084 - | result
|
8085 - | }
|
8086 - | })
|
8087 - | .build_unchecked();
|
8088 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8089 - | .await
|
8090 - | .expect("unable to make an HTTP request");
|
8091 - | assert!(
|
8092 - | receiver.recv().await.is_some(),
|
8093 - | "we expected operation handler to be invoked but it was not entered"
|
7540 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7541 + | let http_response = output.into_response();
|
7542 + | ::pretty_assertions::assert_eq!(
|
7543 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7544 + | http_response.status()
|
8094 7545 | );
|
7546 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7547 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7548 + | http_response.headers(),
|
7549 + | expected_headers,
|
7550 + | ));
|
7551 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7552 + | .await
|
7553 + | .expect("unable to extract body to bytes");
|
7554 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7555 + | &body,
|
7556 + | "{\"Float\":1234.5}",
|
7557 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7558 + | ));
|
8095 7559 | }
|
8096 7560 |
|
8097 - | /// Serializes empty map shapes
|
8098 - | /// Test ID: serializes_empty_map_shapes
|
7561 + | /// Parses double shapes
|
7562 + | /// Test ID: parses_double_shapes
|
8099 7563 | #[::tokio::test]
|
8100 7564 | #[::tracing_test::traced_test]
|
8101 - | async fn serializes_empty_map_shapes_request() {
|
8102 - | #[allow(unused_mut)]
|
8103 - | let mut http_request = ::http::Request::builder()
|
8104 - | .uri("/")
|
8105 - | .method("POST")
|
8106 - | .header("Content-Type", "application/x-amz-json-1.1")
|
8107 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
8108 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
8109 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
8110 - | "{\"MapOfStrings\":{}}".as_bytes(),
|
8111 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8112 - | )),
|
8113 - | ))
|
8114 - | .unwrap();
|
8115 - | #[allow(unused_mut)]
|
8116 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8117 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
8118 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
8119 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
8120 - | let sender = sender.clone();
|
8121 - | async move {
|
8122 - | let result = {
|
8123 - | use ::aws_smithy_protocol_test::FloatEquals;
|
8124 - | let expected = crate::input::KitchenSinkOperationInput {
|
8125 - | map_of_strings: ::std::option::Option::Some(
|
8126 - | ::std::collections::HashMap::new(),
|
8127 - | ),
|
7565 + | async fn parses_double_shapes_response() {
|
7566 + | let output = crate::output::KitchenSinkOperationOutput {
|
7567 + | double: ::std::option::Option::Some(1.2345678912345679E8_f64),
|
8128 7568 | blob: ::std::option::Option::None,
|
8129 7569 | boolean: ::std::option::Option::None,
|
8130 - | double: ::std::option::Option::None,
|
8131 7570 | empty_struct: ::std::option::Option::None,
|
8132 7571 | float: ::std::option::Option::None,
|
8133 7572 | httpdate_timestamp: ::std::option::Option::None,
|
8134 7573 | integer: ::std::option::Option::None,
|
8135 7574 | iso8601_timestamp: ::std::option::Option::None,
|
8136 7575 | json_value: ::std::option::Option::None,
|
8137 7576 | list_of_lists: ::std::option::Option::None,
|
8138 7577 | list_of_maps_of_strings: ::std::option::Option::None,
|
8139 7578 | list_of_strings: ::std::option::Option::None,
|
8140 7579 | list_of_structs: ::std::option::Option::None,
|
8141 7580 | long: ::std::option::Option::None,
|
8142 7581 | map_of_lists_of_strings: ::std::option::Option::None,
|
8143 7582 | map_of_maps: ::std::option::Option::None,
|
7583 + | map_of_strings: ::std::option::Option::None,
|
8144 7584 | map_of_structs: ::std::option::Option::None,
|
8145 7585 | recursive_list: ::std::option::Option::None,
|
8146 7586 | recursive_map: ::std::option::Option::None,
|
8147 7587 | recursive_struct: ::std::option::Option::None,
|
8148 7588 | simple_struct: ::std::option::Option::None,
|
8149 7589 | string: ::std::option::Option::None,
|
8150 7590 | struct_with_json_name: ::std::option::Option::None,
|
8151 7591 | timestamp: ::std::option::Option::None,
|
8152 7592 | unix_timestamp: ::std::option::Option::None,
|
8153 7593 | };
|
7594 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7595 + | let http_response = output.into_response();
|
8154 7596 | ::pretty_assertions::assert_eq!(
|
8155 - | input.blob,
|
8156 - | expected.blob,
|
8157 - | "Unexpected value for `blob`"
|
8158 - | );
|
8159 - | ::pretty_assertions::assert_eq!(
|
8160 - | input.boolean,
|
8161 - | expected.boolean,
|
8162 - | "Unexpected value for `boolean`"
|
8163 - | );
|
8164 - | assert!(
|
8165 - | input.double.float_equals(&expected.double),
|
8166 - | "Unexpected value for `double` {:?} vs. {:?}",
|
8167 - | expected.double,
|
8168 - | input.double
|
8169 - | );
|
8170 - | ::pretty_assertions::assert_eq!(
|
8171 - | input.empty_struct,
|
8172 - | expected.empty_struct,
|
8173 - | "Unexpected value for `empty_struct`"
|
8174 - | );
|
8175 - | assert!(
|
8176 - | input.float.float_equals(&expected.float),
|
8177 - | "Unexpected value for `float` {:?} vs. {:?}",
|
8178 - | expected.float,
|
8179 - | input.float
|
8180 - | );
|
8181 - | ::pretty_assertions::assert_eq!(
|
8182 - | input.httpdate_timestamp,
|
8183 - | expected.httpdate_timestamp,
|
8184 - | "Unexpected value for `httpdate_timestamp`"
|
8185 - | );
|
8186 - | ::pretty_assertions::assert_eq!(
|
8187 - | input.integer,
|
8188 - | expected.integer,
|
8189 - | "Unexpected value for `integer`"
|
8190 - | );
|
8191 - | ::pretty_assertions::assert_eq!(
|
8192 - | input.iso8601_timestamp,
|
8193 - | expected.iso8601_timestamp,
|
8194 - | "Unexpected value for `iso8601_timestamp`"
|
8195 - | );
|
8196 - | ::pretty_assertions::assert_eq!(
|
8197 - | input.json_value,
|
8198 - | expected.json_value,
|
8199 - | "Unexpected value for `json_value`"
|
8200 - | );
|
8201 - | ::pretty_assertions::assert_eq!(
|
8202 - | input.list_of_lists,
|
8203 - | expected.list_of_lists,
|
8204 - | "Unexpected value for `list_of_lists`"
|
8205 - | );
|
8206 - | ::pretty_assertions::assert_eq!(
|
8207 - | input.list_of_maps_of_strings,
|
8208 - | expected.list_of_maps_of_strings,
|
8209 - | "Unexpected value for `list_of_maps_of_strings`"
|
8210 - | );
|
8211 - | ::pretty_assertions::assert_eq!(
|
8212 - | input.list_of_strings,
|
8213 - | expected.list_of_strings,
|
8214 - | "Unexpected value for `list_of_strings`"
|
8215 - | );
|
8216 - | ::pretty_assertions::assert_eq!(
|
8217 - | input.list_of_structs,
|
8218 - | expected.list_of_structs,
|
8219 - | "Unexpected value for `list_of_structs`"
|
8220 - | );
|
8221 - | ::pretty_assertions::assert_eq!(
|
8222 - | input.long,
|
8223 - | expected.long,
|
8224 - | "Unexpected value for `long`"
|
8225 - | );
|
8226 - | ::pretty_assertions::assert_eq!(
|
8227 - | input.map_of_lists_of_strings,
|
8228 - | expected.map_of_lists_of_strings,
|
8229 - | "Unexpected value for `map_of_lists_of_strings`"
|
8230 - | );
|
8231 - | ::pretty_assertions::assert_eq!(
|
8232 - | input.map_of_maps,
|
8233 - | expected.map_of_maps,
|
8234 - | "Unexpected value for `map_of_maps`"
|
8235 - | );
|
8236 - | ::pretty_assertions::assert_eq!(
|
8237 - | input.map_of_strings,
|
8238 - | expected.map_of_strings,
|
8239 - | "Unexpected value for `map_of_strings`"
|
8240 - | );
|
8241 - | ::pretty_assertions::assert_eq!(
|
8242 - | input.map_of_structs,
|
8243 - | expected.map_of_structs,
|
8244 - | "Unexpected value for `map_of_structs`"
|
8245 - | );
|
8246 - | ::pretty_assertions::assert_eq!(
|
8247 - | input.recursive_list,
|
8248 - | expected.recursive_list,
|
8249 - | "Unexpected value for `recursive_list`"
|
8250 - | );
|
8251 - | ::pretty_assertions::assert_eq!(
|
8252 - | input.recursive_map,
|
8253 - | expected.recursive_map,
|
8254 - | "Unexpected value for `recursive_map`"
|
8255 - | );
|
8256 - | ::pretty_assertions::assert_eq!(
|
8257 - | input.recursive_struct,
|
8258 - | expected.recursive_struct,
|
8259 - | "Unexpected value for `recursive_struct`"
|
8260 - | );
|
8261 - | ::pretty_assertions::assert_eq!(
|
8262 - | input.simple_struct,
|
8263 - | expected.simple_struct,
|
8264 - | "Unexpected value for `simple_struct`"
|
8265 - | );
|
8266 - | ::pretty_assertions::assert_eq!(
|
8267 - | input.string,
|
8268 - | expected.string,
|
8269 - | "Unexpected value for `string`"
|
8270 - | );
|
8271 - | ::pretty_assertions::assert_eq!(
|
8272 - | input.struct_with_json_name,
|
8273 - | expected.struct_with_json_name,
|
8274 - | "Unexpected value for `struct_with_json_name`"
|
8275 - | );
|
8276 - | ::pretty_assertions::assert_eq!(
|
8277 - | input.timestamp,
|
8278 - | expected.timestamp,
|
8279 - | "Unexpected value for `timestamp`"
|
7597 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7598 + | http_response.status()
|
8280 7599 | );
|
7600 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7601 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7602 + | http_response.headers(),
|
7603 + | expected_headers,
|
7604 + | ));
|
7605 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7606 + | .await
|
7607 + | .expect("unable to extract body to bytes");
|
7608 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7609 + | &body,
|
7610 + | "{\"Double\":123456789.12345679}",
|
7611 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7612 + | ));
|
7613 + | }
|
7614 + |
|
7615 + | /// Parses boolean shapes (true)
|
7616 + | /// Test ID: parses_boolean_shapes_true
|
7617 + | #[::tokio::test]
|
7618 + | #[::tracing_test::traced_test]
|
7619 + | async fn parses_boolean_shapes_true_response() {
|
7620 + | let output = crate::output::KitchenSinkOperationOutput {
|
7621 + | boolean: ::std::option::Option::Some(true),
|
7622 + | blob: ::std::option::Option::None,
|
7623 + | double: ::std::option::Option::None,
|
7624 + | empty_struct: ::std::option::Option::None,
|
7625 + | float: ::std::option::Option::None,
|
7626 + | httpdate_timestamp: ::std::option::Option::None,
|
7627 + | integer: ::std::option::Option::None,
|
7628 + | iso8601_timestamp: ::std::option::Option::None,
|
7629 + | json_value: ::std::option::Option::None,
|
7630 + | list_of_lists: ::std::option::Option::None,
|
7631 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7632 + | list_of_strings: ::std::option::Option::None,
|
7633 + | list_of_structs: ::std::option::Option::None,
|
7634 + | long: ::std::option::Option::None,
|
7635 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7636 + | map_of_maps: ::std::option::Option::None,
|
7637 + | map_of_strings: ::std::option::Option::None,
|
7638 + | map_of_structs: ::std::option::Option::None,
|
7639 + | recursive_list: ::std::option::Option::None,
|
7640 + | recursive_map: ::std::option::Option::None,
|
7641 + | recursive_struct: ::std::option::Option::None,
|
7642 + | simple_struct: ::std::option::Option::None,
|
7643 + | string: ::std::option::Option::None,
|
7644 + | struct_with_json_name: ::std::option::Option::None,
|
7645 + | timestamp: ::std::option::Option::None,
|
7646 + | unix_timestamp: ::std::option::Option::None,
|
7647 + | };
|
7648 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7649 + | let http_response = output.into_response();
|
8281 7650 | ::pretty_assertions::assert_eq!(
|
8282 - | input.unix_timestamp,
|
8283 - | expected.unix_timestamp,
|
8284 - | "Unexpected value for `unix_timestamp`"
|
7651 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7652 + | http_response.status()
|
8285 7653 | );
|
7654 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7655 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7656 + | http_response.headers(),
|
7657 + | expected_headers,
|
7658 + | ));
|
7659 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7660 + | .await
|
7661 + | .expect("unable to extract body to bytes");
|
7662 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7663 + | &body,
|
7664 + | "{\"Boolean\":true}",
|
7665 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7666 + | ));
|
7667 + | }
|
7668 + |
|
7669 + | /// Parses boolean (false)
|
7670 + | /// Test ID: parses_boolean_false
|
7671 + | #[::tokio::test]
|
7672 + | #[::tracing_test::traced_test]
|
7673 + | async fn parses_boolean_false_response() {
|
8286 7674 | let output = crate::output::KitchenSinkOperationOutput {
|
7675 + | boolean: ::std::option::Option::Some(false),
|
8287 7676 | blob: ::std::option::Option::None,
|
8288 - | boolean: ::std::option::Option::None,
|
8289 7677 | double: ::std::option::Option::None,
|
8290 7678 | empty_struct: ::std::option::Option::None,
|
8291 7679 | float: ::std::option::Option::None,
|
8292 7680 | httpdate_timestamp: ::std::option::Option::None,
|
8293 7681 | integer: ::std::option::Option::None,
|
8294 7682 | iso8601_timestamp: ::std::option::Option::None,
|
8295 7683 | json_value: ::std::option::Option::None,
|
8296 7684 | list_of_lists: ::std::option::Option::None,
|
8297 7685 | list_of_maps_of_strings: ::std::option::Option::None,
|
8298 7686 | list_of_strings: ::std::option::Option::None,
|
8299 7687 | list_of_structs: ::std::option::Option::None,
|
8300 7688 | long: ::std::option::Option::None,
|
8301 7689 | map_of_lists_of_strings: ::std::option::Option::None,
|
8302 7690 | map_of_maps: ::std::option::Option::None,
|
8303 7691 | map_of_strings: ::std::option::Option::None,
|
8304 7692 | map_of_structs: ::std::option::Option::None,
|
8305 7693 | recursive_list: ::std::option::Option::None,
|
8306 7694 | recursive_map: ::std::option::Option::None,
|
8307 7695 | recursive_struct: ::std::option::Option::None,
|
8308 7696 | simple_struct: ::std::option::Option::None,
|
8309 7697 | string: ::std::option::Option::None,
|
8310 7698 | struct_with_json_name: ::std::option::Option::None,
|
8311 7699 | timestamp: ::std::option::Option::None,
|
8312 7700 | unix_timestamp: ::std::option::Option::None,
|
8313 7701 | };
|
8314 - | Ok(output)
|
8315 - | };
|
8316 - | sender.send(()).await.expect("receiver dropped early");
|
8317 - | result
|
8318 - | }
|
8319 - | })
|
8320 - | .build_unchecked();
|
8321 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8322 - | .await
|
8323 - | .expect("unable to make an HTTP request");
|
8324 - | assert!(
|
8325 - | receiver.recv().await.is_some(),
|
8326 - | "we expected operation handler to be invoked but it was not entered"
|
7702 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7703 + | let http_response = output.into_response();
|
7704 + | ::pretty_assertions::assert_eq!(
|
7705 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7706 + | http_response.status()
|
8327 7707 | );
|
7708 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7709 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7710 + | http_response.headers(),
|
7711 + | expected_headers,
|
7712 + | ));
|
7713 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7714 + | .await
|
7715 + | .expect("unable to extract body to bytes");
|
7716 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7717 + | &body,
|
7718 + | "{\"Boolean\":false}",
|
7719 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7720 + | ));
|
8328 7721 | }
|
8329 7722 |
|
8330 - | /// Serializes map of list shapes
|
8331 - | /// Test ID: serializes_map_of_list_shapes
|
7723 + | /// Parses blob shapes
|
7724 + | /// Test ID: parses_blob_shapes
|
8332 7725 | #[::tokio::test]
|
8333 7726 | #[::tracing_test::traced_test]
|
8334 - | async fn serializes_map_of_list_shapes_request() {
|
8335 - | #[allow(unused_mut)]
|
8336 - | let mut http_request = ::http::Request::builder()
|
8337 - | .uri("/")
|
8338 - | .method("POST")
|
8339 - | .header("Content-Type", "application/x-amz-json-1.1")
|
8340 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
8341 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
8342 - | ::bytes::Bytes::copy_from_slice(
|
8343 - | &::aws_smithy_protocol_test::decode_body_data("{\"MapOfListsOfStrings\":{\"abc\":[\"abc\",\"xyz\"],\"mno\":[\"xyz\",\"abc\"]}}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
8344 - | )
|
8345 - | )).unwrap();
|
8346 - | #[allow(unused_mut)]
|
8347 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8348 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
8349 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
8350 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
8351 - | let sender = sender.clone();
|
8352 - | async move {
|
8353 - | let result = {
|
8354 - | use ::aws_smithy_protocol_test::FloatEquals;
|
8355 - | let expected = crate::input::KitchenSinkOperationInput {
|
8356 - | map_of_lists_of_strings: ::std::option::Option::Some({
|
8357 - | let mut ret = ::std::collections::HashMap::new();
|
8358 - | ret.insert(
|
8359 - | "abc".to_owned(),
|
8360 - | vec!["abc".to_owned(), "xyz".to_owned()],
|
8361 - | );
|
8362 - | ret.insert(
|
8363 - | "mno".to_owned(),
|
8364 - | vec!["xyz".to_owned(), "abc".to_owned()],
|
8365 - | );
|
8366 - | ret
|
8367 - | }),
|
8368 - | blob: ::std::option::Option::None,
|
7727 + | async fn parses_blob_shapes_response() {
|
7728 + | let output = crate::output::KitchenSinkOperationOutput {
|
7729 + | blob: ::std::option::Option::Some(::aws_smithy_types::Blob::new("binary-value")),
|
8369 7730 | boolean: ::std::option::Option::None,
|
8370 7731 | double: ::std::option::Option::None,
|
8371 7732 | empty_struct: ::std::option::Option::None,
|
8372 7733 | float: ::std::option::Option::None,
|
8373 7734 | httpdate_timestamp: ::std::option::Option::None,
|
8374 7735 | integer: ::std::option::Option::None,
|
8375 7736 | iso8601_timestamp: ::std::option::Option::None,
|
8376 7737 | json_value: ::std::option::Option::None,
|
8377 7738 | list_of_lists: ::std::option::Option::None,
|
8378 7739 | list_of_maps_of_strings: ::std::option::Option::None,
|
8379 7740 | list_of_strings: ::std::option::Option::None,
|
8380 7741 | list_of_structs: ::std::option::Option::None,
|
8381 7742 | long: ::std::option::Option::None,
|
7743 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8382 7744 | map_of_maps: ::std::option::Option::None,
|
8383 7745 | map_of_strings: ::std::option::Option::None,
|
8384 7746 | map_of_structs: ::std::option::Option::None,
|
8385 7747 | recursive_list: ::std::option::Option::None,
|
8386 7748 | recursive_map: ::std::option::Option::None,
|
8387 7749 | recursive_struct: ::std::option::Option::None,
|
8388 7750 | simple_struct: ::std::option::Option::None,
|
8389 7751 | string: ::std::option::Option::None,
|
8390 7752 | struct_with_json_name: ::std::option::Option::None,
|
8391 7753 | timestamp: ::std::option::Option::None,
|
8392 7754 | unix_timestamp: ::std::option::Option::None,
|
8393 7755 | };
|
7756 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7757 + | let http_response = output.into_response();
|
8394 7758 | ::pretty_assertions::assert_eq!(
|
8395 - | input.blob,
|
8396 - | expected.blob,
|
8397 - | "Unexpected value for `blob`"
|
8398 - | );
|
8399 - | ::pretty_assertions::assert_eq!(
|
8400 - | input.boolean,
|
8401 - | expected.boolean,
|
8402 - | "Unexpected value for `boolean`"
|
8403 - | );
|
8404 - | assert!(
|
8405 - | input.double.float_equals(&expected.double),
|
8406 - | "Unexpected value for `double` {:?} vs. {:?}",
|
8407 - | expected.double,
|
8408 - | input.double
|
8409 - | );
|
8410 - | ::pretty_assertions::assert_eq!(
|
8411 - | input.empty_struct,
|
8412 - | expected.empty_struct,
|
8413 - | "Unexpected value for `empty_struct`"
|
8414 - | );
|
8415 - | assert!(
|
8416 - | input.float.float_equals(&expected.float),
|
8417 - | "Unexpected value for `float` {:?} vs. {:?}",
|
8418 - | expected.float,
|
8419 - | input.float
|
8420 - | );
|
8421 - | ::pretty_assertions::assert_eq!(
|
8422 - | input.httpdate_timestamp,
|
8423 - | expected.httpdate_timestamp,
|
8424 - | "Unexpected value for `httpdate_timestamp`"
|
8425 - | );
|
8426 - | ::pretty_assertions::assert_eq!(
|
8427 - | input.integer,
|
8428 - | expected.integer,
|
8429 - | "Unexpected value for `integer`"
|
8430 - | );
|
8431 - | ::pretty_assertions::assert_eq!(
|
8432 - | input.iso8601_timestamp,
|
8433 - | expected.iso8601_timestamp,
|
8434 - | "Unexpected value for `iso8601_timestamp`"
|
8435 - | );
|
8436 - | ::pretty_assertions::assert_eq!(
|
8437 - | input.json_value,
|
8438 - | expected.json_value,
|
8439 - | "Unexpected value for `json_value`"
|
8440 - | );
|
8441 - | ::pretty_assertions::assert_eq!(
|
8442 - | input.list_of_lists,
|
8443 - | expected.list_of_lists,
|
8444 - | "Unexpected value for `list_of_lists`"
|
8445 - | );
|
8446 - | ::pretty_assertions::assert_eq!(
|
8447 - | input.list_of_maps_of_strings,
|
8448 - | expected.list_of_maps_of_strings,
|
8449 - | "Unexpected value for `list_of_maps_of_strings`"
|
8450 - | );
|
8451 - | ::pretty_assertions::assert_eq!(
|
8452 - | input.list_of_strings,
|
8453 - | expected.list_of_strings,
|
8454 - | "Unexpected value for `list_of_strings`"
|
8455 - | );
|
8456 - | ::pretty_assertions::assert_eq!(
|
8457 - | input.list_of_structs,
|
8458 - | expected.list_of_structs,
|
8459 - | "Unexpected value for `list_of_structs`"
|
8460 - | );
|
8461 - | ::pretty_assertions::assert_eq!(
|
8462 - | input.long,
|
8463 - | expected.long,
|
8464 - | "Unexpected value for `long`"
|
8465 - | );
|
8466 - | ::pretty_assertions::assert_eq!(
|
8467 - | input.map_of_lists_of_strings,
|
8468 - | expected.map_of_lists_of_strings,
|
8469 - | "Unexpected value for `map_of_lists_of_strings`"
|
8470 - | );
|
8471 - | ::pretty_assertions::assert_eq!(
|
8472 - | input.map_of_maps,
|
8473 - | expected.map_of_maps,
|
8474 - | "Unexpected value for `map_of_maps`"
|
8475 - | );
|
8476 - | ::pretty_assertions::assert_eq!(
|
8477 - | input.map_of_strings,
|
8478 - | expected.map_of_strings,
|
8479 - | "Unexpected value for `map_of_strings`"
|
8480 - | );
|
8481 - | ::pretty_assertions::assert_eq!(
|
8482 - | input.map_of_structs,
|
8483 - | expected.map_of_structs,
|
8484 - | "Unexpected value for `map_of_structs`"
|
8485 - | );
|
8486 - | ::pretty_assertions::assert_eq!(
|
8487 - | input.recursive_list,
|
8488 - | expected.recursive_list,
|
8489 - | "Unexpected value for `recursive_list`"
|
8490 - | );
|
8491 - | ::pretty_assertions::assert_eq!(
|
8492 - | input.recursive_map,
|
8493 - | expected.recursive_map,
|
8494 - | "Unexpected value for `recursive_map`"
|
8495 - | );
|
8496 - | ::pretty_assertions::assert_eq!(
|
8497 - | input.recursive_struct,
|
8498 - | expected.recursive_struct,
|
8499 - | "Unexpected value for `recursive_struct`"
|
8500 - | );
|
8501 - | ::pretty_assertions::assert_eq!(
|
8502 - | input.simple_struct,
|
8503 - | expected.simple_struct,
|
8504 - | "Unexpected value for `simple_struct`"
|
8505 - | );
|
8506 - | ::pretty_assertions::assert_eq!(
|
8507 - | input.string,
|
8508 - | expected.string,
|
8509 - | "Unexpected value for `string`"
|
8510 - | );
|
8511 - | ::pretty_assertions::assert_eq!(
|
8512 - | input.struct_with_json_name,
|
8513 - | expected.struct_with_json_name,
|
8514 - | "Unexpected value for `struct_with_json_name`"
|
8515 - | );
|
8516 - | ::pretty_assertions::assert_eq!(
|
8517 - | input.timestamp,
|
8518 - | expected.timestamp,
|
8519 - | "Unexpected value for `timestamp`"
|
8520 - | );
|
8521 - | ::pretty_assertions::assert_eq!(
|
8522 - | input.unix_timestamp,
|
8523 - | expected.unix_timestamp,
|
8524 - | "Unexpected value for `unix_timestamp`"
|
7759 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7760 + | http_response.status()
|
8525 7761 | );
|
7762 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7763 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7764 + | http_response.headers(),
|
7765 + | expected_headers,
|
7766 + | ));
|
7767 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7768 + | .await
|
7769 + | .expect("unable to extract body to bytes");
|
7770 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7771 + | &body,
|
7772 + | "{\"Blob\":\"YmluYXJ5LXZhbHVl\"}",
|
7773 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7774 + | ));
|
7775 + | }
|
7776 + |
|
7777 + | /// Parses timestamp shapes
|
7778 + | /// Test ID: parses_timestamp_shapes
|
7779 + | #[::tokio::test]
|
7780 + | #[::tracing_test::traced_test]
|
7781 + | async fn parses_timestamp_shapes_response() {
|
8526 7782 | let output = crate::output::KitchenSinkOperationOutput {
|
7783 + | timestamp: ::std::option::Option::Some(
|
7784 + | ::aws_smithy_types::DateTime::from_fractional_secs(946845296, 0_f64),
|
7785 + | ),
|
8527 7786 | blob: ::std::option::Option::None,
|
8528 7787 | boolean: ::std::option::Option::None,
|
8529 7788 | double: ::std::option::Option::None,
|
8530 7789 | empty_struct: ::std::option::Option::None,
|
8531 7790 | float: ::std::option::Option::None,
|
8532 7791 | httpdate_timestamp: ::std::option::Option::None,
|
8533 7792 | integer: ::std::option::Option::None,
|
8534 7793 | iso8601_timestamp: ::std::option::Option::None,
|
8535 7794 | json_value: ::std::option::Option::None,
|
8536 7795 | list_of_lists: ::std::option::Option::None,
|
8537 7796 | list_of_maps_of_strings: ::std::option::Option::None,
|
8538 7797 | list_of_strings: ::std::option::Option::None,
|
8539 7798 | list_of_structs: ::std::option::Option::None,
|
8540 7799 | long: ::std::option::Option::None,
|
8541 7800 | map_of_lists_of_strings: ::std::option::Option::None,
|
8542 7801 | map_of_maps: ::std::option::Option::None,
|
8543 7802 | map_of_strings: ::std::option::Option::None,
|
8544 7803 | map_of_structs: ::std::option::Option::None,
|
8545 7804 | recursive_list: ::std::option::Option::None,
|
8546 7805 | recursive_map: ::std::option::Option::None,
|
8547 7806 | recursive_struct: ::std::option::Option::None,
|
8548 7807 | simple_struct: ::std::option::Option::None,
|
8549 7808 | string: ::std::option::Option::None,
|
8550 7809 | struct_with_json_name: ::std::option::Option::None,
|
8551 - | timestamp: ::std::option::Option::None,
|
8552 7810 | unix_timestamp: ::std::option::Option::None,
|
8553 7811 | };
|
8554 - | Ok(output)
|
8555 - | };
|
8556 - | sender.send(()).await.expect("receiver dropped early");
|
8557 - | result
|
8558 - | }
|
8559 - | })
|
8560 - | .build_unchecked();
|
8561 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8562 - | .await
|
8563 - | .expect("unable to make an HTTP request");
|
8564 - | assert!(
|
8565 - | receiver.recv().await.is_some(),
|
8566 - | "we expected operation handler to be invoked but it was not entered"
|
7812 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7813 + | let http_response = output.into_response();
|
7814 + | ::pretty_assertions::assert_eq!(
|
7815 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7816 + | http_response.status()
|
8567 7817 | );
|
7818 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7819 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7820 + | http_response.headers(),
|
7821 + | expected_headers,
|
7822 + | ));
|
7823 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7824 + | .await
|
7825 + | .expect("unable to extract body to bytes");
|
7826 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7827 + | &body,
|
7828 + | "{\"Timestamp\":946845296}",
|
7829 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7830 + | ));
|
8568 7831 | }
|
8569 7832 |
|
8570 - | /// Serializes map of structure shapes
|
8571 - | /// Test ID: serializes_map_of_structure_shapes
|
7833 + | /// Parses iso8601 timestamps
|
7834 + | /// Test ID: parses_iso8601_timestamps
|
8572 7835 | #[::tokio::test]
|
8573 7836 | #[::tracing_test::traced_test]
|
8574 - | async fn serializes_map_of_structure_shapes_request() {
|
8575 - | #[allow(unused_mut)]
|
8576 - | let mut http_request = ::http::Request::builder()
|
8577 - | .uri("/")
|
8578 - | .method("POST")
|
8579 - | .header("Content-Type", "application/x-amz-json-1.1")
|
8580 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
8581 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
8582 - | ::bytes::Bytes::copy_from_slice(
|
8583 - | &::aws_smithy_protocol_test::decode_body_data("{\"MapOfStructs\":{\"key1\":{\"Value\":\"value-1\"},\"key2\":{\"Value\":\"value-2\"}}}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
8584 - | )
|
8585 - | )).unwrap();
|
8586 - | #[allow(unused_mut)]
|
8587 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8588 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
8589 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
8590 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
8591 - | let sender = sender.clone();
|
8592 - | async move {
|
8593 - | let result = {
|
8594 - | use ::aws_smithy_protocol_test::FloatEquals;
|
8595 - | let expected = crate::input::KitchenSinkOperationInput {
|
8596 - | map_of_structs: ::std::option::Option::Some({
|
8597 - | let mut ret = ::std::collections::HashMap::new();
|
8598 - | ret.insert(
|
8599 - | "key1".to_owned(),
|
8600 - | crate::model::SimpleStruct {
|
8601 - | value: ::std::option::Option::Some("value-1".to_owned()),
|
8602 - | },
|
8603 - | );
|
8604 - | ret.insert(
|
8605 - | "key2".to_owned(),
|
8606 - | crate::model::SimpleStruct {
|
8607 - | value: ::std::option::Option::Some("value-2".to_owned()),
|
8608 - | },
|
8609 - | );
|
8610 - | ret
|
8611 - | }),
|
7837 + | async fn parses_iso8601_timestamps_response() {
|
7838 + | let output = crate::output::KitchenSinkOperationOutput {
|
7839 + | iso8601_timestamp: ::std::option::Option::Some(
|
7840 + | ::aws_smithy_types::DateTime::from_fractional_secs(946845296, 0_f64),
|
7841 + | ),
|
8612 7842 | blob: ::std::option::Option::None,
|
8613 7843 | boolean: ::std::option::Option::None,
|
8614 7844 | double: ::std::option::Option::None,
|
8615 7845 | empty_struct: ::std::option::Option::None,
|
8616 7846 | float: ::std::option::Option::None,
|
8617 7847 | httpdate_timestamp: ::std::option::Option::None,
|
8618 7848 | integer: ::std::option::Option::None,
|
8619 - | iso8601_timestamp: ::std::option::Option::None,
|
8620 7849 | json_value: ::std::option::Option::None,
|
8621 7850 | list_of_lists: ::std::option::Option::None,
|
8622 7851 | list_of_maps_of_strings: ::std::option::Option::None,
|
8623 7852 | list_of_strings: ::std::option::Option::None,
|
8624 7853 | list_of_structs: ::std::option::Option::None,
|
8625 7854 | long: ::std::option::Option::None,
|
8626 7855 | map_of_lists_of_strings: ::std::option::Option::None,
|
8627 7856 | map_of_maps: ::std::option::Option::None,
|
8628 7857 | map_of_strings: ::std::option::Option::None,
|
7858 + | map_of_structs: ::std::option::Option::None,
|
8629 7859 | recursive_list: ::std::option::Option::None,
|
8630 7860 | recursive_map: ::std::option::Option::None,
|
8631 7861 | recursive_struct: ::std::option::Option::None,
|
8632 7862 | simple_struct: ::std::option::Option::None,
|
8633 7863 | string: ::std::option::Option::None,
|
8634 7864 | struct_with_json_name: ::std::option::Option::None,
|
8635 7865 | timestamp: ::std::option::Option::None,
|
8636 7866 | unix_timestamp: ::std::option::Option::None,
|
8637 7867 | };
|
7868 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7869 + | let http_response = output.into_response();
|
8638 7870 | ::pretty_assertions::assert_eq!(
|
8639 - | input.blob,
|
8640 - | expected.blob,
|
8641 - | "Unexpected value for `blob`"
|
8642 - | );
|
8643 - | ::pretty_assertions::assert_eq!(
|
8644 - | input.boolean,
|
8645 - | expected.boolean,
|
8646 - | "Unexpected value for `boolean`"
|
8647 - | );
|
8648 - | assert!(
|
8649 - | input.double.float_equals(&expected.double),
|
8650 - | "Unexpected value for `double` {:?} vs. {:?}",
|
8651 - | expected.double,
|
8652 - | input.double
|
8653 - | );
|
8654 - | ::pretty_assertions::assert_eq!(
|
8655 - | input.empty_struct,
|
8656 - | expected.empty_struct,
|
8657 - | "Unexpected value for `empty_struct`"
|
8658 - | );
|
8659 - | assert!(
|
8660 - | input.float.float_equals(&expected.float),
|
8661 - | "Unexpected value for `float` {:?} vs. {:?}",
|
8662 - | expected.float,
|
8663 - | input.float
|
8664 - | );
|
8665 - | ::pretty_assertions::assert_eq!(
|
8666 - | input.httpdate_timestamp,
|
8667 - | expected.httpdate_timestamp,
|
8668 - | "Unexpected value for `httpdate_timestamp`"
|
8669 - | );
|
8670 - | ::pretty_assertions::assert_eq!(
|
8671 - | input.integer,
|
8672 - | expected.integer,
|
8673 - | "Unexpected value for `integer`"
|
8674 - | );
|
8675 - | ::pretty_assertions::assert_eq!(
|
8676 - | input.iso8601_timestamp,
|
8677 - | expected.iso8601_timestamp,
|
8678 - | "Unexpected value for `iso8601_timestamp`"
|
8679 - | );
|
8680 - | ::pretty_assertions::assert_eq!(
|
8681 - | input.json_value,
|
8682 - | expected.json_value,
|
8683 - | "Unexpected value for `json_value`"
|
8684 - | );
|
8685 - | ::pretty_assertions::assert_eq!(
|
8686 - | input.list_of_lists,
|
8687 - | expected.list_of_lists,
|
8688 - | "Unexpected value for `list_of_lists`"
|
8689 - | );
|
8690 - | ::pretty_assertions::assert_eq!(
|
8691 - | input.list_of_maps_of_strings,
|
8692 - | expected.list_of_maps_of_strings,
|
8693 - | "Unexpected value for `list_of_maps_of_strings`"
|
8694 - | );
|
8695 - | ::pretty_assertions::assert_eq!(
|
8696 - | input.list_of_strings,
|
8697 - | expected.list_of_strings,
|
8698 - | "Unexpected value for `list_of_strings`"
|
8699 - | );
|
8700 - | ::pretty_assertions::assert_eq!(
|
8701 - | input.list_of_structs,
|
8702 - | expected.list_of_structs,
|
8703 - | "Unexpected value for `list_of_structs`"
|
8704 - | );
|
8705 - | ::pretty_assertions::assert_eq!(
|
8706 - | input.long,
|
8707 - | expected.long,
|
8708 - | "Unexpected value for `long`"
|
8709 - | );
|
8710 - | ::pretty_assertions::assert_eq!(
|
8711 - | input.map_of_lists_of_strings,
|
8712 - | expected.map_of_lists_of_strings,
|
8713 - | "Unexpected value for `map_of_lists_of_strings`"
|
8714 - | );
|
8715 - | ::pretty_assertions::assert_eq!(
|
8716 - | input.map_of_maps,
|
8717 - | expected.map_of_maps,
|
8718 - | "Unexpected value for `map_of_maps`"
|
8719 - | );
|
8720 - | ::pretty_assertions::assert_eq!(
|
8721 - | input.map_of_strings,
|
8722 - | expected.map_of_strings,
|
8723 - | "Unexpected value for `map_of_strings`"
|
8724 - | );
|
8725 - | ::pretty_assertions::assert_eq!(
|
8726 - | input.map_of_structs,
|
8727 - | expected.map_of_structs,
|
8728 - | "Unexpected value for `map_of_structs`"
|
8729 - | );
|
8730 - | ::pretty_assertions::assert_eq!(
|
8731 - | input.recursive_list,
|
8732 - | expected.recursive_list,
|
8733 - | "Unexpected value for `recursive_list`"
|
8734 - | );
|
8735 - | ::pretty_assertions::assert_eq!(
|
8736 - | input.recursive_map,
|
8737 - | expected.recursive_map,
|
8738 - | "Unexpected value for `recursive_map`"
|
8739 - | );
|
8740 - | ::pretty_assertions::assert_eq!(
|
8741 - | input.recursive_struct,
|
8742 - | expected.recursive_struct,
|
8743 - | "Unexpected value for `recursive_struct`"
|
8744 - | );
|
8745 - | ::pretty_assertions::assert_eq!(
|
8746 - | input.simple_struct,
|
8747 - | expected.simple_struct,
|
8748 - | "Unexpected value for `simple_struct`"
|
8749 - | );
|
8750 - | ::pretty_assertions::assert_eq!(
|
8751 - | input.string,
|
8752 - | expected.string,
|
8753 - | "Unexpected value for `string`"
|
8754 - | );
|
8755 - | ::pretty_assertions::assert_eq!(
|
8756 - | input.struct_with_json_name,
|
8757 - | expected.struct_with_json_name,
|
8758 - | "Unexpected value for `struct_with_json_name`"
|
8759 - | );
|
8760 - | ::pretty_assertions::assert_eq!(
|
8761 - | input.timestamp,
|
8762 - | expected.timestamp,
|
8763 - | "Unexpected value for `timestamp`"
|
7871 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7872 + | http_response.status()
|
8764 7873 | );
|
7874 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7875 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7876 + | http_response.headers(),
|
7877 + | expected_headers,
|
7878 + | ));
|
7879 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7880 + | .await
|
7881 + | .expect("unable to extract body to bytes");
|
7882 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7883 + | &body,
|
7884 + | "{\"Iso8601Timestamp\":\"2000-01-02T20:34:56Z\"}",
|
7885 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7886 + | ));
|
7887 + | }
|
7888 + |
|
7889 + | /// Parses httpdate timestamps
|
7890 + | /// Test ID: parses_httpdate_timestamps
|
7891 + | #[::tokio::test]
|
7892 + | #[::tracing_test::traced_test]
|
7893 + | async fn parses_httpdate_timestamps_response() {
|
7894 + | let output = crate::output::KitchenSinkOperationOutput {
|
7895 + | httpdate_timestamp: ::std::option::Option::Some(
|
7896 + | ::aws_smithy_types::DateTime::from_fractional_secs(946845296, 0_f64),
|
7897 + | ),
|
7898 + | blob: ::std::option::Option::None,
|
7899 + | boolean: ::std::option::Option::None,
|
7900 + | double: ::std::option::Option::None,
|
7901 + | empty_struct: ::std::option::Option::None,
|
7902 + | float: ::std::option::Option::None,
|
7903 + | integer: ::std::option::Option::None,
|
7904 + | iso8601_timestamp: ::std::option::Option::None,
|
7905 + | json_value: ::std::option::Option::None,
|
7906 + | list_of_lists: ::std::option::Option::None,
|
7907 + | list_of_maps_of_strings: ::std::option::Option::None,
|
7908 + | list_of_strings: ::std::option::Option::None,
|
7909 + | list_of_structs: ::std::option::Option::None,
|
7910 + | long: ::std::option::Option::None,
|
7911 + | map_of_lists_of_strings: ::std::option::Option::None,
|
7912 + | map_of_maps: ::std::option::Option::None,
|
7913 + | map_of_strings: ::std::option::Option::None,
|
7914 + | map_of_structs: ::std::option::Option::None,
|
7915 + | recursive_list: ::std::option::Option::None,
|
7916 + | recursive_map: ::std::option::Option::None,
|
7917 + | recursive_struct: ::std::option::Option::None,
|
7918 + | simple_struct: ::std::option::Option::None,
|
7919 + | string: ::std::option::Option::None,
|
7920 + | struct_with_json_name: ::std::option::Option::None,
|
7921 + | timestamp: ::std::option::Option::None,
|
7922 + | unix_timestamp: ::std::option::Option::None,
|
7923 + | };
|
7924 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7925 + | let http_response = output.into_response();
|
8765 7926 | ::pretty_assertions::assert_eq!(
|
8766 - | input.unix_timestamp,
|
8767 - | expected.unix_timestamp,
|
8768 - | "Unexpected value for `unix_timestamp`"
|
7927 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7928 + | http_response.status()
|
8769 7929 | );
|
7930 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7931 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7932 + | http_response.headers(),
|
7933 + | expected_headers,
|
7934 + | ));
|
7935 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7936 + | .await
|
7937 + | .expect("unable to extract body to bytes");
|
7938 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7939 + | &body,
|
7940 + | "{\"HttpdateTimestamp\":\"Sun, 02 Jan 2000 20:34:56 GMT\"}",
|
7941 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
7942 + | ));
|
7943 + | }
|
7944 + |
|
7945 + | /// Parses list shapes
|
7946 + | /// Test ID: parses_list_shapes
|
7947 + | #[::tokio::test]
|
7948 + | #[::tracing_test::traced_test]
|
7949 + | async fn parses_list_shapes_response() {
|
8770 7950 | let output = crate::output::KitchenSinkOperationOutput {
|
7951 + | list_of_strings: ::std::option::Option::Some(vec![
|
7952 + | "abc".to_owned(),
|
7953 + | "mno".to_owned(),
|
7954 + | "xyz".to_owned(),
|
7955 + | ]),
|
8771 7956 | blob: ::std::option::Option::None,
|
8772 7957 | boolean: ::std::option::Option::None,
|
8773 7958 | double: ::std::option::Option::None,
|
8774 7959 | empty_struct: ::std::option::Option::None,
|
8775 7960 | float: ::std::option::Option::None,
|
8776 7961 | httpdate_timestamp: ::std::option::Option::None,
|
8777 7962 | integer: ::std::option::Option::None,
|
8778 7963 | iso8601_timestamp: ::std::option::Option::None,
|
8779 7964 | json_value: ::std::option::Option::None,
|
8780 7965 | list_of_lists: ::std::option::Option::None,
|
8781 7966 | list_of_maps_of_strings: ::std::option::Option::None,
|
8782 - | list_of_strings: ::std::option::Option::None,
|
8783 7967 | list_of_structs: ::std::option::Option::None,
|
8784 7968 | long: ::std::option::Option::None,
|
8785 7969 | map_of_lists_of_strings: ::std::option::Option::None,
|
8786 7970 | map_of_maps: ::std::option::Option::None,
|
8787 7971 | map_of_strings: ::std::option::Option::None,
|
8788 7972 | map_of_structs: ::std::option::Option::None,
|
8789 7973 | recursive_list: ::std::option::Option::None,
|
8790 7974 | recursive_map: ::std::option::Option::None,
|
8791 7975 | recursive_struct: ::std::option::Option::None,
|
8792 7976 | simple_struct: ::std::option::Option::None,
|
8793 7977 | string: ::std::option::Option::None,
|
8794 7978 | struct_with_json_name: ::std::option::Option::None,
|
8795 7979 | timestamp: ::std::option::Option::None,
|
8796 7980 | unix_timestamp: ::std::option::Option::None,
|
8797 7981 | };
|
8798 - | Ok(output)
|
8799 - | };
|
8800 - | sender.send(()).await.expect("receiver dropped early");
|
8801 - | result
|
8802 - | }
|
8803 - | })
|
8804 - | .build_unchecked();
|
8805 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8806 - | .await
|
8807 - | .expect("unable to make an HTTP request");
|
8808 - | assert!(
|
8809 - | receiver.recv().await.is_some(),
|
8810 - | "we expected operation handler to be invoked but it was not entered"
|
7982 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
7983 + | let http_response = output.into_response();
|
7984 + | ::pretty_assertions::assert_eq!(
|
7985 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
7986 + | http_response.status()
|
8811 7987 | );
|
7988 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
7989 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7990 + | http_response.headers(),
|
7991 + | expected_headers,
|
7992 + | ));
|
7993 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7994 + | .await
|
7995 + | .expect("unable to extract body to bytes");
|
7996 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
7997 + | &body,
|
7998 + | "{\"ListOfStrings\":[\"abc\",\"mno\",\"xyz\"]}",
|
7999 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8000 + | ));
|
8812 8001 | }
|
8813 8002 |
|
8814 - | /// Serializes map of recursive structure shapes
|
8815 - | /// Test ID: serializes_map_of_recursive_structure_shapes
|
8003 + | /// Parses list of map shapes
|
8004 + | /// Test ID: parses_list_of_map_shapes
|
8816 8005 | #[::tokio::test]
|
8817 8006 | #[::tracing_test::traced_test]
|
8818 - | async fn serializes_map_of_recursive_structure_shapes_request() {
|
8819 - | #[allow(unused_mut)]
|
8820 - | let mut http_request = ::http::Request::builder()
|
8821 - | .uri("/")
|
8822 - | .method("POST")
|
8823 - | .header("Content-Type", "application/x-amz-json-1.1")
|
8824 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
8825 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
8826 - | ::bytes::Bytes::copy_from_slice(
|
8827 - | &::aws_smithy_protocol_test::decode_body_data("{\"RecursiveMap\":{\"key1\":{\"RecursiveMap\":{\"key2\":{\"RecursiveMap\":{\"key3\":{\"Boolean\":false}}}}}}}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
8828 - | )
|
8829 - | )).unwrap();
|
8830 - | #[allow(unused_mut)]
|
8831 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8832 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
8833 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
8834 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
8835 - | let sender = sender.clone();
|
8836 - | async move {
|
8837 - | let result = {
|
8838 - | use ::aws_smithy_protocol_test::FloatEquals;
|
8839 - | let expected = crate::input::KitchenSinkOperationInput {
|
8840 - | recursive_map: ::std::option::Option::Some({
|
8007 + | async fn parses_list_of_map_shapes_response() {
|
8008 + | let output = crate::output::KitchenSinkOperationOutput {
|
8009 + | list_of_maps_of_strings: ::std::option::Option::Some(vec![
|
8010 + | {
|
8841 8011 | let mut ret = ::std::collections::HashMap::new();
|
8842 - | ret.insert(
|
8843 - | "key1".to_owned(),
|
8844 - | crate::model::KitchenSink {
|
8845 - | recursive_map: ::std::option::Option::Some({
|
8012 + | ret.insert("size".to_owned(), "large".to_owned());
|
8013 + | ret
|
8014 + | },
|
8015 + | {
|
8846 8016 | let mut ret = ::std::collections::HashMap::new();
|
8847 - | ret.insert(
|
8848 - | "key2".to_owned(),
|
8849 - | crate::model::KitchenSink {
|
8850 - | recursive_map: ::std::option::Option::Some({
|
8851 - | let mut ret =
|
8852 - | ::std::collections::HashMap::new();
|
8853 - | ret.insert(
|
8854 - | "key3".to_owned(),
|
8855 - | crate::model::KitchenSink {
|
8856 - | boolean:
|
8857 - | ::std::option::Option::Some(
|
8858 - | false,
|
8859 - | ),
|
8017 + | ret.insert("color".to_owned(), "red".to_owned());
|
8018 + | ret
|
8019 + | },
|
8020 + | ]),
|
8021 + | blob: ::std::option::Option::None,
|
8022 + | boolean: ::std::option::Option::None,
|
8023 + | double: ::std::option::Option::None,
|
8024 + | empty_struct: ::std::option::Option::None,
|
8025 + | float: ::std::option::Option::None,
|
8026 + | httpdate_timestamp: ::std::option::Option::None,
|
8027 + | integer: ::std::option::Option::None,
|
8028 + | iso8601_timestamp: ::std::option::Option::None,
|
8029 + | json_value: ::std::option::Option::None,
|
8030 + | list_of_lists: ::std::option::Option::None,
|
8031 + | list_of_strings: ::std::option::Option::None,
|
8032 + | list_of_structs: ::std::option::Option::None,
|
8033 + | long: ::std::option::Option::None,
|
8034 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8035 + | map_of_maps: ::std::option::Option::None,
|
8036 + | map_of_strings: ::std::option::Option::None,
|
8037 + | map_of_structs: ::std::option::Option::None,
|
8038 + | recursive_list: ::std::option::Option::None,
|
8039 + | recursive_map: ::std::option::Option::None,
|
8040 + | recursive_struct: ::std::option::Option::None,
|
8041 + | simple_struct: ::std::option::Option::None,
|
8042 + | string: ::std::option::Option::None,
|
8043 + | struct_with_json_name: ::std::option::Option::None,
|
8044 + | timestamp: ::std::option::Option::None,
|
8045 + | unix_timestamp: ::std::option::Option::None,
|
8046 + | };
|
8047 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8048 + | let http_response = output.into_response();
|
8049 + | ::pretty_assertions::assert_eq!(
|
8050 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8051 + | http_response.status()
|
8052 + | );
|
8053 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8054 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8055 + | http_response.headers(),
|
8056 + | expected_headers,
|
8057 + | ));
|
8058 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8059 + | .await
|
8060 + | .expect("unable to extract body to bytes");
|
8061 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
8062 + | &body,
|
8063 + | "{\"ListOfMapsOfStrings\":[{\"size\":\"large\"},{\"color\":\"red\"}]}",
|
8064 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8065 + | ));
|
8066 + | }
|
8067 + |
|
8068 + | /// Parses list of list shapes
|
8069 + | /// Test ID: parses_list_of_list_shapes
|
8070 + | #[::tokio::test]
|
8071 + | #[::tracing_test::traced_test]
|
8072 + | async fn parses_list_of_list_shapes_response() {
|
8073 + | let output = crate::output::KitchenSinkOperationOutput {
|
8074 + | list_of_lists: ::std::option::Option::Some(vec![
|
8075 + | vec!["abc".to_owned(), "mno".to_owned(), "xyz".to_owned()],
|
8076 + | vec!["hjk".to_owned(), "qrs".to_owned(), "tuv".to_owned()],
|
8077 + | ]),
|
8860 8078 | blob: ::std::option::Option::None,
|
8079 + | boolean: ::std::option::Option::None,
|
8861 8080 | double: ::std::option::Option::None,
|
8862 - | empty_struct:
|
8863 - | ::std::option::Option::None,
|
8081 + | empty_struct: ::std::option::Option::None,
|
8864 8082 | float: ::std::option::Option::None,
|
8865 - | httpdate_timestamp:
|
8866 - | ::std::option::Option::None,
|
8867 - | integer:
|
8868 - | ::std::option::Option::None,
|
8869 - | iso8601_timestamp:
|
8870 - | ::std::option::Option::None,
|
8871 - | json_value:
|
8872 - | ::std::option::Option::None,
|
8873 - | list_of_lists:
|
8874 - | ::std::option::Option::None,
|
8875 - | list_of_maps_of_strings:
|
8876 - | ::std::option::Option::None,
|
8877 - | list_of_strings:
|
8878 - | ::std::option::Option::None,
|
8879 - | list_of_structs:
|
8880 - | ::std::option::Option::None,
|
8083 + | httpdate_timestamp: ::std::option::Option::None,
|
8084 + | integer: ::std::option::Option::None,
|
8085 + | iso8601_timestamp: ::std::option::Option::None,
|
8086 + | json_value: ::std::option::Option::None,
|
8087 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8088 + | list_of_strings: ::std::option::Option::None,
|
8089 + | list_of_structs: ::std::option::Option::None,
|
8090 + | long: ::std::option::Option::None,
|
8091 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8092 + | map_of_maps: ::std::option::Option::None,
|
8093 + | map_of_strings: ::std::option::Option::None,
|
8094 + | map_of_structs: ::std::option::Option::None,
|
8095 + | recursive_list: ::std::option::Option::None,
|
8096 + | recursive_map: ::std::option::Option::None,
|
8097 + | recursive_struct: ::std::option::Option::None,
|
8098 + | simple_struct: ::std::option::Option::None,
|
8099 + | string: ::std::option::Option::None,
|
8100 + | struct_with_json_name: ::std::option::Option::None,
|
8101 + | timestamp: ::std::option::Option::None,
|
8102 + | unix_timestamp: ::std::option::Option::None,
|
8103 + | };
|
8104 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8105 + | let http_response = output.into_response();
|
8106 + | ::pretty_assertions::assert_eq!(
|
8107 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8108 + | http_response.status()
|
8109 + | );
|
8110 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8111 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8112 + | http_response.headers(),
|
8113 + | expected_headers,
|
8114 + | ));
|
8115 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8116 + | .await
|
8117 + | .expect("unable to extract body to bytes");
|
8118 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
8119 + | &body,
|
8120 + | "{\"ListOfLists\":[[\"abc\",\"mno\",\"xyz\"],[\"hjk\",\"qrs\",\"tuv\"]]}",
|
8121 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8122 + | ));
|
8123 + | }
|
8124 + |
|
8125 + | /// Parses list of structure shapes
|
8126 + | /// Test ID: parses_list_of_structure_shapes
|
8127 + | #[::tokio::test]
|
8128 + | #[::tracing_test::traced_test]
|
8129 + | async fn parses_list_of_structure_shapes_response() {
|
8130 + | let output = crate::output::KitchenSinkOperationOutput {
|
8131 + | list_of_structs: ::std::option::Option::Some(vec![
|
8132 + | crate::model::SimpleStruct {
|
8133 + | value: ::std::option::Option::Some("value-1".to_owned()),
|
8134 + | },
|
8135 + | crate::model::SimpleStruct {
|
8136 + | value: ::std::option::Option::Some("value-2".to_owned()),
|
8137 + | },
|
8138 + | ]),
|
8139 + | blob: ::std::option::Option::None,
|
8140 + | boolean: ::std::option::Option::None,
|
8141 + | double: ::std::option::Option::None,
|
8142 + | empty_struct: ::std::option::Option::None,
|
8143 + | float: ::std::option::Option::None,
|
8144 + | httpdate_timestamp: ::std::option::Option::None,
|
8145 + | integer: ::std::option::Option::None,
|
8146 + | iso8601_timestamp: ::std::option::Option::None,
|
8147 + | json_value: ::std::option::Option::None,
|
8148 + | list_of_lists: ::std::option::Option::None,
|
8149 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8150 + | list_of_strings: ::std::option::Option::None,
|
8881 8151 | long: ::std::option::Option::None,
|
8882 - | map_of_lists_of_strings:
|
8883 - | ::std::option::Option::None,
|
8884 - | map_of_maps:
|
8885 - | ::std::option::Option::None,
|
8886 - | map_of_strings:
|
8887 - | ::std::option::Option::None,
|
8888 - | map_of_structs:
|
8889 - | ::std::option::Option::None,
|
8890 - | recursive_list:
|
8891 - | ::std::option::Option::None,
|
8892 - | recursive_map:
|
8893 - | ::std::option::Option::None,
|
8894 - | recursive_struct:
|
8895 - | ::std::option::Option::None,
|
8896 - | simple_struct:
|
8897 - | ::std::option::Option::None,
|
8152 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8153 + | map_of_maps: ::std::option::Option::None,
|
8154 + | map_of_strings: ::std::option::Option::None,
|
8155 + | map_of_structs: ::std::option::Option::None,
|
8156 + | recursive_list: ::std::option::Option::None,
|
8157 + | recursive_map: ::std::option::Option::None,
|
8158 + | recursive_struct: ::std::option::Option::None,
|
8159 + | simple_struct: ::std::option::Option::None,
|
8898 8160 | string: ::std::option::Option::None,
|
8899 - | struct_with_json_name:
|
8900 - | ::std::option::Option::None,
|
8901 - | timestamp:
|
8902 - | ::std::option::Option::None,
|
8903 - | unix_timestamp:
|
8904 - | ::std::option::Option::None,
|
8905 - | },
|
8161 + | struct_with_json_name: ::std::option::Option::None,
|
8162 + | timestamp: ::std::option::Option::None,
|
8163 + | unix_timestamp: ::std::option::Option::None,
|
8164 + | };
|
8165 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8166 + | let http_response = output.into_response();
|
8167 + | ::pretty_assertions::assert_eq!(
|
8168 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8169 + | http_response.status()
|
8906 8170 | );
|
8907 - | ret
|
8908 - | }),
|
8171 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8172 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8173 + | http_response.headers(),
|
8174 + | expected_headers,
|
8175 + | ));
|
8176 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8177 + | .await
|
8178 + | .expect("unable to extract body to bytes");
|
8179 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
8180 + | &body,
|
8181 + | "{\"ListOfStructs\":[{\"Value\":\"value-1\"},{\"Value\":\"value-2\"}]}",
|
8182 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8183 + | ));
|
8184 + | }
|
8185 + |
|
8186 + | /// Parses list of recursive structure shapes
|
8187 + | /// Test ID: parses_list_of_recursive_structure_shapes
|
8188 + | #[::tokio::test]
|
8189 + | #[::tracing_test::traced_test]
|
8190 + | async fn parses_list_of_recursive_structure_shapes_response() {
|
8191 + | let output = crate::output::KitchenSinkOperationOutput {
|
8192 + | recursive_list: ::std::option::Option::Some(vec![crate::model::KitchenSink {
|
8193 + | recursive_list: ::std::option::Option::Some(vec![crate::model::KitchenSink {
|
8194 + | recursive_list: ::std::option::Option::Some(vec![crate::model::KitchenSink {
|
8195 + | string: ::std::option::Option::Some("value".to_owned()),
|
8909 8196 | blob: ::std::option::Option::None,
|
8910 8197 | boolean: ::std::option::Option::None,
|
8911 8198 | double: ::std::option::Option::None,
|
8912 8199 | empty_struct: ::std::option::Option::None,
|
8913 8200 | float: ::std::option::Option::None,
|
8914 8201 | httpdate_timestamp: ::std::option::Option::None,
|
8915 8202 | integer: ::std::option::Option::None,
|
8916 8203 | iso8601_timestamp: ::std::option::Option::None,
|
8917 8204 | json_value: ::std::option::Option::None,
|
8918 8205 | list_of_lists: ::std::option::Option::None,
|
8919 - | list_of_maps_of_strings:
|
8920 - | ::std::option::Option::None,
|
8206 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8921 8207 | list_of_strings: ::std::option::Option::None,
|
8922 8208 | list_of_structs: ::std::option::Option::None,
|
8923 8209 | long: ::std::option::Option::None,
|
8924 - | map_of_lists_of_strings:
|
8925 - | ::std::option::Option::None,
|
8210 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8926 8211 | map_of_maps: ::std::option::Option::None,
|
8927 8212 | map_of_strings: ::std::option::Option::None,
|
8928 8213 | map_of_structs: ::std::option::Option::None,
|
8929 8214 | recursive_list: ::std::option::Option::None,
|
8215 + | recursive_map: ::std::option::Option::None,
|
8216 + | recursive_struct: ::std::option::Option::None,
|
8217 + | simple_struct: ::std::option::Option::None,
|
8218 + | struct_with_json_name: ::std::option::Option::None,
|
8219 + | timestamp: ::std::option::Option::None,
|
8220 + | unix_timestamp: ::std::option::Option::None,
|
8221 + | }]),
|
8222 + | blob: ::std::option::Option::None,
|
8223 + | boolean: ::std::option::Option::None,
|
8224 + | double: ::std::option::Option::None,
|
8225 + | empty_struct: ::std::option::Option::None,
|
8226 + | float: ::std::option::Option::None,
|
8227 + | httpdate_timestamp: ::std::option::Option::None,
|
8228 + | integer: ::std::option::Option::None,
|
8229 + | iso8601_timestamp: ::std::option::Option::None,
|
8230 + | json_value: ::std::option::Option::None,
|
8231 + | list_of_lists: ::std::option::Option::None,
|
8232 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8233 + | list_of_strings: ::std::option::Option::None,
|
8234 + | list_of_structs: ::std::option::Option::None,
|
8235 + | long: ::std::option::Option::None,
|
8236 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8237 + | map_of_maps: ::std::option::Option::None,
|
8238 + | map_of_strings: ::std::option::Option::None,
|
8239 + | map_of_structs: ::std::option::Option::None,
|
8240 + | recursive_map: ::std::option::Option::None,
|
8930 8241 | recursive_struct: ::std::option::Option::None,
|
8931 8242 | simple_struct: ::std::option::Option::None,
|
8932 8243 | string: ::std::option::Option::None,
|
8933 - | struct_with_json_name:
|
8934 - | ::std::option::Option::None,
|
8244 + | struct_with_json_name: ::std::option::Option::None,
|
8935 8245 | timestamp: ::std::option::Option::None,
|
8936 8246 | unix_timestamp: ::std::option::Option::None,
|
8937 - | },
|
8938 - | );
|
8939 - | ret
|
8940 - | }),
|
8247 + | }]),
|
8941 8248 | blob: ::std::option::Option::None,
|
8942 8249 | boolean: ::std::option::Option::None,
|
8943 8250 | double: ::std::option::Option::None,
|
8944 8251 | empty_struct: ::std::option::Option::None,
|
8945 8252 | float: ::std::option::Option::None,
|
8946 8253 | httpdate_timestamp: ::std::option::Option::None,
|
8947 8254 | integer: ::std::option::Option::None,
|
8948 8255 | iso8601_timestamp: ::std::option::Option::None,
|
8949 8256 | json_value: ::std::option::Option::None,
|
8950 8257 | list_of_lists: ::std::option::Option::None,
|
8951 8258 | list_of_maps_of_strings: ::std::option::Option::None,
|
8952 8259 | list_of_strings: ::std::option::Option::None,
|
8953 8260 | list_of_structs: ::std::option::Option::None,
|
8954 8261 | long: ::std::option::Option::None,
|
8955 8262 | map_of_lists_of_strings: ::std::option::Option::None,
|
8956 8263 | map_of_maps: ::std::option::Option::None,
|
8957 8264 | map_of_strings: ::std::option::Option::None,
|
8958 8265 | map_of_structs: ::std::option::Option::None,
|
8959 - | recursive_list: ::std::option::Option::None,
|
8266 + | recursive_map: ::std::option::Option::None,
|
8960 8267 | recursive_struct: ::std::option::Option::None,
|
8961 8268 | simple_struct: ::std::option::Option::None,
|
8962 8269 | string: ::std::option::Option::None,
|
8963 8270 | struct_with_json_name: ::std::option::Option::None,
|
8964 8271 | timestamp: ::std::option::Option::None,
|
8965 8272 | unix_timestamp: ::std::option::Option::None,
|
8966 - | },
|
8967 - | );
|
8968 - | ret
|
8969 - | }),
|
8273 + | }]),
|
8970 8274 | blob: ::std::option::Option::None,
|
8971 8275 | boolean: ::std::option::Option::None,
|
8972 8276 | double: ::std::option::Option::None,
|
8973 8277 | empty_struct: ::std::option::Option::None,
|
8974 8278 | float: ::std::option::Option::None,
|
8975 8279 | httpdate_timestamp: ::std::option::Option::None,
|
8976 8280 | integer: ::std::option::Option::None,
|
8977 8281 | iso8601_timestamp: ::std::option::Option::None,
|
8978 8282 | json_value: ::std::option::Option::None,
|
8979 8283 | list_of_lists: ::std::option::Option::None,
|
8980 8284 | list_of_maps_of_strings: ::std::option::Option::None,
|
8981 8285 | list_of_strings: ::std::option::Option::None,
|
8982 8286 | list_of_structs: ::std::option::Option::None,
|
8983 8287 | long: ::std::option::Option::None,
|
8984 8288 | map_of_lists_of_strings: ::std::option::Option::None,
|
8985 8289 | map_of_maps: ::std::option::Option::None,
|
8986 8290 | map_of_strings: ::std::option::Option::None,
|
8987 8291 | map_of_structs: ::std::option::Option::None,
|
8988 - | recursive_list: ::std::option::Option::None,
|
8292 + | recursive_map: ::std::option::Option::None,
|
8989 8293 | recursive_struct: ::std::option::Option::None,
|
8990 8294 | simple_struct: ::std::option::Option::None,
|
8991 8295 | string: ::std::option::Option::None,
|
8992 8296 | struct_with_json_name: ::std::option::Option::None,
|
8993 8297 | timestamp: ::std::option::Option::None,
|
8994 8298 | unix_timestamp: ::std::option::Option::None,
|
8995 8299 | };
|
8300 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8301 + | let http_response = output.into_response();
|
8996 8302 | ::pretty_assertions::assert_eq!(
|
8997 - | input.blob,
|
8998 - | expected.blob,
|
8999 - | "Unexpected value for `blob`"
|
9000 - | );
|
9001 - | ::pretty_assertions::assert_eq!(
|
9002 - | input.boolean,
|
9003 - | expected.boolean,
|
9004 - | "Unexpected value for `boolean`"
|
9005 - | );
|
9006 - | assert!(
|
9007 - | input.double.float_equals(&expected.double),
|
9008 - | "Unexpected value for `double` {:?} vs. {:?}",
|
9009 - | expected.double,
|
9010 - | input.double
|
9011 - | );
|
9012 - | ::pretty_assertions::assert_eq!(
|
9013 - | input.empty_struct,
|
9014 - | expected.empty_struct,
|
9015 - | "Unexpected value for `empty_struct`"
|
9016 - | );
|
9017 - | assert!(
|
9018 - | input.float.float_equals(&expected.float),
|
9019 - | "Unexpected value for `float` {:?} vs. {:?}",
|
9020 - | expected.float,
|
9021 - | input.float
|
9022 - | );
|
9023 - | ::pretty_assertions::assert_eq!(
|
9024 - | input.httpdate_timestamp,
|
9025 - | expected.httpdate_timestamp,
|
9026 - | "Unexpected value for `httpdate_timestamp`"
|
9027 - | );
|
9028 - | ::pretty_assertions::assert_eq!(
|
9029 - | input.integer,
|
9030 - | expected.integer,
|
9031 - | "Unexpected value for `integer`"
|
9032 - | );
|
9033 - | ::pretty_assertions::assert_eq!(
|
9034 - | input.iso8601_timestamp,
|
9035 - | expected.iso8601_timestamp,
|
9036 - | "Unexpected value for `iso8601_timestamp`"
|
9037 - | );
|
9038 - | ::pretty_assertions::assert_eq!(
|
9039 - | input.json_value,
|
9040 - | expected.json_value,
|
9041 - | "Unexpected value for `json_value`"
|
9042 - | );
|
9043 - | ::pretty_assertions::assert_eq!(
|
9044 - | input.list_of_lists,
|
9045 - | expected.list_of_lists,
|
9046 - | "Unexpected value for `list_of_lists`"
|
9047 - | );
|
9048 - | ::pretty_assertions::assert_eq!(
|
9049 - | input.list_of_maps_of_strings,
|
9050 - | expected.list_of_maps_of_strings,
|
9051 - | "Unexpected value for `list_of_maps_of_strings`"
|
9052 - | );
|
9053 - | ::pretty_assertions::assert_eq!(
|
9054 - | input.list_of_strings,
|
9055 - | expected.list_of_strings,
|
9056 - | "Unexpected value for `list_of_strings`"
|
9057 - | );
|
9058 - | ::pretty_assertions::assert_eq!(
|
9059 - | input.list_of_structs,
|
9060 - | expected.list_of_structs,
|
9061 - | "Unexpected value for `list_of_structs`"
|
9062 - | );
|
9063 - | ::pretty_assertions::assert_eq!(
|
9064 - | input.long,
|
9065 - | expected.long,
|
9066 - | "Unexpected value for `long`"
|
9067 - | );
|
9068 - | ::pretty_assertions::assert_eq!(
|
9069 - | input.map_of_lists_of_strings,
|
9070 - | expected.map_of_lists_of_strings,
|
9071 - | "Unexpected value for `map_of_lists_of_strings`"
|
9072 - | );
|
9073 - | ::pretty_assertions::assert_eq!(
|
9074 - | input.map_of_maps,
|
9075 - | expected.map_of_maps,
|
9076 - | "Unexpected value for `map_of_maps`"
|
9077 - | );
|
9078 - | ::pretty_assertions::assert_eq!(
|
9079 - | input.map_of_strings,
|
9080 - | expected.map_of_strings,
|
9081 - | "Unexpected value for `map_of_strings`"
|
9082 - | );
|
9083 - | ::pretty_assertions::assert_eq!(
|
9084 - | input.map_of_structs,
|
9085 - | expected.map_of_structs,
|
9086 - | "Unexpected value for `map_of_structs`"
|
9087 - | );
|
9088 - | ::pretty_assertions::assert_eq!(
|
9089 - | input.recursive_list,
|
9090 - | expected.recursive_list,
|
9091 - | "Unexpected value for `recursive_list`"
|
9092 - | );
|
9093 - | ::pretty_assertions::assert_eq!(
|
9094 - | input.recursive_map,
|
9095 - | expected.recursive_map,
|
9096 - | "Unexpected value for `recursive_map`"
|
9097 - | );
|
9098 - | ::pretty_assertions::assert_eq!(
|
9099 - | input.recursive_struct,
|
9100 - | expected.recursive_struct,
|
9101 - | "Unexpected value for `recursive_struct`"
|
9102 - | );
|
9103 - | ::pretty_assertions::assert_eq!(
|
9104 - | input.simple_struct,
|
9105 - | expected.simple_struct,
|
9106 - | "Unexpected value for `simple_struct`"
|
9107 - | );
|
9108 - | ::pretty_assertions::assert_eq!(
|
9109 - | input.string,
|
9110 - | expected.string,
|
9111 - | "Unexpected value for `string`"
|
9112 - | );
|
9113 - | ::pretty_assertions::assert_eq!(
|
9114 - | input.struct_with_json_name,
|
9115 - | expected.struct_with_json_name,
|
9116 - | "Unexpected value for `struct_with_json_name`"
|
9117 - | );
|
9118 - | ::pretty_assertions::assert_eq!(
|
9119 - | input.timestamp,
|
9120 - | expected.timestamp,
|
9121 - | "Unexpected value for `timestamp`"
|
8303 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8304 + | http_response.status()
|
9122 8305 | );
|
9123 - | ::pretty_assertions::assert_eq!(
|
9124 - | input.unix_timestamp,
|
9125 - | expected.unix_timestamp,
|
9126 - | "Unexpected value for `unix_timestamp`"
|
8306 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8307 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8308 + | http_response.headers(),
|
8309 + | expected_headers,
|
8310 + | ));
|
8311 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8312 + | .await
|
8313 + | .expect("unable to extract body to bytes");
|
8314 + | ::aws_smithy_protocol_test::assert_ok(
|
8315 + | ::aws_smithy_protocol_test::validate_body(&body, "{\"RecursiveList\":[{\"RecursiveList\":[{\"RecursiveList\":[{\"String\":\"value\"}]}]}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9127 8316 | );
|
8317 + | }
|
8318 + |
|
8319 + | /// Parses map shapes
|
8320 + | /// Test ID: parses_map_shapes
|
8321 + | #[::tokio::test]
|
8322 + | #[::tracing_test::traced_test]
|
8323 + | async fn parses_map_shapes_response() {
|
9128 8324 | let output = crate::output::KitchenSinkOperationOutput {
|
8325 + | map_of_strings: ::std::option::Option::Some({
|
8326 + | let mut ret = ::std::collections::HashMap::new();
|
8327 + | ret.insert("size".to_owned(), "large".to_owned());
|
8328 + | ret.insert("color".to_owned(), "red".to_owned());
|
8329 + | ret
|
8330 + | }),
|
9129 8331 | blob: ::std::option::Option::None,
|
9130 8332 | boolean: ::std::option::Option::None,
|
9131 8333 | double: ::std::option::Option::None,
|
9132 8334 | empty_struct: ::std::option::Option::None,
|
9133 8335 | float: ::std::option::Option::None,
|
9134 8336 | httpdate_timestamp: ::std::option::Option::None,
|
9135 8337 | integer: ::std::option::Option::None,
|
9136 8338 | iso8601_timestamp: ::std::option::Option::None,
|
9137 8339 | json_value: ::std::option::Option::None,
|
9138 8340 | list_of_lists: ::std::option::Option::None,
|
9139 8341 | list_of_maps_of_strings: ::std::option::Option::None,
|
9140 8342 | list_of_strings: ::std::option::Option::None,
|
9141 8343 | list_of_structs: ::std::option::Option::None,
|
9142 8344 | long: ::std::option::Option::None,
|
9143 8345 | map_of_lists_of_strings: ::std::option::Option::None,
|
9144 8346 | map_of_maps: ::std::option::Option::None,
|
9145 - | map_of_strings: ::std::option::Option::None,
|
9146 8347 | map_of_structs: ::std::option::Option::None,
|
9147 8348 | recursive_list: ::std::option::Option::None,
|
9148 8349 | recursive_map: ::std::option::Option::None,
|
9149 8350 | recursive_struct: ::std::option::Option::None,
|
9150 8351 | simple_struct: ::std::option::Option::None,
|
9151 8352 | string: ::std::option::Option::None,
|
9152 8353 | struct_with_json_name: ::std::option::Option::None,
|
9153 8354 | timestamp: ::std::option::Option::None,
|
9154 8355 | unix_timestamp: ::std::option::Option::None,
|
9155 8356 | };
|
9156 - | Ok(output)
|
9157 - | };
|
9158 - | sender.send(()).await.expect("receiver dropped early");
|
9159 - | result
|
9160 - | }
|
9161 - | })
|
9162 - | .build_unchecked();
|
9163 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9164 - | .await
|
9165 - | .expect("unable to make an HTTP request");
|
9166 - | assert!(
|
9167 - | receiver.recv().await.is_some(),
|
9168 - | "we expected operation handler to be invoked but it was not entered"
|
8357 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8358 + | let http_response = output.into_response();
|
8359 + | ::pretty_assertions::assert_eq!(
|
8360 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8361 + | http_response.status()
|
9169 8362 | );
|
8363 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8364 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8365 + | http_response.headers(),
|
8366 + | expected_headers,
|
8367 + | ));
|
8368 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8369 + | .await
|
8370 + | .expect("unable to extract body to bytes");
|
8371 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
8372 + | &body,
|
8373 + | "{\"MapOfStrings\":{\"size\":\"large\",\"color\":\"red\"}}",
|
8374 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8375 + | ));
|
9170 8376 | }
|
9171 8377 |
|
9172 - | /// Serializes structure shapes
|
9173 - | /// Test ID: serializes_structure_shapes
|
8378 + | /// Parses map of list shapes
|
8379 + | /// Test ID: parses_map_of_list_shapes
|
9174 8380 | #[::tokio::test]
|
9175 8381 | #[::tracing_test::traced_test]
|
9176 - | async fn serializes_structure_shapes_request() {
|
9177 - | #[allow(unused_mut)]
|
9178 - | let mut http_request = ::http::Request::builder()
|
9179 - | .uri("/")
|
9180 - | .method("POST")
|
9181 - | .header("Content-Type", "application/x-amz-json-1.1")
|
9182 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
9183 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9184 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9185 - | "{\"SimpleStruct\":{\"Value\":\"abc\"}}".as_bytes(),
|
9186 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9187 - | )),
|
9188 - | ))
|
9189 - | .unwrap();
|
9190 - | #[allow(unused_mut)]
|
9191 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9192 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
9193 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9194 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
9195 - | let sender = sender.clone();
|
9196 - | async move {
|
9197 - | let result = {
|
9198 - | use ::aws_smithy_protocol_test::FloatEquals;
|
9199 - | let expected = crate::input::KitchenSinkOperationInput {
|
9200 - | simple_struct: ::std::option::Option::Some(
|
9201 - | crate::model::SimpleStruct {
|
9202 - | value: ::std::option::Option::Some("abc".to_owned()),
|
9203 - | },
|
9204 - | ),
|
8382 + | async fn parses_map_of_list_shapes_response() {
|
8383 + | let output = crate::output::KitchenSinkOperationOutput {
|
8384 + | map_of_lists_of_strings: ::std::option::Option::Some({
|
8385 + | let mut ret = ::std::collections::HashMap::new();
|
8386 + | ret.insert(
|
8387 + | "sizes".to_owned(),
|
8388 + | vec!["large".to_owned(), "small".to_owned()],
|
8389 + | );
|
8390 + | ret.insert(
|
8391 + | "colors".to_owned(),
|
8392 + | vec!["red".to_owned(), "green".to_owned()],
|
8393 + | );
|
8394 + | ret
|
8395 + | }),
|
9205 8396 | blob: ::std::option::Option::None,
|
9206 8397 | boolean: ::std::option::Option::None,
|
9207 8398 | double: ::std::option::Option::None,
|
9208 8399 | empty_struct: ::std::option::Option::None,
|
9209 8400 | float: ::std::option::Option::None,
|
9210 8401 | httpdate_timestamp: ::std::option::Option::None,
|
9211 8402 | integer: ::std::option::Option::None,
|
9212 8403 | iso8601_timestamp: ::std::option::Option::None,
|
9213 8404 | json_value: ::std::option::Option::None,
|
9214 8405 | list_of_lists: ::std::option::Option::None,
|
9215 8406 | list_of_maps_of_strings: ::std::option::Option::None,
|
9216 8407 | list_of_strings: ::std::option::Option::None,
|
9217 8408 | list_of_structs: ::std::option::Option::None,
|
9218 8409 | long: ::std::option::Option::None,
|
9219 - | map_of_lists_of_strings: ::std::option::Option::None,
|
9220 8410 | map_of_maps: ::std::option::Option::None,
|
9221 8411 | map_of_strings: ::std::option::Option::None,
|
9222 8412 | map_of_structs: ::std::option::Option::None,
|
9223 8413 | recursive_list: ::std::option::Option::None,
|
9224 8414 | recursive_map: ::std::option::Option::None,
|
9225 8415 | recursive_struct: ::std::option::Option::None,
|
8416 + | simple_struct: ::std::option::Option::None,
|
9226 8417 | string: ::std::option::Option::None,
|
9227 8418 | struct_with_json_name: ::std::option::Option::None,
|
9228 8419 | timestamp: ::std::option::Option::None,
|
9229 8420 | unix_timestamp: ::std::option::Option::None,
|
9230 8421 | };
|
8422 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8423 + | let http_response = output.into_response();
|
9231 8424 | ::pretty_assertions::assert_eq!(
|
9232 - | input.blob,
|
9233 - | expected.blob,
|
9234 - | "Unexpected value for `blob`"
|
9235 - | );
|
9236 - | ::pretty_assertions::assert_eq!(
|
9237 - | input.boolean,
|
9238 - | expected.boolean,
|
9239 - | "Unexpected value for `boolean`"
|
9240 - | );
|
9241 - | assert!(
|
9242 - | input.double.float_equals(&expected.double),
|
9243 - | "Unexpected value for `double` {:?} vs. {:?}",
|
9244 - | expected.double,
|
9245 - | input.double
|
9246 - | );
|
9247 - | ::pretty_assertions::assert_eq!(
|
9248 - | input.empty_struct,
|
9249 - | expected.empty_struct,
|
9250 - | "Unexpected value for `empty_struct`"
|
9251 - | );
|
9252 - | assert!(
|
9253 - | input.float.float_equals(&expected.float),
|
9254 - | "Unexpected value for `float` {:?} vs. {:?}",
|
9255 - | expected.float,
|
9256 - | input.float
|
9257 - | );
|
9258 - | ::pretty_assertions::assert_eq!(
|
9259 - | input.httpdate_timestamp,
|
9260 - | expected.httpdate_timestamp,
|
9261 - | "Unexpected value for `httpdate_timestamp`"
|
9262 - | );
|
9263 - | ::pretty_assertions::assert_eq!(
|
9264 - | input.integer,
|
9265 - | expected.integer,
|
9266 - | "Unexpected value for `integer`"
|
9267 - | );
|
9268 - | ::pretty_assertions::assert_eq!(
|
9269 - | input.iso8601_timestamp,
|
9270 - | expected.iso8601_timestamp,
|
9271 - | "Unexpected value for `iso8601_timestamp`"
|
9272 - | );
|
9273 - | ::pretty_assertions::assert_eq!(
|
9274 - | input.json_value,
|
9275 - | expected.json_value,
|
9276 - | "Unexpected value for `json_value`"
|
9277 - | );
|
9278 - | ::pretty_assertions::assert_eq!(
|
9279 - | input.list_of_lists,
|
9280 - | expected.list_of_lists,
|
9281 - | "Unexpected value for `list_of_lists`"
|
9282 - | );
|
9283 - | ::pretty_assertions::assert_eq!(
|
9284 - | input.list_of_maps_of_strings,
|
9285 - | expected.list_of_maps_of_strings,
|
9286 - | "Unexpected value for `list_of_maps_of_strings`"
|
9287 - | );
|
9288 - | ::pretty_assertions::assert_eq!(
|
9289 - | input.list_of_strings,
|
9290 - | expected.list_of_strings,
|
9291 - | "Unexpected value for `list_of_strings`"
|
9292 - | );
|
9293 - | ::pretty_assertions::assert_eq!(
|
9294 - | input.list_of_structs,
|
9295 - | expected.list_of_structs,
|
9296 - | "Unexpected value for `list_of_structs`"
|
9297 - | );
|
9298 - | ::pretty_assertions::assert_eq!(
|
9299 - | input.long,
|
9300 - | expected.long,
|
9301 - | "Unexpected value for `long`"
|
9302 - | );
|
9303 - | ::pretty_assertions::assert_eq!(
|
9304 - | input.map_of_lists_of_strings,
|
9305 - | expected.map_of_lists_of_strings,
|
9306 - | "Unexpected value for `map_of_lists_of_strings`"
|
9307 - | );
|
9308 - | ::pretty_assertions::assert_eq!(
|
9309 - | input.map_of_maps,
|
9310 - | expected.map_of_maps,
|
9311 - | "Unexpected value for `map_of_maps`"
|
9312 - | );
|
9313 - | ::pretty_assertions::assert_eq!(
|
9314 - | input.map_of_strings,
|
9315 - | expected.map_of_strings,
|
9316 - | "Unexpected value for `map_of_strings`"
|
9317 - | );
|
9318 - | ::pretty_assertions::assert_eq!(
|
9319 - | input.map_of_structs,
|
9320 - | expected.map_of_structs,
|
9321 - | "Unexpected value for `map_of_structs`"
|
9322 - | );
|
9323 - | ::pretty_assertions::assert_eq!(
|
9324 - | input.recursive_list,
|
9325 - | expected.recursive_list,
|
9326 - | "Unexpected value for `recursive_list`"
|
9327 - | );
|
9328 - | ::pretty_assertions::assert_eq!(
|
9329 - | input.recursive_map,
|
9330 - | expected.recursive_map,
|
9331 - | "Unexpected value for `recursive_map`"
|
9332 - | );
|
9333 - | ::pretty_assertions::assert_eq!(
|
9334 - | input.recursive_struct,
|
9335 - | expected.recursive_struct,
|
9336 - | "Unexpected value for `recursive_struct`"
|
9337 - | );
|
9338 - | ::pretty_assertions::assert_eq!(
|
9339 - | input.simple_struct,
|
9340 - | expected.simple_struct,
|
9341 - | "Unexpected value for `simple_struct`"
|
9342 - | );
|
9343 - | ::pretty_assertions::assert_eq!(
|
9344 - | input.string,
|
9345 - | expected.string,
|
9346 - | "Unexpected value for `string`"
|
9347 - | );
|
9348 - | ::pretty_assertions::assert_eq!(
|
9349 - | input.struct_with_json_name,
|
9350 - | expected.struct_with_json_name,
|
9351 - | "Unexpected value for `struct_with_json_name`"
|
9352 - | );
|
9353 - | ::pretty_assertions::assert_eq!(
|
9354 - | input.timestamp,
|
9355 - | expected.timestamp,
|
9356 - | "Unexpected value for `timestamp`"
|
8425 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8426 + | http_response.status()
|
9357 8427 | );
|
9358 - | ::pretty_assertions::assert_eq!(
|
9359 - | input.unix_timestamp,
|
9360 - | expected.unix_timestamp,
|
9361 - | "Unexpected value for `unix_timestamp`"
|
8428 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8429 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8430 + | http_response.headers(),
|
8431 + | expected_headers,
|
8432 + | ));
|
8433 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8434 + | .await
|
8435 + | .expect("unable to extract body to bytes");
|
8436 + | ::aws_smithy_protocol_test::assert_ok(
|
8437 + | ::aws_smithy_protocol_test::validate_body(&body, "{\"MapOfListsOfStrings\":{\"sizes\":[\"large\",\"small\"],\"colors\":[\"red\",\"green\"]}}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9362 8438 | );
|
8439 + | }
|
8440 + |
|
8441 + | /// Parses map of map shapes
|
8442 + | /// Test ID: parses_map_of_map_shapes
|
8443 + | #[::tokio::test]
|
8444 + | #[::tracing_test::traced_test]
|
8445 + | async fn parses_map_of_map_shapes_response() {
|
9363 8446 | let output = crate::output::KitchenSinkOperationOutput {
|
8447 + | map_of_maps: ::std::option::Option::Some({
|
8448 + | let mut ret = ::std::collections::HashMap::new();
|
8449 + | ret.insert("sizes".to_owned(), {
|
8450 + | let mut ret = ::std::collections::HashMap::new();
|
8451 + | ret.insert("large".to_owned(), "L".to_owned());
|
8452 + | ret.insert("medium".to_owned(), "M".to_owned());
|
8453 + | ret
|
8454 + | });
|
8455 + | ret.insert("colors".to_owned(), {
|
8456 + | let mut ret = ::std::collections::HashMap::new();
|
8457 + | ret.insert("red".to_owned(), "R".to_owned());
|
8458 + | ret.insert("blue".to_owned(), "B".to_owned());
|
8459 + | ret
|
8460 + | });
|
8461 + | ret
|
8462 + | }),
|
9364 8463 | blob: ::std::option::Option::None,
|
9365 8464 | boolean: ::std::option::Option::None,
|
9366 8465 | double: ::std::option::Option::None,
|
9367 8466 | empty_struct: ::std::option::Option::None,
|
9368 8467 | float: ::std::option::Option::None,
|
9369 8468 | httpdate_timestamp: ::std::option::Option::None,
|
9370 8469 | integer: ::std::option::Option::None,
|
9371 8470 | iso8601_timestamp: ::std::option::Option::None,
|
9372 8471 | json_value: ::std::option::Option::None,
|
9373 8472 | list_of_lists: ::std::option::Option::None,
|
9374 8473 | list_of_maps_of_strings: ::std::option::Option::None,
|
9375 8474 | list_of_strings: ::std::option::Option::None,
|
9376 8475 | list_of_structs: ::std::option::Option::None,
|
9377 8476 | long: ::std::option::Option::None,
|
9378 8477 | map_of_lists_of_strings: ::std::option::Option::None,
|
9379 - | map_of_maps: ::std::option::Option::None,
|
9380 8478 | map_of_strings: ::std::option::Option::None,
|
9381 8479 | map_of_structs: ::std::option::Option::None,
|
9382 8480 | recursive_list: ::std::option::Option::None,
|
9383 8481 | recursive_map: ::std::option::Option::None,
|
9384 8482 | recursive_struct: ::std::option::Option::None,
|
9385 8483 | simple_struct: ::std::option::Option::None,
|
9386 8484 | string: ::std::option::Option::None,
|
9387 8485 | struct_with_json_name: ::std::option::Option::None,
|
9388 8486 | timestamp: ::std::option::Option::None,
|
9389 8487 | unix_timestamp: ::std::option::Option::None,
|
9390 8488 | };
|
9391 - | Ok(output)
|
9392 - | };
|
9393 - | sender.send(()).await.expect("receiver dropped early");
|
9394 - | result
|
9395 - | }
|
9396 - | })
|
9397 - | .build_unchecked();
|
9398 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8489 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8490 + | let http_response = output.into_response();
|
8491 + | ::pretty_assertions::assert_eq!(
|
8492 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8493 + | http_response.status()
|
8494 + | );
|
8495 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8496 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8497 + | http_response.headers(),
|
8498 + | expected_headers,
|
8499 + | ));
|
8500 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9399 8501 | .await
|
9400 - | .expect("unable to make an HTTP request");
|
9401 - | assert!(
|
9402 - | receiver.recv().await.is_some(),
|
9403 - | "we expected operation handler to be invoked but it was not entered"
|
8502 + | .expect("unable to extract body to bytes");
|
8503 + | ::aws_smithy_protocol_test::assert_ok(
|
8504 + | ::aws_smithy_protocol_test::validate_body(&body, "{\"MapOfMaps\":{\"sizes\":{\"large\":\"L\",\"medium\":\"M\"},\"colors\":{\"red\":\"R\",\"blue\":\"B\"}}}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9404 8505 | );
|
9405 8506 | }
|
9406 8507 |
|
9407 - | /// Serializes structure members with locationName traits
|
9408 - | /// Test ID: serializes_structure_members_with_locationname_traits
|
8508 + | /// Parses map of structure shapes
|
8509 + | /// Test ID: parses_map_of_structure_shapes
|
9409 8510 | #[::tokio::test]
|
9410 8511 | #[::tracing_test::traced_test]
|
9411 - | async fn serializes_structure_members_with_locationname_traits_request() {
|
9412 - | #[allow(unused_mut)]
|
9413 - | let mut http_request = ::http::Request::builder()
|
9414 - | .uri("/")
|
9415 - | .method("POST")
|
9416 - | .header("Content-Type", "application/x-amz-json-1.1")
|
9417 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
9418 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9419 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9420 - | "{\"StructWithJsonName\":{\"Value\":\"some-value\"}}".as_bytes(),
|
9421 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9422 - | )),
|
9423 - | ))
|
9424 - | .unwrap();
|
9425 - | #[allow(unused_mut)]
|
9426 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9427 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
9428 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9429 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
9430 - | let sender = sender.clone();
|
9431 - | async move {
|
9432 - | let result = {
|
9433 - | use ::aws_smithy_protocol_test::FloatEquals;
|
9434 - | let expected = crate::input::KitchenSinkOperationInput {
|
9435 - | struct_with_json_name: ::std::option::Option::Some(
|
9436 - | crate::model::StructWithJsonName {
|
9437 - | value: ::std::option::Option::Some("some-value".to_owned()),
|
8512 + | async fn parses_map_of_structure_shapes_response() {
|
8513 + | let output = crate::output::KitchenSinkOperationOutput {
|
8514 + | map_of_structs: ::std::option::Option::Some({
|
8515 + | let mut ret = ::std::collections::HashMap::new();
|
8516 + | ret.insert(
|
8517 + | "size".to_owned(),
|
8518 + | crate::model::SimpleStruct {
|
8519 + | value: ::std::option::Option::Some("small".to_owned()),
|
9438 8520 | },
|
9439 - | ),
|
8521 + | );
|
8522 + | ret.insert(
|
8523 + | "color".to_owned(),
|
8524 + | crate::model::SimpleStruct {
|
8525 + | value: ::std::option::Option::Some("red".to_owned()),
|
8526 + | },
|
8527 + | );
|
8528 + | ret
|
8529 + | }),
|
9440 8530 | blob: ::std::option::Option::None,
|
9441 8531 | boolean: ::std::option::Option::None,
|
9442 8532 | double: ::std::option::Option::None,
|
9443 8533 | empty_struct: ::std::option::Option::None,
|
9444 8534 | float: ::std::option::Option::None,
|
9445 8535 | httpdate_timestamp: ::std::option::Option::None,
|
9446 8536 | integer: ::std::option::Option::None,
|
9447 8537 | iso8601_timestamp: ::std::option::Option::None,
|
9448 8538 | json_value: ::std::option::Option::None,
|
9449 8539 | list_of_lists: ::std::option::Option::None,
|
9450 8540 | list_of_maps_of_strings: ::std::option::Option::None,
|
9451 8541 | list_of_strings: ::std::option::Option::None,
|
9452 8542 | list_of_structs: ::std::option::Option::None,
|
9453 8543 | long: ::std::option::Option::None,
|
9454 8544 | map_of_lists_of_strings: ::std::option::Option::None,
|
9455 8545 | map_of_maps: ::std::option::Option::None,
|
9456 8546 | map_of_strings: ::std::option::Option::None,
|
9457 - | map_of_structs: ::std::option::Option::None,
|
9458 8547 | recursive_list: ::std::option::Option::None,
|
9459 8548 | recursive_map: ::std::option::Option::None,
|
9460 8549 | recursive_struct: ::std::option::Option::None,
|
9461 8550 | simple_struct: ::std::option::Option::None,
|
9462 8551 | string: ::std::option::Option::None,
|
8552 + | struct_with_json_name: ::std::option::Option::None,
|
9463 8553 | timestamp: ::std::option::Option::None,
|
9464 8554 | unix_timestamp: ::std::option::Option::None,
|
9465 8555 | };
|
8556 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8557 + | let http_response = output.into_response();
|
9466 8558 | ::pretty_assertions::assert_eq!(
|
9467 - | input.blob,
|
9468 - | expected.blob,
|
9469 - | "Unexpected value for `blob`"
|
9470 - | );
|
9471 - | ::pretty_assertions::assert_eq!(
|
9472 - | input.boolean,
|
9473 - | expected.boolean,
|
9474 - | "Unexpected value for `boolean`"
|
9475 - | );
|
9476 - | assert!(
|
9477 - | input.double.float_equals(&expected.double),
|
9478 - | "Unexpected value for `double` {:?} vs. {:?}",
|
9479 - | expected.double,
|
9480 - | input.double
|
9481 - | );
|
9482 - | ::pretty_assertions::assert_eq!(
|
9483 - | input.empty_struct,
|
9484 - | expected.empty_struct,
|
9485 - | "Unexpected value for `empty_struct`"
|
9486 - | );
|
9487 - | assert!(
|
9488 - | input.float.float_equals(&expected.float),
|
9489 - | "Unexpected value for `float` {:?} vs. {:?}",
|
9490 - | expected.float,
|
9491 - | input.float
|
9492 - | );
|
9493 - | ::pretty_assertions::assert_eq!(
|
9494 - | input.httpdate_timestamp,
|
9495 - | expected.httpdate_timestamp,
|
9496 - | "Unexpected value for `httpdate_timestamp`"
|
9497 - | );
|
9498 - | ::pretty_assertions::assert_eq!(
|
9499 - | input.integer,
|
9500 - | expected.integer,
|
9501 - | "Unexpected value for `integer`"
|
9502 - | );
|
9503 - | ::pretty_assertions::assert_eq!(
|
9504 - | input.iso8601_timestamp,
|
9505 - | expected.iso8601_timestamp,
|
9506 - | "Unexpected value for `iso8601_timestamp`"
|
9507 - | );
|
9508 - | ::pretty_assertions::assert_eq!(
|
9509 - | input.json_value,
|
9510 - | expected.json_value,
|
9511 - | "Unexpected value for `json_value`"
|
9512 - | );
|
9513 - | ::pretty_assertions::assert_eq!(
|
9514 - | input.list_of_lists,
|
9515 - | expected.list_of_lists,
|
9516 - | "Unexpected value for `list_of_lists`"
|
9517 - | );
|
9518 - | ::pretty_assertions::assert_eq!(
|
9519 - | input.list_of_maps_of_strings,
|
9520 - | expected.list_of_maps_of_strings,
|
9521 - | "Unexpected value for `list_of_maps_of_strings`"
|
9522 - | );
|
9523 - | ::pretty_assertions::assert_eq!(
|
9524 - | input.list_of_strings,
|
9525 - | expected.list_of_strings,
|
9526 - | "Unexpected value for `list_of_strings`"
|
9527 - | );
|
9528 - | ::pretty_assertions::assert_eq!(
|
9529 - | input.list_of_structs,
|
9530 - | expected.list_of_structs,
|
9531 - | "Unexpected value for `list_of_structs`"
|
9532 - | );
|
9533 - | ::pretty_assertions::assert_eq!(
|
9534 - | input.long,
|
9535 - | expected.long,
|
9536 - | "Unexpected value for `long`"
|
9537 - | );
|
9538 - | ::pretty_assertions::assert_eq!(
|
9539 - | input.map_of_lists_of_strings,
|
9540 - | expected.map_of_lists_of_strings,
|
9541 - | "Unexpected value for `map_of_lists_of_strings`"
|
9542 - | );
|
9543 - | ::pretty_assertions::assert_eq!(
|
9544 - | input.map_of_maps,
|
9545 - | expected.map_of_maps,
|
9546 - | "Unexpected value for `map_of_maps`"
|
9547 - | );
|
9548 - | ::pretty_assertions::assert_eq!(
|
9549 - | input.map_of_strings,
|
9550 - | expected.map_of_strings,
|
9551 - | "Unexpected value for `map_of_strings`"
|
9552 - | );
|
9553 - | ::pretty_assertions::assert_eq!(
|
9554 - | input.map_of_structs,
|
9555 - | expected.map_of_structs,
|
9556 - | "Unexpected value for `map_of_structs`"
|
9557 - | );
|
9558 - | ::pretty_assertions::assert_eq!(
|
9559 - | input.recursive_list,
|
9560 - | expected.recursive_list,
|
9561 - | "Unexpected value for `recursive_list`"
|
9562 - | );
|
9563 - | ::pretty_assertions::assert_eq!(
|
9564 - | input.recursive_map,
|
9565 - | expected.recursive_map,
|
9566 - | "Unexpected value for `recursive_map`"
|
9567 - | );
|
9568 - | ::pretty_assertions::assert_eq!(
|
9569 - | input.recursive_struct,
|
9570 - | expected.recursive_struct,
|
9571 - | "Unexpected value for `recursive_struct`"
|
8559 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8560 + | http_response.status()
|
9572 8561 | );
|
9573 - | ::pretty_assertions::assert_eq!(
|
9574 - | input.simple_struct,
|
9575 - | expected.simple_struct,
|
9576 - | "Unexpected value for `simple_struct`"
|
8562 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8563 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8564 + | http_response.headers(),
|
8565 + | expected_headers,
|
8566 + | ));
|
8567 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8568 + | .await
|
8569 + | .expect("unable to extract body to bytes");
|
8570 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
8571 + | &body,
|
8572 + | "{\"MapOfStructs\":{\"size\":{\"Value\":\"small\"},\"color\":{\"Value\":\"red\"}}}",
|
8573 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8574 + | ));
|
8575 + | }
|
8576 + |
|
8577 + | /// Parses map of recursive structure shapes
|
8578 + | /// Test ID: parses_map_of_recursive_structure_shapes
|
8579 + | #[::tokio::test]
|
8580 + | #[::tracing_test::traced_test]
|
8581 + | async fn parses_map_of_recursive_structure_shapes_response() {
|
8582 + | let output = crate::output::KitchenSinkOperationOutput {
|
8583 + | recursive_map: ::std::option::Option::Some({
|
8584 + | let mut ret = ::std::collections::HashMap::new();
|
8585 + | ret.insert(
|
8586 + | "key-1".to_owned(),
|
8587 + | crate::model::KitchenSink {
|
8588 + | recursive_map: ::std::option::Option::Some({
|
8589 + | let mut ret = ::std::collections::HashMap::new();
|
8590 + | ret.insert(
|
8591 + | "key-2".to_owned(),
|
8592 + | crate::model::KitchenSink {
|
8593 + | recursive_map: ::std::option::Option::Some({
|
8594 + | let mut ret = ::std::collections::HashMap::new();
|
8595 + | ret.insert(
|
8596 + | "key-3".to_owned(),
|
8597 + | crate::model::KitchenSink {
|
8598 + | string: ::std::option::Option::Some(
|
8599 + | "value".to_owned(),
|
8600 + | ),
|
8601 + | blob: ::std::option::Option::None,
|
8602 + | boolean: ::std::option::Option::None,
|
8603 + | double: ::std::option::Option::None,
|
8604 + | empty_struct: ::std::option::Option::None,
|
8605 + | float: ::std::option::Option::None,
|
8606 + | httpdate_timestamp: ::std::option::Option::None,
|
8607 + | integer: ::std::option::Option::None,
|
8608 + | iso8601_timestamp: ::std::option::Option::None,
|
8609 + | json_value: ::std::option::Option::None,
|
8610 + | list_of_lists: ::std::option::Option::None,
|
8611 + | list_of_maps_of_strings:
|
8612 + | ::std::option::Option::None,
|
8613 + | list_of_strings: ::std::option::Option::None,
|
8614 + | list_of_structs: ::std::option::Option::None,
|
8615 + | long: ::std::option::Option::None,
|
8616 + | map_of_lists_of_strings:
|
8617 + | ::std::option::Option::None,
|
8618 + | map_of_maps: ::std::option::Option::None,
|
8619 + | map_of_strings: ::std::option::Option::None,
|
8620 + | map_of_structs: ::std::option::Option::None,
|
8621 + | recursive_list: ::std::option::Option::None,
|
8622 + | recursive_map: ::std::option::Option::None,
|
8623 + | recursive_struct: ::std::option::Option::None,
|
8624 + | simple_struct: ::std::option::Option::None,
|
8625 + | struct_with_json_name: ::std::option::Option::None,
|
8626 + | timestamp: ::std::option::Option::None,
|
8627 + | unix_timestamp: ::std::option::Option::None,
|
8628 + | },
|
9577 8629 | );
|
9578 - | ::pretty_assertions::assert_eq!(
|
9579 - | input.string,
|
9580 - | expected.string,
|
9581 - | "Unexpected value for `string`"
|
8630 + | ret
|
8631 + | }),
|
8632 + | blob: ::std::option::Option::None,
|
8633 + | boolean: ::std::option::Option::None,
|
8634 + | double: ::std::option::Option::None,
|
8635 + | empty_struct: ::std::option::Option::None,
|
8636 + | float: ::std::option::Option::None,
|
8637 + | httpdate_timestamp: ::std::option::Option::None,
|
8638 + | integer: ::std::option::Option::None,
|
8639 + | iso8601_timestamp: ::std::option::Option::None,
|
8640 + | json_value: ::std::option::Option::None,
|
8641 + | list_of_lists: ::std::option::Option::None,
|
8642 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8643 + | list_of_strings: ::std::option::Option::None,
|
8644 + | list_of_structs: ::std::option::Option::None,
|
8645 + | long: ::std::option::Option::None,
|
8646 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8647 + | map_of_maps: ::std::option::Option::None,
|
8648 + | map_of_strings: ::std::option::Option::None,
|
8649 + | map_of_structs: ::std::option::Option::None,
|
8650 + | recursive_list: ::std::option::Option::None,
|
8651 + | recursive_struct: ::std::option::Option::None,
|
8652 + | simple_struct: ::std::option::Option::None,
|
8653 + | string: ::std::option::Option::None,
|
8654 + | struct_with_json_name: ::std::option::Option::None,
|
8655 + | timestamp: ::std::option::Option::None,
|
8656 + | unix_timestamp: ::std::option::Option::None,
|
8657 + | },
|
9582 8658 | );
|
9583 - | ::pretty_assertions::assert_eq!(
|
9584 - | input.struct_with_json_name,
|
9585 - | expected.struct_with_json_name,
|
9586 - | "Unexpected value for `struct_with_json_name`"
|
8659 + | ret
|
8660 + | }),
|
8661 + | blob: ::std::option::Option::None,
|
8662 + | boolean: ::std::option::Option::None,
|
8663 + | double: ::std::option::Option::None,
|
8664 + | empty_struct: ::std::option::Option::None,
|
8665 + | float: ::std::option::Option::None,
|
8666 + | httpdate_timestamp: ::std::option::Option::None,
|
8667 + | integer: ::std::option::Option::None,
|
8668 + | iso8601_timestamp: ::std::option::Option::None,
|
8669 + | json_value: ::std::option::Option::None,
|
8670 + | list_of_lists: ::std::option::Option::None,
|
8671 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8672 + | list_of_strings: ::std::option::Option::None,
|
8673 + | list_of_structs: ::std::option::Option::None,
|
8674 + | long: ::std::option::Option::None,
|
8675 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8676 + | map_of_maps: ::std::option::Option::None,
|
8677 + | map_of_strings: ::std::option::Option::None,
|
8678 + | map_of_structs: ::std::option::Option::None,
|
8679 + | recursive_list: ::std::option::Option::None,
|
8680 + | recursive_struct: ::std::option::Option::None,
|
8681 + | simple_struct: ::std::option::Option::None,
|
8682 + | string: ::std::option::Option::None,
|
8683 + | struct_with_json_name: ::std::option::Option::None,
|
8684 + | timestamp: ::std::option::Option::None,
|
8685 + | unix_timestamp: ::std::option::Option::None,
|
8686 + | },
|
9587 8687 | );
|
8688 + | ret
|
8689 + | }),
|
8690 + | blob: ::std::option::Option::None,
|
8691 + | boolean: ::std::option::Option::None,
|
8692 + | double: ::std::option::Option::None,
|
8693 + | empty_struct: ::std::option::Option::None,
|
8694 + | float: ::std::option::Option::None,
|
8695 + | httpdate_timestamp: ::std::option::Option::None,
|
8696 + | integer: ::std::option::Option::None,
|
8697 + | iso8601_timestamp: ::std::option::Option::None,
|
8698 + | json_value: ::std::option::Option::None,
|
8699 + | list_of_lists: ::std::option::Option::None,
|
8700 + | list_of_maps_of_strings: ::std::option::Option::None,
|
8701 + | list_of_strings: ::std::option::Option::None,
|
8702 + | list_of_structs: ::std::option::Option::None,
|
8703 + | long: ::std::option::Option::None,
|
8704 + | map_of_lists_of_strings: ::std::option::Option::None,
|
8705 + | map_of_maps: ::std::option::Option::None,
|
8706 + | map_of_strings: ::std::option::Option::None,
|
8707 + | map_of_structs: ::std::option::Option::None,
|
8708 + | recursive_list: ::std::option::Option::None,
|
8709 + | recursive_struct: ::std::option::Option::None,
|
8710 + | simple_struct: ::std::option::Option::None,
|
8711 + | string: ::std::option::Option::None,
|
8712 + | struct_with_json_name: ::std::option::Option::None,
|
8713 + | timestamp: ::std::option::Option::None,
|
8714 + | unix_timestamp: ::std::option::Option::None,
|
8715 + | };
|
8716 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8717 + | let http_response = output.into_response();
|
9588 8718 | ::pretty_assertions::assert_eq!(
|
9589 - | input.timestamp,
|
9590 - | expected.timestamp,
|
9591 - | "Unexpected value for `timestamp`"
|
8719 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8720 + | http_response.status()
|
9592 8721 | );
|
9593 - | ::pretty_assertions::assert_eq!(
|
9594 - | input.unix_timestamp,
|
9595 - | expected.unix_timestamp,
|
9596 - | "Unexpected value for `unix_timestamp`"
|
8722 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
8723 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8724 + | http_response.headers(),
|
8725 + | expected_headers,
|
8726 + | ));
|
8727 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8728 + | .await
|
8729 + | .expect("unable to extract body to bytes");
|
8730 + | ::aws_smithy_protocol_test::assert_ok(
|
8731 + | ::aws_smithy_protocol_test::validate_body(&body, "{\"RecursiveMap\":{\"key-1\":{\"RecursiveMap\":{\"key-2\":{\"RecursiveMap\":{\"key-3\":{\"String\":\"value\"}}}}}}}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9597 8732 | );
|
8733 + | }
|
8734 + |
|
8735 + | /// Parses the request id from the response
|
8736 + | /// Test ID: parses_the_request_id_from_the_response
|
8737 + | #[::tokio::test]
|
8738 + | #[::tracing_test::traced_test]
|
8739 + | #[should_panic]
|
8740 + | async fn parses_the_request_id_from_the_response_response() {
|
9598 8741 | let output = crate::output::KitchenSinkOperationOutput {
|
9599 8742 | blob: ::std::option::Option::None,
|
9600 8743 | boolean: ::std::option::Option::None,
|
9601 8744 | double: ::std::option::Option::None,
|
9602 8745 | empty_struct: ::std::option::Option::None,
|
9603 8746 | float: ::std::option::Option::None,
|
9604 8747 | httpdate_timestamp: ::std::option::Option::None,
|
9605 8748 | integer: ::std::option::Option::None,
|
9606 8749 | iso8601_timestamp: ::std::option::Option::None,
|
9607 8750 | json_value: ::std::option::Option::None,
|
9608 8751 | list_of_lists: ::std::option::Option::None,
|
9609 8752 | list_of_maps_of_strings: ::std::option::Option::None,
|
9610 8753 | list_of_strings: ::std::option::Option::None,
|
9611 8754 | list_of_structs: ::std::option::Option::None,
|
9612 8755 | long: ::std::option::Option::None,
|
9613 8756 | map_of_lists_of_strings: ::std::option::Option::None,
|
9614 8757 | map_of_maps: ::std::option::Option::None,
|
9615 8758 | map_of_strings: ::std::option::Option::None,
|
9616 8759 | map_of_structs: ::std::option::Option::None,
|
9617 8760 | recursive_list: ::std::option::Option::None,
|
9618 8761 | recursive_map: ::std::option::Option::None,
|
9619 8762 | recursive_struct: ::std::option::Option::None,
|
9620 8763 | simple_struct: ::std::option::Option::None,
|
9621 8764 | string: ::std::option::Option::None,
|
9622 8765 | struct_with_json_name: ::std::option::Option::None,
|
9623 8766 | timestamp: ::std::option::Option::None,
|
9624 8767 | unix_timestamp: ::std::option::Option::None,
|
9625 8768 | };
|
9626 - | Ok(output)
|
8769 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
8770 + | let http_response = output.into_response();
|
8771 + | ::pretty_assertions::assert_eq!(
|
8772 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
8773 + | http_response.status()
|
8774 + | );
|
8775 + | let expected_headers = [
|
8776 + | ("Content-Type", "application/x-amz-json-1.1"),
|
8777 + | ("X-Amzn-Requestid", "amazon-uniq-request-id"),
|
8778 + | ];
|
8779 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8780 + | http_response.headers(),
|
8781 + | expected_headers,
|
8782 + | ));
|
8783 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8784 + | .await
|
8785 + | .expect("unable to extract body to bytes");
|
8786 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
8787 + | &body,
|
8788 + | "{}",
|
8789 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8790 + | ));
|
8791 + | }
|
8792 + | }
|
8793 + |
|
8794 + | ::pin_project_lite::pin_project! {
|
8795 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
8796 + | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
8797 + | pub struct SimpleScalarPropertiesInputFuture {
|
8798 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
8799 + | }
|
8800 + | }
|
8801 + |
|
8802 + | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
8803 + | type Output = Result<
|
8804 + | crate::input::SimpleScalarPropertiesInput,
|
8805 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
8806 + | >;
|
8807 + |
|
8808 + | fn poll(
|
8809 + | self: std::pin::Pin<&mut Self>,
|
8810 + | cx: &mut std::task::Context<'_>,
|
8811 + | ) -> std::task::Poll<Self::Output> {
|
8812 + | let this = self.project();
|
8813 + | this.inner.as_mut().poll(cx)
|
8814 + | }
|
8815 + | }
|
8816 + |
|
8817 + | impl<B>
|
8818 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
8819 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
8820 + | B,
|
8821 + | > for crate::input::SimpleScalarPropertiesInput
|
8822 + | where
|
8823 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
8824 + | B: 'static,
|
8825 + |
|
8826 + | B::Data: Send,
|
8827 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
8828 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
8829 + | {
|
8830 + | type Rejection =
|
8831 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
8832 + | type Future = SimpleScalarPropertiesInputFuture;
|
8833 + |
|
8834 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
8835 + | let fut = async move {
|
8836 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
8837 + | request.headers(),
|
8838 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
8839 + | ) {
|
8840 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
8841 + | }
|
8842 + | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
8843 + | .await
|
9627 8844 | };
|
8845 + | use ::futures_util::future::TryFutureExt;
|
8846 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
8847 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
8848 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
8849 + | });
|
8850 + | SimpleScalarPropertiesInputFuture {
|
8851 + | inner: Box::pin(fut),
|
8852 + | }
|
8853 + | }
|
8854 + | }
|
8855 + | impl
|
8856 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
8857 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
8858 + | > for crate::output::SimpleScalarPropertiesOutput
|
8859 + | {
|
8860 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
8861 + | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
8862 + | Ok(response) => response,
|
8863 + | Err(e) => {
|
8864 + | ::tracing::error!(error = %e, "failed to serialize response");
|
8865 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
8866 + | }
|
8867 + | }
|
8868 + | }
|
8869 + | }
|
8870 + |
|
8871 + | #[allow(unreachable_code, unused_variables)]
|
8872 + | #[cfg(test)]
|
8873 + | mod simple_scalar_properties_test {
|
8874 + |
|
8875 + | /// Supports handling NaN float values.
|
8876 + | /// Test ID: AwsJson11SupportsNaNFloatInputs
|
8877 + | #[::tokio::test]
|
8878 + | #[::tracing_test::traced_test]
|
8879 + | async fn aws_json11_supports_na_n_float_inputs_request() {
|
8880 + | #[allow(unused_mut)]
|
8881 + | let mut http_request = ::http::Request::builder()
|
8882 + | .uri("/")
|
8883 + | .method("POST")
|
8884 + | .header("Content-Type", "application/x-amz-json-1.1")
|
8885 + | .header("X-Amz-Target", "JsonProtocol.SimpleScalarProperties")
|
8886 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
8887 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
8888 + | "{\n \"floatValue\": \"NaN\",\n \"doubleValue\": \"NaN\"\n}".as_bytes(),
|
8889 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
8890 + | )),
|
8891 + | ))
|
8892 + | .unwrap();
|
8893 + | #[allow(unused_mut)]
|
8894 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8895 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
8896 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
8897 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
8898 + | let sender = sender.clone();
|
8899 + | async move {
|
8900 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
8901 + | let expected =
|
8902 + | crate::input::SimpleScalarPropertiesInput {
|
8903 + | float_value:
|
8904 + | ::std::option::Option::Some(
|
8905 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN").expect("invalid string for number")
|
8906 + | )
|
8907 + | ,
|
8908 + | double_value:
|
8909 + | ::std::option::Option::Some(
|
8910 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN").expect("invalid string for number")
|
8911 + | )
|
8912 + | ,
|
8913 + | }
|
8914 + | ;
|
8915 + | assert!(input.float_value.float_equals(&expected.float_value),
|
8916 + | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
8917 + | assert!(input.double_value.float_equals(&expected.double_value),
|
8918 + | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
8919 + | let output =
|
8920 + | crate::output::SimpleScalarPropertiesOutput {
|
8921 + | float_value:
|
8922 + | ::std::option::Option::None
|
8923 + | ,
|
8924 + | double_value:
|
8925 + | ::std::option::Option::None
|
8926 + | ,
|
8927 + | }
|
8928 + | ;
|
8929 + | output };
|
9628 8930 | sender.send(()).await.expect("receiver dropped early");
|
9629 8931 | result
|
9630 8932 | }
|
9631 8933 | })
|
9632 8934 | .build_unchecked();
|
9633 8935 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9634 8936 | .await
|
9635 8937 | .expect("unable to make an HTTP request");
|
9636 8938 | assert!(
|
9637 8939 | receiver.recv().await.is_some(),
|
9638 8940 | "we expected operation handler to be invoked but it was not entered"
|
9639 8941 | );
|
9640 8942 | }
|
9641 8943 |
|
9642 - | /// Serializes empty structure shapes
|
9643 - | /// Test ID: serializes_empty_structure_shapes
|
8944 + | /// Supports handling Infinity float values.
|
8945 + | /// Test ID: AwsJson11SupportsInfinityFloatInputs
|
9644 8946 | #[::tokio::test]
|
9645 8947 | #[::tracing_test::traced_test]
|
9646 - | async fn serializes_empty_structure_shapes_request() {
|
8948 + | async fn aws_json11_supports_infinity_float_inputs_request() {
|
9647 8949 | #[allow(unused_mut)]
|
9648 8950 | let mut http_request = ::http::Request::builder()
|
9649 8951 | .uri("/")
|
9650 8952 | .method("POST")
|
9651 8953 | .header("Content-Type", "application/x-amz-json-1.1")
|
9652 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
8954 + | .header("X-Amz-Target", "JsonProtocol.SimpleScalarProperties")
|
9653 8955 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9654 8956 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9655 - | "{\"SimpleStruct\":{}}".as_bytes(),
|
8957 + | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}"
|
8958 + | .as_bytes(),
|
9656 8959 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9657 8960 | )),
|
9658 8961 | ))
|
9659 8962 | .unwrap();
|
9660 8963 | #[allow(unused_mut)]
|
9661 8964 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9662 8965 | let config = crate::service::JsonProtocolConfig::builder().build();
|
9663 8966 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9664 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
8967 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
9665 8968 | let sender = sender.clone();
|
9666 8969 | async move {
|
9667 - | let result = {
|
9668 - | use ::aws_smithy_protocol_test::FloatEquals;
|
9669 - | let expected = crate::input::KitchenSinkOperationInput {
|
9670 - | simple_struct: ::std::option::Option::Some(
|
9671 - | crate::model::SimpleStruct {
|
9672 - | value: ::std::option::Option::None,
|
9673 - | },
|
9674 - | ),
|
9675 - | blob: ::std::option::Option::None,
|
9676 - | boolean: ::std::option::Option::None,
|
9677 - | double: ::std::option::Option::None,
|
9678 - | empty_struct: ::std::option::Option::None,
|
9679 - | float: ::std::option::Option::None,
|
9680 - | httpdate_timestamp: ::std::option::Option::None,
|
9681 - | integer: ::std::option::Option::None,
|
9682 - | iso8601_timestamp: ::std::option::Option::None,
|
9683 - | json_value: ::std::option::Option::None,
|
9684 - | list_of_lists: ::std::option::Option::None,
|
9685 - | list_of_maps_of_strings: ::std::option::Option::None,
|
9686 - | list_of_strings: ::std::option::Option::None,
|
9687 - | list_of_structs: ::std::option::Option::None,
|
9688 - | long: ::std::option::Option::None,
|
9689 - | map_of_lists_of_strings: ::std::option::Option::None,
|
9690 - | map_of_maps: ::std::option::Option::None,
|
9691 - | map_of_strings: ::std::option::Option::None,
|
9692 - | map_of_structs: ::std::option::Option::None,
|
9693 - | recursive_list: ::std::option::Option::None,
|
9694 - | recursive_map: ::std::option::Option::None,
|
9695 - | recursive_struct: ::std::option::Option::None,
|
9696 - | string: ::std::option::Option::None,
|
9697 - | struct_with_json_name: ::std::option::Option::None,
|
9698 - | timestamp: ::std::option::Option::None,
|
9699 - | unix_timestamp: ::std::option::Option::None,
|
9700 - | };
|
9701 - | ::pretty_assertions::assert_eq!(
|
9702 - | input.blob,
|
9703 - | expected.blob,
|
9704 - | "Unexpected value for `blob`"
|
9705 - | );
|
9706 - | ::pretty_assertions::assert_eq!(
|
9707 - | input.boolean,
|
9708 - | expected.boolean,
|
9709 - | "Unexpected value for `boolean`"
|
9710 - | );
|
9711 - | assert!(
|
9712 - | input.double.float_equals(&expected.double),
|
9713 - | "Unexpected value for `double` {:?} vs. {:?}",
|
9714 - | expected.double,
|
9715 - | input.double
|
9716 - | );
|
9717 - | ::pretty_assertions::assert_eq!(
|
9718 - | input.empty_struct,
|
9719 - | expected.empty_struct,
|
9720 - | "Unexpected value for `empty_struct`"
|
9721 - | );
|
8970 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
8971 + | let expected =
|
8972 + | crate::input::SimpleScalarPropertiesInput {
|
8973 + | float_value:
|
8974 + | ::std::option::Option::Some(
|
8975 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number")
|
8976 + | )
|
8977 + | ,
|
8978 + | double_value:
|
8979 + | ::std::option::Option::Some(
|
8980 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number")
|
8981 + | )
|
8982 + | ,
|
8983 + | }
|
8984 + | ;
|
8985 + | assert!(input.float_value.float_equals(&expected.float_value),
|
8986 + | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
8987 + | assert!(input.double_value.float_equals(&expected.double_value),
|
8988 + | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
8989 + | let output =
|
8990 + | crate::output::SimpleScalarPropertiesOutput {
|
8991 + | float_value:
|
8992 + | ::std::option::Option::None
|
8993 + | ,
|
8994 + | double_value:
|
8995 + | ::std::option::Option::None
|
8996 + | ,
|
8997 + | }
|
8998 + | ;
|
8999 + | output };
|
9000 + | sender.send(()).await.expect("receiver dropped early");
|
9001 + | result
|
9002 + | }
|
9003 + | })
|
9004 + | .build_unchecked();
|
9005 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9006 + | .await
|
9007 + | .expect("unable to make an HTTP request");
|
9722 9008 | assert!(
|
9723 - | input.float.float_equals(&expected.float),
|
9724 - | "Unexpected value for `float` {:?} vs. {:?}",
|
9725 - | expected.float,
|
9726 - | input.float
|
9727 - | );
|
9728 - | ::pretty_assertions::assert_eq!(
|
9729 - | input.httpdate_timestamp,
|
9730 - | expected.httpdate_timestamp,
|
9731 - | "Unexpected value for `httpdate_timestamp`"
|
9732 - | );
|
9733 - | ::pretty_assertions::assert_eq!(
|
9734 - | input.integer,
|
9735 - | expected.integer,
|
9736 - | "Unexpected value for `integer`"
|
9737 - | );
|
9738 - | ::pretty_assertions::assert_eq!(
|
9739 - | input.iso8601_timestamp,
|
9740 - | expected.iso8601_timestamp,
|
9741 - | "Unexpected value for `iso8601_timestamp`"
|
9742 - | );
|
9743 - | ::pretty_assertions::assert_eq!(
|
9744 - | input.json_value,
|
9745 - | expected.json_value,
|
9746 - | "Unexpected value for `json_value`"
|
9747 - | );
|
9748 - | ::pretty_assertions::assert_eq!(
|
9749 - | input.list_of_lists,
|
9750 - | expected.list_of_lists,
|
9751 - | "Unexpected value for `list_of_lists`"
|
9752 - | );
|
9753 - | ::pretty_assertions::assert_eq!(
|
9754 - | input.list_of_maps_of_strings,
|
9755 - | expected.list_of_maps_of_strings,
|
9756 - | "Unexpected value for `list_of_maps_of_strings`"
|
9757 - | );
|
9758 - | ::pretty_assertions::assert_eq!(
|
9759 - | input.list_of_strings,
|
9760 - | expected.list_of_strings,
|
9761 - | "Unexpected value for `list_of_strings`"
|
9762 - | );
|
9763 - | ::pretty_assertions::assert_eq!(
|
9764 - | input.list_of_structs,
|
9765 - | expected.list_of_structs,
|
9766 - | "Unexpected value for `list_of_structs`"
|
9767 - | );
|
9768 - | ::pretty_assertions::assert_eq!(
|
9769 - | input.long,
|
9770 - | expected.long,
|
9771 - | "Unexpected value for `long`"
|
9772 - | );
|
9773 - | ::pretty_assertions::assert_eq!(
|
9774 - | input.map_of_lists_of_strings,
|
9775 - | expected.map_of_lists_of_strings,
|
9776 - | "Unexpected value for `map_of_lists_of_strings`"
|
9777 - | );
|
9778 - | ::pretty_assertions::assert_eq!(
|
9779 - | input.map_of_maps,
|
9780 - | expected.map_of_maps,
|
9781 - | "Unexpected value for `map_of_maps`"
|
9782 - | );
|
9783 - | ::pretty_assertions::assert_eq!(
|
9784 - | input.map_of_strings,
|
9785 - | expected.map_of_strings,
|
9786 - | "Unexpected value for `map_of_strings`"
|
9787 - | );
|
9788 - | ::pretty_assertions::assert_eq!(
|
9789 - | input.map_of_structs,
|
9790 - | expected.map_of_structs,
|
9791 - | "Unexpected value for `map_of_structs`"
|
9792 - | );
|
9793 - | ::pretty_assertions::assert_eq!(
|
9794 - | input.recursive_list,
|
9795 - | expected.recursive_list,
|
9796 - | "Unexpected value for `recursive_list`"
|
9797 - | );
|
9798 - | ::pretty_assertions::assert_eq!(
|
9799 - | input.recursive_map,
|
9800 - | expected.recursive_map,
|
9801 - | "Unexpected value for `recursive_map`"
|
9802 - | );
|
9803 - | ::pretty_assertions::assert_eq!(
|
9804 - | input.recursive_struct,
|
9805 - | expected.recursive_struct,
|
9806 - | "Unexpected value for `recursive_struct`"
|
9009 + | receiver.recv().await.is_some(),
|
9010 + | "we expected operation handler to be invoked but it was not entered"
|
9807 9011 | );
|
9808 - | ::pretty_assertions::assert_eq!(
|
9809 - | input.simple_struct,
|
9810 - | expected.simple_struct,
|
9811 - | "Unexpected value for `simple_struct`"
|
9012 + | }
|
9013 + |
|
9014 + | /// Supports handling -Infinity float values.
|
9015 + | /// Test ID: AwsJson11SupportsNegativeInfinityFloatInputs
|
9016 + | #[::tokio::test]
|
9017 + | #[::tracing_test::traced_test]
|
9018 + | async fn aws_json11_supports_negative_infinity_float_inputs_request() {
|
9019 + | #[allow(unused_mut)]
|
9020 + | let mut http_request = ::http::Request::builder()
|
9021 + | .uri("/")
|
9022 + | .method("POST")
|
9023 + | .header("Content-Type", "application/x-amz-json-1.1")
|
9024 + | .header("X-Amz-Target", "JsonProtocol.SimpleScalarProperties")
|
9025 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9026 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9027 + | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}"
|
9028 + | .as_bytes(),
|
9029 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9030 + | )),
|
9031 + | ))
|
9032 + | .unwrap();
|
9033 + | #[allow(unused_mut)]
|
9034 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9035 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
9036 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9037 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
9038 + | let sender = sender.clone();
|
9039 + | async move {
|
9040 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
9041 + | let expected =
|
9042 + | crate::input::SimpleScalarPropertiesInput {
|
9043 + | float_value:
|
9044 + | ::std::option::Option::Some(
|
9045 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number")
|
9046 + | )
|
9047 + | ,
|
9048 + | double_value:
|
9049 + | ::std::option::Option::Some(
|
9050 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number")
|
9051 + | )
|
9052 + | ,
|
9053 + | }
|
9054 + | ;
|
9055 + | assert!(input.float_value.float_equals(&expected.float_value),
|
9056 + | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
9057 + | assert!(input.double_value.float_equals(&expected.double_value),
|
9058 + | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
9059 + | let output =
|
9060 + | crate::output::SimpleScalarPropertiesOutput {
|
9061 + | float_value:
|
9062 + | ::std::option::Option::None
|
9063 + | ,
|
9064 + | double_value:
|
9065 + | ::std::option::Option::None
|
9066 + | ,
|
9067 + | }
|
9068 + | ;
|
9069 + | output };
|
9070 + | sender.send(()).await.expect("receiver dropped early");
|
9071 + | result
|
9072 + | }
|
9073 + | })
|
9074 + | .build_unchecked();
|
9075 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9076 + | .await
|
9077 + | .expect("unable to make an HTTP request");
|
9078 + | assert!(
|
9079 + | receiver.recv().await.is_some(),
|
9080 + | "we expected operation handler to be invoked but it was not entered"
|
9812 9081 | );
|
9082 + | }
|
9083 + |
|
9084 + | /// Supports handling NaN float values.
|
9085 + | /// Test ID: AwsJson11SupportsNaNFloatInputs
|
9086 + | #[::tokio::test]
|
9087 + | #[::tracing_test::traced_test]
|
9088 + | async fn aws_json11_supports_na_n_float_inputs_response() {
|
9089 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
9090 + | float_value: ::std::option::Option::Some(
|
9091 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
9092 + | .expect("invalid string for number"),
|
9093 + | ),
|
9094 + | double_value: ::std::option::Option::Some(
|
9095 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
9096 + | .expect("invalid string for number"),
|
9097 + | ),
|
9098 + | };
|
9099 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
9100 + | let http_response = output.into_response();
|
9813 9101 | ::pretty_assertions::assert_eq!(
|
9814 - | input.string,
|
9815 - | expected.string,
|
9816 - | "Unexpected value for `string`"
|
9102 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
9103 + | http_response.status()
|
9817 9104 | );
|
9105 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
9106 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
9107 + | http_response.headers(),
|
9108 + | expected_headers,
|
9109 + | ));
|
9110 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9111 + | .await
|
9112 + | .expect("unable to extract body to bytes");
|
9113 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
9114 + | &body,
|
9115 + | "{\n \"floatValue\": \"NaN\",\n \"doubleValue\": \"NaN\"\n}",
|
9116 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9117 + | ));
|
9118 + | }
|
9119 + |
|
9120 + | /// Supports handling Infinity float values.
|
9121 + | /// Test ID: AwsJson11SupportsInfinityFloatInputs
|
9122 + | #[::tokio::test]
|
9123 + | #[::tracing_test::traced_test]
|
9124 + | async fn aws_json11_supports_infinity_float_inputs_response() {
|
9125 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
9126 + | float_value: ::std::option::Option::Some(
|
9127 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
9128 + | .expect("invalid string for number"),
|
9129 + | ),
|
9130 + | double_value: ::std::option::Option::Some(
|
9131 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
9132 + | .expect("invalid string for number"),
|
9133 + | ),
|
9134 + | };
|
9135 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
9136 + | let http_response = output.into_response();
|
9818 9137 | ::pretty_assertions::assert_eq!(
|
9819 - | input.struct_with_json_name,
|
9820 - | expected.struct_with_json_name,
|
9821 - | "Unexpected value for `struct_with_json_name`"
|
9138 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
9139 + | http_response.status()
|
9822 9140 | );
|
9141 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
9142 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
9143 + | http_response.headers(),
|
9144 + | expected_headers,
|
9145 + | ));
|
9146 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9147 + | .await
|
9148 + | .expect("unable to extract body to bytes");
|
9149 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
9150 + | &body,
|
9151 + | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}",
|
9152 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9153 + | ));
|
9154 + | }
|
9155 + |
|
9156 + | /// Supports handling -Infinity float values.
|
9157 + | /// Test ID: AwsJson11SupportsNegativeInfinityFloatInputs
|
9158 + | #[::tokio::test]
|
9159 + | #[::tracing_test::traced_test]
|
9160 + | async fn aws_json11_supports_negative_infinity_float_inputs_response() {
|
9161 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
9162 + | float_value: ::std::option::Option::Some(
|
9163 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
9164 + | .expect("invalid string for number"),
|
9165 + | ),
|
9166 + | double_value: ::std::option::Option::Some(
|
9167 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
9168 + | .expect("invalid string for number"),
|
9169 + | ),
|
9170 + | };
|
9171 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
9172 + | let http_response = output.into_response();
|
9823 9173 | ::pretty_assertions::assert_eq!(
|
9824 - | input.timestamp,
|
9825 - | expected.timestamp,
|
9826 - | "Unexpected value for `timestamp`"
|
9174 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
9175 + | http_response.status()
|
9827 9176 | );
|
9828 - | ::pretty_assertions::assert_eq!(
|
9829 - | input.unix_timestamp,
|
9830 - | expected.unix_timestamp,
|
9831 - | "Unexpected value for `unix_timestamp`"
|
9177 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
9178 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
9179 + | http_response.headers(),
|
9180 + | expected_headers,
|
9181 + | ));
|
9182 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9183 + | .await
|
9184 + | .expect("unable to extract body to bytes");
|
9185 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
9186 + | &body,
|
9187 + | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}",
|
9188 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9189 + | ));
|
9190 + | }
|
9191 + | }
|
9192 + |
|
9193 + | ::pin_project_lite::pin_project! {
|
9194 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
9195 + | /// [`OperationWithOptionalInputOutputInput`](crate::input::OperationWithOptionalInputOutputInput) using modelled bindings.
|
9196 + | pub struct OperationWithOptionalInputOutputInputFuture {
|
9197 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithOptionalInputOutputInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
9198 + | }
|
9199 + | }
|
9200 + |
|
9201 + | impl std::future::Future for OperationWithOptionalInputOutputInputFuture {
|
9202 + | type Output = Result<
|
9203 + | crate::input::OperationWithOptionalInputOutputInput,
|
9204 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
9205 + | >;
|
9206 + |
|
9207 + | fn poll(
|
9208 + | self: std::pin::Pin<&mut Self>,
|
9209 + | cx: &mut std::task::Context<'_>,
|
9210 + | ) -> std::task::Poll<Self::Output> {
|
9211 + | let this = self.project();
|
9212 + | this.inner.as_mut().poll(cx)
|
9213 + | }
|
9214 + | }
|
9215 + |
|
9216 + | impl<B>
|
9217 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
9218 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9219 + | B,
|
9220 + | > for crate::input::OperationWithOptionalInputOutputInput
|
9221 + | where
|
9222 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
9223 + | B: 'static,
|
9224 + |
|
9225 + | B::Data: Send,
|
9226 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
9227 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
9228 + | {
|
9229 + | type Rejection =
|
9230 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
9231 + | type Future = OperationWithOptionalInputOutputInputFuture;
|
9232 + |
|
9233 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
9234 + | let fut = async move {
|
9235 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
9236 + | request.headers(),
|
9237 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
9238 + | ) {
|
9239 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
9240 + | }
|
9241 + | crate::protocol_serde::shape_operation_with_optional_input_output::de_operation_with_optional_input_output_http_request(request)
|
9242 + | .await
|
9243 + | };
|
9244 + | use ::futures_util::future::TryFutureExt;
|
9245 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
9246 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
9247 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
9248 + | });
|
9249 + | OperationWithOptionalInputOutputInputFuture {
|
9250 + | inner: Box::pin(fut),
|
9251 + | }
|
9252 + | }
|
9253 + | }
|
9254 + | impl
|
9255 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
9256 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9257 + | > for crate::output::OperationWithOptionalInputOutputOutput
|
9258 + | {
|
9259 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
9260 + | match crate::protocol_serde::shape_operation_with_optional_input_output::ser_operation_with_optional_input_output_http_response(self) {
|
9261 + | Ok(response) => response,
|
9262 + | Err(e) => {
|
9263 + | ::tracing::error!(error = %e, "failed to serialize response");
|
9264 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
9265 + | }
|
9266 + | }
|
9267 + | }
|
9268 + | }
|
9269 + |
|
9270 + | #[allow(unreachable_code, unused_variables)]
|
9271 + | #[cfg(test)]
|
9272 + | mod operation_with_optional_input_output_test {
|
9273 + |
|
9274 + | /// Can call operations with no input or output
|
9275 + | /// Test ID: can_call_operation_with_no_input_or_output
|
9276 + | #[::tokio::test]
|
9277 + | #[::tracing_test::traced_test]
|
9278 + | async fn can_call_operation_with_no_input_or_output_request() {
|
9279 + | #[allow(unused_mut)]
|
9280 + | let mut http_request = ::http::Request::builder()
|
9281 + | .uri("/")
|
9282 + | .method("POST")
|
9283 + | .header("Content-Type", "application/x-amz-json-1.1")
|
9284 + | .header(
|
9285 + | "X-Amz-Target",
|
9286 + | "JsonProtocol.OperationWithOptionalInputOutput",
|
9287 + | )
|
9288 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9289 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9290 + | "{}".as_bytes(),
|
9291 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9292 + | )),
|
9293 + | ))
|
9294 + | .unwrap();
|
9295 + | #[allow(unused_mut)]
|
9296 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9297 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
9298 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9299 + | .operation_with_optional_input_output(
|
9300 + | move |input: crate::input::OperationWithOptionalInputOutputInput| {
|
9301 + | let sender = sender.clone();
|
9302 + | async move {
|
9303 + | let result = {
|
9304 + | let expected = crate::input::OperationWithOptionalInputOutputInput {
|
9305 + | value: ::std::option::Option::None,
|
9306 + | };
|
9307 + | ::pretty_assertions::assert_eq!(input, expected);
|
9308 + | let output = crate::output::OperationWithOptionalInputOutputOutput {
|
9309 + | value: ::std::option::Option::None,
|
9310 + | };
|
9311 + | output
|
9312 + | };
|
9313 + | sender.send(()).await.expect("receiver dropped early");
|
9314 + | result
|
9315 + | }
|
9316 + | },
|
9317 + | )
|
9318 + | .build_unchecked();
|
9319 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9320 + | .await
|
9321 + | .expect("unable to make an HTTP request");
|
9322 + | assert!(
|
9323 + | receiver.recv().await.is_some(),
|
9324 + | "we expected operation handler to be invoked but it was not entered"
|
9832 9325 | );
|
9833 - | let output = crate::output::KitchenSinkOperationOutput {
|
9834 - | blob: ::std::option::Option::None,
|
9835 - | boolean: ::std::option::Option::None,
|
9836 - | double: ::std::option::Option::None,
|
9837 - | empty_struct: ::std::option::Option::None,
|
9838 - | float: ::std::option::Option::None,
|
9839 - | httpdate_timestamp: ::std::option::Option::None,
|
9840 - | integer: ::std::option::Option::None,
|
9841 - | iso8601_timestamp: ::std::option::Option::None,
|
9842 - | json_value: ::std::option::Option::None,
|
9843 - | list_of_lists: ::std::option::Option::None,
|
9844 - | list_of_maps_of_strings: ::std::option::Option::None,
|
9845 - | list_of_strings: ::std::option::Option::None,
|
9846 - | list_of_structs: ::std::option::Option::None,
|
9847 - | long: ::std::option::Option::None,
|
9848 - | map_of_lists_of_strings: ::std::option::Option::None,
|
9849 - | map_of_maps: ::std::option::Option::None,
|
9850 - | map_of_strings: ::std::option::Option::None,
|
9851 - | map_of_structs: ::std::option::Option::None,
|
9852 - | recursive_list: ::std::option::Option::None,
|
9853 - | recursive_map: ::std::option::Option::None,
|
9854 - | recursive_struct: ::std::option::Option::None,
|
9855 - | simple_struct: ::std::option::Option::None,
|
9856 - | string: ::std::option::Option::None,
|
9857 - | struct_with_json_name: ::std::option::Option::None,
|
9858 - | timestamp: ::std::option::Option::None,
|
9859 - | unix_timestamp: ::std::option::Option::None,
|
9326 + | }
|
9327 + |
|
9328 + | /// Can invoke operations with optional input
|
9329 + | /// Test ID: can_call_operation_with_optional_input
|
9330 + | #[::tokio::test]
|
9331 + | #[::tracing_test::traced_test]
|
9332 + | async fn can_call_operation_with_optional_input_request() {
|
9333 + | #[allow(unused_mut)]
|
9334 + | let mut http_request = ::http::Request::builder()
|
9335 + | .uri("/")
|
9336 + | .method("POST")
|
9337 + | .header("Content-Type", "application/x-amz-json-1.1")
|
9338 + | .header(
|
9339 + | "X-Amz-Target",
|
9340 + | "JsonProtocol.OperationWithOptionalInputOutput",
|
9341 + | )
|
9342 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9343 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9344 + | "{\"Value\":\"Hi\"}".as_bytes(),
|
9345 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9346 + | )),
|
9347 + | ))
|
9348 + | .unwrap();
|
9349 + | #[allow(unused_mut)]
|
9350 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9351 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
9352 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9353 + | .operation_with_optional_input_output(
|
9354 + | move |input: crate::input::OperationWithOptionalInputOutputInput| {
|
9355 + | let sender = sender.clone();
|
9356 + | async move {
|
9357 + | let result = {
|
9358 + | let expected = crate::input::OperationWithOptionalInputOutputInput {
|
9359 + | value: ::std::option::Option::Some("Hi".to_owned()),
|
9860 9360 | };
|
9861 - | Ok(output)
|
9361 + | ::pretty_assertions::assert_eq!(input, expected);
|
9362 + | let output = crate::output::OperationWithOptionalInputOutputOutput {
|
9363 + | value: ::std::option::Option::None,
|
9364 + | };
|
9365 + | output
|
9862 9366 | };
|
9863 9367 | sender.send(()).await.expect("receiver dropped early");
|
9864 9368 | result
|
9865 9369 | }
|
9866 - | })
|
9370 + | },
|
9371 + | )
|
9867 9372 | .build_unchecked();
|
9868 9373 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9869 9374 | .await
|
9870 9375 | .expect("unable to make an HTTP request");
|
9871 9376 | assert!(
|
9872 9377 | receiver.recv().await.is_some(),
|
9873 9378 | "we expected operation handler to be invoked but it was not entered"
|
9874 9379 | );
|
9875 9380 | }
|
9381 + | }
|
9876 9382 |
|
9877 - | /// Serializes structure which have no members
|
9878 - | /// Test ID: serializes_structure_which_have_no_members
|
9383 + | ::pin_project_lite::pin_project! {
|
9384 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
9385 + | /// [`PutAndGetInlineDocumentsInput`](crate::input::PutAndGetInlineDocumentsInput) using modelled bindings.
|
9386 + | pub struct PutAndGetInlineDocumentsInputFuture {
|
9387 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PutAndGetInlineDocumentsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
9388 + | }
|
9389 + | }
|
9390 + |
|
9391 + | impl std::future::Future for PutAndGetInlineDocumentsInputFuture {
|
9392 + | type Output = Result<
|
9393 + | crate::input::PutAndGetInlineDocumentsInput,
|
9394 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
9395 + | >;
|
9396 + |
|
9397 + | fn poll(
|
9398 + | self: std::pin::Pin<&mut Self>,
|
9399 + | cx: &mut std::task::Context<'_>,
|
9400 + | ) -> std::task::Poll<Self::Output> {
|
9401 + | let this = self.project();
|
9402 + | this.inner.as_mut().poll(cx)
|
9403 + | }
|
9404 + | }
|
9405 + |
|
9406 + | impl<B>
|
9407 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
9408 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9409 + | B,
|
9410 + | > for crate::input::PutAndGetInlineDocumentsInput
|
9411 + | where
|
9412 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
9413 + | B: 'static,
|
9414 + |
|
9415 + | B::Data: Send,
|
9416 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
9417 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
9418 + | {
|
9419 + | type Rejection =
|
9420 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
9421 + | type Future = PutAndGetInlineDocumentsInputFuture;
|
9422 + |
|
9423 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
9424 + | let fut = async move {
|
9425 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
9426 + | request.headers(),
|
9427 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
9428 + | ) {
|
9429 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
9430 + | }
|
9431 + | crate::protocol_serde::shape_put_and_get_inline_documents::de_put_and_get_inline_documents_http_request(request)
|
9432 + | .await
|
9433 + | };
|
9434 + | use ::futures_util::future::TryFutureExt;
|
9435 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
9436 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
9437 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
9438 + | });
|
9439 + | PutAndGetInlineDocumentsInputFuture {
|
9440 + | inner: Box::pin(fut),
|
9441 + | }
|
9442 + | }
|
9443 + | }
|
9444 + | impl
|
9445 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
9446 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9447 + | > for crate::output::PutAndGetInlineDocumentsOutput
|
9448 + | {
|
9449 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
9450 + | match crate::protocol_serde::shape_put_and_get_inline_documents::ser_put_and_get_inline_documents_http_response(self) {
|
9451 + | Ok(response) => response,
|
9452 + | Err(e) => {
|
9453 + | ::tracing::error!(error = %e, "failed to serialize response");
|
9454 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
9455 + | }
|
9456 + | }
|
9457 + | }
|
9458 + | }
|
9459 + |
|
9460 + | #[allow(unreachable_code, unused_variables)]
|
9461 + | #[cfg(test)]
|
9462 + | mod put_and_get_inline_documents_test {
|
9463 + |
|
9464 + | /// Serializes inline documents in a JSON request.
|
9465 + | /// Test ID: PutAndGetInlineDocumentsInput
|
9879 9466 | #[::tokio::test]
|
9880 9467 | #[::tracing_test::traced_test]
|
9881 - | async fn serializes_structure_which_have_no_members_request() {
|
9468 + | async fn put_and_get_inline_documents_input_request() {
|
9882 9469 | #[allow(unused_mut)]
|
9883 9470 | let mut http_request = ::http::Request::builder()
|
9884 9471 | .uri("/")
|
9885 9472 | .method("POST")
|
9886 9473 | .header("Content-Type", "application/x-amz-json-1.1")
|
9887 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
9474 + | .header("X-Amz-Target", "JsonProtocol.PutAndGetInlineDocuments")
|
9888 9475 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9889 9476 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
9890 - | "{\"EmptyStruct\":{}}".as_bytes(),
|
9477 + | "{\n \"inlineDocument\": {\"foo\": \"bar\"}\n}".as_bytes(),
|
9891 9478 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9892 9479 | )),
|
9893 9480 | ))
|
9894 9481 | .unwrap();
|
9895 9482 | #[allow(unused_mut)]
|
9896 9483 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9897 9484 | let config = crate::service::JsonProtocolConfig::builder().build();
|
9898 9485 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9899 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
9486 + | .put_and_get_inline_documents(
|
9487 + | move |input: crate::input::PutAndGetInlineDocumentsInput| {
|
9900 9488 | let sender = sender.clone();
|
9901 9489 | async move {
|
9902 9490 | let result = {
|
9903 - | use ::aws_smithy_protocol_test::FloatEquals;
|
9904 - | let expected = crate::input::KitchenSinkOperationInput {
|
9905 - | empty_struct: ::std::option::Option::Some(crate::model::EmptyStruct {}),
|
9906 - | blob: ::std::option::Option::None,
|
9907 - | boolean: ::std::option::Option::None,
|
9908 - | double: ::std::option::Option::None,
|
9909 - | float: ::std::option::Option::None,
|
9910 - | httpdate_timestamp: ::std::option::Option::None,
|
9911 - | integer: ::std::option::Option::None,
|
9912 - | iso8601_timestamp: ::std::option::Option::None,
|
9913 - | json_value: ::std::option::Option::None,
|
9914 - | list_of_lists: ::std::option::Option::None,
|
9915 - | list_of_maps_of_strings: ::std::option::Option::None,
|
9916 - | list_of_strings: ::std::option::Option::None,
|
9917 - | list_of_structs: ::std::option::Option::None,
|
9918 - | long: ::std::option::Option::None,
|
9919 - | map_of_lists_of_strings: ::std::option::Option::None,
|
9920 - | map_of_maps: ::std::option::Option::None,
|
9921 - | map_of_strings: ::std::option::Option::None,
|
9922 - | map_of_structs: ::std::option::Option::None,
|
9923 - | recursive_list: ::std::option::Option::None,
|
9924 - | recursive_map: ::std::option::Option::None,
|
9925 - | recursive_struct: ::std::option::Option::None,
|
9926 - | simple_struct: ::std::option::Option::None,
|
9927 - | string: ::std::option::Option::None,
|
9928 - | struct_with_json_name: ::std::option::Option::None,
|
9929 - | timestamp: ::std::option::Option::None,
|
9930 - | unix_timestamp: ::std::option::Option::None,
|
9491 + | let expected = crate::input::PutAndGetInlineDocumentsInput {
|
9492 + | inline_document: ::std::option::Option::Some({
|
9493 + | let json_bytes = br#"{
|
9494 + | "foo": "bar"
|
9495 + | }"#;
|
9496 + | let mut tokens =
|
9497 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
9498 + | .peekable();
|
9499 + | ::aws_smithy_json::deserialize::token::expect_document(
|
9500 + | &mut tokens,
|
9501 + | )
|
9502 + | .expect("well formed json")
|
9503 + | }),
|
9931 9504 | };
|
9932 - | ::pretty_assertions::assert_eq!(
|
9933 - | input.blob,
|
9934 - | expected.blob,
|
9935 - | "Unexpected value for `blob`"
|
9936 - | );
|
9937 - | ::pretty_assertions::assert_eq!(
|
9938 - | input.boolean,
|
9939 - | expected.boolean,
|
9940 - | "Unexpected value for `boolean`"
|
9941 - | );
|
9942 - | assert!(
|
9943 - | input.double.float_equals(&expected.double),
|
9944 - | "Unexpected value for `double` {:?} vs. {:?}",
|
9945 - | expected.double,
|
9946 - | input.double
|
9947 - | );
|
9948 - | ::pretty_assertions::assert_eq!(
|
9949 - | input.empty_struct,
|
9950 - | expected.empty_struct,
|
9951 - | "Unexpected value for `empty_struct`"
|
9952 - | );
|
9505 + | ::pretty_assertions::assert_eq!(input, expected);
|
9506 + | let output = crate::output::PutAndGetInlineDocumentsOutput {
|
9507 + | inline_document: ::std::option::Option::Some({
|
9508 + | let json_bytes = br#"null"#;
|
9509 + | let mut tokens =
|
9510 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
9511 + | .peekable();
|
9512 + | ::aws_smithy_json::deserialize::token::expect_document(
|
9513 + | &mut tokens,
|
9514 + | )
|
9515 + | .expect("well formed json")
|
9516 + | }),
|
9517 + | };
|
9518 + | output
|
9519 + | };
|
9520 + | sender.send(()).await.expect("receiver dropped early");
|
9521 + | result
|
9522 + | }
|
9523 + | },
|
9524 + | )
|
9525 + | .build_unchecked();
|
9526 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9527 + | .await
|
9528 + | .expect("unable to make an HTTP request");
|
9953 9529 | assert!(
|
9954 - | input.float.float_equals(&expected.float),
|
9955 - | "Unexpected value for `float` {:?} vs. {:?}",
|
9956 - | expected.float,
|
9957 - | input.float
|
9958 - | );
|
9959 - | ::pretty_assertions::assert_eq!(
|
9960 - | input.httpdate_timestamp,
|
9961 - | expected.httpdate_timestamp,
|
9962 - | "Unexpected value for `httpdate_timestamp`"
|
9963 - | );
|
9964 - | ::pretty_assertions::assert_eq!(
|
9965 - | input.integer,
|
9966 - | expected.integer,
|
9967 - | "Unexpected value for `integer`"
|
9968 - | );
|
9969 - | ::pretty_assertions::assert_eq!(
|
9970 - | input.iso8601_timestamp,
|
9971 - | expected.iso8601_timestamp,
|
9972 - | "Unexpected value for `iso8601_timestamp`"
|
9973 - | );
|
9974 - | ::pretty_assertions::assert_eq!(
|
9975 - | input.json_value,
|
9976 - | expected.json_value,
|
9977 - | "Unexpected value for `json_value`"
|
9978 - | );
|
9979 - | ::pretty_assertions::assert_eq!(
|
9980 - | input.list_of_lists,
|
9981 - | expected.list_of_lists,
|
9982 - | "Unexpected value for `list_of_lists`"
|
9983 - | );
|
9984 - | ::pretty_assertions::assert_eq!(
|
9985 - | input.list_of_maps_of_strings,
|
9986 - | expected.list_of_maps_of_strings,
|
9987 - | "Unexpected value for `list_of_maps_of_strings`"
|
9988 - | );
|
9989 - | ::pretty_assertions::assert_eq!(
|
9990 - | input.list_of_strings,
|
9991 - | expected.list_of_strings,
|
9992 - | "Unexpected value for `list_of_strings`"
|
9993 - | );
|
9994 - | ::pretty_assertions::assert_eq!(
|
9995 - | input.list_of_structs,
|
9996 - | expected.list_of_structs,
|
9997 - | "Unexpected value for `list_of_structs`"
|
9998 - | );
|
9999 - | ::pretty_assertions::assert_eq!(
|
10000 - | input.long,
|
10001 - | expected.long,
|
10002 - | "Unexpected value for `long`"
|
10003 - | );
|
10004 - | ::pretty_assertions::assert_eq!(
|
10005 - | input.map_of_lists_of_strings,
|
10006 - | expected.map_of_lists_of_strings,
|
10007 - | "Unexpected value for `map_of_lists_of_strings`"
|
10008 - | );
|
10009 - | ::pretty_assertions::assert_eq!(
|
10010 - | input.map_of_maps,
|
10011 - | expected.map_of_maps,
|
10012 - | "Unexpected value for `map_of_maps`"
|
10013 - | );
|
10014 - | ::pretty_assertions::assert_eq!(
|
10015 - | input.map_of_strings,
|
10016 - | expected.map_of_strings,
|
10017 - | "Unexpected value for `map_of_strings`"
|
10018 - | );
|
10019 - | ::pretty_assertions::assert_eq!(
|
10020 - | input.map_of_structs,
|
10021 - | expected.map_of_structs,
|
10022 - | "Unexpected value for `map_of_structs`"
|
10023 - | );
|
10024 - | ::pretty_assertions::assert_eq!(
|
10025 - | input.recursive_list,
|
10026 - | expected.recursive_list,
|
10027 - | "Unexpected value for `recursive_list`"
|
10028 - | );
|
10029 - | ::pretty_assertions::assert_eq!(
|
10030 - | input.recursive_map,
|
10031 - | expected.recursive_map,
|
10032 - | "Unexpected value for `recursive_map`"
|
10033 - | );
|
10034 - | ::pretty_assertions::assert_eq!(
|
10035 - | input.recursive_struct,
|
10036 - | expected.recursive_struct,
|
10037 - | "Unexpected value for `recursive_struct`"
|
10038 - | );
|
10039 - | ::pretty_assertions::assert_eq!(
|
10040 - | input.simple_struct,
|
10041 - | expected.simple_struct,
|
10042 - | "Unexpected value for `simple_struct`"
|
9530 + | receiver.recv().await.is_some(),
|
9531 + | "we expected operation handler to be invoked but it was not entered"
|
10043 9532 | );
|
9533 + | }
|
9534 + |
|
9535 + | /// Serializes inline documents in a JSON response.
|
9536 + | /// Test ID: PutAndGetInlineDocumentsInput
|
9537 + | #[::tokio::test]
|
9538 + | #[::tracing_test::traced_test]
|
9539 + | async fn put_and_get_inline_documents_input_response() {
|
9540 + | let output = crate::output::PutAndGetInlineDocumentsOutput {
|
9541 + | inline_document: ::std::option::Option::Some({
|
9542 + | let json_bytes = br#"{
|
9543 + | "foo": "bar"
|
9544 + | }"#;
|
9545 + | let mut tokens =
|
9546 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
9547 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
9548 + | .expect("well formed json")
|
9549 + | }),
|
9550 + | };
|
9551 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
9552 + | let http_response = output.into_response();
|
10044 9553 | ::pretty_assertions::assert_eq!(
|
10045 - | input.string,
|
10046 - | expected.string,
|
10047 - | "Unexpected value for `string`"
|
9554 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
9555 + | http_response.status()
|
10048 9556 | );
|
10049 - | ::pretty_assertions::assert_eq!(
|
10050 - | input.struct_with_json_name,
|
10051 - | expected.struct_with_json_name,
|
10052 - | "Unexpected value for `struct_with_json_name`"
|
9557 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
9558 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
9559 + | http_response.headers(),
|
9560 + | expected_headers,
|
9561 + | ));
|
9562 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9563 + | .await
|
9564 + | .expect("unable to extract body to bytes");
|
9565 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
9566 + | &body,
|
9567 + | "{\n \"inlineDocument\": {\"foo\": \"bar\"}\n}",
|
9568 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
9569 + | ));
|
9570 + | }
|
9571 + | }
|
9572 + |
|
9573 + | ::pin_project_lite::pin_project! {
|
9574 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
9575 + | /// [`JsonEnumsInput`](crate::input::JsonEnumsInput) using modelled bindings.
|
9576 + | pub struct JsonEnumsInputFuture {
|
9577 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::JsonEnumsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
9578 + | }
|
9579 + | }
|
9580 + |
|
9581 + | impl std::future::Future for JsonEnumsInputFuture {
|
9582 + | type Output = Result<
|
9583 + | crate::input::JsonEnumsInput,
|
9584 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
9585 + | >;
|
9586 + |
|
9587 + | fn poll(
|
9588 + | self: std::pin::Pin<&mut Self>,
|
9589 + | cx: &mut std::task::Context<'_>,
|
9590 + | ) -> std::task::Poll<Self::Output> {
|
9591 + | let this = self.project();
|
9592 + | this.inner.as_mut().poll(cx)
|
9593 + | }
|
9594 + | }
|
9595 + |
|
9596 + | impl<B>
|
9597 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
9598 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9599 + | B,
|
9600 + | > for crate::input::JsonEnumsInput
|
9601 + | where
|
9602 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
9603 + | B: 'static,
|
9604 + |
|
9605 + | B::Data: Send,
|
9606 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
9607 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
9608 + | {
|
9609 + | type Rejection =
|
9610 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
9611 + | type Future = JsonEnumsInputFuture;
|
9612 + |
|
9613 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
9614 + | let fut = async move {
|
9615 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
9616 + | request.headers(),
|
9617 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
9618 + | ) {
|
9619 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
9620 + | }
|
9621 + | crate::protocol_serde::shape_json_enums::de_json_enums_http_request(request).await
|
9622 + | };
|
9623 + | use ::futures_util::future::TryFutureExt;
|
9624 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
9625 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
9626 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
9627 + | });
|
9628 + | JsonEnumsInputFuture {
|
9629 + | inner: Box::pin(fut),
|
9630 + | }
|
9631 + | }
|
9632 + | }
|
9633 + | impl
|
9634 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
9635 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9636 + | > for crate::output::JsonEnumsOutput
|
9637 + | {
|
9638 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
9639 + | match crate::protocol_serde::shape_json_enums::ser_json_enums_http_response(self) {
|
9640 + | Ok(response) => response,
|
9641 + | Err(e) => {
|
9642 + | ::tracing::error!(error = %e, "failed to serialize response");
|
9643 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
9644 + | }
|
9645 + | }
|
9646 + | }
|
9647 + | }
|
9648 + | impl
|
9649 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
9650 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9651 + | > for crate::error::JsonEnumsError
|
9652 + | {
|
9653 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
9654 + | match crate::protocol_serde::shape_json_enums::ser_json_enums_http_error(&self) {
|
9655 + | Ok(mut response) => {
|
9656 + | response.extensions_mut().insert(
|
9657 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
9658 + | self.name(),
|
9659 + | ),
|
10053 9660 | );
|
10054 - | ::pretty_assertions::assert_eq!(
|
10055 - | input.timestamp,
|
10056 - | expected.timestamp,
|
10057 - | "Unexpected value for `timestamp`"
|
9661 + | response
|
9662 + | }
|
9663 + | Err(e) => {
|
9664 + | ::tracing::error!(error = %e, "failed to serialize response");
|
9665 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
9666 + | }
|
9667 + | }
|
9668 + | }
|
9669 + | }
|
9670 + |
|
9671 + | #[allow(unreachable_code, unused_variables)]
|
9672 + | #[cfg(test)]
|
9673 + | mod json_enums_test {
|
9674 + |
|
9675 + | /// Serializes simple scalar properties
|
9676 + | /// Test ID: AwsJson11Enums
|
9677 + | #[::tokio::test]
|
9678 + | #[::tracing_test::traced_test]
|
9679 + | async fn aws_json11_enums_request() {
|
9680 + | #[allow(unused_mut)]
|
9681 + | let mut http_request = ::http::Request::builder()
|
9682 + | .uri("/")
|
9683 + | .method("POST")
|
9684 + | .header("Content-Type", "application/x-amz-json-1.1")
|
9685 + | .header("X-Amz-Target", "JsonProtocol.JsonEnums")
|
9686 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
9687 + | ::bytes::Bytes::copy_from_slice(
|
9688 + | &::aws_smithy_protocol_test::decode_body_data("{\n \"fooEnum1\": \"Foo\",\n \"fooEnum2\": \"0\",\n \"fooEnum3\": \"1\",\n \"fooEnumList\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumSet\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumMap\": {\n \"hi\": \"Foo\",\n \"zero\": \"0\"\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9689 + | )
|
9690 + | )).unwrap();
|
9691 + | #[allow(unused_mut)]
|
9692 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
9693 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
9694 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
9695 + | .json_enums(move |input: crate::input::JsonEnumsInput| {
|
9696 + | let sender = sender.clone();
|
9697 + | async move {
|
9698 + | let result = {
|
9699 + | let expected = crate::input::JsonEnumsInput {
|
9700 + | foo_enum1: ::std::option::Option::Some(
|
9701 + | "Foo"
|
9702 + | .parse::<crate::model::FooEnum>()
|
9703 + | .expect("static value validated to member"),
|
9704 + | ),
|
9705 + | foo_enum2: ::std::option::Option::Some(
|
9706 + | "0".parse::<crate::model::FooEnum>()
|
9707 + | .expect("static value validated to member"),
|
9708 + | ),
|
9709 + | foo_enum3: ::std::option::Option::Some(
|
9710 + | "1".parse::<crate::model::FooEnum>()
|
9711 + | .expect("static value validated to member"),
|
9712 + | ),
|
9713 + | foo_enum_list: ::std::option::Option::Some(vec![
|
9714 + | "Foo"
|
9715 + | .parse::<crate::model::FooEnum>()
|
9716 + | .expect("static value validated to member"),
|
9717 + | "0".parse::<crate::model::FooEnum>()
|
9718 + | .expect("static value validated to member"),
|
9719 + | ]),
|
9720 + | foo_enum_set: ::std::option::Option::Some(
|
9721 + | vec![
|
9722 + | "Foo"
|
9723 + | .parse::<crate::model::FooEnum>()
|
9724 + | .expect("static value validated to member"),
|
9725 + | "0".parse::<crate::model::FooEnum>()
|
9726 + | .expect("static value validated to member"),
|
9727 + | ]
|
9728 + | .try_into()
|
9729 + | .expect("this is only used in tests"),
|
9730 + | ),
|
9731 + | foo_enum_map: ::std::option::Option::Some({
|
9732 + | let mut ret = ::std::collections::HashMap::new();
|
9733 + | ret.insert(
|
9734 + | "hi".to_owned(),
|
9735 + | "Foo"
|
9736 + | .parse::<crate::model::FooEnum>()
|
9737 + | .expect("static value validated to member"),
|
10058 9738 | );
|
10059 - | ::pretty_assertions::assert_eq!(
|
10060 - | input.unix_timestamp,
|
10061 - | expected.unix_timestamp,
|
10062 - | "Unexpected value for `unix_timestamp`"
|
9739 + | ret.insert(
|
9740 + | "zero".to_owned(),
|
9741 + | "0".parse::<crate::model::FooEnum>()
|
9742 + | .expect("static value validated to member"),
|
10063 9743 | );
|
10064 - | let output = crate::output::KitchenSinkOperationOutput {
|
10065 - | blob: ::std::option::Option::None,
|
10066 - | boolean: ::std::option::Option::None,
|
10067 - | double: ::std::option::Option::None,
|
10068 - | empty_struct: ::std::option::Option::None,
|
10069 - | float: ::std::option::Option::None,
|
10070 - | httpdate_timestamp: ::std::option::Option::None,
|
10071 - | integer: ::std::option::Option::None,
|
10072 - | iso8601_timestamp: ::std::option::Option::None,
|
10073 - | json_value: ::std::option::Option::None,
|
10074 - | list_of_lists: ::std::option::Option::None,
|
10075 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10076 - | list_of_strings: ::std::option::Option::None,
|
10077 - | list_of_structs: ::std::option::Option::None,
|
10078 - | long: ::std::option::Option::None,
|
10079 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10080 - | map_of_maps: ::std::option::Option::None,
|
10081 - | map_of_strings: ::std::option::Option::None,
|
10082 - | map_of_structs: ::std::option::Option::None,
|
10083 - | recursive_list: ::std::option::Option::None,
|
10084 - | recursive_map: ::std::option::Option::None,
|
10085 - | recursive_struct: ::std::option::Option::None,
|
10086 - | simple_struct: ::std::option::Option::None,
|
10087 - | string: ::std::option::Option::None,
|
10088 - | struct_with_json_name: ::std::option::Option::None,
|
10089 - | timestamp: ::std::option::Option::None,
|
10090 - | unix_timestamp: ::std::option::Option::None,
|
9744 + | ret
|
9745 + | }),
|
9746 + | };
|
9747 + | ::pretty_assertions::assert_eq!(input, expected);
|
9748 + | let output = crate::output::JsonEnumsOutput {
|
9749 + | foo_enum1: ::std::option::Option::None,
|
9750 + | foo_enum2: ::std::option::Option::None,
|
9751 + | foo_enum3: ::std::option::Option::None,
|
9752 + | foo_enum_list: ::std::option::Option::None,
|
9753 + | foo_enum_set: ::std::option::Option::None,
|
9754 + | foo_enum_map: ::std::option::Option::None,
|
10091 9755 | };
|
10092 9756 | Ok(output)
|
10093 9757 | };
|
10094 9758 | sender.send(()).await.expect("receiver dropped early");
|
10095 9759 | result
|
10096 9760 | }
|
10097 - | })
|
10098 - | .build_unchecked();
|
10099 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9761 + | })
|
9762 + | .build_unchecked();
|
9763 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
9764 + | .await
|
9765 + | .expect("unable to make an HTTP request");
|
9766 + | assert!(
|
9767 + | receiver.recv().await.is_some(),
|
9768 + | "we expected operation handler to be invoked but it was not entered"
|
9769 + | );
|
9770 + | }
|
9771 + |
|
9772 + | /// Serializes simple scalar properties
|
9773 + | /// Test ID: AwsJson11Enums
|
9774 + | #[::tokio::test]
|
9775 + | #[::tracing_test::traced_test]
|
9776 + | async fn aws_json11_enums_response() {
|
9777 + | let output = crate::output::JsonEnumsOutput {
|
9778 + | foo_enum1: ::std::option::Option::Some(
|
9779 + | "Foo"
|
9780 + | .parse::<crate::model::FooEnum>()
|
9781 + | .expect("static value validated to member"),
|
9782 + | ),
|
9783 + | foo_enum2: ::std::option::Option::Some(
|
9784 + | "0".parse::<crate::model::FooEnum>()
|
9785 + | .expect("static value validated to member"),
|
9786 + | ),
|
9787 + | foo_enum3: ::std::option::Option::Some(
|
9788 + | "1".parse::<crate::model::FooEnum>()
|
9789 + | .expect("static value validated to member"),
|
9790 + | ),
|
9791 + | foo_enum_list: ::std::option::Option::Some(vec![
|
9792 + | "Foo"
|
9793 + | .parse::<crate::model::FooEnum>()
|
9794 + | .expect("static value validated to member"),
|
9795 + | "0".parse::<crate::model::FooEnum>()
|
9796 + | .expect("static value validated to member"),
|
9797 + | ]),
|
9798 + | foo_enum_set: ::std::option::Option::Some(
|
9799 + | vec![
|
9800 + | "Foo"
|
9801 + | .parse::<crate::model::FooEnum>()
|
9802 + | .expect("static value validated to member"),
|
9803 + | "0".parse::<crate::model::FooEnum>()
|
9804 + | .expect("static value validated to member"),
|
9805 + | ]
|
9806 + | .try_into()
|
9807 + | .expect("this is only used in tests"),
|
9808 + | ),
|
9809 + | foo_enum_map: ::std::option::Option::Some({
|
9810 + | let mut ret = ::std::collections::HashMap::new();
|
9811 + | ret.insert(
|
9812 + | "hi".to_owned(),
|
9813 + | "Foo"
|
9814 + | .parse::<crate::model::FooEnum>()
|
9815 + | .expect("static value validated to member"),
|
9816 + | );
|
9817 + | ret.insert(
|
9818 + | "zero".to_owned(),
|
9819 + | "0".parse::<crate::model::FooEnum>()
|
9820 + | .expect("static value validated to member"),
|
9821 + | );
|
9822 + | ret
|
9823 + | }),
|
9824 + | };
|
9825 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
9826 + | let http_response = output.into_response();
|
9827 + | ::pretty_assertions::assert_eq!(
|
9828 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
9829 + | http_response.status()
|
9830 + | );
|
9831 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
9832 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
9833 + | http_response.headers(),
|
9834 + | expected_headers,
|
9835 + | ));
|
9836 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9837 + | .await
|
9838 + | .expect("unable to extract body to bytes");
|
9839 + | ::aws_smithy_protocol_test::assert_ok(
|
9840 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"fooEnum1\": \"Foo\",\n \"fooEnum2\": \"0\",\n \"fooEnum3\": \"1\",\n \"fooEnumList\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumSet\": [\n \"Foo\",\n \"0\"\n ],\n \"fooEnumMap\": {\n \"hi\": \"Foo\",\n \"zero\": \"0\"\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9841 + | );
|
9842 + | }
|
9843 + | }
|
9844 + |
|
9845 + | ::pin_project_lite::pin_project! {
|
9846 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
9847 + | /// [`JsonIntEnumsInput`](crate::input::JsonIntEnumsInput) using modelled bindings.
|
9848 + | pub struct JsonIntEnumsInputFuture {
|
9849 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::JsonIntEnumsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
9850 + | }
|
9851 + | }
|
9852 + |
|
9853 + | impl std::future::Future for JsonIntEnumsInputFuture {
|
9854 + | type Output = Result<
|
9855 + | crate::input::JsonIntEnumsInput,
|
9856 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
9857 + | >;
|
9858 + |
|
9859 + | fn poll(
|
9860 + | self: std::pin::Pin<&mut Self>,
|
9861 + | cx: &mut std::task::Context<'_>,
|
9862 + | ) -> std::task::Poll<Self::Output> {
|
9863 + | let this = self.project();
|
9864 + | this.inner.as_mut().poll(cx)
|
9865 + | }
|
9866 + | }
|
9867 + |
|
9868 + | impl<B>
|
9869 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
9870 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9871 + | B,
|
9872 + | > for crate::input::JsonIntEnumsInput
|
9873 + | where
|
9874 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
9875 + | B: 'static,
|
9876 + |
|
9877 + | B::Data: Send,
|
9878 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
9879 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
9880 + | {
|
9881 + | type Rejection =
|
9882 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
9883 + | type Future = JsonIntEnumsInputFuture;
|
9884 + |
|
9885 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
9886 + | let fut = async move {
|
9887 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
9888 + | request.headers(),
|
9889 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
9890 + | ) {
|
9891 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
9892 + | }
|
9893 + | crate::protocol_serde::shape_json_int_enums::de_json_int_enums_http_request(request)
|
10100 9894 | .await
|
10101 - | .expect("unable to make an HTTP request");
|
10102 - | assert!(
|
10103 - | receiver.recv().await.is_some(),
|
10104 - | "we expected operation handler to be invoked but it was not entered"
|
9895 + | };
|
9896 + | use ::futures_util::future::TryFutureExt;
|
9897 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
9898 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
9899 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
9900 + | });
|
9901 + | JsonIntEnumsInputFuture {
|
9902 + | inner: Box::pin(fut),
|
9903 + | }
|
9904 + | }
|
9905 + | }
|
9906 + | impl
|
9907 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
9908 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9909 + | > for crate::output::JsonIntEnumsOutput
|
9910 + | {
|
9911 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
9912 + | match crate::protocol_serde::shape_json_int_enums::ser_json_int_enums_http_response(self) {
|
9913 + | Ok(response) => response,
|
9914 + | Err(e) => {
|
9915 + | ::tracing::error!(error = %e, "failed to serialize response");
|
9916 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
9917 + | }
|
9918 + | }
|
9919 + | }
|
9920 + | }
|
9921 + | impl
|
9922 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
9923 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
9924 + | > for crate::error::JsonIntEnumsError
|
9925 + | {
|
9926 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
9927 + | match crate::protocol_serde::shape_json_int_enums::ser_json_int_enums_http_error(&self) {
|
9928 + | Ok(mut response) => {
|
9929 + | response.extensions_mut().insert(
|
9930 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
9931 + | self.name(),
|
9932 + | ),
|
10105 9933 | );
|
9934 + | response
|
9935 + | }
|
9936 + | Err(e) => {
|
9937 + | ::tracing::error!(error = %e, "failed to serialize response");
|
9938 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
9939 + | }
|
10106 9940 | }
|
9941 + | }
|
9942 + | }
|
10107 9943 |
|
10108 - | /// Serializes recursive structure shapes
|
10109 - | /// Test ID: serializes_recursive_structure_shapes
|
9944 + | #[allow(unreachable_code, unused_variables)]
|
9945 + | #[cfg(test)]
|
9946 + | mod json_int_enums_test {
|
9947 + |
|
9948 + | /// Serializes simple scalar properties
|
9949 + | /// Test ID: AwsJson11IntEnums
|
10110 9950 | #[::tokio::test]
|
10111 9951 | #[::tracing_test::traced_test]
|
10112 - | async fn serializes_recursive_structure_shapes_request() {
|
9952 + | async fn aws_json11_int_enums_request() {
|
10113 9953 | #[allow(unused_mut)]
|
10114 9954 | let mut http_request = ::http::Request::builder()
|
10115 9955 | .uri("/")
|
10116 9956 | .method("POST")
|
10117 9957 | .header("Content-Type", "application/x-amz-json-1.1")
|
10118 - | .header("X-Amz-Target", "JsonProtocol.KitchenSinkOperation")
|
9958 + | .header("X-Amz-Target", "JsonProtocol.JsonIntEnums")
|
10119 9959 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10120 9960 | ::bytes::Bytes::copy_from_slice(
|
10121 - | &::aws_smithy_protocol_test::decode_body_data("{\"String\":\"top-value\",\"Boolean\":false,\"RecursiveStruct\":{\"String\":\"nested-value\",\"Boolean\":true,\"RecursiveList\":[{\"String\":\"string-only\"},{\"RecursiveStruct\":{\"MapOfStrings\":{\"color\":\"red\",\"size\":\"large\"}}}]}}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
9961 + | &::aws_smithy_protocol_test::decode_body_data("{\n \"intEnum1\": 1,\n \"intEnum2\": 2,\n \"intEnum3\": 3,\n \"intEnumList\": [\n 1,\n 2\n ],\n \"intEnumSet\": [\n 1,\n 2\n ],\n \"intEnumMap\": {\n \"a\": 1,\n \"b\": 2\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
10122 9962 | )
|
10123 9963 | )).unwrap();
|
10124 9964 | #[allow(unused_mut)]
|
10125 9965 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10126 9966 | let config = crate::service::JsonProtocolConfig::builder().build();
|
10127 9967 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10128 - | .kitchen_sink_operation(move |input: crate::input::KitchenSinkOperationInput| {
|
9968 + | .json_int_enums(move |input: crate::input::JsonIntEnumsInput| {
|
10129 9969 | let sender = sender.clone();
|
10130 9970 | async move {
|
10131 9971 | let result = {
|
10132 - | use ::aws_smithy_protocol_test::FloatEquals;
|
10133 - | let expected = crate::input::KitchenSinkOperationInput {
|
10134 - | string: ::std::option::Option::Some("top-value".to_owned()),
|
10135 - | boolean: ::std::option::Option::Some(false),
|
10136 - | recursive_struct: ::std::option::Option::Some(::std::boxed::Box::new(
|
10137 - | crate::model::KitchenSink {
|
10138 - | string: ::std::option::Option::Some("nested-value".to_owned()),
|
10139 - | boolean: ::std::option::Option::Some(true),
|
10140 - | recursive_list: ::std::option::Option::Some(vec![
|
10141 - | crate::model::KitchenSink {
|
10142 - | string: ::std::option::Option::Some(
|
10143 - | "string-only".to_owned(),
|
10144 - | ),
|
10145 - | blob: ::std::option::Option::None,
|
10146 - | boolean: ::std::option::Option::None,
|
10147 - | double: ::std::option::Option::None,
|
10148 - | empty_struct: ::std::option::Option::None,
|
10149 - | float: ::std::option::Option::None,
|
10150 - | httpdate_timestamp: ::std::option::Option::None,
|
10151 - | integer: ::std::option::Option::None,
|
10152 - | iso8601_timestamp: ::std::option::Option::None,
|
10153 - | json_value: ::std::option::Option::None,
|
10154 - | list_of_lists: ::std::option::Option::None,
|
10155 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10156 - | list_of_strings: ::std::option::Option::None,
|
10157 - | list_of_structs: ::std::option::Option::None,
|
10158 - | long: ::std::option::Option::None,
|
10159 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10160 - | map_of_maps: ::std::option::Option::None,
|
10161 - | map_of_strings: ::std::option::Option::None,
|
10162 - | map_of_structs: ::std::option::Option::None,
|
10163 - | recursive_list: ::std::option::Option::None,
|
10164 - | recursive_map: ::std::option::Option::None,
|
10165 - | recursive_struct: ::std::option::Option::None,
|
10166 - | simple_struct: ::std::option::Option::None,
|
10167 - | struct_with_json_name: ::std::option::Option::None,
|
10168 - | timestamp: ::std::option::Option::None,
|
10169 - | unix_timestamp: ::std::option::Option::None,
|
10170 - | },
|
10171 - | crate::model::KitchenSink {
|
10172 - | recursive_struct: ::std::option::Option::Some(
|
10173 - | ::std::boxed::Box::new(crate::model::KitchenSink {
|
10174 - | map_of_strings: ::std::option::Option::Some({
|
10175 - | let mut ret =
|
10176 - | ::std::collections::HashMap::new();
|
10177 - | ret.insert(
|
10178 - | "color".to_owned(),
|
10179 - | "red".to_owned(),
|
10180 - | );
|
10181 - | ret.insert(
|
10182 - | "size".to_owned(),
|
10183 - | "large".to_owned(),
|
10184 - | );
|
10185 - | ret
|
10186 - | }),
|
10187 - | blob: ::std::option::Option::None,
|
10188 - | boolean: ::std::option::Option::None,
|
10189 - | double: ::std::option::Option::None,
|
10190 - | empty_struct: ::std::option::Option::None,
|
10191 - | float: ::std::option::Option::None,
|
10192 - | httpdate_timestamp: ::std::option::Option::None,
|
10193 - | integer: ::std::option::Option::None,
|
10194 - | iso8601_timestamp: ::std::option::Option::None,
|
10195 - | json_value: ::std::option::Option::None,
|
10196 - | list_of_lists: ::std::option::Option::None,
|
10197 - | list_of_maps_of_strings:
|
10198 - | ::std::option::Option::None,
|
10199 - | list_of_strings: ::std::option::Option::None,
|
10200 - | list_of_structs: ::std::option::Option::None,
|
10201 - | long: ::std::option::Option::None,
|
10202 - | map_of_lists_of_strings:
|
10203 - | ::std::option::Option::None,
|
10204 - | map_of_maps: ::std::option::Option::None,
|
10205 - | map_of_structs: ::std::option::Option::None,
|
10206 - | recursive_list: ::std::option::Option::None,
|
10207 - | recursive_map: ::std::option::Option::None,
|
10208 - | recursive_struct: ::std::option::Option::None,
|
10209 - | simple_struct: ::std::option::Option::None,
|
10210 - | string: ::std::option::Option::None,
|
10211 - | struct_with_json_name:
|
10212 - | ::std::option::Option::None,
|
10213 - | timestamp: ::std::option::Option::None,
|
10214 - | unix_timestamp: ::std::option::Option::None,
|
10215 - | }),
|
9972 + | let expected = crate::input::JsonIntEnumsInput {
|
9973 + | int_enum1: ::std::option::Option::Some(1),
|
9974 + | int_enum2: ::std::option::Option::Some(2),
|
9975 + | int_enum3: ::std::option::Option::Some(3),
|
9976 + | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
9977 + | int_enum_set: ::std::option::Option::Some(
|
9978 + | vec![1, 2].try_into().expect("this is only used in tests"),
|
10216 9979 | ),
|
10217 - | blob: ::std::option::Option::None,
|
10218 - | boolean: ::std::option::Option::None,
|
10219 - | double: ::std::option::Option::None,
|
10220 - | empty_struct: ::std::option::Option::None,
|
10221 - | float: ::std::option::Option::None,
|
10222 - | httpdate_timestamp: ::std::option::Option::None,
|
10223 - | integer: ::std::option::Option::None,
|
10224 - | iso8601_timestamp: ::std::option::Option::None,
|
10225 - | json_value: ::std::option::Option::None,
|
10226 - | list_of_lists: ::std::option::Option::None,
|
10227 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10228 - | list_of_strings: ::std::option::Option::None,
|
10229 - | list_of_structs: ::std::option::Option::None,
|
10230 - | long: ::std::option::Option::None,
|
10231 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10232 - | map_of_maps: ::std::option::Option::None,
|
10233 - | map_of_strings: ::std::option::Option::None,
|
10234 - | map_of_structs: ::std::option::Option::None,
|
10235 - | recursive_list: ::std::option::Option::None,
|
10236 - | recursive_map: ::std::option::Option::None,
|
10237 - | simple_struct: ::std::option::Option::None,
|
10238 - | string: ::std::option::Option::None,
|
10239 - | struct_with_json_name: ::std::option::Option::None,
|
10240 - | timestamp: ::std::option::Option::None,
|
10241 - | unix_timestamp: ::std::option::Option::None,
|
10242 - | },
|
10243 - | ]),
|
10244 - | blob: ::std::option::Option::None,
|
10245 - | double: ::std::option::Option::None,
|
10246 - | empty_struct: ::std::option::Option::None,
|
10247 - | float: ::std::option::Option::None,
|
10248 - | httpdate_timestamp: ::std::option::Option::None,
|
10249 - | integer: ::std::option::Option::None,
|
10250 - | iso8601_timestamp: ::std::option::Option::None,
|
10251 - | json_value: ::std::option::Option::None,
|
10252 - | list_of_lists: ::std::option::Option::None,
|
10253 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10254 - | list_of_strings: ::std::option::Option::None,
|
10255 - | list_of_structs: ::std::option::Option::None,
|
10256 - | long: ::std::option::Option::None,
|
10257 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10258 - | map_of_maps: ::std::option::Option::None,
|
10259 - | map_of_strings: ::std::option::Option::None,
|
10260 - | map_of_structs: ::std::option::Option::None,
|
10261 - | recursive_map: ::std::option::Option::None,
|
10262 - | recursive_struct: ::std::option::Option::None,
|
10263 - | simple_struct: ::std::option::Option::None,
|
10264 - | struct_with_json_name: ::std::option::Option::None,
|
10265 - | timestamp: ::std::option::Option::None,
|
10266 - | unix_timestamp: ::std::option::Option::None,
|
10267 - | },
|
10268 - | )),
|
10269 - | blob: ::std::option::Option::None,
|
10270 - | double: ::std::option::Option::None,
|
10271 - | empty_struct: ::std::option::Option::None,
|
10272 - | float: ::std::option::Option::None,
|
10273 - | httpdate_timestamp: ::std::option::Option::None,
|
10274 - | integer: ::std::option::Option::None,
|
10275 - | iso8601_timestamp: ::std::option::Option::None,
|
10276 - | json_value: ::std::option::Option::None,
|
10277 - | list_of_lists: ::std::option::Option::None,
|
10278 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10279 - | list_of_strings: ::std::option::Option::None,
|
10280 - | list_of_structs: ::std::option::Option::None,
|
10281 - | long: ::std::option::Option::None,
|
10282 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10283 - | map_of_maps: ::std::option::Option::None,
|
10284 - | map_of_strings: ::std::option::Option::None,
|
10285 - | map_of_structs: ::std::option::Option::None,
|
10286 - | recursive_list: ::std::option::Option::None,
|
10287 - | recursive_map: ::std::option::Option::None,
|
10288 - | simple_struct: ::std::option::Option::None,
|
10289 - | struct_with_json_name: ::std::option::Option::None,
|
10290 - | timestamp: ::std::option::Option::None,
|
10291 - | unix_timestamp: ::std::option::Option::None,
|
9980 + | int_enum_map: ::std::option::Option::Some({
|
9981 + | let mut ret = ::std::collections::HashMap::new();
|
9982 + | ret.insert("a".to_owned(), 1);
|
9983 + | ret.insert("b".to_owned(), 2);
|
9984 + | ret
|
9985 + | }),
|
10292 9986 | };
|
10293 - | ::pretty_assertions::assert_eq!(
|
10294 - | input.blob,
|
10295 - | expected.blob,
|
10296 - | "Unexpected value for `blob`"
|
10297 - | );
|
10298 - | ::pretty_assertions::assert_eq!(
|
10299 - | input.boolean,
|
10300 - | expected.boolean,
|
10301 - | "Unexpected value for `boolean`"
|
10302 - | );
|
10303 - | assert!(
|
10304 - | input.double.float_equals(&expected.double),
|
10305 - | "Unexpected value for `double` {:?} vs. {:?}",
|
10306 - | expected.double,
|
10307 - | input.double
|
10308 - | );
|
10309 - | ::pretty_assertions::assert_eq!(
|
10310 - | input.empty_struct,
|
10311 - | expected.empty_struct,
|
10312 - | "Unexpected value for `empty_struct`"
|
10313 - | );
|
9987 + | ::pretty_assertions::assert_eq!(input, expected);
|
9988 + | let output = crate::output::JsonIntEnumsOutput {
|
9989 + | int_enum1: ::std::option::Option::None,
|
9990 + | int_enum2: ::std::option::Option::None,
|
9991 + | int_enum3: ::std::option::Option::None,
|
9992 + | int_enum_list: ::std::option::Option::None,
|
9993 + | int_enum_set: ::std::option::Option::None,
|
9994 + | int_enum_map: ::std::option::Option::None,
|
9995 + | };
|
9996 + | Ok(output)
|
9997 + | };
|
9998 + | sender.send(()).await.expect("receiver dropped early");
|
9999 + | result
|
10000 + | }
|
10001 + | })
|
10002 + | .build_unchecked();
|
10003 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10004 + | .await
|
10005 + | .expect("unable to make an HTTP request");
|
10314 10006 | assert!(
|
10315 - | input.float.float_equals(&expected.float),
|
10316 - | "Unexpected value for `float` {:?} vs. {:?}",
|
10317 - | expected.float,
|
10318 - | input.float
|
10319 - | );
|
10320 - | ::pretty_assertions::assert_eq!(
|
10321 - | input.httpdate_timestamp,
|
10322 - | expected.httpdate_timestamp,
|
10323 - | "Unexpected value for `httpdate_timestamp`"
|
10324 - | );
|
10325 - | ::pretty_assertions::assert_eq!(
|
10326 - | input.integer,
|
10327 - | expected.integer,
|
10328 - | "Unexpected value for `integer`"
|
10329 - | );
|
10330 - | ::pretty_assertions::assert_eq!(
|
10331 - | input.iso8601_timestamp,
|
10332 - | expected.iso8601_timestamp,
|
10333 - | "Unexpected value for `iso8601_timestamp`"
|
10334 - | );
|
10335 - | ::pretty_assertions::assert_eq!(
|
10336 - | input.json_value,
|
10337 - | expected.json_value,
|
10338 - | "Unexpected value for `json_value`"
|
10339 - | );
|
10340 - | ::pretty_assertions::assert_eq!(
|
10341 - | input.list_of_lists,
|
10342 - | expected.list_of_lists,
|
10343 - | "Unexpected value for `list_of_lists`"
|
10344 - | );
|
10345 - | ::pretty_assertions::assert_eq!(
|
10346 - | input.list_of_maps_of_strings,
|
10347 - | expected.list_of_maps_of_strings,
|
10348 - | "Unexpected value for `list_of_maps_of_strings`"
|
10349 - | );
|
10350 - | ::pretty_assertions::assert_eq!(
|
10351 - | input.list_of_strings,
|
10352 - | expected.list_of_strings,
|
10353 - | "Unexpected value for `list_of_strings`"
|
10354 - | );
|
10355 - | ::pretty_assertions::assert_eq!(
|
10356 - | input.list_of_structs,
|
10357 - | expected.list_of_structs,
|
10358 - | "Unexpected value for `list_of_structs`"
|
10359 - | );
|
10360 - | ::pretty_assertions::assert_eq!(
|
10361 - | input.long,
|
10362 - | expected.long,
|
10363 - | "Unexpected value for `long`"
|
10364 - | );
|
10365 - | ::pretty_assertions::assert_eq!(
|
10366 - | input.map_of_lists_of_strings,
|
10367 - | expected.map_of_lists_of_strings,
|
10368 - | "Unexpected value for `map_of_lists_of_strings`"
|
10369 - | );
|
10370 - | ::pretty_assertions::assert_eq!(
|
10371 - | input.map_of_maps,
|
10372 - | expected.map_of_maps,
|
10373 - | "Unexpected value for `map_of_maps`"
|
10374 - | );
|
10375 - | ::pretty_assertions::assert_eq!(
|
10376 - | input.map_of_strings,
|
10377 - | expected.map_of_strings,
|
10378 - | "Unexpected value for `map_of_strings`"
|
10379 - | );
|
10380 - | ::pretty_assertions::assert_eq!(
|
10381 - | input.map_of_structs,
|
10382 - | expected.map_of_structs,
|
10383 - | "Unexpected value for `map_of_structs`"
|
10384 - | );
|
10385 - | ::pretty_assertions::assert_eq!(
|
10386 - | input.recursive_list,
|
10387 - | expected.recursive_list,
|
10388 - | "Unexpected value for `recursive_list`"
|
10389 - | );
|
10390 - | ::pretty_assertions::assert_eq!(
|
10391 - | input.recursive_map,
|
10392 - | expected.recursive_map,
|
10393 - | "Unexpected value for `recursive_map`"
|
10394 - | );
|
10395 - | ::pretty_assertions::assert_eq!(
|
10396 - | input.recursive_struct,
|
10397 - | expected.recursive_struct,
|
10398 - | "Unexpected value for `recursive_struct`"
|
10007 + | receiver.recv().await.is_some(),
|
10008 + | "we expected operation handler to be invoked but it was not entered"
|
10399 10009 | );
|
10010 + | }
|
10011 + |
|
10012 + | /// Serializes simple scalar properties
|
10013 + | /// Test ID: AwsJson11IntEnums
|
10014 + | #[::tokio::test]
|
10015 + | #[::tracing_test::traced_test]
|
10016 + | #[should_panic]
|
10017 + | async fn aws_json11_int_enums_response() {
|
10018 + | let output = crate::output::JsonIntEnumsOutput {
|
10019 + | int_enum1: ::std::option::Option::Some(1),
|
10020 + | int_enum2: ::std::option::Option::Some(2),
|
10021 + | int_enum3: ::std::option::Option::Some(3),
|
10022 + | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
10023 + | int_enum_set: ::std::option::Option::Some(
|
10024 + | vec![1, 2].try_into().expect("this is only used in tests"),
|
10025 + | ),
|
10026 + | int_enum_map: ::std::option::Option::Some({
|
10027 + | let mut ret = ::std::collections::HashMap::new();
|
10028 + | ret.insert("a".to_owned(), 1);
|
10029 + | ret.insert("b".to_owned(), 2);
|
10030 + | ret
|
10031 + | }),
|
10032 + | };
|
10033 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10034 + | let http_response = output.into_response();
|
10400 10035 | ::pretty_assertions::assert_eq!(
|
10401 - | input.simple_struct,
|
10402 - | expected.simple_struct,
|
10403 - | "Unexpected value for `simple_struct`"
|
10036 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10037 + | http_response.status()
|
10404 10038 | );
|
10405 - | ::pretty_assertions::assert_eq!(
|
10406 - | input.string,
|
10407 - | expected.string,
|
10408 - | "Unexpected value for `string`"
|
10039 + | let expected_headers = [
|
10040 + | ("Content-Type", "application/x-amz-json-1.1"),
|
10041 + | ("X-Amz-Target", "JsonProtocol.JsonIntEnums"),
|
10042 + | ];
|
10043 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10044 + | http_response.headers(),
|
10045 + | expected_headers,
|
10046 + | ));
|
10047 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10048 + | .await
|
10049 + | .expect("unable to extract body to bytes");
|
10050 + | ::aws_smithy_protocol_test::assert_ok(
|
10051 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"intEnum1\": 1,\n \"intEnum2\": 2,\n \"intEnum3\": 3,\n \"intEnumList\": [\n 1,\n 2\n ],\n \"intEnumSet\": [\n 1,\n 2\n ],\n \"intEnumMap\": {\n \"a\": 1,\n \"b\": 2\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
10409 10052 | );
|
10410 - | ::pretty_assertions::assert_eq!(
|
10411 - | input.struct_with_json_name,
|
10412 - | expected.struct_with_json_name,
|
10413 - | "Unexpected value for `struct_with_json_name`"
|
10053 + | }
|
10054 + | }
|
10055 + |
|
10056 + | ::pin_project_lite::pin_project! {
|
10057 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
10058 + | /// [`NullOperationInput`](crate::input::NullOperationInput) using modelled bindings.
|
10059 + | pub struct NullOperationInputFuture {
|
10060 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NullOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
10061 + | }
|
10062 + | }
|
10063 + |
|
10064 + | impl std::future::Future for NullOperationInputFuture {
|
10065 + | type Output = Result<
|
10066 + | crate::input::NullOperationInput,
|
10067 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
10068 + | >;
|
10069 + |
|
10070 + | fn poll(
|
10071 + | self: std::pin::Pin<&mut Self>,
|
10072 + | cx: &mut std::task::Context<'_>,
|
10073 + | ) -> std::task::Poll<Self::Output> {
|
10074 + | let this = self.project();
|
10075 + | this.inner.as_mut().poll(cx)
|
10076 + | }
|
10077 + | }
|
10078 + |
|
10079 + | impl<B>
|
10080 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
10081 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10082 + | B,
|
10083 + | > for crate::input::NullOperationInput
|
10084 + | where
|
10085 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
10086 + | B: 'static,
|
10087 + |
|
10088 + | B::Data: Send,
|
10089 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
10090 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
10091 + | {
|
10092 + | type Rejection =
|
10093 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
10094 + | type Future = NullOperationInputFuture;
|
10095 + |
|
10096 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
10097 + | let fut = async move {
|
10098 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
10099 + | request.headers(),
|
10100 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
10101 + | ) {
|
10102 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
10103 + | }
|
10104 + | crate::protocol_serde::shape_null_operation::de_null_operation_http_request(request)
|
10105 + | .await
|
10106 + | };
|
10107 + | use ::futures_util::future::TryFutureExt;
|
10108 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
10109 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
10110 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
10111 + | });
|
10112 + | NullOperationInputFuture {
|
10113 + | inner: Box::pin(fut),
|
10114 + | }
|
10115 + | }
|
10116 + | }
|
10117 + | impl
|
10118 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
10119 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10120 + | > for crate::output::NullOperationOutput
|
10121 + | {
|
10122 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
10123 + | match crate::protocol_serde::shape_null_operation::ser_null_operation_http_response(self) {
|
10124 + | Ok(response) => response,
|
10125 + | Err(e) => {
|
10126 + | ::tracing::error!(error = %e, "failed to serialize response");
|
10127 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
10128 + | }
|
10129 + | }
|
10130 + | }
|
10131 + | }
|
10132 + |
|
10133 + | #[allow(unreachable_code, unused_variables)]
|
10134 + | #[cfg(test)]
|
10135 + | mod null_operation_test {
|
10136 + |
|
10137 + | /// Null structure values are dropped
|
10138 + | /// Test ID: AwsJson11ServersDontDeserializeNullStructureValues
|
10139 + | #[::tokio::test]
|
10140 + | #[::tracing_test::traced_test]
|
10141 + | async fn aws_json11_servers_dont_deserialize_null_structure_values_request() {
|
10142 + | #[allow(unused_mut)]
|
10143 + | let mut http_request = ::http::Request::builder()
|
10144 + | .uri("/")
|
10145 + | .method("POST")
|
10146 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10147 + | .header("X-Amz-Target", "JsonProtocol.NullOperation")
|
10148 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10149 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10150 + | "{\n \"string\": null\n}".as_bytes(),
|
10151 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10152 + | )),
|
10153 + | ))
|
10154 + | .unwrap();
|
10155 + | #[allow(unused_mut)]
|
10156 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10157 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10158 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10159 + | .null_operation(move |input: crate::input::NullOperationInput| {
|
10160 + | let sender = sender.clone();
|
10161 + | async move {
|
10162 + | let result = {
|
10163 + | let expected = crate::input::NullOperationInput {
|
10164 + | string: ::std::option::Option::None,
|
10165 + | };
|
10166 + | ::pretty_assertions::assert_eq!(input, expected);
|
10167 + | let output = crate::output::NullOperationOutput {
|
10168 + | string: ::std::option::Option::None,
|
10169 + | };
|
10170 + | output
|
10171 + | };
|
10172 + | sender.send(()).await.expect("receiver dropped early");
|
10173 + | result
|
10174 + | }
|
10175 + | })
|
10176 + | .build_unchecked();
|
10177 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10178 + | .await
|
10179 + | .expect("unable to make an HTTP request");
|
10180 + | assert!(
|
10181 + | receiver.recv().await.is_some(),
|
10182 + | "we expected operation handler to be invoked but it was not entered"
|
10414 10183 | );
|
10184 + | }
|
10185 + |
|
10186 + | /// Null structure values are dropped
|
10187 + | /// Test ID: AwsJson11ServersDontSerializeNullStructureValues
|
10188 + | #[::tokio::test]
|
10189 + | #[::tracing_test::traced_test]
|
10190 + | async fn aws_json11_servers_dont_serialize_null_structure_values_response() {
|
10191 + | let output = crate::output::NullOperationOutput {
|
10192 + | string: ::std::option::Option::None,
|
10193 + | };
|
10194 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10195 + | let http_response = output.into_response();
|
10415 10196 | ::pretty_assertions::assert_eq!(
|
10416 - | input.timestamp,
|
10417 - | expected.timestamp,
|
10418 - | "Unexpected value for `timestamp`"
|
10197 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10198 + | http_response.status()
|
10419 10199 | );
|
10420 - | ::pretty_assertions::assert_eq!(
|
10421 - | input.unix_timestamp,
|
10422 - | expected.unix_timestamp,
|
10423 - | "Unexpected value for `unix_timestamp`"
|
10200 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10201 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10202 + | http_response.headers(),
|
10203 + | expected_headers,
|
10204 + | ));
|
10205 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10206 + | .await
|
10207 + | .expect("unable to extract body to bytes");
|
10208 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10209 + | &body,
|
10210 + | "{}",
|
10211 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10212 + | ));
|
10213 + | }
|
10214 + | }
|
10215 + |
|
10216 + | ::pin_project_lite::pin_project! {
|
10217 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
10218 + | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
10219 + | pub struct SparseNullsOperationInputFuture {
|
10220 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
10221 + | }
|
10222 + | }
|
10223 + |
|
10224 + | impl std::future::Future for SparseNullsOperationInputFuture {
|
10225 + | type Output = Result<
|
10226 + | crate::input::SparseNullsOperationInput,
|
10227 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
10228 + | >;
|
10229 + |
|
10230 + | fn poll(
|
10231 + | self: std::pin::Pin<&mut Self>,
|
10232 + | cx: &mut std::task::Context<'_>,
|
10233 + | ) -> std::task::Poll<Self::Output> {
|
10234 + | let this = self.project();
|
10235 + | this.inner.as_mut().poll(cx)
|
10236 + | }
|
10237 + | }
|
10238 + |
|
10239 + | impl<B>
|
10240 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
10241 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10242 + | B,
|
10243 + | > for crate::input::SparseNullsOperationInput
|
10244 + | where
|
10245 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
10246 + | B: 'static,
|
10247 + |
|
10248 + | B::Data: Send,
|
10249 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
10250 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
10251 + | {
|
10252 + | type Rejection =
|
10253 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
10254 + | type Future = SparseNullsOperationInputFuture;
|
10255 + |
|
10256 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
10257 + | let fut = async move {
|
10258 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
10259 + | request.headers(),
|
10260 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
10261 + | ) {
|
10262 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
10263 + | }
|
10264 + | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
10265 + | .await
|
10266 + | };
|
10267 + | use ::futures_util::future::TryFutureExt;
|
10268 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
10269 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
10270 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
10271 + | });
|
10272 + | SparseNullsOperationInputFuture {
|
10273 + | inner: Box::pin(fut),
|
10274 + | }
|
10275 + | }
|
10276 + | }
|
10277 + | impl
|
10278 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
10279 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10280 + | > for crate::output::SparseNullsOperationOutput
|
10281 + | {
|
10282 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
10283 + | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
10284 + | Ok(response) => response,
|
10285 + | Err(e) => {
|
10286 + | ::tracing::error!(error = %e, "failed to serialize response");
|
10287 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
10288 + | }
|
10289 + | }
|
10290 + | }
|
10291 + | }
|
10292 + |
|
10293 + | #[allow(unreachable_code, unused_variables)]
|
10294 + | #[cfg(test)]
|
10295 + | mod sparse_nulls_operation_test {
|
10296 + |
|
10297 + | /// Serializes null values in maps
|
10298 + | /// Test ID: AwsJson11SparseMapsSerializeNullValues
|
10299 + | #[::tokio::test]
|
10300 + | #[::tracing_test::traced_test]
|
10301 + | async fn aws_json11_sparse_maps_serialize_null_values_request() {
|
10302 + | #[allow(unused_mut)]
|
10303 + | let mut http_request = ::http::Request::builder()
|
10304 + | .uri("/")
|
10305 + | .method("POST")
|
10306 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10307 + | .header("X-Amz-Target", "JsonProtocol.SparseNullsOperation")
|
10308 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10309 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10310 + | "{\n \"sparseStringMap\": {\n \"foo\": null\n }\n}".as_bytes(),
|
10311 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10312 + | )),
|
10313 + | ))
|
10314 + | .unwrap();
|
10315 + | #[allow(unused_mut)]
|
10316 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10317 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10318 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10319 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
10320 + | let sender = sender.clone();
|
10321 + | async move {
|
10322 + | let result = {
|
10323 + | let expected = crate::input::SparseNullsOperationInput {
|
10324 + | sparse_string_map: ::std::option::Option::Some({
|
10325 + | let mut ret = ::std::collections::HashMap::new();
|
10326 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
10327 + | ret
|
10328 + | }),
|
10329 + | sparse_string_list: ::std::option::Option::None,
|
10330 + | };
|
10331 + | ::pretty_assertions::assert_eq!(input, expected);
|
10332 + | let output = crate::output::SparseNullsOperationOutput {
|
10333 + | sparse_string_list: ::std::option::Option::None,
|
10334 + | sparse_string_map: ::std::option::Option::None,
|
10335 + | };
|
10336 + | output
|
10337 + | };
|
10338 + | sender.send(()).await.expect("receiver dropped early");
|
10339 + | result
|
10340 + | }
|
10341 + | })
|
10342 + | .build_unchecked();
|
10343 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10344 + | .await
|
10345 + | .expect("unable to make an HTTP request");
|
10346 + | assert!(
|
10347 + | receiver.recv().await.is_some(),
|
10348 + | "we expected operation handler to be invoked but it was not entered"
|
10424 10349 | );
|
10425 - | let output = crate::output::KitchenSinkOperationOutput {
|
10426 - | blob: ::std::option::Option::None,
|
10427 - | boolean: ::std::option::Option::None,
|
10428 - | double: ::std::option::Option::None,
|
10429 - | empty_struct: ::std::option::Option::None,
|
10430 - | float: ::std::option::Option::None,
|
10431 - | httpdate_timestamp: ::std::option::Option::None,
|
10432 - | integer: ::std::option::Option::None,
|
10433 - | iso8601_timestamp: ::std::option::Option::None,
|
10434 - | json_value: ::std::option::Option::None,
|
10435 - | list_of_lists: ::std::option::Option::None,
|
10436 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10437 - | list_of_strings: ::std::option::Option::None,
|
10438 - | list_of_structs: ::std::option::Option::None,
|
10439 - | long: ::std::option::Option::None,
|
10440 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10441 - | map_of_maps: ::std::option::Option::None,
|
10442 - | map_of_strings: ::std::option::Option::None,
|
10443 - | map_of_structs: ::std::option::Option::None,
|
10444 - | recursive_list: ::std::option::Option::None,
|
10445 - | recursive_map: ::std::option::Option::None,
|
10446 - | recursive_struct: ::std::option::Option::None,
|
10447 - | simple_struct: ::std::option::Option::None,
|
10448 - | string: ::std::option::Option::None,
|
10449 - | struct_with_json_name: ::std::option::Option::None,
|
10450 - | timestamp: ::std::option::Option::None,
|
10451 - | unix_timestamp: ::std::option::Option::None,
|
10350 + | }
|
10351 + |
|
10352 + | /// Serializes null values in lists
|
10353 + | /// Test ID: AwsJson11SparseListsSerializeNull
|
10354 + | #[::tokio::test]
|
10355 + | #[::tracing_test::traced_test]
|
10356 + | async fn aws_json11_sparse_lists_serialize_null_request() {
|
10357 + | #[allow(unused_mut)]
|
10358 + | let mut http_request = ::http::Request::builder()
|
10359 + | .uri("/")
|
10360 + | .method("POST")
|
10361 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10362 + | .header("X-Amz-Target", "JsonProtocol.SparseNullsOperation")
|
10363 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10364 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10365 + | "{\n \"sparseStringList\": [\n null\n ]\n}".as_bytes(),
|
10366 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10367 + | )),
|
10368 + | ))
|
10369 + | .unwrap();
|
10370 + | #[allow(unused_mut)]
|
10371 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10372 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10373 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10374 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
10375 + | let sender = sender.clone();
|
10376 + | async move {
|
10377 + | let result = {
|
10378 + | let expected = crate::input::SparseNullsOperationInput {
|
10379 + | sparse_string_list: ::std::option::Option::Some(vec![
|
10380 + | ::std::option::Option::None,
|
10381 + | ]),
|
10382 + | sparse_string_map: ::std::option::Option::None,
|
10452 10383 | };
|
10453 - | Ok(output)
|
10384 + | ::pretty_assertions::assert_eq!(input, expected);
|
10385 + | let output = crate::output::SparseNullsOperationOutput {
|
10386 + | sparse_string_list: ::std::option::Option::None,
|
10387 + | sparse_string_map: ::std::option::Option::None,
|
10388 + | };
|
10389 + | output
|
10454 10390 | };
|
10455 10391 | sender.send(()).await.expect("receiver dropped early");
|
10456 10392 | result
|
10457 10393 | }
|
10458 10394 | })
|
10459 10395 | .build_unchecked();
|
10460 10396 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10461 10397 | .await
|
10462 10398 | .expect("unable to make an HTTP request");
|
10463 10399 | assert!(
|
10464 10400 | receiver.recv().await.is_some(),
|
10465 10401 | "we expected operation handler to be invoked but it was not entered"
|
10466 10402 | );
|
10467 10403 | }
|
10468 10404 |
|
10469 - | /// Parses operations with empty JSON bodies
|
10470 - | /// Test ID: parses_operations_with_empty_json_bodies
|
10405 + | /// Deserializes null values in maps
|
10406 + | /// Test ID: AwsJson11SparseMapsDeserializeNullValues
|
10471 10407 | #[::tokio::test]
|
10472 10408 | #[::tracing_test::traced_test]
|
10473 - | async fn parses_operations_with_empty_json_bodies_response() {
|
10474 - | let output = crate::output::KitchenSinkOperationOutput {
|
10475 - | blob: ::std::option::Option::None,
|
10476 - | boolean: ::std::option::Option::None,
|
10477 - | double: ::std::option::Option::None,
|
10478 - | empty_struct: ::std::option::Option::None,
|
10479 - | float: ::std::option::Option::None,
|
10480 - | httpdate_timestamp: ::std::option::Option::None,
|
10481 - | integer: ::std::option::Option::None,
|
10482 - | iso8601_timestamp: ::std::option::Option::None,
|
10483 - | json_value: ::std::option::Option::None,
|
10484 - | list_of_lists: ::std::option::Option::None,
|
10485 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10486 - | list_of_strings: ::std::option::Option::None,
|
10487 - | list_of_structs: ::std::option::Option::None,
|
10488 - | long: ::std::option::Option::None,
|
10489 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10490 - | map_of_maps: ::std::option::Option::None,
|
10491 - | map_of_strings: ::std::option::Option::None,
|
10492 - | map_of_structs: ::std::option::Option::None,
|
10493 - | recursive_list: ::std::option::Option::None,
|
10494 - | recursive_map: ::std::option::Option::None,
|
10495 - | recursive_struct: ::std::option::Option::None,
|
10496 - | simple_struct: ::std::option::Option::None,
|
10497 - | string: ::std::option::Option::None,
|
10498 - | struct_with_json_name: ::std::option::Option::None,
|
10499 - | timestamp: ::std::option::Option::None,
|
10500 - | unix_timestamp: ::std::option::Option::None,
|
10409 + | async fn aws_json11_sparse_maps_deserialize_null_values_response() {
|
10410 + | let output = crate::output::SparseNullsOperationOutput {
|
10411 + | sparse_string_map: ::std::option::Option::Some({
|
10412 + | let mut ret = ::std::collections::HashMap::new();
|
10413 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
10414 + | ret
|
10415 + | }),
|
10416 + | sparse_string_list: ::std::option::Option::None,
|
10501 10417 | };
|
10502 10418 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10503 10419 | let http_response = output.into_response();
|
10504 10420 | ::pretty_assertions::assert_eq!(
|
10505 10421 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10506 10422 | http_response.status()
|
10507 10423 | );
|
10508 10424 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10509 10425 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10510 10426 | http_response.headers(),
|
10511 10427 | expected_headers,
|
10512 10428 | ));
|
10513 10429 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10514 10430 | .await
|
10515 10431 | .expect("unable to extract body to bytes");
|
10516 10432 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10517 10433 | &body,
|
10518 - | "{}",
|
10434 + | "{\n \"sparseStringMap\": {\n \"foo\": null\n }\n}",
|
10519 10435 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10520 10436 | ));
|
10521 10437 | }
|
10522 10438 |
|
10523 - | /// Parses string shapes
|
10524 - | /// Test ID: parses_string_shapes
|
10439 + | /// Deserializes null values in lists
|
10440 + | /// Test ID: AwsJson11SparseListsDeserializeNull
|
10525 10441 | #[::tokio::test]
|
10526 10442 | #[::tracing_test::traced_test]
|
10527 - | async fn parses_string_shapes_response() {
|
10528 - | let output = crate::output::KitchenSinkOperationOutput {
|
10529 - | string: ::std::option::Option::Some("string-value".to_owned()),
|
10530 - | blob: ::std::option::Option::None,
|
10531 - | boolean: ::std::option::Option::None,
|
10532 - | double: ::std::option::Option::None,
|
10533 - | empty_struct: ::std::option::Option::None,
|
10534 - | float: ::std::option::Option::None,
|
10535 - | httpdate_timestamp: ::std::option::Option::None,
|
10536 - | integer: ::std::option::Option::None,
|
10537 - | iso8601_timestamp: ::std::option::Option::None,
|
10538 - | json_value: ::std::option::Option::None,
|
10539 - | list_of_lists: ::std::option::Option::None,
|
10540 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10541 - | list_of_strings: ::std::option::Option::None,
|
10542 - | list_of_structs: ::std::option::Option::None,
|
10543 - | long: ::std::option::Option::None,
|
10544 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10545 - | map_of_maps: ::std::option::Option::None,
|
10546 - | map_of_strings: ::std::option::Option::None,
|
10547 - | map_of_structs: ::std::option::Option::None,
|
10548 - | recursive_list: ::std::option::Option::None,
|
10549 - | recursive_map: ::std::option::Option::None,
|
10550 - | recursive_struct: ::std::option::Option::None,
|
10551 - | simple_struct: ::std::option::Option::None,
|
10552 - | struct_with_json_name: ::std::option::Option::None,
|
10553 - | timestamp: ::std::option::Option::None,
|
10554 - | unix_timestamp: ::std::option::Option::None,
|
10443 + | async fn aws_json11_sparse_lists_deserialize_null_response() {
|
10444 + | let output = crate::output::SparseNullsOperationOutput {
|
10445 + | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
10446 + | sparse_string_map: ::std::option::Option::None,
|
10555 10447 | };
|
10556 10448 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10557 10449 | let http_response = output.into_response();
|
10558 10450 | ::pretty_assertions::assert_eq!(
|
10559 10451 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10560 10452 | http_response.status()
|
10561 10453 | );
|
10562 10454 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10563 10455 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10564 10456 | http_response.headers(),
|
10565 10457 | expected_headers,
|
10566 10458 | ));
|
10567 10459 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10568 10460 | .await
|
10569 10461 | .expect("unable to extract body to bytes");
|
10570 10462 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10571 10463 | &body,
|
10572 - | "{\"String\":\"string-value\"}",
|
10464 + | "{\n \"sparseStringList\": [\n null\n ]\n}",
|
10573 10465 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10574 10466 | ));
|
10575 10467 | }
|
10468 + | }
|
10576 10469 |
|
10577 - | /// Parses integer shapes
|
10578 - | /// Test ID: parses_integer_shapes
|
10579 - | #[::tokio::test]
|
10580 - | #[::tracing_test::traced_test]
|
10581 - | async fn parses_integer_shapes_response() {
|
10582 - | let output = crate::output::KitchenSinkOperationOutput {
|
10583 - | integer: ::std::option::Option::Some(1234),
|
10584 - | blob: ::std::option::Option::None,
|
10585 - | boolean: ::std::option::Option::None,
|
10586 - | double: ::std::option::Option::None,
|
10587 - | empty_struct: ::std::option::Option::None,
|
10588 - | float: ::std::option::Option::None,
|
10589 - | httpdate_timestamp: ::std::option::Option::None,
|
10590 - | iso8601_timestamp: ::std::option::Option::None,
|
10591 - | json_value: ::std::option::Option::None,
|
10592 - | list_of_lists: ::std::option::Option::None,
|
10593 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10594 - | list_of_strings: ::std::option::Option::None,
|
10595 - | list_of_structs: ::std::option::Option::None,
|
10596 - | long: ::std::option::Option::None,
|
10597 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10598 - | map_of_maps: ::std::option::Option::None,
|
10599 - | map_of_strings: ::std::option::Option::None,
|
10600 - | map_of_structs: ::std::option::Option::None,
|
10601 - | recursive_list: ::std::option::Option::None,
|
10602 - | recursive_map: ::std::option::Option::None,
|
10603 - | recursive_struct: ::std::option::Option::None,
|
10604 - | simple_struct: ::std::option::Option::None,
|
10605 - | string: ::std::option::Option::None,
|
10606 - | struct_with_json_name: ::std::option::Option::None,
|
10607 - | timestamp: ::std::option::Option::None,
|
10608 - | unix_timestamp: ::std::option::Option::None,
|
10470 + | ::pin_project_lite::pin_project! {
|
10471 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
10472 + | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
10473 + | pub struct GreetingWithErrorsInputFuture {
|
10474 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
10475 + | }
|
10476 + | }
|
10477 + |
|
10478 + | impl std::future::Future for GreetingWithErrorsInputFuture {
|
10479 + | type Output = Result<
|
10480 + | crate::input::GreetingWithErrorsInput,
|
10481 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
10482 + | >;
|
10483 + |
|
10484 + | fn poll(
|
10485 + | self: std::pin::Pin<&mut Self>,
|
10486 + | cx: &mut std::task::Context<'_>,
|
10487 + | ) -> std::task::Poll<Self::Output> {
|
10488 + | let this = self.project();
|
10489 + | this.inner.as_mut().poll(cx)
|
10490 + | }
|
10491 + | }
|
10492 + |
|
10493 + | impl<B>
|
10494 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
10495 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10496 + | B,
|
10497 + | > for crate::input::GreetingWithErrorsInput
|
10498 + | where
|
10499 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
10500 + | B: 'static,
|
10501 + |
|
10502 + | B::Data: Send,
|
10503 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
10504 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
10505 + | {
|
10506 + | type Rejection =
|
10507 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
10508 + | type Future = GreetingWithErrorsInputFuture;
|
10509 + |
|
10510 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
10511 + | let fut = async move {
|
10512 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
10513 + | request.headers(),
|
10514 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
10515 + | ) {
|
10516 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
10517 + | }
|
10518 + | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
10519 + | request,
|
10520 + | )
|
10521 + | .await
|
10522 + | };
|
10523 + | use ::futures_util::future::TryFutureExt;
|
10524 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
10525 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
10526 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
10527 + | });
|
10528 + | GreetingWithErrorsInputFuture {
|
10529 + | inner: Box::pin(fut),
|
10530 + | }
|
10531 + | }
|
10532 + | }
|
10533 + | impl
|
10534 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
10535 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10536 + | > for crate::output::GreetingWithErrorsOutput
|
10537 + | {
|
10538 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
10539 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
10540 + | Ok(response) => response,
|
10541 + | Err(e) => {
|
10542 + | ::tracing::error!(error = %e, "failed to serialize response");
|
10543 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
10544 + | }
|
10545 + | }
|
10546 + | }
|
10547 + | }
|
10548 + | impl
|
10549 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
10550 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10551 + | > for crate::error::GreetingWithErrorsError
|
10552 + | {
|
10553 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
10554 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
10555 + | &self,
|
10556 + | ) {
|
10557 + | Ok(mut response) => {
|
10558 + | response.extensions_mut().insert(
|
10559 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
10560 + | self.name(),
|
10561 + | ),
|
10562 + | );
|
10563 + | response
|
10564 + | }
|
10565 + | Err(e) => {
|
10566 + | ::tracing::error!(error = %e, "failed to serialize response");
|
10567 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
10568 + | }
|
10569 + | }
|
10570 + | }
|
10571 + | }
|
10572 + |
|
10573 + | #[allow(unreachable_code, unused_variables)]
|
10574 + | #[cfg(test)]
|
10575 + | mod greeting_with_errors_test {
|
10576 + |
|
10577 + | /// Parses simple JSON errors
|
10578 + | /// Test ID: AwsJson11InvalidGreetingError
|
10579 + | #[::tokio::test]
|
10580 + | #[::tracing_test::traced_test]
|
10581 + | async fn aws_json11_invalid_greeting_error_response() {
|
10582 + | let output = crate::error::InvalidGreeting {
|
10583 + | message: ::std::option::Option::Some("Hi".to_owned()),
|
10609 10584 | };
|
10585 + | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
10610 10586 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10611 10587 | let http_response = output.into_response();
|
10612 10588 | ::pretty_assertions::assert_eq!(
|
10613 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10589 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
10614 10590 | http_response.status()
|
10615 10591 | );
|
10616 10592 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10617 10593 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10618 10594 | http_response.headers(),
|
10619 10595 | expected_headers,
|
10620 10596 | ));
|
10621 10597 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10622 10598 | .await
|
10623 10599 | .expect("unable to extract body to bytes");
|
10624 10600 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10625 10601 | &body,
|
10626 - | "{\"Integer\":1234}",
|
10602 + | "{\n \"__type\": \"InvalidGreeting\",\n \"Message\": \"Hi\"\n}",
|
10627 10603 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10628 10604 | ));
|
10629 10605 | }
|
10630 10606 |
|
10631 - | /// Parses long shapes
|
10632 - | /// Test ID: parses_long_shapes
|
10607 + | /// Parses a complex error with no message member
|
10608 + | /// Test ID: AwsJson11ComplexError
|
10633 10609 | #[::tokio::test]
|
10634 10610 | #[::tracing_test::traced_test]
|
10635 - | async fn parses_long_shapes_response() {
|
10636 - | let output = crate::output::KitchenSinkOperationOutput {
|
10637 - | long: ::std::option::Option::Some(1234567890123456789),
|
10638 - | blob: ::std::option::Option::None,
|
10639 - | boolean: ::std::option::Option::None,
|
10640 - | double: ::std::option::Option::None,
|
10641 - | empty_struct: ::std::option::Option::None,
|
10642 - | float: ::std::option::Option::None,
|
10643 - | httpdate_timestamp: ::std::option::Option::None,
|
10644 - | integer: ::std::option::Option::None,
|
10645 - | iso8601_timestamp: ::std::option::Option::None,
|
10646 - | json_value: ::std::option::Option::None,
|
10647 - | list_of_lists: ::std::option::Option::None,
|
10648 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10649 - | list_of_strings: ::std::option::Option::None,
|
10650 - | list_of_structs: ::std::option::Option::None,
|
10651 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10652 - | map_of_maps: ::std::option::Option::None,
|
10653 - | map_of_strings: ::std::option::Option::None,
|
10654 - | map_of_structs: ::std::option::Option::None,
|
10655 - | recursive_list: ::std::option::Option::None,
|
10656 - | recursive_map: ::std::option::Option::None,
|
10657 - | recursive_struct: ::std::option::Option::None,
|
10658 - | simple_struct: ::std::option::Option::None,
|
10659 - | string: ::std::option::Option::None,
|
10660 - | struct_with_json_name: ::std::option::Option::None,
|
10661 - | timestamp: ::std::option::Option::None,
|
10662 - | unix_timestamp: ::std::option::Option::None,
|
10611 + | async fn aws_json11_complex_error_response() {
|
10612 + | let output = crate::error::ComplexError {
|
10613 + | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
10614 + | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
10615 + | foo: ::std::option::Option::Some("bar".to_owned()),
|
10616 + | }),
|
10663 10617 | };
|
10618 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
10664 10619 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10665 10620 | let http_response = output.into_response();
|
10666 10621 | ::pretty_assertions::assert_eq!(
|
10667 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10622 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
10668 10623 | http_response.status()
|
10669 10624 | );
|
10670 10625 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10671 10626 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10672 10627 | http_response.headers(),
|
10673 10628 | expected_headers,
|
10674 10629 | ));
|
10675 10630 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10676 10631 | .await
|
10677 10632 | .expect("unable to extract body to bytes");
|
10678 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10679 - | &body,
|
10680 - | "{\"Long\":1234567890123456789}",
|
10681 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10682 - | ));
|
10633 + | ::aws_smithy_protocol_test::assert_ok(
|
10634 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"__type\": \"ComplexError\",\n \"TopLevel\": \"Top level\",\n \"Nested\": {\n \"Foo\": \"bar\"\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
10635 + | );
|
10683 10636 | }
|
10684 - |
|
10685 - | /// Parses float shapes
|
10686 - | /// Test ID: parses_float_shapes
|
10637 + | /// Test ID: AwsJson11EmptyComplexError
|
10687 10638 | #[::tokio::test]
|
10688 10639 | #[::tracing_test::traced_test]
|
10689 - | async fn parses_float_shapes_response() {
|
10690 - | let output = crate::output::KitchenSinkOperationOutput {
|
10691 - | float: ::std::option::Option::Some(1234.5_f32),
|
10692 - | blob: ::std::option::Option::None,
|
10693 - | boolean: ::std::option::Option::None,
|
10694 - | double: ::std::option::Option::None,
|
10695 - | empty_struct: ::std::option::Option::None,
|
10696 - | httpdate_timestamp: ::std::option::Option::None,
|
10697 - | integer: ::std::option::Option::None,
|
10698 - | iso8601_timestamp: ::std::option::Option::None,
|
10699 - | json_value: ::std::option::Option::None,
|
10700 - | list_of_lists: ::std::option::Option::None,
|
10701 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10702 - | list_of_strings: ::std::option::Option::None,
|
10703 - | list_of_structs: ::std::option::Option::None,
|
10704 - | long: ::std::option::Option::None,
|
10705 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10706 - | map_of_maps: ::std::option::Option::None,
|
10707 - | map_of_strings: ::std::option::Option::None,
|
10708 - | map_of_structs: ::std::option::Option::None,
|
10709 - | recursive_list: ::std::option::Option::None,
|
10710 - | recursive_map: ::std::option::Option::None,
|
10711 - | recursive_struct: ::std::option::Option::None,
|
10712 - | simple_struct: ::std::option::Option::None,
|
10713 - | string: ::std::option::Option::None,
|
10714 - | struct_with_json_name: ::std::option::Option::None,
|
10715 - | timestamp: ::std::option::Option::None,
|
10716 - | unix_timestamp: ::std::option::Option::None,
|
10640 + | async fn aws_json11_empty_complex_error_response() {
|
10641 + | let output = crate::error::ComplexError {
|
10642 + | top_level: ::std::option::Option::None,
|
10643 + | nested: ::std::option::Option::None,
|
10717 10644 | };
|
10645 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
10718 10646 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10719 10647 | let http_response = output.into_response();
|
10720 10648 | ::pretty_assertions::assert_eq!(
|
10721 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10649 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
10722 10650 | http_response.status()
|
10723 10651 | );
|
10724 10652 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10725 10653 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10726 10654 | http_response.headers(),
|
10727 10655 | expected_headers,
|
10728 10656 | ));
|
10729 10657 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10730 10658 | .await
|
10731 10659 | .expect("unable to extract body to bytes");
|
10732 10660 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10733 10661 | &body,
|
10734 - | "{\"Float\":1234.5}",
|
10662 + | "{\n \"__type\": \"ComplexError\"\n}",
|
10735 10663 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10736 10664 | ));
|
10737 10665 | }
|
10666 + | }
|
10738 10667 |
|
10739 - | /// Parses double shapes
|
10740 - | /// Test ID: parses_double_shapes
|
10668 + | ::pin_project_lite::pin_project! {
|
10669 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
10670 + | /// [`JsonUnionsInput`](crate::input::JsonUnionsInput) using modelled bindings.
|
10671 + | pub struct JsonUnionsInputFuture {
|
10672 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::JsonUnionsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
10673 + | }
|
10674 + | }
|
10675 + |
|
10676 + | impl std::future::Future for JsonUnionsInputFuture {
|
10677 + | type Output = Result<
|
10678 + | crate::input::JsonUnionsInput,
|
10679 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
10680 + | >;
|
10681 + |
|
10682 + | fn poll(
|
10683 + | self: std::pin::Pin<&mut Self>,
|
10684 + | cx: &mut std::task::Context<'_>,
|
10685 + | ) -> std::task::Poll<Self::Output> {
|
10686 + | let this = self.project();
|
10687 + | this.inner.as_mut().poll(cx)
|
10688 + | }
|
10689 + | }
|
10690 + |
|
10691 + | impl<B>
|
10692 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
10693 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10694 + | B,
|
10695 + | > for crate::input::JsonUnionsInput
|
10696 + | where
|
10697 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
10698 + | B: 'static,
|
10699 + |
|
10700 + | B::Data: Send,
|
10701 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
10702 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
10703 + | {
|
10704 + | type Rejection =
|
10705 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
10706 + | type Future = JsonUnionsInputFuture;
|
10707 + |
|
10708 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
10709 + | let fut = async move {
|
10710 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
10711 + | request.headers(),
|
10712 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
10713 + | ) {
|
10714 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
10715 + | }
|
10716 + | crate::protocol_serde::shape_json_unions::de_json_unions_http_request(request).await
|
10717 + | };
|
10718 + | use ::futures_util::future::TryFutureExt;
|
10719 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
10720 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
10721 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
10722 + | });
|
10723 + | JsonUnionsInputFuture {
|
10724 + | inner: Box::pin(fut),
|
10725 + | }
|
10726 + | }
|
10727 + | }
|
10728 + | impl
|
10729 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
10730 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10731 + | > for crate::output::JsonUnionsOutput
|
10732 + | {
|
10733 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
10734 + | match crate::protocol_serde::shape_json_unions::ser_json_unions_http_response(self) {
|
10735 + | Ok(response) => response,
|
10736 + | Err(e) => {
|
10737 + | ::tracing::error!(error = %e, "failed to serialize response");
|
10738 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
10739 + | }
|
10740 + | }
|
10741 + | }
|
10742 + | }
|
10743 + | impl
|
10744 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
10745 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
10746 + | > for crate::error::JsonUnionsError
|
10747 + | {
|
10748 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
10749 + | match crate::protocol_serde::shape_json_unions::ser_json_unions_http_error(&self) {
|
10750 + | Ok(mut response) => {
|
10751 + | response.extensions_mut().insert(
|
10752 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
10753 + | self.name(),
|
10754 + | ),
|
10755 + | );
|
10756 + | response
|
10757 + | }
|
10758 + | Err(e) => {
|
10759 + | ::tracing::error!(error = %e, "failed to serialize response");
|
10760 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
10761 + | }
|
10762 + | }
|
10763 + | }
|
10764 + | }
|
10765 + |
|
10766 + | #[allow(unreachable_code, unused_variables)]
|
10767 + | #[cfg(test)]
|
10768 + | mod json_unions_test {
|
10769 + |
|
10770 + | /// Serializes a string union value
|
10771 + | /// Test ID: AwsJson11SerializeStringUnionValue
|
10741 10772 | #[::tokio::test]
|
10742 10773 | #[::tracing_test::traced_test]
|
10743 - | async fn parses_double_shapes_response() {
|
10744 - | let output = crate::output::KitchenSinkOperationOutput {
|
10745 - | double: ::std::option::Option::Some(1.2345678912345679E8_f64),
|
10746 - | blob: ::std::option::Option::None,
|
10747 - | boolean: ::std::option::Option::None,
|
10748 - | empty_struct: ::std::option::Option::None,
|
10749 - | float: ::std::option::Option::None,
|
10750 - | httpdate_timestamp: ::std::option::Option::None,
|
10751 - | integer: ::std::option::Option::None,
|
10752 - | iso8601_timestamp: ::std::option::Option::None,
|
10753 - | json_value: ::std::option::Option::None,
|
10754 - | list_of_lists: ::std::option::Option::None,
|
10755 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10756 - | list_of_strings: ::std::option::Option::None,
|
10757 - | list_of_structs: ::std::option::Option::None,
|
10758 - | long: ::std::option::Option::None,
|
10759 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10760 - | map_of_maps: ::std::option::Option::None,
|
10761 - | map_of_strings: ::std::option::Option::None,
|
10762 - | map_of_structs: ::std::option::Option::None,
|
10763 - | recursive_list: ::std::option::Option::None,
|
10764 - | recursive_map: ::std::option::Option::None,
|
10765 - | recursive_struct: ::std::option::Option::None,
|
10766 - | simple_struct: ::std::option::Option::None,
|
10767 - | string: ::std::option::Option::None,
|
10768 - | struct_with_json_name: ::std::option::Option::None,
|
10769 - | timestamp: ::std::option::Option::None,
|
10770 - | unix_timestamp: ::std::option::Option::None,
|
10774 + | async fn aws_json11_serialize_string_union_value_request() {
|
10775 + | #[allow(unused_mut)]
|
10776 + | let mut http_request = ::http::Request::builder()
|
10777 + | .uri("/")
|
10778 + | .method("POST")
|
10779 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10780 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
10781 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10782 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10783 + | "{\n \"contents\": {\n \"stringValue\": \"foo\"\n }\n}".as_bytes(),
|
10784 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10785 + | )),
|
10786 + | ))
|
10787 + | .unwrap();
|
10788 + | #[allow(unused_mut)]
|
10789 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10790 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10791 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10792 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
10793 + | let sender = sender.clone();
|
10794 + | async move {
|
10795 + | let result = {
|
10796 + | let expected = crate::input::JsonUnionsInput {
|
10797 + | contents: ::std::option::Option::Some(
|
10798 + | crate::model::MyUnion::StringValue("foo".to_owned()),
|
10799 + | ),
|
10771 10800 | };
|
10772 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10773 - | let http_response = output.into_response();
|
10774 - | ::pretty_assertions::assert_eq!(
|
10775 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10776 - | http_response.status()
|
10777 - | );
|
10778 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10779 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10780 - | http_response.headers(),
|
10781 - | expected_headers,
|
10782 - | ));
|
10783 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10801 + | ::pretty_assertions::assert_eq!(input, expected);
|
10802 + | let output = crate::output::JsonUnionsOutput {
|
10803 + | contents: ::std::option::Option::None,
|
10804 + | };
|
10805 + | Ok(output)
|
10806 + | };
|
10807 + | sender.send(()).await.expect("receiver dropped early");
|
10808 + | result
|
10809 + | }
|
10810 + | })
|
10811 + | .build_unchecked();
|
10812 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10784 10813 | .await
|
10785 - | .expect("unable to extract body to bytes");
|
10786 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10787 - | &body,
|
10788 - | "{\"Double\":123456789.12345679}",
|
10789 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10790 - | ));
|
10814 + | .expect("unable to make an HTTP request");
|
10815 + | assert!(
|
10816 + | receiver.recv().await.is_some(),
|
10817 + | "we expected operation handler to be invoked but it was not entered"
|
10818 + | );
|
10791 10819 | }
|
10792 10820 |
|
10793 - | /// Parses boolean shapes (true)
|
10794 - | /// Test ID: parses_boolean_shapes_true
|
10821 + | /// Serializes a boolean union value
|
10822 + | /// Test ID: AwsJson11SerializeBooleanUnionValue
|
10795 10823 | #[::tokio::test]
|
10796 10824 | #[::tracing_test::traced_test]
|
10797 - | async fn parses_boolean_shapes_true_response() {
|
10798 - | let output = crate::output::KitchenSinkOperationOutput {
|
10799 - | boolean: ::std::option::Option::Some(true),
|
10800 - | blob: ::std::option::Option::None,
|
10801 - | double: ::std::option::Option::None,
|
10802 - | empty_struct: ::std::option::Option::None,
|
10803 - | float: ::std::option::Option::None,
|
10804 - | httpdate_timestamp: ::std::option::Option::None,
|
10805 - | integer: ::std::option::Option::None,
|
10806 - | iso8601_timestamp: ::std::option::Option::None,
|
10807 - | json_value: ::std::option::Option::None,
|
10808 - | list_of_lists: ::std::option::Option::None,
|
10809 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10810 - | list_of_strings: ::std::option::Option::None,
|
10811 - | list_of_structs: ::std::option::Option::None,
|
10812 - | long: ::std::option::Option::None,
|
10813 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10814 - | map_of_maps: ::std::option::Option::None,
|
10815 - | map_of_strings: ::std::option::Option::None,
|
10816 - | map_of_structs: ::std::option::Option::None,
|
10817 - | recursive_list: ::std::option::Option::None,
|
10818 - | recursive_map: ::std::option::Option::None,
|
10819 - | recursive_struct: ::std::option::Option::None,
|
10820 - | simple_struct: ::std::option::Option::None,
|
10821 - | string: ::std::option::Option::None,
|
10822 - | struct_with_json_name: ::std::option::Option::None,
|
10823 - | timestamp: ::std::option::Option::None,
|
10824 - | unix_timestamp: ::std::option::Option::None,
|
10825 + | async fn aws_json11_serialize_boolean_union_value_request() {
|
10826 + | #[allow(unused_mut)]
|
10827 + | let mut http_request = ::http::Request::builder()
|
10828 + | .uri("/")
|
10829 + | .method("POST")
|
10830 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10831 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
10832 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10833 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10834 + | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}".as_bytes(),
|
10835 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10836 + | )),
|
10837 + | ))
|
10838 + | .unwrap();
|
10839 + | #[allow(unused_mut)]
|
10840 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10841 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10842 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10843 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
10844 + | let sender = sender.clone();
|
10845 + | async move {
|
10846 + | let result = {
|
10847 + | let expected = crate::input::JsonUnionsInput {
|
10848 + | contents: ::std::option::Option::Some(
|
10849 + | crate::model::MyUnion::BooleanValue(true),
|
10850 + | ),
|
10825 10851 | };
|
10826 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10827 - | let http_response = output.into_response();
|
10828 - | ::pretty_assertions::assert_eq!(
|
10829 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10830 - | http_response.status()
|
10831 - | );
|
10832 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10833 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10834 - | http_response.headers(),
|
10835 - | expected_headers,
|
10836 - | ));
|
10837 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10852 + | ::pretty_assertions::assert_eq!(input, expected);
|
10853 + | let output = crate::output::JsonUnionsOutput {
|
10854 + | contents: ::std::option::Option::None,
|
10855 + | };
|
10856 + | Ok(output)
|
10857 + | };
|
10858 + | sender.send(()).await.expect("receiver dropped early");
|
10859 + | result
|
10860 + | }
|
10861 + | })
|
10862 + | .build_unchecked();
|
10863 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10838 10864 | .await
|
10839 - | .expect("unable to extract body to bytes");
|
10840 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10841 - | &body,
|
10842 - | "{\"Boolean\":true}",
|
10843 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10844 - | ));
|
10865 + | .expect("unable to make an HTTP request");
|
10866 + | assert!(
|
10867 + | receiver.recv().await.is_some(),
|
10868 + | "we expected operation handler to be invoked but it was not entered"
|
10869 + | );
|
10845 10870 | }
|
10846 10871 |
|
10847 - | /// Parses boolean (false)
|
10848 - | /// Test ID: parses_boolean_false
|
10872 + | /// Serializes a number union value
|
10873 + | /// Test ID: AwsJson11SerializeNumberUnionValue
|
10849 10874 | #[::tokio::test]
|
10850 10875 | #[::tracing_test::traced_test]
|
10851 - | async fn parses_boolean_false_response() {
|
10852 - | let output = crate::output::KitchenSinkOperationOutput {
|
10853 - | boolean: ::std::option::Option::Some(false),
|
10854 - | blob: ::std::option::Option::None,
|
10855 - | double: ::std::option::Option::None,
|
10856 - | empty_struct: ::std::option::Option::None,
|
10857 - | float: ::std::option::Option::None,
|
10858 - | httpdate_timestamp: ::std::option::Option::None,
|
10859 - | integer: ::std::option::Option::None,
|
10860 - | iso8601_timestamp: ::std::option::Option::None,
|
10861 - | json_value: ::std::option::Option::None,
|
10862 - | list_of_lists: ::std::option::Option::None,
|
10863 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10864 - | list_of_strings: ::std::option::Option::None,
|
10865 - | list_of_structs: ::std::option::Option::None,
|
10866 - | long: ::std::option::Option::None,
|
10867 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10868 - | map_of_maps: ::std::option::Option::None,
|
10869 - | map_of_strings: ::std::option::Option::None,
|
10870 - | map_of_structs: ::std::option::Option::None,
|
10871 - | recursive_list: ::std::option::Option::None,
|
10872 - | recursive_map: ::std::option::Option::None,
|
10873 - | recursive_struct: ::std::option::Option::None,
|
10874 - | simple_struct: ::std::option::Option::None,
|
10875 - | string: ::std::option::Option::None,
|
10876 - | struct_with_json_name: ::std::option::Option::None,
|
10877 - | timestamp: ::std::option::Option::None,
|
10878 - | unix_timestamp: ::std::option::Option::None,
|
10876 + | async fn aws_json11_serialize_number_union_value_request() {
|
10877 + | #[allow(unused_mut)]
|
10878 + | let mut http_request = ::http::Request::builder()
|
10879 + | .uri("/")
|
10880 + | .method("POST")
|
10881 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10882 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
10883 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10884 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10885 + | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}".as_bytes(),
|
10886 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10887 + | )),
|
10888 + | ))
|
10889 + | .unwrap();
|
10890 + | #[allow(unused_mut)]
|
10891 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10892 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10893 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10894 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
10895 + | let sender = sender.clone();
|
10896 + | async move {
|
10897 + | let result = {
|
10898 + | let expected = crate::input::JsonUnionsInput {
|
10899 + | contents: ::std::option::Option::Some(
|
10900 + | crate::model::MyUnion::NumberValue(1),
|
10901 + | ),
|
10879 10902 | };
|
10880 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10881 - | let http_response = output.into_response();
|
10882 - | ::pretty_assertions::assert_eq!(
|
10883 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10884 - | http_response.status()
|
10903 + | ::pretty_assertions::assert_eq!(input, expected);
|
10904 + | let output = crate::output::JsonUnionsOutput {
|
10905 + | contents: ::std::option::Option::None,
|
10906 + | };
|
10907 + | Ok(output)
|
10908 + | };
|
10909 + | sender.send(()).await.expect("receiver dropped early");
|
10910 + | result
|
10911 + | }
|
10912 + | })
|
10913 + | .build_unchecked();
|
10914 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10915 + | .await
|
10916 + | .expect("unable to make an HTTP request");
|
10917 + | assert!(
|
10918 + | receiver.recv().await.is_some(),
|
10919 + | "we expected operation handler to be invoked but it was not entered"
|
10885 10920 | );
|
10886 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10887 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10888 - | http_response.headers(),
|
10889 - | expected_headers,
|
10890 - | ));
|
10891 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
10921 + | }
|
10922 + |
|
10923 + | /// Serializes a blob union value
|
10924 + | /// Test ID: AwsJson11SerializeBlobUnionValue
|
10925 + | #[::tokio::test]
|
10926 + | #[::tracing_test::traced_test]
|
10927 + | async fn aws_json11_serialize_blob_union_value_request() {
|
10928 + | #[allow(unused_mut)]
|
10929 + | let mut http_request = ::http::Request::builder()
|
10930 + | .uri("/")
|
10931 + | .method("POST")
|
10932 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10933 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
10934 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10935 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10936 + | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}".as_bytes(),
|
10937 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10938 + | )),
|
10939 + | ))
|
10940 + | .unwrap();
|
10941 + | #[allow(unused_mut)]
|
10942 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10943 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10944 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10945 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
10946 + | let sender = sender.clone();
|
10947 + | async move {
|
10948 + | let result = {
|
10949 + | let expected = crate::input::JsonUnionsInput {
|
10950 + | contents: ::std::option::Option::Some(
|
10951 + | crate::model::MyUnion::BlobValue(::aws_smithy_types::Blob::new(
|
10952 + | "foo",
|
10953 + | )),
|
10954 + | ),
|
10955 + | };
|
10956 + | ::pretty_assertions::assert_eq!(input, expected);
|
10957 + | let output = crate::output::JsonUnionsOutput {
|
10958 + | contents: ::std::option::Option::None,
|
10959 + | };
|
10960 + | Ok(output)
|
10961 + | };
|
10962 + | sender.send(()).await.expect("receiver dropped early");
|
10963 + | result
|
10964 + | }
|
10965 + | })
|
10966 + | .build_unchecked();
|
10967 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10892 10968 | .await
|
10893 - | .expect("unable to extract body to bytes");
|
10894 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10895 - | &body,
|
10896 - | "{\"Boolean\":false}",
|
10897 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10898 - | ));
|
10969 + | .expect("unable to make an HTTP request");
|
10970 + | assert!(
|
10971 + | receiver.recv().await.is_some(),
|
10972 + | "we expected operation handler to be invoked but it was not entered"
|
10973 + | );
|
10899 10974 | }
|
10900 10975 |
|
10901 - | /// Parses blob shapes
|
10902 - | /// Test ID: parses_blob_shapes
|
10976 + | /// Serializes a timestamp union value
|
10977 + | /// Test ID: AwsJson11SerializeTimestampUnionValue
|
10903 10978 | #[::tokio::test]
|
10904 10979 | #[::tracing_test::traced_test]
|
10905 - | async fn parses_blob_shapes_response() {
|
10906 - | let output = crate::output::KitchenSinkOperationOutput {
|
10907 - | blob: ::std::option::Option::Some(::aws_smithy_types::Blob::new("binary-value")),
|
10908 - | boolean: ::std::option::Option::None,
|
10909 - | double: ::std::option::Option::None,
|
10910 - | empty_struct: ::std::option::Option::None,
|
10911 - | float: ::std::option::Option::None,
|
10912 - | httpdate_timestamp: ::std::option::Option::None,
|
10913 - | integer: ::std::option::Option::None,
|
10914 - | iso8601_timestamp: ::std::option::Option::None,
|
10915 - | json_value: ::std::option::Option::None,
|
10916 - | list_of_lists: ::std::option::Option::None,
|
10917 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10918 - | list_of_strings: ::std::option::Option::None,
|
10919 - | list_of_structs: ::std::option::Option::None,
|
10920 - | long: ::std::option::Option::None,
|
10921 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10922 - | map_of_maps: ::std::option::Option::None,
|
10923 - | map_of_strings: ::std::option::Option::None,
|
10924 - | map_of_structs: ::std::option::Option::None,
|
10925 - | recursive_list: ::std::option::Option::None,
|
10926 - | recursive_map: ::std::option::Option::None,
|
10927 - | recursive_struct: ::std::option::Option::None,
|
10928 - | simple_struct: ::std::option::Option::None,
|
10929 - | string: ::std::option::Option::None,
|
10930 - | struct_with_json_name: ::std::option::Option::None,
|
10931 - | timestamp: ::std::option::Option::None,
|
10932 - | unix_timestamp: ::std::option::Option::None,
|
10980 + | async fn aws_json11_serialize_timestamp_union_value_request() {
|
10981 + | #[allow(unused_mut)]
|
10982 + | let mut http_request = ::http::Request::builder()
|
10983 + | .uri("/")
|
10984 + | .method("POST")
|
10985 + | .header("Content-Type", "application/x-amz-json-1.1")
|
10986 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
10987 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
10988 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
10989 + | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}"
|
10990 + | .as_bytes(),
|
10991 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10992 + | )),
|
10993 + | ))
|
10994 + | .unwrap();
|
10995 + | #[allow(unused_mut)]
|
10996 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
10997 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
10998 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
10999 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
11000 + | let sender = sender.clone();
|
11001 + | async move {
|
11002 + | let result = {
|
11003 + | let expected = crate::input::JsonUnionsInput {
|
11004 + | contents: ::std::option::Option::Some(
|
11005 + | crate::model::MyUnion::TimestampValue(
|
11006 + | ::aws_smithy_types::DateTime::from_fractional_secs(
|
11007 + | 1398796238, 0_f64,
|
11008 + | ),
|
11009 + | ),
|
11010 + | ),
|
10933 11011 | };
|
10934 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10935 - | let http_response = output.into_response();
|
10936 - | ::pretty_assertions::assert_eq!(
|
10937 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10938 - | http_response.status()
|
10939 - | );
|
10940 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10941 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10942 - | http_response.headers(),
|
10943 - | expected_headers,
|
10944 - | ));
|
10945 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11012 + | ::pretty_assertions::assert_eq!(input, expected);
|
11013 + | let output = crate::output::JsonUnionsOutput {
|
11014 + | contents: ::std::option::Option::None,
|
11015 + | };
|
11016 + | Ok(output)
|
11017 + | };
|
11018 + | sender.send(()).await.expect("receiver dropped early");
|
11019 + | result
|
11020 + | }
|
11021 + | })
|
11022 + | .build_unchecked();
|
11023 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
10946 11024 | .await
|
10947 - | .expect("unable to extract body to bytes");
|
10948 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
10949 - | &body,
|
10950 - | "{\"Blob\":\"YmluYXJ5LXZhbHVl\"}",
|
10951 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
10952 - | ));
|
11025 + | .expect("unable to make an HTTP request");
|
11026 + | assert!(
|
11027 + | receiver.recv().await.is_some(),
|
11028 + | "we expected operation handler to be invoked but it was not entered"
|
11029 + | );
|
10953 11030 | }
|
10954 11031 |
|
10955 - | /// Parses timestamp shapes
|
10956 - | /// Test ID: parses_timestamp_shapes
|
11032 + | /// Serializes an enum union value
|
11033 + | /// Test ID: AwsJson11SerializeEnumUnionValue
|
10957 11034 | #[::tokio::test]
|
10958 11035 | #[::tracing_test::traced_test]
|
10959 - | async fn parses_timestamp_shapes_response() {
|
10960 - | let output = crate::output::KitchenSinkOperationOutput {
|
10961 - | timestamp: ::std::option::Option::Some(
|
10962 - | ::aws_smithy_types::DateTime::from_fractional_secs(946845296, 0_f64),
|
11036 + | async fn aws_json11_serialize_enum_union_value_request() {
|
11037 + | #[allow(unused_mut)]
|
11038 + | let mut http_request = ::http::Request::builder()
|
11039 + | .uri("/")
|
11040 + | .method("POST")
|
11041 + | .header("Content-Type", "application/x-amz-json-1.1")
|
11042 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
11043 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
11044 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
11045 + | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}".as_bytes(),
|
11046 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11047 + | )),
|
11048 + | ))
|
11049 + | .unwrap();
|
11050 + | #[allow(unused_mut)]
|
11051 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
11052 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
11053 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
11054 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
11055 + | let sender = sender.clone();
|
11056 + | async move {
|
11057 + | let result = {
|
11058 + | let expected = crate::input::JsonUnionsInput {
|
11059 + | contents: ::std::option::Option::Some(
|
11060 + | crate::model::MyUnion::EnumValue(
|
11061 + | "Foo"
|
11062 + | .parse::<crate::model::FooEnum>()
|
11063 + | .expect("static value validated to member"),
|
11064 + | ),
|
10963 11065 | ),
|
10964 - | blob: ::std::option::Option::None,
|
10965 - | boolean: ::std::option::Option::None,
|
10966 - | double: ::std::option::Option::None,
|
10967 - | empty_struct: ::std::option::Option::None,
|
10968 - | float: ::std::option::Option::None,
|
10969 - | httpdate_timestamp: ::std::option::Option::None,
|
10970 - | integer: ::std::option::Option::None,
|
10971 - | iso8601_timestamp: ::std::option::Option::None,
|
10972 - | json_value: ::std::option::Option::None,
|
10973 - | list_of_lists: ::std::option::Option::None,
|
10974 - | list_of_maps_of_strings: ::std::option::Option::None,
|
10975 - | list_of_strings: ::std::option::Option::None,
|
10976 - | list_of_structs: ::std::option::Option::None,
|
10977 - | long: ::std::option::Option::None,
|
10978 - | map_of_lists_of_strings: ::std::option::Option::None,
|
10979 - | map_of_maps: ::std::option::Option::None,
|
10980 - | map_of_strings: ::std::option::Option::None,
|
10981 - | map_of_structs: ::std::option::Option::None,
|
10982 - | recursive_list: ::std::option::Option::None,
|
10983 - | recursive_map: ::std::option::Option::None,
|
10984 - | recursive_struct: ::std::option::Option::None,
|
10985 - | simple_struct: ::std::option::Option::None,
|
10986 - | string: ::std::option::Option::None,
|
10987 - | struct_with_json_name: ::std::option::Option::None,
|
10988 - | unix_timestamp: ::std::option::Option::None,
|
10989 11066 | };
|
10990 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
10991 - | let http_response = output.into_response();
|
10992 - | ::pretty_assertions::assert_eq!(
|
10993 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
10994 - | http_response.status()
|
10995 - | );
|
10996 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
10997 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
10998 - | http_response.headers(),
|
10999 - | expected_headers,
|
11000 - | ));
|
11001 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11067 + | ::pretty_assertions::assert_eq!(input, expected);
|
11068 + | let output = crate::output::JsonUnionsOutput {
|
11069 + | contents: ::std::option::Option::None,
|
11070 + | };
|
11071 + | Ok(output)
|
11072 + | };
|
11073 + | sender.send(()).await.expect("receiver dropped early");
|
11074 + | result
|
11075 + | }
|
11076 + | })
|
11077 + | .build_unchecked();
|
11078 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
11002 11079 | .await
|
11003 - | .expect("unable to extract body to bytes");
|
11004 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11005 - | &body,
|
11006 - | "{\"Timestamp\":946845296}",
|
11007 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11008 - | ));
|
11080 + | .expect("unable to make an HTTP request");
|
11081 + | assert!(
|
11082 + | receiver.recv().await.is_some(),
|
11083 + | "we expected operation handler to be invoked but it was not entered"
|
11084 + | );
|
11009 11085 | }
|
11010 11086 |
|
11011 - | /// Parses iso8601 timestamps
|
11012 - | /// Test ID: parses_iso8601_timestamps
|
11087 + | /// Serializes a list union value
|
11088 + | /// Test ID: AwsJson11SerializeListUnionValue
|
11013 11089 | #[::tokio::test]
|
11014 11090 | #[::tracing_test::traced_test]
|
11015 - | async fn parses_iso8601_timestamps_response() {
|
11016 - | let output = crate::output::KitchenSinkOperationOutput {
|
11017 - | iso8601_timestamp: ::std::option::Option::Some(
|
11018 - | ::aws_smithy_types::DateTime::from_fractional_secs(946845296, 0_f64),
|
11091 + | async fn aws_json11_serialize_list_union_value_request() {
|
11092 + | #[allow(unused_mut)]
|
11093 + | let mut http_request = ::http::Request::builder()
|
11094 + | .uri("/")
|
11095 + | .method("POST")
|
11096 + | .header("Content-Type", "application/x-amz-json-1.1")
|
11097 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
11098 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
11099 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
11100 + | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}"
|
11101 + | .as_bytes(),
|
11102 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11103 + | )),
|
11104 + | ))
|
11105 + | .unwrap();
|
11106 + | #[allow(unused_mut)]
|
11107 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
11108 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
11109 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
11110 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
11111 + | let sender = sender.clone();
|
11112 + | async move {
|
11113 + | let result = {
|
11114 + | let expected = crate::input::JsonUnionsInput {
|
11115 + | contents: ::std::option::Option::Some(
|
11116 + | crate::model::MyUnion::ListValue(vec![
|
11117 + | "foo".to_owned(),
|
11118 + | "bar".to_owned(),
|
11119 + | ]),
|
11019 11120 | ),
|
11020 - | blob: ::std::option::Option::None,
|
11021 - | boolean: ::std::option::Option::None,
|
11022 - | double: ::std::option::Option::None,
|
11023 - | empty_struct: ::std::option::Option::None,
|
11024 - | float: ::std::option::Option::None,
|
11025 - | httpdate_timestamp: ::std::option::Option::None,
|
11026 - | integer: ::std::option::Option::None,
|
11027 - | json_value: ::std::option::Option::None,
|
11028 - | list_of_lists: ::std::option::Option::None,
|
11029 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11030 - | list_of_strings: ::std::option::Option::None,
|
11031 - | list_of_structs: ::std::option::Option::None,
|
11032 - | long: ::std::option::Option::None,
|
11033 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11034 - | map_of_maps: ::std::option::Option::None,
|
11035 - | map_of_strings: ::std::option::Option::None,
|
11036 - | map_of_structs: ::std::option::Option::None,
|
11037 - | recursive_list: ::std::option::Option::None,
|
11038 - | recursive_map: ::std::option::Option::None,
|
11039 - | recursive_struct: ::std::option::Option::None,
|
11040 - | simple_struct: ::std::option::Option::None,
|
11041 - | string: ::std::option::Option::None,
|
11042 - | struct_with_json_name: ::std::option::Option::None,
|
11043 - | timestamp: ::std::option::Option::None,
|
11044 - | unix_timestamp: ::std::option::Option::None,
|
11045 11121 | };
|
11046 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11047 - | let http_response = output.into_response();
|
11048 - | ::pretty_assertions::assert_eq!(
|
11049 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11050 - | http_response.status()
|
11051 - | );
|
11052 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11053 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11054 - | http_response.headers(),
|
11055 - | expected_headers,
|
11056 - | ));
|
11057 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11122 + | ::pretty_assertions::assert_eq!(input, expected);
|
11123 + | let output = crate::output::JsonUnionsOutput {
|
11124 + | contents: ::std::option::Option::None,
|
11125 + | };
|
11126 + | Ok(output)
|
11127 + | };
|
11128 + | sender.send(()).await.expect("receiver dropped early");
|
11129 + | result
|
11130 + | }
|
11131 + | })
|
11132 + | .build_unchecked();
|
11133 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
11058 11134 | .await
|
11059 - | .expect("unable to extract body to bytes");
|
11060 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11061 - | &body,
|
11062 - | "{\"Iso8601Timestamp\":\"2000-01-02T20:34:56Z\"}",
|
11063 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11064 - | ));
|
11135 + | .expect("unable to make an HTTP request");
|
11136 + | assert!(
|
11137 + | receiver.recv().await.is_some(),
|
11138 + | "we expected operation handler to be invoked but it was not entered"
|
11139 + | );
|
11065 11140 | }
|
11066 11141 |
|
11067 - | /// Parses httpdate timestamps
|
11068 - | /// Test ID: parses_httpdate_timestamps
|
11142 + | /// Serializes a map union value
|
11143 + | /// Test ID: AwsJson11SerializeMapUnionValue
|
11069 11144 | #[::tokio::test]
|
11070 11145 | #[::tracing_test::traced_test]
|
11071 - | async fn parses_httpdate_timestamps_response() {
|
11072 - | let output = crate::output::KitchenSinkOperationOutput {
|
11073 - | httpdate_timestamp: ::std::option::Option::Some(
|
11074 - | ::aws_smithy_types::DateTime::from_fractional_secs(946845296, 0_f64),
|
11075 - | ),
|
11076 - | blob: ::std::option::Option::None,
|
11077 - | boolean: ::std::option::Option::None,
|
11078 - | double: ::std::option::Option::None,
|
11079 - | empty_struct: ::std::option::Option::None,
|
11080 - | float: ::std::option::Option::None,
|
11081 - | integer: ::std::option::Option::None,
|
11082 - | iso8601_timestamp: ::std::option::Option::None,
|
11083 - | json_value: ::std::option::Option::None,
|
11084 - | list_of_lists: ::std::option::Option::None,
|
11085 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11086 - | list_of_strings: ::std::option::Option::None,
|
11087 - | list_of_structs: ::std::option::Option::None,
|
11088 - | long: ::std::option::Option::None,
|
11089 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11090 - | map_of_maps: ::std::option::Option::None,
|
11091 - | map_of_strings: ::std::option::Option::None,
|
11092 - | map_of_structs: ::std::option::Option::None,
|
11093 - | recursive_list: ::std::option::Option::None,
|
11094 - | recursive_map: ::std::option::Option::None,
|
11095 - | recursive_struct: ::std::option::Option::None,
|
11096 - | simple_struct: ::std::option::Option::None,
|
11097 - | string: ::std::option::Option::None,
|
11098 - | struct_with_json_name: ::std::option::Option::None,
|
11099 - | timestamp: ::std::option::Option::None,
|
11100 - | unix_timestamp: ::std::option::Option::None,
|
11146 + | async fn aws_json11_serialize_map_union_value_request() {
|
11147 + | #[allow(unused_mut)]
|
11148 + | let mut http_request = ::http::Request::builder()
|
11149 + | .uri("/")
|
11150 + | .method("POST")
|
11151 + | .header("Content-Type", "application/x-amz-json-1.1")
|
11152 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
11153 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
11154 + | ::bytes::Bytes::copy_from_slice(
|
11155 + | &::aws_smithy_protocol_test::decode_body_data("{\n \"contents\": {\n \"mapValue\": {\n \"foo\": \"bar\",\n \"spam\": \"eggs\"\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11156 + | )
|
11157 + | )).unwrap();
|
11158 + | #[allow(unused_mut)]
|
11159 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
11160 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
11161 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
11162 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
11163 + | let sender = sender.clone();
|
11164 + | async move {
|
11165 + | let result = {
|
11166 + | let expected = crate::input::JsonUnionsInput {
|
11167 + | contents: ::std::option::Option::Some(crate::model::MyUnion::MapValue(
|
11168 + | {
|
11169 + | let mut ret = ::std::collections::HashMap::new();
|
11170 + | ret.insert("foo".to_owned(), "bar".to_owned());
|
11171 + | ret.insert("spam".to_owned(), "eggs".to_owned());
|
11172 + | ret
|
11173 + | },
|
11174 + | )),
|
11101 11175 | };
|
11102 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11103 - | let http_response = output.into_response();
|
11104 - | ::pretty_assertions::assert_eq!(
|
11105 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11106 - | http_response.status()
|
11107 - | );
|
11108 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11109 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11110 - | http_response.headers(),
|
11111 - | expected_headers,
|
11112 - | ));
|
11113 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11176 + | ::pretty_assertions::assert_eq!(input, expected);
|
11177 + | let output = crate::output::JsonUnionsOutput {
|
11178 + | contents: ::std::option::Option::None,
|
11179 + | };
|
11180 + | Ok(output)
|
11181 + | };
|
11182 + | sender.send(()).await.expect("receiver dropped early");
|
11183 + | result
|
11184 + | }
|
11185 + | })
|
11186 + | .build_unchecked();
|
11187 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
11114 11188 | .await
|
11115 - | .expect("unable to extract body to bytes");
|
11116 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11117 - | &body,
|
11118 - | "{\"HttpdateTimestamp\":\"Sun, 02 Jan 2000 20:34:56 GMT\"}",
|
11119 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11120 - | ));
|
11189 + | .expect("unable to make an HTTP request");
|
11190 + | assert!(
|
11191 + | receiver.recv().await.is_some(),
|
11192 + | "we expected operation handler to be invoked but it was not entered"
|
11193 + | );
|
11121 11194 | }
|
11122 11195 |
|
11123 - | /// Parses list shapes
|
11124 - | /// Test ID: parses_list_shapes
|
11196 + | /// Serializes a structure union value
|
11197 + | /// Test ID: AwsJson11SerializeStructureUnionValue
|
11125 11198 | #[::tokio::test]
|
11126 11199 | #[::tracing_test::traced_test]
|
11127 - | async fn parses_list_shapes_response() {
|
11128 - | let output = crate::output::KitchenSinkOperationOutput {
|
11129 - | list_of_strings: ::std::option::Option::Some(vec![
|
11130 - | "abc".to_owned(),
|
11131 - | "mno".to_owned(),
|
11132 - | "xyz".to_owned(),
|
11133 - | ]),
|
11134 - | blob: ::std::option::Option::None,
|
11135 - | boolean: ::std::option::Option::None,
|
11136 - | double: ::std::option::Option::None,
|
11137 - | empty_struct: ::std::option::Option::None,
|
11138 - | float: ::std::option::Option::None,
|
11139 - | httpdate_timestamp: ::std::option::Option::None,
|
11140 - | integer: ::std::option::Option::None,
|
11141 - | iso8601_timestamp: ::std::option::Option::None,
|
11142 - | json_value: ::std::option::Option::None,
|
11143 - | list_of_lists: ::std::option::Option::None,
|
11144 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11145 - | list_of_structs: ::std::option::Option::None,
|
11146 - | long: ::std::option::Option::None,
|
11147 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11148 - | map_of_maps: ::std::option::Option::None,
|
11149 - | map_of_strings: ::std::option::Option::None,
|
11150 - | map_of_structs: ::std::option::Option::None,
|
11151 - | recursive_list: ::std::option::Option::None,
|
11152 - | recursive_map: ::std::option::Option::None,
|
11153 - | recursive_struct: ::std::option::Option::None,
|
11154 - | simple_struct: ::std::option::Option::None,
|
11155 - | string: ::std::option::Option::None,
|
11156 - | struct_with_json_name: ::std::option::Option::None,
|
11157 - | timestamp: ::std::option::Option::None,
|
11158 - | unix_timestamp: ::std::option::Option::None,
|
11200 + | async fn aws_json11_serialize_structure_union_value_request() {
|
11201 + | #[allow(unused_mut)]
|
11202 + | let mut http_request = ::http::Request::builder()
|
11203 + | .uri("/")
|
11204 + | .method("POST")
|
11205 + | .header("Content-Type", "application/x-amz-json-1.1")
|
11206 + | .header("X-Amz-Target", "JsonProtocol.JsonUnions")
|
11207 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
11208 + | ::bytes::Bytes::copy_from_slice(
|
11209 + | &::aws_smithy_protocol_test::decode_body_data("{\n \"contents\": {\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11210 + | )
|
11211 + | )).unwrap();
|
11212 + | #[allow(unused_mut)]
|
11213 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
11214 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
11215 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
11216 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
11217 + | let sender = sender.clone();
|
11218 + | async move {
|
11219 + | let result = {
|
11220 + | let expected = crate::input::JsonUnionsInput {
|
11221 + | contents: ::std::option::Option::Some(
|
11222 + | crate::model::MyUnion::StructureValue(
|
11223 + | crate::model::GreetingStruct {
|
11224 + | hi: ::std::option::Option::Some("hello".to_owned()),
|
11225 + | },
|
11226 + | ),
|
11227 + | ),
|
11159 11228 | };
|
11160 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11161 - | let http_response = output.into_response();
|
11162 - | ::pretty_assertions::assert_eq!(
|
11163 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11164 - | http_response.status()
|
11165 - | );
|
11166 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11167 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11168 - | http_response.headers(),
|
11169 - | expected_headers,
|
11170 - | ));
|
11171 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11229 + | ::pretty_assertions::assert_eq!(input, expected);
|
11230 + | let output = crate::output::JsonUnionsOutput {
|
11231 + | contents: ::std::option::Option::None,
|
11232 + | };
|
11233 + | Ok(output)
|
11234 + | };
|
11235 + | sender.send(()).await.expect("receiver dropped early");
|
11236 + | result
|
11237 + | }
|
11238 + | })
|
11239 + | .build_unchecked();
|
11240 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
11172 11241 | .await
|
11173 - | .expect("unable to extract body to bytes");
|
11174 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11175 - | &body,
|
11176 - | "{\"ListOfStrings\":[\"abc\",\"mno\",\"xyz\"]}",
|
11177 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11178 - | ));
|
11242 + | .expect("unable to make an HTTP request");
|
11243 + | assert!(
|
11244 + | receiver.recv().await.is_some(),
|
11245 + | "we expected operation handler to be invoked but it was not entered"
|
11246 + | );
|
11179 11247 | }
|
11180 11248 |
|
11181 - | /// Parses list of map shapes
|
11182 - | /// Test ID: parses_list_of_map_shapes
|
11249 + | /// Deserializes a string union value
|
11250 + | /// Test ID: AwsJson11DeserializeStringUnionValue
|
11183 11251 | #[::tokio::test]
|
11184 11252 | #[::tracing_test::traced_test]
|
11185 - | async fn parses_list_of_map_shapes_response() {
|
11186 - | let output = crate::output::KitchenSinkOperationOutput {
|
11187 - | list_of_maps_of_strings: ::std::option::Option::Some(vec![
|
11188 - | {
|
11189 - | let mut ret = ::std::collections::HashMap::new();
|
11190 - | ret.insert("size".to_owned(), "large".to_owned());
|
11191 - | ret
|
11192 - | },
|
11193 - | {
|
11194 - | let mut ret = ::std::collections::HashMap::new();
|
11195 - | ret.insert("color".to_owned(), "red".to_owned());
|
11196 - | ret
|
11197 - | },
|
11198 - | ]),
|
11199 - | blob: ::std::option::Option::None,
|
11200 - | boolean: ::std::option::Option::None,
|
11201 - | double: ::std::option::Option::None,
|
11202 - | empty_struct: ::std::option::Option::None,
|
11203 - | float: ::std::option::Option::None,
|
11204 - | httpdate_timestamp: ::std::option::Option::None,
|
11205 - | integer: ::std::option::Option::None,
|
11206 - | iso8601_timestamp: ::std::option::Option::None,
|
11207 - | json_value: ::std::option::Option::None,
|
11208 - | list_of_lists: ::std::option::Option::None,
|
11209 - | list_of_strings: ::std::option::Option::None,
|
11210 - | list_of_structs: ::std::option::Option::None,
|
11211 - | long: ::std::option::Option::None,
|
11212 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11213 - | map_of_maps: ::std::option::Option::None,
|
11214 - | map_of_strings: ::std::option::Option::None,
|
11215 - | map_of_structs: ::std::option::Option::None,
|
11216 - | recursive_list: ::std::option::Option::None,
|
11217 - | recursive_map: ::std::option::Option::None,
|
11218 - | recursive_struct: ::std::option::Option::None,
|
11219 - | simple_struct: ::std::option::Option::None,
|
11220 - | string: ::std::option::Option::None,
|
11221 - | struct_with_json_name: ::std::option::Option::None,
|
11222 - | timestamp: ::std::option::Option::None,
|
11223 - | unix_timestamp: ::std::option::Option::None,
|
11253 + | async fn aws_json11_deserialize_string_union_value_response() {
|
11254 + | let output = crate::output::JsonUnionsOutput {
|
11255 + | contents: ::std::option::Option::Some(crate::model::MyUnion::StringValue(
|
11256 + | "foo".to_owned(),
|
11257 + | )),
|
11224 11258 | };
|
11225 11259 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11226 11260 | let http_response = output.into_response();
|
11227 11261 | ::pretty_assertions::assert_eq!(
|
11228 11262 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11229 11263 | http_response.status()
|
11230 11264 | );
|
11231 11265 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11232 11266 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11233 11267 | http_response.headers(),
|
11234 11268 | expected_headers,
|
11235 11269 | ));
|
11236 11270 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11237 11271 | .await
|
11238 11272 | .expect("unable to extract body to bytes");
|
11239 11273 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11240 11274 | &body,
|
11241 - | "{\"ListOfMapsOfStrings\":[{\"size\":\"large\"},{\"color\":\"red\"}]}",
|
11275 + | "{\n \"contents\": {\n \"stringValue\": \"foo\"\n }\n}",
|
11242 11276 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11243 11277 | ));
|
11244 11278 | }
|
11245 11279 |
|
11246 - | /// Parses list of list shapes
|
11247 - | /// Test ID: parses_list_of_list_shapes
|
11280 + | /// Deserializes a boolean union value
|
11281 + | /// Test ID: AwsJson11DeserializeBooleanUnionValue
|
11248 11282 | #[::tokio::test]
|
11249 11283 | #[::tracing_test::traced_test]
|
11250 - | async fn parses_list_of_list_shapes_response() {
|
11251 - | let output = crate::output::KitchenSinkOperationOutput {
|
11252 - | list_of_lists: ::std::option::Option::Some(vec![
|
11253 - | vec!["abc".to_owned(), "mno".to_owned(), "xyz".to_owned()],
|
11254 - | vec!["hjk".to_owned(), "qrs".to_owned(), "tuv".to_owned()],
|
11255 - | ]),
|
11256 - | blob: ::std::option::Option::None,
|
11257 - | boolean: ::std::option::Option::None,
|
11258 - | double: ::std::option::Option::None,
|
11259 - | empty_struct: ::std::option::Option::None,
|
11260 - | float: ::std::option::Option::None,
|
11261 - | httpdate_timestamp: ::std::option::Option::None,
|
11262 - | integer: ::std::option::Option::None,
|
11263 - | iso8601_timestamp: ::std::option::Option::None,
|
11264 - | json_value: ::std::option::Option::None,
|
11265 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11266 - | list_of_strings: ::std::option::Option::None,
|
11267 - | list_of_structs: ::std::option::Option::None,
|
11268 - | long: ::std::option::Option::None,
|
11269 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11270 - | map_of_maps: ::std::option::Option::None,
|
11271 - | map_of_strings: ::std::option::Option::None,
|
11272 - | map_of_structs: ::std::option::Option::None,
|
11273 - | recursive_list: ::std::option::Option::None,
|
11274 - | recursive_map: ::std::option::Option::None,
|
11275 - | recursive_struct: ::std::option::Option::None,
|
11276 - | simple_struct: ::std::option::Option::None,
|
11277 - | string: ::std::option::Option::None,
|
11278 - | struct_with_json_name: ::std::option::Option::None,
|
11279 - | timestamp: ::std::option::Option::None,
|
11280 - | unix_timestamp: ::std::option::Option::None,
|
11284 + | async fn aws_json11_deserialize_boolean_union_value_response() {
|
11285 + | let output = crate::output::JsonUnionsOutput {
|
11286 + | contents: ::std::option::Option::Some(crate::model::MyUnion::BooleanValue(true)),
|
11281 11287 | };
|
11282 11288 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11283 11289 | let http_response = output.into_response();
|
11284 11290 | ::pretty_assertions::assert_eq!(
|
11285 11291 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11286 11292 | http_response.status()
|
11287 11293 | );
|
11288 11294 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11289 11295 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11290 11296 | http_response.headers(),
|
11291 11297 | expected_headers,
|
11292 11298 | ));
|
11293 11299 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11294 11300 | .await
|
11295 11301 | .expect("unable to extract body to bytes");
|
11296 11302 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11297 11303 | &body,
|
11298 - | "{\"ListOfLists\":[[\"abc\",\"mno\",\"xyz\"],[\"hjk\",\"qrs\",\"tuv\"]]}",
|
11304 + | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}",
|
11299 11305 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11300 11306 | ));
|
11301 11307 | }
|
11302 11308 |
|
11303 - | /// Parses list of structure shapes
|
11304 - | /// Test ID: parses_list_of_structure_shapes
|
11309 + | /// Deserializes a number union value
|
11310 + | /// Test ID: AwsJson11DeserializeNumberUnionValue
|
11305 11311 | #[::tokio::test]
|
11306 11312 | #[::tracing_test::traced_test]
|
11307 - | async fn parses_list_of_structure_shapes_response() {
|
11308 - | let output = crate::output::KitchenSinkOperationOutput {
|
11309 - | list_of_structs: ::std::option::Option::Some(vec![
|
11310 - | crate::model::SimpleStruct {
|
11311 - | value: ::std::option::Option::Some("value-1".to_owned()),
|
11312 - | },
|
11313 - | crate::model::SimpleStruct {
|
11314 - | value: ::std::option::Option::Some("value-2".to_owned()),
|
11315 - | },
|
11316 - | ]),
|
11317 - | blob: ::std::option::Option::None,
|
11318 - | boolean: ::std::option::Option::None,
|
11319 - | double: ::std::option::Option::None,
|
11320 - | empty_struct: ::std::option::Option::None,
|
11321 - | float: ::std::option::Option::None,
|
11322 - | httpdate_timestamp: ::std::option::Option::None,
|
11323 - | integer: ::std::option::Option::None,
|
11324 - | iso8601_timestamp: ::std::option::Option::None,
|
11325 - | json_value: ::std::option::Option::None,
|
11326 - | list_of_lists: ::std::option::Option::None,
|
11327 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11328 - | list_of_strings: ::std::option::Option::None,
|
11329 - | long: ::std::option::Option::None,
|
11330 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11331 - | map_of_maps: ::std::option::Option::None,
|
11332 - | map_of_strings: ::std::option::Option::None,
|
11333 - | map_of_structs: ::std::option::Option::None,
|
11334 - | recursive_list: ::std::option::Option::None,
|
11335 - | recursive_map: ::std::option::Option::None,
|
11336 - | recursive_struct: ::std::option::Option::None,
|
11337 - | simple_struct: ::std::option::Option::None,
|
11338 - | string: ::std::option::Option::None,
|
11339 - | struct_with_json_name: ::std::option::Option::None,
|
11340 - | timestamp: ::std::option::Option::None,
|
11341 - | unix_timestamp: ::std::option::Option::None,
|
11313 + | async fn aws_json11_deserialize_number_union_value_response() {
|
11314 + | let output = crate::output::JsonUnionsOutput {
|
11315 + | contents: ::std::option::Option::Some(crate::model::MyUnion::NumberValue(1)),
|
11342 11316 | };
|
11343 11317 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11344 11318 | let http_response = output.into_response();
|
11345 11319 | ::pretty_assertions::assert_eq!(
|
11346 11320 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11347 11321 | http_response.status()
|
11348 11322 | );
|
11349 11323 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11350 11324 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11351 11325 | http_response.headers(),
|
11352 11326 | expected_headers,
|
11353 11327 | ));
|
11354 11328 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11355 - | .await
|
11356 - | .expect("unable to extract body to bytes");
|
11357 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11358 - | &body,
|
11359 - | "{\"ListOfStructs\":[{\"Value\":\"value-1\"},{\"Value\":\"value-2\"}]}",
|
11360 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11361 - | ));
|
11362 - | }
|
11363 - |
|
11364 - | /// Parses list of recursive structure shapes
|
11365 - | /// Test ID: parses_list_of_recursive_structure_shapes
|
11366 - | #[::tokio::test]
|
11367 - | #[::tracing_test::traced_test]
|
11368 - | async fn parses_list_of_recursive_structure_shapes_response() {
|
11369 - | let output = crate::output::KitchenSinkOperationOutput {
|
11370 - | recursive_list: ::std::option::Option::Some(vec![crate::model::KitchenSink {
|
11371 - | recursive_list: ::std::option::Option::Some(vec![crate::model::KitchenSink {
|
11372 - | recursive_list: ::std::option::Option::Some(vec![crate::model::KitchenSink {
|
11373 - | string: ::std::option::Option::Some("value".to_owned()),
|
11374 - | blob: ::std::option::Option::None,
|
11375 - | boolean: ::std::option::Option::None,
|
11376 - | double: ::std::option::Option::None,
|
11377 - | empty_struct: ::std::option::Option::None,
|
11378 - | float: ::std::option::Option::None,
|
11379 - | httpdate_timestamp: ::std::option::Option::None,
|
11380 - | integer: ::std::option::Option::None,
|
11381 - | iso8601_timestamp: ::std::option::Option::None,
|
11382 - | json_value: ::std::option::Option::None,
|
11383 - | list_of_lists: ::std::option::Option::None,
|
11384 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11385 - | list_of_strings: ::std::option::Option::None,
|
11386 - | list_of_structs: ::std::option::Option::None,
|
11387 - | long: ::std::option::Option::None,
|
11388 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11389 - | map_of_maps: ::std::option::Option::None,
|
11390 - | map_of_strings: ::std::option::Option::None,
|
11391 - | map_of_structs: ::std::option::Option::None,
|
11392 - | recursive_list: ::std::option::Option::None,
|
11393 - | recursive_map: ::std::option::Option::None,
|
11394 - | recursive_struct: ::std::option::Option::None,
|
11395 - | simple_struct: ::std::option::Option::None,
|
11396 - | struct_with_json_name: ::std::option::Option::None,
|
11397 - | timestamp: ::std::option::Option::None,
|
11398 - | unix_timestamp: ::std::option::Option::None,
|
11399 - | }]),
|
11400 - | blob: ::std::option::Option::None,
|
11401 - | boolean: ::std::option::Option::None,
|
11402 - | double: ::std::option::Option::None,
|
11403 - | empty_struct: ::std::option::Option::None,
|
11404 - | float: ::std::option::Option::None,
|
11405 - | httpdate_timestamp: ::std::option::Option::None,
|
11406 - | integer: ::std::option::Option::None,
|
11407 - | iso8601_timestamp: ::std::option::Option::None,
|
11408 - | json_value: ::std::option::Option::None,
|
11409 - | list_of_lists: ::std::option::Option::None,
|
11410 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11411 - | list_of_strings: ::std::option::Option::None,
|
11412 - | list_of_structs: ::std::option::Option::None,
|
11413 - | long: ::std::option::Option::None,
|
11414 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11415 - | map_of_maps: ::std::option::Option::None,
|
11416 - | map_of_strings: ::std::option::Option::None,
|
11417 - | map_of_structs: ::std::option::Option::None,
|
11418 - | recursive_map: ::std::option::Option::None,
|
11419 - | recursive_struct: ::std::option::Option::None,
|
11420 - | simple_struct: ::std::option::Option::None,
|
11421 - | string: ::std::option::Option::None,
|
11422 - | struct_with_json_name: ::std::option::Option::None,
|
11423 - | timestamp: ::std::option::Option::None,
|
11424 - | unix_timestamp: ::std::option::Option::None,
|
11425 - | }]),
|
11426 - | blob: ::std::option::Option::None,
|
11427 - | boolean: ::std::option::Option::None,
|
11428 - | double: ::std::option::Option::None,
|
11429 - | empty_struct: ::std::option::Option::None,
|
11430 - | float: ::std::option::Option::None,
|
11431 - | httpdate_timestamp: ::std::option::Option::None,
|
11432 - | integer: ::std::option::Option::None,
|
11433 - | iso8601_timestamp: ::std::option::Option::None,
|
11434 - | json_value: ::std::option::Option::None,
|
11435 - | list_of_lists: ::std::option::Option::None,
|
11436 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11437 - | list_of_strings: ::std::option::Option::None,
|
11438 - | list_of_structs: ::std::option::Option::None,
|
11439 - | long: ::std::option::Option::None,
|
11440 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11441 - | map_of_maps: ::std::option::Option::None,
|
11442 - | map_of_strings: ::std::option::Option::None,
|
11443 - | map_of_structs: ::std::option::Option::None,
|
11444 - | recursive_map: ::std::option::Option::None,
|
11445 - | recursive_struct: ::std::option::Option::None,
|
11446 - | simple_struct: ::std::option::Option::None,
|
11447 - | string: ::std::option::Option::None,
|
11448 - | struct_with_json_name: ::std::option::Option::None,
|
11449 - | timestamp: ::std::option::Option::None,
|
11450 - | unix_timestamp: ::std::option::Option::None,
|
11451 - | }]),
|
11452 - | blob: ::std::option::Option::None,
|
11453 - | boolean: ::std::option::Option::None,
|
11454 - | double: ::std::option::Option::None,
|
11455 - | empty_struct: ::std::option::Option::None,
|
11456 - | float: ::std::option::Option::None,
|
11457 - | httpdate_timestamp: ::std::option::Option::None,
|
11458 - | integer: ::std::option::Option::None,
|
11459 - | iso8601_timestamp: ::std::option::Option::None,
|
11460 - | json_value: ::std::option::Option::None,
|
11461 - | list_of_lists: ::std::option::Option::None,
|
11462 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11463 - | list_of_strings: ::std::option::Option::None,
|
11464 - | list_of_structs: ::std::option::Option::None,
|
11465 - | long: ::std::option::Option::None,
|
11466 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11467 - | map_of_maps: ::std::option::Option::None,
|
11468 - | map_of_strings: ::std::option::Option::None,
|
11469 - | map_of_structs: ::std::option::Option::None,
|
11470 - | recursive_map: ::std::option::Option::None,
|
11471 - | recursive_struct: ::std::option::Option::None,
|
11472 - | simple_struct: ::std::option::Option::None,
|
11473 - | string: ::std::option::Option::None,
|
11474 - | struct_with_json_name: ::std::option::Option::None,
|
11475 - | timestamp: ::std::option::Option::None,
|
11476 - | unix_timestamp: ::std::option::Option::None,
|
11329 + | .await
|
11330 + | .expect("unable to extract body to bytes");
|
11331 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11332 + | &body,
|
11333 + | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}",
|
11334 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11335 + | ));
|
11336 + | }
|
11337 + |
|
11338 + | /// Deserializes a blob union value
|
11339 + | /// Test ID: AwsJson11DeserializeBlobUnionValue
|
11340 + | #[::tokio::test]
|
11341 + | #[::tracing_test::traced_test]
|
11342 + | async fn aws_json11_deserialize_blob_union_value_response() {
|
11343 + | let output = crate::output::JsonUnionsOutput {
|
11344 + | contents: ::std::option::Option::Some(crate::model::MyUnion::BlobValue(
|
11345 + | ::aws_smithy_types::Blob::new("foo"),
|
11346 + | )),
|
11477 11347 | };
|
11478 11348 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11479 11349 | let http_response = output.into_response();
|
11480 11350 | ::pretty_assertions::assert_eq!(
|
11481 11351 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11482 11352 | http_response.status()
|
11483 11353 | );
|
11484 11354 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11485 11355 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11486 11356 | http_response.headers(),
|
11487 11357 | expected_headers,
|
11488 11358 | ));
|
11489 11359 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11490 11360 | .await
|
11491 11361 | .expect("unable to extract body to bytes");
|
11492 - | ::aws_smithy_protocol_test::assert_ok(
|
11493 - | ::aws_smithy_protocol_test::validate_body(&body, "{\"RecursiveList\":[{\"RecursiveList\":[{\"RecursiveList\":[{\"String\":\"value\"}]}]}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11494 - | );
|
11362 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11363 + | &body,
|
11364 + | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}",
|
11365 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11366 + | ));
|
11495 11367 | }
|
11496 11368 |
|
11497 - | /// Parses map shapes
|
11498 - | /// Test ID: parses_map_shapes
|
11369 + | /// Deserializes a timestamp union value
|
11370 + | /// Test ID: AwsJson11DeserializeTimestampUnionValue
|
11499 11371 | #[::tokio::test]
|
11500 11372 | #[::tracing_test::traced_test]
|
11501 - | async fn parses_map_shapes_response() {
|
11502 - | let output = crate::output::KitchenSinkOperationOutput {
|
11503 - | map_of_strings: ::std::option::Option::Some({
|
11504 - | let mut ret = ::std::collections::HashMap::new();
|
11505 - | ret.insert("size".to_owned(), "large".to_owned());
|
11506 - | ret.insert("color".to_owned(), "red".to_owned());
|
11507 - | ret
|
11508 - | }),
|
11509 - | blob: ::std::option::Option::None,
|
11510 - | boolean: ::std::option::Option::None,
|
11511 - | double: ::std::option::Option::None,
|
11512 - | empty_struct: ::std::option::Option::None,
|
11513 - | float: ::std::option::Option::None,
|
11514 - | httpdate_timestamp: ::std::option::Option::None,
|
11515 - | integer: ::std::option::Option::None,
|
11516 - | iso8601_timestamp: ::std::option::Option::None,
|
11517 - | json_value: ::std::option::Option::None,
|
11518 - | list_of_lists: ::std::option::Option::None,
|
11519 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11520 - | list_of_strings: ::std::option::Option::None,
|
11521 - | list_of_structs: ::std::option::Option::None,
|
11522 - | long: ::std::option::Option::None,
|
11523 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11524 - | map_of_maps: ::std::option::Option::None,
|
11525 - | map_of_structs: ::std::option::Option::None,
|
11526 - | recursive_list: ::std::option::Option::None,
|
11527 - | recursive_map: ::std::option::Option::None,
|
11528 - | recursive_struct: ::std::option::Option::None,
|
11529 - | simple_struct: ::std::option::Option::None,
|
11530 - | string: ::std::option::Option::None,
|
11531 - | struct_with_json_name: ::std::option::Option::None,
|
11532 - | timestamp: ::std::option::Option::None,
|
11533 - | unix_timestamp: ::std::option::Option::None,
|
11373 + | async fn aws_json11_deserialize_timestamp_union_value_response() {
|
11374 + | let output = crate::output::JsonUnionsOutput {
|
11375 + | contents: ::std::option::Option::Some(crate::model::MyUnion::TimestampValue(
|
11376 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
11377 + | )),
|
11534 11378 | };
|
11535 11379 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11536 11380 | let http_response = output.into_response();
|
11537 11381 | ::pretty_assertions::assert_eq!(
|
11538 11382 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11539 11383 | http_response.status()
|
11540 11384 | );
|
11541 11385 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11542 11386 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11543 11387 | http_response.headers(),
|
11544 11388 | expected_headers,
|
11545 11389 | ));
|
11546 11390 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11547 11391 | .await
|
11548 11392 | .expect("unable to extract body to bytes");
|
11549 11393 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11550 11394 | &body,
|
11551 - | "{\"MapOfStrings\":{\"size\":\"large\",\"color\":\"red\"}}",
|
11395 + | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}",
|
11552 11396 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11553 11397 | ));
|
11554 11398 | }
|
11555 11399 |
|
11556 - | /// Parses map of list shapes
|
11557 - | /// Test ID: parses_map_of_list_shapes
|
11400 + | /// Deserializes an enum union value
|
11401 + | /// Test ID: AwsJson11DeserializeEnumUnionValue
|
11558 11402 | #[::tokio::test]
|
11559 11403 | #[::tracing_test::traced_test]
|
11560 - | async fn parses_map_of_list_shapes_response() {
|
11561 - | let output = crate::output::KitchenSinkOperationOutput {
|
11562 - | map_of_lists_of_strings: ::std::option::Option::Some({
|
11563 - | let mut ret = ::std::collections::HashMap::new();
|
11564 - | ret.insert(
|
11565 - | "sizes".to_owned(),
|
11566 - | vec!["large".to_owned(), "small".to_owned()],
|
11567 - | );
|
11568 - | ret.insert(
|
11569 - | "colors".to_owned(),
|
11570 - | vec!["red".to_owned(), "green".to_owned()],
|
11571 - | );
|
11572 - | ret
|
11573 - | }),
|
11574 - | blob: ::std::option::Option::None,
|
11575 - | boolean: ::std::option::Option::None,
|
11576 - | double: ::std::option::Option::None,
|
11577 - | empty_struct: ::std::option::Option::None,
|
11578 - | float: ::std::option::Option::None,
|
11579 - | httpdate_timestamp: ::std::option::Option::None,
|
11580 - | integer: ::std::option::Option::None,
|
11581 - | iso8601_timestamp: ::std::option::Option::None,
|
11582 - | json_value: ::std::option::Option::None,
|
11583 - | list_of_lists: ::std::option::Option::None,
|
11584 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11585 - | list_of_strings: ::std::option::Option::None,
|
11586 - | list_of_structs: ::std::option::Option::None,
|
11587 - | long: ::std::option::Option::None,
|
11588 - | map_of_maps: ::std::option::Option::None,
|
11589 - | map_of_strings: ::std::option::Option::None,
|
11590 - | map_of_structs: ::std::option::Option::None,
|
11591 - | recursive_list: ::std::option::Option::None,
|
11592 - | recursive_map: ::std::option::Option::None,
|
11593 - | recursive_struct: ::std::option::Option::None,
|
11594 - | simple_struct: ::std::option::Option::None,
|
11595 - | string: ::std::option::Option::None,
|
11596 - | struct_with_json_name: ::std::option::Option::None,
|
11597 - | timestamp: ::std::option::Option::None,
|
11598 - | unix_timestamp: ::std::option::Option::None,
|
11404 + | async fn aws_json11_deserialize_enum_union_value_response() {
|
11405 + | let output = crate::output::JsonUnionsOutput {
|
11406 + | contents: ::std::option::Option::Some(crate::model::MyUnion::EnumValue(
|
11407 + | "Foo"
|
11408 + | .parse::<crate::model::FooEnum>()
|
11409 + | .expect("static value validated to member"),
|
11410 + | )),
|
11599 11411 | };
|
11600 11412 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11601 11413 | let http_response = output.into_response();
|
11602 11414 | ::pretty_assertions::assert_eq!(
|
11603 11415 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11604 11416 | http_response.status()
|
11605 11417 | );
|
11606 11418 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11607 11419 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11608 11420 | http_response.headers(),
|
11609 11421 | expected_headers,
|
11610 11422 | ));
|
11611 11423 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11612 11424 | .await
|
11613 11425 | .expect("unable to extract body to bytes");
|
11614 - | ::aws_smithy_protocol_test::assert_ok(
|
11615 - | ::aws_smithy_protocol_test::validate_body(&body, "{\"MapOfListsOfStrings\":{\"sizes\":[\"large\",\"small\"],\"colors\":[\"red\",\"green\"]}}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11616 - | );
|
11426 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11427 + | &body,
|
11428 + | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}",
|
11429 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11430 + | ));
|
11617 11431 | }
|
11618 11432 |
|
11619 - | /// Parses map of map shapes
|
11620 - | /// Test ID: parses_map_of_map_shapes
|
11433 + | /// Deserializes a list union value
|
11434 + | /// Test ID: AwsJson11DeserializeListUnionValue
|
11621 11435 | #[::tokio::test]
|
11622 11436 | #[::tracing_test::traced_test]
|
11623 - | async fn parses_map_of_map_shapes_response() {
|
11624 - | let output = crate::output::KitchenSinkOperationOutput {
|
11625 - | map_of_maps: ::std::option::Option::Some({
|
11626 - | let mut ret = ::std::collections::HashMap::new();
|
11627 - | ret.insert("sizes".to_owned(), {
|
11628 - | let mut ret = ::std::collections::HashMap::new();
|
11629 - | ret.insert("large".to_owned(), "L".to_owned());
|
11630 - | ret.insert("medium".to_owned(), "M".to_owned());
|
11631 - | ret
|
11632 - | });
|
11633 - | ret.insert("colors".to_owned(), {
|
11634 - | let mut ret = ::std::collections::HashMap::new();
|
11635 - | ret.insert("red".to_owned(), "R".to_owned());
|
11636 - | ret.insert("blue".to_owned(), "B".to_owned());
|
11637 - | ret
|
11638 - | });
|
11639 - | ret
|
11640 - | }),
|
11641 - | blob: ::std::option::Option::None,
|
11642 - | boolean: ::std::option::Option::None,
|
11643 - | double: ::std::option::Option::None,
|
11644 - | empty_struct: ::std::option::Option::None,
|
11645 - | float: ::std::option::Option::None,
|
11646 - | httpdate_timestamp: ::std::option::Option::None,
|
11647 - | integer: ::std::option::Option::None,
|
11648 - | iso8601_timestamp: ::std::option::Option::None,
|
11649 - | json_value: ::std::option::Option::None,
|
11650 - | list_of_lists: ::std::option::Option::None,
|
11651 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11652 - | list_of_strings: ::std::option::Option::None,
|
11653 - | list_of_structs: ::std::option::Option::None,
|
11654 - | long: ::std::option::Option::None,
|
11655 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11656 - | map_of_strings: ::std::option::Option::None,
|
11657 - | map_of_structs: ::std::option::Option::None,
|
11658 - | recursive_list: ::std::option::Option::None,
|
11659 - | recursive_map: ::std::option::Option::None,
|
11660 - | recursive_struct: ::std::option::Option::None,
|
11661 - | simple_struct: ::std::option::Option::None,
|
11662 - | string: ::std::option::Option::None,
|
11663 - | struct_with_json_name: ::std::option::Option::None,
|
11664 - | timestamp: ::std::option::Option::None,
|
11665 - | unix_timestamp: ::std::option::Option::None,
|
11437 + | async fn aws_json11_deserialize_list_union_value_response() {
|
11438 + | let output = crate::output::JsonUnionsOutput {
|
11439 + | contents: ::std::option::Option::Some(crate::model::MyUnion::ListValue(vec![
|
11440 + | "foo".to_owned(),
|
11441 + | "bar".to_owned(),
|
11442 + | ])),
|
11666 11443 | };
|
11667 11444 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11668 11445 | let http_response = output.into_response();
|
11669 11446 | ::pretty_assertions::assert_eq!(
|
11670 11447 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11671 11448 | http_response.status()
|
11672 11449 | );
|
11673 11450 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11674 11451 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11675 11452 | http_response.headers(),
|
11676 11453 | expected_headers,
|
11677 11454 | ));
|
11678 11455 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11679 11456 | .await
|
11680 11457 | .expect("unable to extract body to bytes");
|
11681 - | ::aws_smithy_protocol_test::assert_ok(
|
11682 - | ::aws_smithy_protocol_test::validate_body(&body, "{\"MapOfMaps\":{\"sizes\":{\"large\":\"L\",\"medium\":\"M\"},\"colors\":{\"red\":\"R\",\"blue\":\"B\"}}}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11683 - | );
|
11458 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11459 + | &body,
|
11460 + | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}",
|
11461 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11462 + | ));
|
11684 11463 | }
|
11685 11464 |
|
11686 - | /// Parses map of structure shapes
|
11687 - | /// Test ID: parses_map_of_structure_shapes
|
11465 + | /// Deserializes a map union value
|
11466 + | /// Test ID: AwsJson11DeserializeMapUnionValue
|
11688 11467 | #[::tokio::test]
|
11689 11468 | #[::tracing_test::traced_test]
|
11690 - | async fn parses_map_of_structure_shapes_response() {
|
11691 - | let output = crate::output::KitchenSinkOperationOutput {
|
11692 - | map_of_structs: ::std::option::Option::Some({
|
11469 + | async fn aws_json11_deserialize_map_union_value_response() {
|
11470 + | let output = crate::output::JsonUnionsOutput {
|
11471 + | contents: ::std::option::Option::Some(crate::model::MyUnion::MapValue({
|
11693 11472 | let mut ret = ::std::collections::HashMap::new();
|
11694 - | ret.insert(
|
11695 - | "size".to_owned(),
|
11696 - | crate::model::SimpleStruct {
|
11697 - | value: ::std::option::Option::Some("small".to_owned()),
|
11698 - | },
|
11699 - | );
|
11700 - | ret.insert(
|
11701 - | "color".to_owned(),
|
11702 - | crate::model::SimpleStruct {
|
11703 - | value: ::std::option::Option::Some("red".to_owned()),
|
11704 - | },
|
11705 - | );
|
11473 + | ret.insert("foo".to_owned(), "bar".to_owned());
|
11474 + | ret.insert("spam".to_owned(), "eggs".to_owned());
|
11706 11475 | ret
|
11707 - | }),
|
11708 - | blob: ::std::option::Option::None,
|
11709 - | boolean: ::std::option::Option::None,
|
11710 - | double: ::std::option::Option::None,
|
11711 - | empty_struct: ::std::option::Option::None,
|
11712 - | float: ::std::option::Option::None,
|
11713 - | httpdate_timestamp: ::std::option::Option::None,
|
11714 - | integer: ::std::option::Option::None,
|
11715 - | iso8601_timestamp: ::std::option::Option::None,
|
11716 - | json_value: ::std::option::Option::None,
|
11717 - | list_of_lists: ::std::option::Option::None,
|
11718 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11719 - | list_of_strings: ::std::option::Option::None,
|
11720 - | list_of_structs: ::std::option::Option::None,
|
11721 - | long: ::std::option::Option::None,
|
11722 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11723 - | map_of_maps: ::std::option::Option::None,
|
11724 - | map_of_strings: ::std::option::Option::None,
|
11725 - | recursive_list: ::std::option::Option::None,
|
11726 - | recursive_map: ::std::option::Option::None,
|
11727 - | recursive_struct: ::std::option::Option::None,
|
11728 - | simple_struct: ::std::option::Option::None,
|
11729 - | string: ::std::option::Option::None,
|
11730 - | struct_with_json_name: ::std::option::Option::None,
|
11731 - | timestamp: ::std::option::Option::None,
|
11732 - | unix_timestamp: ::std::option::Option::None,
|
11476 + | })),
|
11477 + | };
|
11478 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11479 + | let http_response = output.into_response();
|
11480 + | ::pretty_assertions::assert_eq!(
|
11481 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11482 + | http_response.status()
|
11483 + | );
|
11484 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11485 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11486 + | http_response.headers(),
|
11487 + | expected_headers,
|
11488 + | ));
|
11489 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11490 + | .await
|
11491 + | .expect("unable to extract body to bytes");
|
11492 + | ::aws_smithy_protocol_test::assert_ok(
|
11493 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"contents\": {\n \"mapValue\": {\n \"foo\": \"bar\",\n \"spam\": \"eggs\"\n }\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11494 + | );
|
11495 + | }
|
11496 + |
|
11497 + | /// Deserializes a structure union value
|
11498 + | /// Test ID: AwsJson11DeserializeStructureUnionValue
|
11499 + | #[::tokio::test]
|
11500 + | #[::tracing_test::traced_test]
|
11501 + | async fn aws_json11_deserialize_structure_union_value_response() {
|
11502 + | let output = crate::output::JsonUnionsOutput {
|
11503 + | contents: ::std::option::Option::Some(crate::model::MyUnion::StructureValue(
|
11504 + | crate::model::GreetingStruct {
|
11505 + | hi: ::std::option::Option::Some("hello".to_owned()),
|
11506 + | },
|
11507 + | )),
|
11733 11508 | };
|
11734 11509 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11735 11510 | let http_response = output.into_response();
|
11736 11511 | ::pretty_assertions::assert_eq!(
|
11737 11512 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11738 11513 | http_response.status()
|
11739 11514 | );
|
11740 11515 | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11741 11516 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11742 11517 | http_response.headers(),
|
11743 11518 | expected_headers,
|
11744 11519 | ));
|
11745 11520 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11746 11521 | .await
|
11747 11522 | .expect("unable to extract body to bytes");
|
11748 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11749 - | &body,
|
11750 - | "{\"MapOfStructs\":{\"size\":{\"Value\":\"small\"},\"color\":{\"Value\":\"red\"}}}",
|
11751 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11752 - | ));
|
11523 + | ::aws_smithy_protocol_test::assert_ok(
|
11524 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"contents\": {\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11525 + | );
|
11526 + | }
|
11527 + | }
|
11528 + |
|
11529 + | ::pin_project_lite::pin_project! {
|
11530 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
11531 + | /// [`EndpointOperationInput`](crate::input::EndpointOperationInput) using modelled bindings.
|
11532 + | pub struct EndpointOperationInputFuture {
|
11533 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EndpointOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
11534 + | }
|
11535 + | }
|
11536 + |
|
11537 + | impl std::future::Future for EndpointOperationInputFuture {
|
11538 + | type Output = Result<
|
11539 + | crate::input::EndpointOperationInput,
|
11540 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
11541 + | >;
|
11542 + |
|
11543 + | fn poll(
|
11544 + | self: std::pin::Pin<&mut Self>,
|
11545 + | cx: &mut std::task::Context<'_>,
|
11546 + | ) -> std::task::Poll<Self::Output> {
|
11547 + | let this = self.project();
|
11548 + | this.inner.as_mut().poll(cx)
|
11549 + | }
|
11550 + | }
|
11551 + |
|
11552 + | impl<B>
|
11553 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
11554 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11555 + | B,
|
11556 + | > for crate::input::EndpointOperationInput
|
11557 + | where
|
11558 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11559 + | B: 'static,
|
11560 + |
|
11561 + | B::Data: Send,
|
11562 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
11563 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
11564 + | {
|
11565 + | type Rejection =
|
11566 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
11567 + | type Future = EndpointOperationInputFuture;
|
11568 + |
|
11569 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
11570 + | let fut = async move {
|
11571 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
11572 + | request.headers(),
|
11573 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
11574 + | ) {
|
11575 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
11576 + | }
|
11577 + | crate::protocol_serde::shape_endpoint_operation::de_endpoint_operation_http_request(
|
11578 + | request,
|
11579 + | )
|
11580 + | .await
|
11581 + | };
|
11582 + | use ::futures_util::future::TryFutureExt;
|
11583 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
11584 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
11585 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
11586 + | });
|
11587 + | EndpointOperationInputFuture {
|
11588 + | inner: Box::pin(fut),
|
11589 + | }
|
11590 + | }
|
11591 + | }
|
11592 + | impl
|
11593 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
11594 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11595 + | > for crate::output::EndpointOperationOutput
|
11596 + | {
|
11597 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
11598 + | match crate::protocol_serde::shape_endpoint_operation::ser_endpoint_operation_http_response(
|
11599 + | self,
|
11600 + | ) {
|
11601 + | Ok(response) => response,
|
11602 + | Err(e) => {
|
11603 + | ::tracing::error!(error = %e, "failed to serialize response");
|
11604 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
11605 + | }
|
11606 + | }
|
11607 + | }
|
11608 + | }
|
11609 + |
|
11610 + | #[allow(unreachable_code, unused_variables)]
|
11611 + | #[cfg(test)]
|
11612 + | mod endpoint_operation_test {
|
11613 + |
|
11614 + | /// Operations can prepend to the given host if they define the
|
11615 + | /// endpoint trait.
|
11616 + | /// Test ID: AwsJson11EndpointTrait
|
11617 + | #[::tokio::test]
|
11618 + | #[::tracing_test::traced_test]
|
11619 + | #[should_panic]
|
11620 + | async fn aws_json11_endpoint_trait_request() {
|
11621 + | #[allow(unused_mut)]
|
11622 + | let mut http_request = ::http::Request::builder()
|
11623 + | .uri("/")
|
11624 + | .method("POST")
|
11625 + | .header("Content-Type", "application/x-amz-json-1.1")
|
11626 + | .header("X-Amz-Target", "JsonProtocol.EndpointOperation")
|
11627 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
11628 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
11629 + | "{}".as_bytes(),
|
11630 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
11631 + | )),
|
11632 + | ))
|
11633 + | .unwrap();
|
11634 + | todo!("endpoint trait not supported yet");
|
11635 + | #[allow(unused_mut)]
|
11636 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
11637 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
11638 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
11639 + | .endpoint_operation(move |input: crate::input::EndpointOperationInput| {
|
11640 + | let sender = sender.clone();
|
11641 + | async move {
|
11642 + | let result = {
|
11643 + | let expected = crate::input::EndpointOperationInput {};
|
11644 + | ::pretty_assertions::assert_eq!(input, expected);
|
11645 + | let output = crate::output::EndpointOperationOutput {};
|
11646 + | output
|
11647 + | };
|
11648 + | sender.send(()).await.expect("receiver dropped early");
|
11649 + | result
|
11650 + | }
|
11651 + | })
|
11652 + | .build_unchecked();
|
11653 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
11654 + | .await
|
11655 + | .expect("unable to make an HTTP request");
|
11656 + | assert!(
|
11657 + | receiver.recv().await.is_some(),
|
11658 + | "we expected operation handler to be invoked but it was not entered"
|
11659 + | );
|
11660 + | }
|
11661 + | }
|
11662 + |
|
11663 + | ::pin_project_lite::pin_project! {
|
11664 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
11665 + | /// [`EndpointWithHostLabelOperationInput`](crate::input::EndpointWithHostLabelOperationInput) using modelled bindings.
|
11666 + | pub struct EndpointWithHostLabelOperationInputFuture {
|
11667 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EndpointWithHostLabelOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
11668 + | }
|
11669 + | }
|
11670 + |
|
11671 + | impl std::future::Future for EndpointWithHostLabelOperationInputFuture {
|
11672 + | type Output = Result<
|
11673 + | crate::input::EndpointWithHostLabelOperationInput,
|
11674 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
11675 + | >;
|
11676 + |
|
11677 + | fn poll(
|
11678 + | self: std::pin::Pin<&mut Self>,
|
11679 + | cx: &mut std::task::Context<'_>,
|
11680 + | ) -> std::task::Poll<Self::Output> {
|
11681 + | let this = self.project();
|
11682 + | this.inner.as_mut().poll(cx)
|
11683 + | }
|
11684 + | }
|
11685 + |
|
11686 + | impl<B>
|
11687 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
11688 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11689 + | B,
|
11690 + | > for crate::input::EndpointWithHostLabelOperationInput
|
11691 + | where
|
11692 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11693 + | B: 'static,
|
11694 + |
|
11695 + | B::Data: Send,
|
11696 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
11697 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
11698 + | {
|
11699 + | type Rejection =
|
11700 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
11701 + | type Future = EndpointWithHostLabelOperationInputFuture;
|
11702 + |
|
11703 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
11704 + | let fut = async move {
|
11705 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
11706 + | request.headers(),
|
11707 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
11708 + | ) {
|
11709 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
11710 + | }
|
11711 + | crate::protocol_serde::shape_endpoint_with_host_label_operation::de_endpoint_with_host_label_operation_http_request(request)
|
11712 + | .await
|
11713 + | };
|
11714 + | use ::futures_util::future::TryFutureExt;
|
11715 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
11716 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
11717 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
11718 + | });
|
11719 + | EndpointWithHostLabelOperationInputFuture {
|
11720 + | inner: Box::pin(fut),
|
11721 + | }
|
11722 + | }
|
11723 + | }
|
11724 + | impl
|
11725 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
11726 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11727 + | > for crate::output::EndpointWithHostLabelOperationOutput
|
11728 + | {
|
11729 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
11730 + | match crate::protocol_serde::shape_endpoint_with_host_label_operation::ser_endpoint_with_host_label_operation_http_response(self) {
|
11731 + | Ok(response) => response,
|
11732 + | Err(e) => {
|
11733 + | ::tracing::error!(error = %e, "failed to serialize response");
|
11734 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
11735 + | }
|
11736 + | }
|
11737 + | }
|
11738 + | }
|
11739 + | impl
|
11740 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
11741 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11742 + | > for crate::error::EndpointWithHostLabelOperationError
|
11743 + | {
|
11744 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
11745 + | match crate::protocol_serde::shape_endpoint_with_host_label_operation::ser_endpoint_with_host_label_operation_http_error(&self) {
|
11746 + | Ok(mut response) => {
|
11747 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
11748 + | response
|
11749 + | },
|
11750 + | Err(e) => {
|
11751 + | ::tracing::error!(error = %e, "failed to serialize response");
|
11752 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
11753 + | }
|
11754 + | }
|
11753 11755 | }
|
11756 + | }
|
11757 + |
|
11758 + | #[allow(unreachable_code, unused_variables)]
|
11759 + | #[cfg(test)]
|
11760 + | mod endpoint_with_host_label_operation_test {
|
11754 11761 |
|
11755 - | /// Parses map of recursive structure shapes
|
11756 - | /// Test ID: parses_map_of_recursive_structure_shapes
|
11762 + | /// Operations can prepend to the given host if they define the
|
11763 + | /// endpoint trait, and can use the host label trait to define
|
11764 + | /// further customization based on user input.
|
11765 + | /// Test ID: AwsJson11EndpointTraitWithHostLabel
|
11757 11766 | #[::tokio::test]
|
11758 11767 | #[::tracing_test::traced_test]
|
11759 - | async fn parses_map_of_recursive_structure_shapes_response() {
|
11760 - | let output = crate::output::KitchenSinkOperationOutput {
|
11761 - | recursive_map: ::std::option::Option::Some({
|
11762 - | let mut ret = ::std::collections::HashMap::new();
|
11763 - | ret.insert(
|
11764 - | "key-1".to_owned(),
|
11765 - | crate::model::KitchenSink {
|
11766 - | recursive_map: ::std::option::Option::Some({
|
11767 - | let mut ret = ::std::collections::HashMap::new();
|
11768 - | ret.insert(
|
11769 - | "key-2".to_owned(),
|
11770 - | crate::model::KitchenSink {
|
11771 - | recursive_map: ::std::option::Option::Some({
|
11772 - | let mut ret = ::std::collections::HashMap::new();
|
11773 - | ret.insert(
|
11774 - | "key-3".to_owned(),
|
11775 - | crate::model::KitchenSink {
|
11776 - | string: ::std::option::Option::Some(
|
11777 - | "value".to_owned(),
|
11778 - | ),
|
11779 - | blob: ::std::option::Option::None,
|
11780 - | boolean: ::std::option::Option::None,
|
11781 - | double: ::std::option::Option::None,
|
11782 - | empty_struct: ::std::option::Option::None,
|
11783 - | float: ::std::option::Option::None,
|
11784 - | httpdate_timestamp: ::std::option::Option::None,
|
11785 - | integer: ::std::option::Option::None,
|
11786 - | iso8601_timestamp: ::std::option::Option::None,
|
11787 - | json_value: ::std::option::Option::None,
|
11788 - | list_of_lists: ::std::option::Option::None,
|
11789 - | list_of_maps_of_strings:
|
11790 - | ::std::option::Option::None,
|
11791 - | list_of_strings: ::std::option::Option::None,
|
11792 - | list_of_structs: ::std::option::Option::None,
|
11793 - | long: ::std::option::Option::None,
|
11794 - | map_of_lists_of_strings:
|
11795 - | ::std::option::Option::None,
|
11796 - | map_of_maps: ::std::option::Option::None,
|
11797 - | map_of_strings: ::std::option::Option::None,
|
11798 - | map_of_structs: ::std::option::Option::None,
|
11799 - | recursive_list: ::std::option::Option::None,
|
11800 - | recursive_map: ::std::option::Option::None,
|
11801 - | recursive_struct: ::std::option::Option::None,
|
11802 - | simple_struct: ::std::option::Option::None,
|
11803 - | struct_with_json_name: ::std::option::Option::None,
|
11804 - | timestamp: ::std::option::Option::None,
|
11805 - | unix_timestamp: ::std::option::Option::None,
|
11806 - | },
|
11807 - | );
|
11808 - | ret
|
11809 - | }),
|
11810 - | blob: ::std::option::Option::None,
|
11811 - | boolean: ::std::option::Option::None,
|
11812 - | double: ::std::option::Option::None,
|
11813 - | empty_struct: ::std::option::Option::None,
|
11814 - | float: ::std::option::Option::None,
|
11815 - | httpdate_timestamp: ::std::option::Option::None,
|
11816 - | integer: ::std::option::Option::None,
|
11817 - | iso8601_timestamp: ::std::option::Option::None,
|
11818 - | json_value: ::std::option::Option::None,
|
11819 - | list_of_lists: ::std::option::Option::None,
|
11820 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11821 - | list_of_strings: ::std::option::Option::None,
|
11822 - | list_of_structs: ::std::option::Option::None,
|
11823 - | long: ::std::option::Option::None,
|
11824 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11825 - | map_of_maps: ::std::option::Option::None,
|
11826 - | map_of_strings: ::std::option::Option::None,
|
11827 - | map_of_structs: ::std::option::Option::None,
|
11828 - | recursive_list: ::std::option::Option::None,
|
11829 - | recursive_struct: ::std::option::Option::None,
|
11830 - | simple_struct: ::std::option::Option::None,
|
11831 - | string: ::std::option::Option::None,
|
11832 - | struct_with_json_name: ::std::option::Option::None,
|
11833 - | timestamp: ::std::option::Option::None,
|
11834 - | unix_timestamp: ::std::option::Option::None,
|
11835 - | },
|
11836 - | );
|
11837 - | ret
|
11838 - | }),
|
11839 - | blob: ::std::option::Option::None,
|
11840 - | boolean: ::std::option::Option::None,
|
11841 - | double: ::std::option::Option::None,
|
11842 - | empty_struct: ::std::option::Option::None,
|
11843 - | float: ::std::option::Option::None,
|
11844 - | httpdate_timestamp: ::std::option::Option::None,
|
11845 - | integer: ::std::option::Option::None,
|
11846 - | iso8601_timestamp: ::std::option::Option::None,
|
11847 - | json_value: ::std::option::Option::None,
|
11848 - | list_of_lists: ::std::option::Option::None,
|
11849 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11850 - | list_of_strings: ::std::option::Option::None,
|
11851 - | list_of_structs: ::std::option::Option::None,
|
11852 - | long: ::std::option::Option::None,
|
11853 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11854 - | map_of_maps: ::std::option::Option::None,
|
11855 - | map_of_strings: ::std::option::Option::None,
|
11856 - | map_of_structs: ::std::option::Option::None,
|
11857 - | recursive_list: ::std::option::Option::None,
|
11858 - | recursive_struct: ::std::option::Option::None,
|
11859 - | simple_struct: ::std::option::Option::None,
|
11860 - | string: ::std::option::Option::None,
|
11861 - | struct_with_json_name: ::std::option::Option::None,
|
11862 - | timestamp: ::std::option::Option::None,
|
11863 - | unix_timestamp: ::std::option::Option::None,
|
11768 + | #[should_panic]
|
11769 + | async fn aws_json11_endpoint_trait_with_host_label_request() {
|
11770 + | #[allow(unused_mut)]
|
11771 + | let mut http_request = ::http::Request::builder()
|
11772 + | .uri("/")
|
11773 + | .method("POST")
|
11774 + | .header("Content-Type", "application/x-amz-json-1.1")
|
11775 + | .header(
|
11776 + | "X-Amz-Target",
|
11777 + | "JsonProtocol.EndpointWithHostLabelOperation",
|
11778 + | )
|
11779 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
11780 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
11781 + | "{\"label\": \"bar\"}".as_bytes(),
|
11782 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11783 + | )),
|
11784 + | ))
|
11785 + | .unwrap();
|
11786 + | todo!("endpoint trait not supported yet");
|
11787 + | #[allow(unused_mut)]
|
11788 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
11789 + | let config = crate::service::JsonProtocolConfig::builder().build();
|
11790 + | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
11791 + | .endpoint_with_host_label_operation(
|
11792 + | move |input: crate::input::EndpointWithHostLabelOperationInput| {
|
11793 + | let sender = sender.clone();
|
11794 + | async move {
|
11795 + | let result = {
|
11796 + | let expected = crate::input::EndpointWithHostLabelOperationInput {
|
11797 + | label: "bar".to_owned(),
|
11798 + | };
|
11799 + | ::pretty_assertions::assert_eq!(input, expected);
|
11800 + | let output = crate::output::EndpointWithHostLabelOperationOutput {};
|
11801 + | Ok(output)
|
11802 + | };
|
11803 + | sender.send(()).await.expect("receiver dropped early");
|
11804 + | result
|
11805 + | }
|
11864 11806 | },
|
11807 + | )
|
11808 + | .build_unchecked();
|
11809 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
11810 + | .await
|
11811 + | .expect("unable to make an HTTP request");
|
11812 + | assert!(
|
11813 + | receiver.recv().await.is_some(),
|
11814 + | "we expected operation handler to be invoked but it was not entered"
|
11865 11815 | );
|
11866 - | ret
|
11867 - | }),
|
11868 - | blob: ::std::option::Option::None,
|
11869 - | boolean: ::std::option::Option::None,
|
11870 - | double: ::std::option::Option::None,
|
11871 - | empty_struct: ::std::option::Option::None,
|
11872 - | float: ::std::option::Option::None,
|
11873 - | httpdate_timestamp: ::std::option::Option::None,
|
11874 - | integer: ::std::option::Option::None,
|
11875 - | iso8601_timestamp: ::std::option::Option::None,
|
11876 - | json_value: ::std::option::Option::None,
|
11877 - | list_of_lists: ::std::option::Option::None,
|
11878 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11879 - | list_of_strings: ::std::option::Option::None,
|
11880 - | list_of_structs: ::std::option::Option::None,
|
11881 - | long: ::std::option::Option::None,
|
11882 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11883 - | map_of_maps: ::std::option::Option::None,
|
11884 - | map_of_strings: ::std::option::Option::None,
|
11885 - | map_of_structs: ::std::option::Option::None,
|
11886 - | recursive_list: ::std::option::Option::None,
|
11887 - | recursive_struct: ::std::option::Option::None,
|
11888 - | simple_struct: ::std::option::Option::None,
|
11889 - | string: ::std::option::Option::None,
|
11890 - | struct_with_json_name: ::std::option::Option::None,
|
11891 - | timestamp: ::std::option::Option::None,
|
11892 - | unix_timestamp: ::std::option::Option::None,
|
11816 + | }
|
11817 + | }
|
11818 + |
|
11819 + | ::pin_project_lite::pin_project! {
|
11820 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
11821 + | /// [`HostWithPathOperationInput`](crate::input::HostWithPathOperationInput) using modelled bindings.
|
11822 + | pub struct HostWithPathOperationInputFuture {
|
11823 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HostWithPathOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
11824 + | }
|
11825 + | }
|
11826 + |
|
11827 + | impl std::future::Future for HostWithPathOperationInputFuture {
|
11828 + | type Output = Result<
|
11829 + | crate::input::HostWithPathOperationInput,
|
11830 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
11831 + | >;
|
11832 + |
|
11833 + | fn poll(
|
11834 + | self: std::pin::Pin<&mut Self>,
|
11835 + | cx: &mut std::task::Context<'_>,
|
11836 + | ) -> std::task::Poll<Self::Output> {
|
11837 + | let this = self.project();
|
11838 + | this.inner.as_mut().poll(cx)
|
11839 + | }
|
11840 + | }
|
11841 + |
|
11842 + | impl<B>
|
11843 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
11844 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11845 + | B,
|
11846 + | > for crate::input::HostWithPathOperationInput
|
11847 + | where
|
11848 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11849 + | B: 'static,
|
11850 + |
|
11851 + | B::Data: Send,
|
11852 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
11853 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
11854 + | {
|
11855 + | type Rejection =
|
11856 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
11857 + | type Future = HostWithPathOperationInputFuture;
|
11858 + |
|
11859 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
11860 + | let fut = async move {
|
11861 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
11862 + | request.headers(),
|
11863 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
11864 + | ) {
|
11865 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
11866 + | }
|
11867 + | crate::protocol_serde::shape_host_with_path_operation::de_host_with_path_operation_http_request(request)
|
11868 + | .await
|
11893 11869 | };
|
11894 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11895 - | let http_response = output.into_response();
|
11896 - | ::pretty_assertions::assert_eq!(
|
11897 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11898 - | http_response.status()
|
11899 - | );
|
11900 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
11901 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11902 - | http_response.headers(),
|
11903 - | expected_headers,
|
11904 - | ));
|
11905 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
11870 + | use ::futures_util::future::TryFutureExt;
|
11871 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
11872 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
11873 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
11874 + | });
|
11875 + | HostWithPathOperationInputFuture {
|
11876 + | inner: Box::pin(fut),
|
11877 + | }
|
11878 + | }
|
11879 + | }
|
11880 + | impl
|
11881 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
11882 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11883 + | > for crate::output::HostWithPathOperationOutput
|
11884 + | {
|
11885 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
11886 + | match crate::protocol_serde::shape_host_with_path_operation::ser_host_with_path_operation_http_response(self) {
|
11887 + | Ok(response) => response,
|
11888 + | Err(e) => {
|
11889 + | ::tracing::error!(error = %e, "failed to serialize response");
|
11890 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
11891 + | }
|
11892 + | }
|
11893 + | }
|
11894 + | }
|
11895 + |
|
11896 + | ::pin_project_lite::pin_project! {
|
11897 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
11898 + | /// [`DatetimeOffsetsInput`](crate::input::DatetimeOffsetsInput) using modelled bindings.
|
11899 + | pub struct DatetimeOffsetsInputFuture {
|
11900 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::DatetimeOffsetsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
11901 + | }
|
11902 + | }
|
11903 + |
|
11904 + | impl std::future::Future for DatetimeOffsetsInputFuture {
|
11905 + | type Output = Result<
|
11906 + | crate::input::DatetimeOffsetsInput,
|
11907 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
11908 + | >;
|
11909 + |
|
11910 + | fn poll(
|
11911 + | self: std::pin::Pin<&mut Self>,
|
11912 + | cx: &mut std::task::Context<'_>,
|
11913 + | ) -> std::task::Poll<Self::Output> {
|
11914 + | let this = self.project();
|
11915 + | this.inner.as_mut().poll(cx)
|
11916 + | }
|
11917 + | }
|
11918 + |
|
11919 + | impl<B>
|
11920 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
11921 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11922 + | B,
|
11923 + | > for crate::input::DatetimeOffsetsInput
|
11924 + | where
|
11925 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11926 + | B: 'static,
|
11927 + |
|
11928 + | B::Data: Send,
|
11929 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
11930 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
11931 + | {
|
11932 + | type Rejection =
|
11933 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
11934 + | type Future = DatetimeOffsetsInputFuture;
|
11935 + |
|
11936 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
11937 + | let fut = async move {
|
11938 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
11939 + | request.headers(),
|
11940 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
11941 + | ) {
|
11942 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
11943 + | }
|
11944 + | crate::protocol_serde::shape_datetime_offsets::de_datetime_offsets_http_request(request)
|
11906 11945 | .await
|
11907 - | .expect("unable to extract body to bytes");
|
11908 - | ::aws_smithy_protocol_test::assert_ok(
|
11909 - | ::aws_smithy_protocol_test::validate_body(&body, "{\"RecursiveMap\":{\"key-1\":{\"RecursiveMap\":{\"key-2\":{\"RecursiveMap\":{\"key-3\":{\"String\":\"value\"}}}}}}}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
11910 - | );
|
11946 + | };
|
11947 + | use ::futures_util::future::TryFutureExt;
|
11948 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
11949 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
11950 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
11951 + | });
|
11952 + | DatetimeOffsetsInputFuture {
|
11953 + | inner: Box::pin(fut),
|
11954 + | }
|
11955 + | }
|
11956 + | }
|
11957 + | impl
|
11958 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
11959 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11960 + | > for crate::output::DatetimeOffsetsOutput
|
11961 + | {
|
11962 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
11963 + | match crate::protocol_serde::shape_datetime_offsets::ser_datetime_offsets_http_response(
|
11964 + | self,
|
11965 + | ) {
|
11966 + | Ok(response) => response,
|
11967 + | Err(e) => {
|
11968 + | ::tracing::error!(error = %e, "failed to serialize response");
|
11969 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
11970 + | }
|
11911 11971 | }
|
11972 + | }
|
11973 + | }
|
11912 11974 |
|
11913 - | /// Parses the request id from the response
|
11914 - | /// Test ID: parses_the_request_id_from_the_response
|
11915 - | #[::tokio::test]
|
11916 - | #[::tracing_test::traced_test]
|
11917 - | #[should_panic]
|
11918 - | async fn parses_the_request_id_from_the_response_response() {
|
11919 - | let output = crate::output::KitchenSinkOperationOutput {
|
11920 - | blob: ::std::option::Option::None,
|
11921 - | boolean: ::std::option::Option::None,
|
11922 - | double: ::std::option::Option::None,
|
11923 - | empty_struct: ::std::option::Option::None,
|
11924 - | float: ::std::option::Option::None,
|
11925 - | httpdate_timestamp: ::std::option::Option::None,
|
11926 - | integer: ::std::option::Option::None,
|
11927 - | iso8601_timestamp: ::std::option::Option::None,
|
11928 - | json_value: ::std::option::Option::None,
|
11929 - | list_of_lists: ::std::option::Option::None,
|
11930 - | list_of_maps_of_strings: ::std::option::Option::None,
|
11931 - | list_of_strings: ::std::option::Option::None,
|
11932 - | list_of_structs: ::std::option::Option::None,
|
11933 - | long: ::std::option::Option::None,
|
11934 - | map_of_lists_of_strings: ::std::option::Option::None,
|
11935 - | map_of_maps: ::std::option::Option::None,
|
11936 - | map_of_strings: ::std::option::Option::None,
|
11937 - | map_of_structs: ::std::option::Option::None,
|
11938 - | recursive_list: ::std::option::Option::None,
|
11939 - | recursive_map: ::std::option::Option::None,
|
11940 - | recursive_struct: ::std::option::Option::None,
|
11941 - | simple_struct: ::std::option::Option::None,
|
11942 - | string: ::std::option::Option::None,
|
11943 - | struct_with_json_name: ::std::option::Option::None,
|
11944 - | timestamp: ::std::option::Option::None,
|
11945 - | unix_timestamp: ::std::option::Option::None,
|
11975 + | ::pin_project_lite::pin_project! {
|
11976 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
11977 + | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
11978 + | pub struct FractionalSecondsInputFuture {
|
11979 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
11980 + | }
|
11981 + | }
|
11982 + |
|
11983 + | impl std::future::Future for FractionalSecondsInputFuture {
|
11984 + | type Output = Result<
|
11985 + | crate::input::FractionalSecondsInput,
|
11986 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
11987 + | >;
|
11988 + |
|
11989 + | fn poll(
|
11990 + | self: std::pin::Pin<&mut Self>,
|
11991 + | cx: &mut std::task::Context<'_>,
|
11992 + | ) -> std::task::Poll<Self::Output> {
|
11993 + | let this = self.project();
|
11994 + | this.inner.as_mut().poll(cx)
|
11995 + | }
|
11996 + | }
|
11997 + |
|
11998 + | impl<B>
|
11999 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
12000 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
12001 + | B,
|
12002 + | > for crate::input::FractionalSecondsInput
|
12003 + | where
|
12004 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
12005 + | B: 'static,
|
12006 + |
|
12007 + | B::Data: Send,
|
12008 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
12009 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
12010 + | {
|
12011 + | type Rejection =
|
12012 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
12013 + | type Future = FractionalSecondsInputFuture;
|
12014 + |
|
12015 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
12016 + | let fut = async move {
|
12017 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
12018 + | request.headers(),
|
12019 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
12020 + | ) {
|
12021 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
12022 + | }
|
12023 + | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
12024 + | request,
|
12025 + | )
|
12026 + | .await
|
11946 12027 | };
|
11947 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
11948 - | let http_response = output.into_response();
|
11949 - | ::pretty_assertions::assert_eq!(
|
11950 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
11951 - | http_response.status()
|
11952 - | );
|
11953 - | let expected_headers = [
|
11954 - | ("Content-Type", "application/x-amz-json-1.1"),
|
11955 - | ("X-Amzn-Requestid", "amazon-uniq-request-id"),
|
11956 - | ];
|
11957 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
11958 - | http_response.headers(),
|
11959 - | expected_headers,
|
11960 - | ));
|
11961 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
12028 + | use ::futures_util::future::TryFutureExt;
|
12029 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
12030 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
12031 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
12032 + | });
|
12033 + | FractionalSecondsInputFuture {
|
12034 + | inner: Box::pin(fut),
|
12035 + | }
|
12036 + | }
|
12037 + | }
|
12038 + | impl
|
12039 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
12040 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
12041 + | > for crate::output::FractionalSecondsOutput
|
12042 + | {
|
12043 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
12044 + | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
12045 + | self,
|
12046 + | ) {
|
12047 + | Ok(response) => response,
|
12048 + | Err(e) => {
|
12049 + | ::tracing::error!(error = %e, "failed to serialize response");
|
12050 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
12051 + | }
|
12052 + | }
|
12053 + | }
|
12054 + | }
|
12055 + |
|
12056 + | ::pin_project_lite::pin_project! {
|
12057 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
12058 + | /// [`PutWithContentEncodingInput`](crate::input::PutWithContentEncodingInput) using modelled bindings.
|
12059 + | pub struct PutWithContentEncodingInputFuture {
|
12060 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PutWithContentEncodingInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
12061 + | }
|
12062 + | }
|
12063 + |
|
12064 + | impl std::future::Future for PutWithContentEncodingInputFuture {
|
12065 + | type Output = Result<
|
12066 + | crate::input::PutWithContentEncodingInput,
|
12067 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
12068 + | >;
|
12069 + |
|
12070 + | fn poll(
|
12071 + | self: std::pin::Pin<&mut Self>,
|
12072 + | cx: &mut std::task::Context<'_>,
|
12073 + | ) -> std::task::Poll<Self::Output> {
|
12074 + | let this = self.project();
|
12075 + | this.inner.as_mut().poll(cx)
|
12076 + | }
|
12077 + | }
|
12078 + |
|
12079 + | impl<B>
|
12080 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
12081 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
12082 + | B,
|
12083 + | > for crate::input::PutWithContentEncodingInput
|
12084 + | where
|
12085 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
12086 + | B: 'static,
|
12087 + |
|
12088 + | B::Data: Send,
|
12089 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
12090 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
12091 + | {
|
12092 + | type Rejection =
|
12093 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
12094 + | type Future = PutWithContentEncodingInputFuture;
|
12095 + |
|
12096 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
12097 + | let fut = async move {
|
12098 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
12099 + | request.headers(),
|
12100 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
12101 + | ) {
|
12102 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
12103 + | }
|
12104 + | crate::protocol_serde::shape_put_with_content_encoding::de_put_with_content_encoding_http_request(request)
|
11962 12105 | .await
|
11963 - | .expect("unable to extract body to bytes");
|
11964 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
11965 - | &body,
|
11966 - | "{}",
|
11967 - | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
11968 - | ));
|
12106 + | };
|
12107 + | use ::futures_util::future::TryFutureExt;
|
12108 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
12109 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
12110 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
12111 + | });
|
12112 + | PutWithContentEncodingInputFuture {
|
12113 + | inner: Box::pin(fut),
|
12114 + | }
|
12115 + | }
|
12116 + | }
|
12117 + | impl
|
12118 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
12119 + | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
12120 + | > for crate::output::PutWithContentEncodingOutput
|
12121 + | {
|
12122 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
12123 + | match crate::protocol_serde::shape_put_with_content_encoding::ser_put_with_content_encoding_http_response(self) {
|
12124 + | Ok(response) => response,
|
12125 + | Err(e) => {
|
12126 + | ::tracing::error!(error = %e, "failed to serialize response");
|
12127 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
12128 + | }
|
12129 + | }
|
11969 12130 | }
|
11970 12131 | }
|
11971 12132 |
|
11972 12133 | ::pin_project_lite::pin_project! {
|
11973 12134 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
11974 - | /// [`EmptyOperationInput`](crate::input::EmptyOperationInput) using modelled bindings.
|
11975 - | pub struct EmptyOperationInputFuture {
|
11976 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
12135 + | /// [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput) using modelled bindings.
|
12136 + | pub struct ContentTypeParametersInputFuture {
|
12137 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ContentTypeParametersInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
11977 12138 | }
|
11978 12139 | }
|
11979 12140 |
|
11980 - | impl std::future::Future for EmptyOperationInputFuture {
|
12141 + | impl std::future::Future for ContentTypeParametersInputFuture {
|
11981 12142 | type Output = Result<
|
11982 - | crate::input::EmptyOperationInput,
|
12143 + | crate::input::ContentTypeParametersInput,
|
11983 12144 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
11984 12145 | >;
|
11985 12146 |
|
11986 12147 | fn poll(
|
11987 12148 | self: std::pin::Pin<&mut Self>,
|
11988 12149 | cx: &mut std::task::Context<'_>,
|
11989 12150 | ) -> std::task::Poll<Self::Output> {
|
11990 12151 | let this = self.project();
|
11991 12152 | this.inner.as_mut().poll(cx)
|
11992 12153 | }
|
11993 12154 | }
|
11994 12155 |
|
11995 12156 | impl<B>
|
11996 12157 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
11997 12158 | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
11998 12159 | B,
|
11999 - | > for crate::input::EmptyOperationInput
|
12160 + | > for crate::input::ContentTypeParametersInput
|
12000 12161 | where
|
12001 12162 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
12002 12163 | B: 'static,
|
12003 12164 |
|
12004 12165 | B::Data: Send,
|
12005 12166 | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
12006 12167 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
12007 12168 | {
|
12008 12169 | type Rejection =
|
12009 12170 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
12010 - | type Future = EmptyOperationInputFuture;
|
12171 + | type Future = ContentTypeParametersInputFuture;
|
12011 12172 |
|
12012 12173 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
12013 12174 | let fut = async move {
|
12014 12175 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
12015 12176 | request.headers(),
|
12016 12177 | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_1,
|
12017 12178 | ) {
|
12018 12179 | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
12019 12180 | }
|
12020 - | crate::protocol_serde::shape_empty_operation::de_empty_operation_http_request(request)
|
12181 + | crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters_http_request(request)
|
12021 12182 | .await
|
12022 12183 | };
|
12023 12184 | use ::futures_util::future::TryFutureExt;
|
12024 12185 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
12025 12186 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
12026 12187 | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
12027 12188 | });
|
12028 - | EmptyOperationInputFuture {
|
12189 + | ContentTypeParametersInputFuture {
|
12029 12190 | inner: Box::pin(fut),
|
12030 12191 | }
|
12031 12192 | }
|
12032 12193 | }
|
12033 12194 | impl
|
12034 12195 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
12035 12196 | ::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1,
|
12036 - | > for crate::output::EmptyOperationOutput
|
12197 + | > for crate::output::ContentTypeParametersOutput
|
12037 12198 | {
|
12038 12199 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
12039 - | match crate::protocol_serde::shape_empty_operation::ser_empty_operation_http_response(self)
|
12040 - | {
|
12200 + | match crate::protocol_serde::shape_content_type_parameters::ser_content_type_parameters_http_response(self) {
|
12041 12201 | Ok(response) => response,
|
12042 12202 | Err(e) => {
|
12043 12203 | ::tracing::error!(error = %e, "failed to serialize response");
|
12044 12204 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_11::AwsJson1_1>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
12045 12205 | }
|
12046 12206 | }
|
12047 12207 | }
|
12048 12208 | }
|
12049 12209 |
|
12050 12210 | #[allow(unreachable_code, unused_variables)]
|
12051 12211 | #[cfg(test)]
|
12052 - | mod empty_operation_test {
|
12053 - |
|
12054 - | /// Sends requests to /
|
12055 - | /// Test ID: sends_requests_to_slash
|
12056 - | #[::tokio::test]
|
12057 - | #[::tracing_test::traced_test]
|
12058 - | async fn sends_requests_to_slash_request() {
|
12059 - | #[allow(unused_mut)]
|
12060 - | let mut http_request = ::http::Request::builder()
|
12061 - | .uri("/")
|
12062 - | .method("POST")
|
12063 - | .header("Content-Type", "application/x-amz-json-1.1")
|
12064 - | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
12065 - | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
12066 - | .unwrap();
|
12067 - | #[allow(unused_mut)]
|
12068 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
12069 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
12070 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
12071 - | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
12072 - | let sender = sender.clone();
|
12073 - | async move {
|
12074 - | let result = {
|
12075 - | let expected = crate::input::EmptyOperationInput {};
|
12076 - | ::pretty_assertions::assert_eq!(input, expected);
|
12077 - | let output = crate::output::EmptyOperationOutput {};
|
12078 - | output
|
12079 - | };
|
12080 - | sender.send(()).await.expect("receiver dropped early");
|
12081 - | result
|
12082 - | }
|
12083 - | })
|
12084 - | .build_unchecked();
|
12085 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
12086 - | .await
|
12087 - | .expect("unable to make an HTTP request");
|
12088 - | assert!(
|
12089 - | receiver.recv().await.is_some(),
|
12090 - | "we expected operation handler to be invoked but it was not entered"
|
12091 - | );
|
12092 - | }
|
12093 - |
|
12094 - | /// Includes X-Amz-Target header and Content-Type
|
12095 - | /// Test ID: includes_x_amz_target_and_content_type
|
12096 - | #[::tokio::test]
|
12097 - | #[::tracing_test::traced_test]
|
12098 - | async fn includes_x_amz_target_and_content_type_request() {
|
12099 - | #[allow(unused_mut)]
|
12100 - | let mut http_request = ::http::Request::builder()
|
12101 - | .uri("/")
|
12102 - | .method("POST")
|
12103 - | .header("Content-Type", "application/x-amz-json-1.1")
|
12104 - | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
12105 - | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
12106 - | .unwrap();
|
12107 - | #[allow(unused_mut)]
|
12108 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
12109 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
12110 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
12111 - | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
12112 - | let sender = sender.clone();
|
12113 - | async move {
|
12114 - | let result = {
|
12115 - | let expected = crate::input::EmptyOperationInput {};
|
12116 - | ::pretty_assertions::assert_eq!(input, expected);
|
12117 - | let output = crate::output::EmptyOperationOutput {};
|
12118 - | output
|
12119 - | };
|
12120 - | sender.send(()).await.expect("receiver dropped early");
|
12121 - | result
|
12122 - | }
|
12123 - | })
|
12124 - | .build_unchecked();
|
12125 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
12126 - | .await
|
12127 - | .expect("unable to make an HTTP request");
|
12128 - | assert!(
|
12129 - | receiver.recv().await.is_some(),
|
12130 - | "we expected operation handler to be invoked but it was not entered"
|
12131 - | );
|
12132 - | }
|
12212 + | mod content_type_parameters_test {
|
12133 12213 |
|
12134 - | /// Clients must always send an empty JSON object payload for
|
12135 - | /// operations with no input (that is, `{}`). While AWS service
|
12136 - | /// implementations support requests with no payload or requests
|
12137 - | /// that send `{}`, always sending `{}` from the client is
|
12138 - | /// preferred for forward compatibility in case input is ever
|
12139 - | /// added to an operation.
|
12140 - | /// Test ID: json_1_1_client_sends_empty_payload_for_no_input_shape
|
12214 + | /// A server should ignore parameters added to the content type
|
12215 + | /// Test ID: AwsJson11MustSupportParametersInContentType
|
12141 12216 | #[::tokio::test]
|
12142 12217 | #[::tracing_test::traced_test]
|
12143 - | async fn json_1_1_client_sends_empty_payload_for_no_input_shape_request() {
|
12218 + | async fn aws_json11_must_support_parameters_in_content_type_request() {
|
12144 12219 | #[allow(unused_mut)]
|
12145 12220 | let mut http_request = ::http::Request::builder()
|
12146 12221 | .uri("/")
|
12147 12222 | .method("POST")
|
12148 - | .header("Content-Type", "application/x-amz-json-1.1")
|
12149 - | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
12223 + | .header("Content-Type", "application/x-amz-json-1.1; charset=utf-8")
|
12224 + | .header("X-Amz-Target", "JsonProtocol.ContentTypeParameters")
|
12150 12225 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
12151 12226 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
12152 - | "{}".as_bytes(),
|
12227 + | "{\"value\":5}".as_bytes(),
|
12153 12228 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
12154 12229 | )),
|
12155 12230 | ))
|
12156 12231 | .unwrap();
|
12157 12232 | #[allow(unused_mut)]
|
12158 12233 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
12159 12234 | let config = crate::service::JsonProtocolConfig::builder().build();
|
12160 12235 | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
12161 - | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
12236 + | .content_type_parameters(move |input: crate::input::ContentTypeParametersInput| {
|
12162 12237 | let sender = sender.clone();
|
12163 12238 | async move {
|
12164 12239 | let result = {
|
12165 - | let expected = crate::input::EmptyOperationInput {};
|
12166 - | ::pretty_assertions::assert_eq!(input, expected);
|
12167 - | let output = crate::output::EmptyOperationOutput {};
|
12168 - | output
|
12240 + | let expected = crate::input::ContentTypeParametersInput {
|
12241 + | value: ::std::option::Option::Some(5),
|
12169 12242 | };
|
12170 - | sender.send(()).await.expect("receiver dropped early");
|
12171 - | result
|
12172 - | }
|
12173 - | })
|
12174 - | .build_unchecked();
|
12175 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
12176 - | .await
|
12177 - | .expect("unable to make an HTTP request");
|
12178 - | assert!(
|
12179 - | receiver.recv().await.is_some(),
|
12180 - | "we expected operation handler to be invoked but it was not entered"
|
12181 - | );
|
12182 - | }
|
12183 - |
|
12184 - | /// Service implementations must support no payload or an empty
|
12185 - | /// object payload for operations that define no input. However,
|
12186 - | /// despite the lack of a payload, a Content-Type header is still
|
12187 - | /// required in order for the service to properly detect the
|
12188 - | /// protocol.
|
12189 - | /// Test ID: json_1_1_service_supports_empty_payload_for_no_input_shape
|
12190 - | #[::tokio::test]
|
12191 - | #[::tracing_test::traced_test]
|
12192 - | async fn json_1_1_service_supports_empty_payload_for_no_input_shape_request() {
|
12193 - | #[allow(unused_mut)]
|
12194 - | let mut http_request = ::http::Request::builder()
|
12195 - | .uri("/")
|
12196 - | .method("POST")
|
12197 - | .header("Content-Type", "application/x-amz-json-1.1")
|
12198 - | .header("X-Amz-Target", "JsonProtocol.EmptyOperation")
|
12199 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
12200 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
12201 - | "".as_bytes(),
|
12202 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
12203 - | )),
|
12204 - | ))
|
12205 - | .unwrap();
|
12206 - | #[allow(unused_mut)]
|
12207 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
12208 - | let config = crate::service::JsonProtocolConfig::builder().build();
|
12209 - | let service = crate::service::JsonProtocol::builder::<::hyper::body::Body, _, _, _>(config)
|
12210 - | .empty_operation(move |input: crate::input::EmptyOperationInput| {
|
12211 - | let sender = sender.clone();
|
12212 - | async move {
|
12213 - | let result = {
|
12214 - | let expected = crate::input::EmptyOperationInput {};
|
12215 12243 | ::pretty_assertions::assert_eq!(input, expected);
|
12216 - | let output = crate::output::EmptyOperationOutput {};
|
12244 + | let output = crate::output::ContentTypeParametersOutput {};
|
12217 12245 | output
|
12218 12246 | };
|
12219 12247 | sender.send(()).await.expect("receiver dropped early");
|
12220 12248 | result
|
12221 12249 | }
|
12222 12250 | })
|
12223 12251 | .build_unchecked();
|
12224 12252 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
12225 12253 | .await
|
12226 12254 | .expect("unable to make an HTTP request");
|
12227 12255 | assert!(
|
12228 12256 | receiver.recv().await.is_some(),
|
12229 12257 | "we expected operation handler to be invoked but it was not entered"
|
12230 12258 | );
|
12231 12259 | }
|
12232 - |
|
12233 - | /// When no output is defined, the service is expected to return
|
12234 - | /// an empty payload. Despite the lack of a payload, the service
|
12235 - | /// is expected to always send a Content-Type header. Clients must
|
12236 - | /// handle cases where a service returns a JSON object and where
|
12237 - | /// a service returns no JSON at all.
|
12238 - | /// Test ID: json_1_1_service_responds_with_no_payload
|
12239 - | #[::tokio::test]
|
12240 - | #[::tracing_test::traced_test]
|
12241 - | async fn json_1_1_service_responds_with_no_payload_response() {
|
12242 - | let output = crate::output::EmptyOperationOutput {};
|
12243 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
12244 - | let http_response = output.into_response();
|
12245 - | ::pretty_assertions::assert_eq!(
|
12246 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
12247 - | http_response.status()
|
12248 - | );
|
12249 - | let expected_headers = [("Content-Type", "application/x-amz-json-1.1")];
|
12250 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
12251 - | http_response.headers(),
|
12252 - | expected_headers,
|
12253 - | ));
|
12254 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
12255 - | .await
|
12256 - | .expect("unable to extract body to bytes");
|
12257 - | // No body.
|
12258 - | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
12259 - | }
|
12260 12260 | }
|