1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | ::pin_project_lite::pin_project! {
|
3 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 + | /// [`QueryIncompatibleOperationInput`](crate::input::QueryIncompatibleOperationInput) using modelled bindings.
|
5 + | pub struct QueryIncompatibleOperationInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::QueryIncompatibleOperationInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
7 + | }
|
8 + | }
|
9 + |
|
10 + | impl std::future::Future for QueryIncompatibleOperationInputFuture {
|
11 + | type Output = Result<
|
12 + | crate::input::QueryIncompatibleOperationInput,
|
13 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
14 + | >;
|
15 + |
|
16 + | fn poll(
|
17 + | self: std::pin::Pin<&mut Self>,
|
18 + | cx: &mut std::task::Context<'_>,
|
19 + | ) -> std::task::Poll<Self::Output> {
|
20 + | let this = self.project();
|
21 + | this.inner.as_mut().poll(cx)
|
22 + | }
|
23 + | }
|
24 + |
|
25 + | impl<B>
|
26 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
27 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
28 + | B,
|
29 + | > for crate::input::QueryIncompatibleOperationInput
|
30 + | where
|
31 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
32 + | B: 'static,
|
33 + |
|
34 + | B::Data: Send,
|
35 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
36 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
37 + | {
|
38 + | type Rejection =
|
39 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
40 + | type Future = QueryIncompatibleOperationInputFuture;
|
41 + |
|
42 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
43 + | let fut = async move {
|
44 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
45 + | request.headers(),
|
46 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
47 + | ) {
|
48 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
49 + | }
|
50 + | crate::protocol_serde::shape_query_incompatible_operation::de_query_incompatible_operation_http_request(request)
|
51 + | .await
|
52 + | };
|
53 + | use ::futures_util::future::TryFutureExt;
|
54 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
55 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
56 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
57 + | });
|
58 + | QueryIncompatibleOperationInputFuture {
|
59 + | inner: Box::pin(fut),
|
60 + | }
|
61 + | }
|
62 + | }
|
63 + | impl
|
64 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
65 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
66 + | > for crate::output::QueryIncompatibleOperationOutput
|
67 + | {
|
68 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
69 + | match crate::protocol_serde::shape_query_incompatible_operation::ser_query_incompatible_operation_http_response(self) {
|
70 + | Ok(response) => response,
|
71 + | Err(e) => {
|
72 + | ::tracing::error!(error = %e, "failed to serialize response");
|
73 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
74 + | }
|
75 + | }
|
76 + | }
|
77 + | }
|
78 + |
|
79 + | #[allow(unreachable_code, unused_variables)]
|
80 + | #[cfg(test)]
|
81 + | mod query_incompatible_operation_test {
|
82 + |
|
83 + | /// The query mode header MUST NOT be set on non-query-compatible services.
|
84 + | /// Test ID: NonQueryCompatibleAwsJson10ForbidsQueryModeHeader
|
85 + | #[::tokio::test]
|
86 + | #[::tracing_test::traced_test]
|
87 + | async fn non_query_compatible_aws_json10_forbids_query_mode_header_request() {
|
88 + | #[allow(unused_mut)]
|
89 + | let mut http_request = ::http::Request::builder()
|
90 + | .uri("/")
|
91 + | .method("POST")
|
92 + | .header("Content-Type", "application/x-amz-json-1.0")
|
93 + | .header("X-Amz-Target", "JsonRpc10.QueryIncompatibleOperation")
|
94 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
95 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
96 + | "{}".as_bytes(),
|
97 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
98 + | )),
|
99 + | ))
|
100 + | .unwrap();
|
101 + | #[allow(unused_mut)]
|
102 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
103 + | let config = crate::service::JsonRpc10Config::builder().build();
|
104 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
105 + | .query_incompatible_operation(
|
106 + | move |input: crate::input::QueryIncompatibleOperationInput| {
|
107 + | let sender = sender.clone();
|
108 + | async move {
|
109 + | let result = {
|
110 + | let expected = crate::input::QueryIncompatibleOperationInput {};
|
111 + | ::pretty_assertions::assert_eq!(input, expected);
|
112 + | let output = crate::output::QueryIncompatibleOperationOutput {};
|
113 + | output
|
114 + | };
|
115 + | sender.send(()).await.expect("receiver dropped early");
|
116 + | result
|
117 + | }
|
118 + | },
|
119 + | )
|
120 + | .build_unchecked();
|
121 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
122 + | .await
|
123 + | .expect("unable to make an HTTP request");
|
124 + | assert!(
|
125 + | receiver.recv().await.is_some(),
|
126 + | "we expected operation handler to be invoked but it was not entered"
|
127 + | );
|
128 + | }
|
129 + | }
|
130 + |
|
131 + | ::pin_project_lite::pin_project! {
|
132 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
133 + | /// [`OperationWithRequiredMembersWithDefaultsInput`](crate::input::OperationWithRequiredMembersWithDefaultsInput) using modelled bindings.
|
134 + | pub struct OperationWithRequiredMembersWithDefaultsInputFuture {
|
135 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithRequiredMembersWithDefaultsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
136 + | }
|
137 + | }
|
138 + |
|
139 + | impl std::future::Future for OperationWithRequiredMembersWithDefaultsInputFuture {
|
140 + | type Output = Result<
|
141 + | crate::input::OperationWithRequiredMembersWithDefaultsInput,
|
142 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
143 + | >;
|
144 + |
|
145 + | fn poll(
|
146 + | self: std::pin::Pin<&mut Self>,
|
147 + | cx: &mut std::task::Context<'_>,
|
148 + | ) -> std::task::Poll<Self::Output> {
|
149 + | let this = self.project();
|
150 + | this.inner.as_mut().poll(cx)
|
151 + | }
|
152 + | }
|
153 + |
|
154 + | impl<B>
|
155 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
156 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
157 + | B,
|
158 + | > for crate::input::OperationWithRequiredMembersWithDefaultsInput
|
159 + | where
|
160 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
161 + | B: 'static,
|
162 + |
|
163 + | B::Data: Send,
|
164 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
165 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
166 + | {
|
167 + | type Rejection =
|
168 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
169 + | type Future = OperationWithRequiredMembersWithDefaultsInputFuture;
|
170 + |
|
171 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
172 + | let fut = async move {
|
173 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
174 + | request.headers(),
|
175 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
176 + | ) {
|
177 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
178 + | }
|
179 + | crate::protocol_serde::shape_operation_with_required_members_with_defaults::de_operation_with_required_members_with_defaults_http_request(request)
|
180 + | .await
|
181 + | };
|
182 + | use ::futures_util::future::TryFutureExt;
|
183 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
184 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
185 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
186 + | });
|
187 + | OperationWithRequiredMembersWithDefaultsInputFuture {
|
188 + | inner: Box::pin(fut),
|
189 + | }
|
190 + | }
|
191 + | }
|
192 + | impl
|
193 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
194 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
195 + | > for crate::output::OperationWithRequiredMembersWithDefaultsOutput
|
196 + | {
|
197 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
198 + | match crate::protocol_serde::shape_operation_with_required_members_with_defaults::ser_operation_with_required_members_with_defaults_http_response(self) {
|
199 + | Ok(response) => response,
|
200 + | Err(e) => {
|
201 + | ::tracing::error!(error = %e, "failed to serialize response");
|
202 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
203 + | }
|
204 + | }
|
205 + | }
|
206 + | }
|
207 + |
|
208 + | ::pin_project_lite::pin_project! {
|
209 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
210 + | /// [`OperationWithNestedStructureInput`](crate::input::OperationWithNestedStructureInput) using modelled bindings.
|
211 + | pub struct OperationWithNestedStructureInputFuture {
|
212 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithNestedStructureInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
213 + | }
|
214 + | }
|
215 + |
|
216 + | impl std::future::Future for OperationWithNestedStructureInputFuture {
|
217 + | type Output = Result<
|
218 + | crate::input::OperationWithNestedStructureInput,
|
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_10::AwsJson1_0,
|
234 + | B,
|
235 + | > for crate::input::OperationWithNestedStructureInput
|
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 = OperationWithNestedStructureInputFuture;
|
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_0,
|
253 + | ) {
|
254 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
255 + | }
|
256 + | crate::protocol_serde::shape_operation_with_nested_structure::de_operation_with_nested_structure_http_request(request)
|
257 + | .await
|
258 + | };
|
259 + | use ::futures_util::future::TryFutureExt;
|
260 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
261 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
262 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
263 + | });
|
264 + | OperationWithNestedStructureInputFuture {
|
265 + | inner: Box::pin(fut),
|
266 + | }
|
267 + | }
|
268 + | }
|
269 + | impl
|
270 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
271 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
272 + | > for crate::output::OperationWithNestedStructureOutput
|
273 + | {
|
274 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
275 + | match crate::protocol_serde::shape_operation_with_nested_structure::ser_operation_with_nested_structure_http_response(self) {
|
276 + | Ok(response) => response,
|
277 + | Err(e) => {
|
278 + | ::tracing::error!(error = %e, "failed to serialize response");
|
279 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
280 + | }
|
281 + | }
|
282 + | }
|
283 + | }
|
284 + | impl
|
285 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
286 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
287 + | > for crate::error::OperationWithNestedStructureError
|
288 + | {
|
289 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
290 + | match crate::protocol_serde::shape_operation_with_nested_structure::ser_operation_with_nested_structure_http_error(&self) {
|
291 + | Ok(mut response) => {
|
292 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
293 + | response
|
294 + | },
|
295 + | Err(e) => {
|
296 + | ::tracing::error!(error = %e, "failed to serialize response");
|
297 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
298 + | }
|
299 + | }
|
300 + | }
|
301 + | }
|
302 + |
|
303 + | #[allow(unreachable_code, unused_variables)]
|
304 + | #[cfg(test)]
|
305 + | mod operation_with_nested_structure_test {
|
306 + |
|
307 + | /// Server populates nested default values when missing in request body.
|
308 + | /// Test ID: AwsJson10ServerPopulatesNestedDefaultsWhenMissingInRequestBody
|
309 + | #[::tokio::test]
|
310 + | #[::tracing_test::traced_test]
|
311 + | #[should_panic]
|
312 + | async fn aws_json10_server_populates_nested_defaults_when_missing_in_request_body_request() {
|
313 + | #[allow(unused_mut)]
|
314 + | let mut http_request = ::http::Request::builder()
|
315 + | .uri("/")
|
316 + | .method("POST")
|
317 + | .header("Content-Type", "application/x-amz-json-1.0")
|
318 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
319 + | ::bytes::Bytes::copy_from_slice(
|
320 + | &::aws_smithy_protocol_test::decode_body_data("{\n \"topLevel\": {\n \"dialog\": {\n \"language\": \"en\"\n },\n \"dialogList\": [\n {\n },\n {\n \"farewell\": {}\n },\n {\n \"language\": \"it\",\n \"greeting\": \"ciao\",\n \"farewell\": {\n \"phrase\": \"arrivederci\"\n }\n }\n ],\n \"dialogMap\": {\n \"emptyDialog\": {\n },\n \"partialEmptyDialog\": {\n \"language\": \"en\",\n \"farewell\": {}\n },\n \"nonEmptyDialog\": {\n \"greeting\": \"konnichiwa\",\n \"farewell\": {\n \"phrase\": \"sayonara\"\n }\n }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
321 + | )
|
322 + | )).unwrap();
|
323 + | #[allow(unused_mut)]
|
324 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
325 + | let config = crate::service::JsonRpc10Config::builder().build();
|
326 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
327 + | .operation_with_nested_structure(
|
328 + | move |input: crate::input::OperationWithNestedStructureInput| {
|
329 + | let sender = sender.clone();
|
330 + | async move {
|
331 + | let result = {
|
332 + | let expected = crate::input::OperationWithNestedStructureInput {
|
333 + | top_level: crate::model::TopLevel {
|
334 + | dialog: crate::model::Dialog {
|
335 + | language: ::std::option::Option::Some("en".to_owned()),
|
336 + | greeting: "hi".to_owned(),
|
337 + | farewell: ::std::option::Option::None,
|
338 + | },
|
339 + | dialog_list: vec![
|
340 + | crate::model::Dialog {
|
341 + | greeting: "hi".to_owned(),
|
342 + | language: ::std::option::Option::None,
|
343 + | farewell: ::std::option::Option::None,
|
344 + | },
|
345 + | crate::model::Dialog {
|
346 + | greeting: "hi".to_owned(),
|
347 + | farewell: ::std::option::Option::Some(
|
348 + | crate::model::Farewell {
|
349 + | phrase: "bye".to_owned(),
|
350 + | },
|
351 + | ),
|
352 + | language: ::std::option::Option::None,
|
353 + | },
|
354 + | crate::model::Dialog {
|
355 + | language: ::std::option::Option::Some("it".to_owned()),
|
356 + | greeting: "ciao".to_owned(),
|
357 + | farewell: ::std::option::Option::Some(
|
358 + | crate::model::Farewell {
|
359 + | phrase: "arrivederci".to_owned(),
|
360 + | },
|
361 + | ),
|
362 + | },
|
363 + | ],
|
364 + | dialog_map: {
|
365 + | let mut ret = ::std::collections::HashMap::new();
|
366 + | ret.insert(
|
367 + | "emptyDialog".to_owned(),
|
368 + | crate::model::Dialog {
|
369 + | greeting: "hi".to_owned(),
|
370 + | language: ::std::option::Option::None,
|
371 + | farewell: ::std::option::Option::None,
|
372 + | },
|
373 + | );
|
374 + | ret.insert(
|
375 + | "partialEmptyDialog".to_owned(),
|
376 + | crate::model::Dialog {
|
377 + | language: ::std::option::Option::Some(
|
378 + | "en".to_owned(),
|
379 + | ),
|
380 + | greeting: "hi".to_owned(),
|
381 + | farewell: ::std::option::Option::Some(
|
382 + | crate::model::Farewell {
|
383 + | phrase: "bye".to_owned(),
|
384 + | },
|
385 + | ),
|
386 + | },
|
387 + | );
|
388 + | ret.insert(
|
389 + | "nonEmptyDialog".to_owned(),
|
390 + | crate::model::Dialog {
|
391 + | greeting: "konnichiwa".to_owned(),
|
392 + | farewell: ::std::option::Option::Some(
|
393 + | crate::model::Farewell {
|
394 + | phrase: "sayonara".to_owned(),
|
395 + | },
|
396 + | ),
|
397 + | language: ::std::option::Option::None,
|
398 + | },
|
399 + | );
|
400 + | ret
|
401 + | },
|
402 + | },
|
403 + | };
|
404 + | ::pretty_assertions::assert_eq!(input, expected);
|
405 + | let output = crate::output::OperationWithNestedStructureOutput {
|
406 + | dialog: crate::model::Dialog {
|
407 + | greeting: "".to_owned(),
|
408 + | language: ::std::option::Option::None,
|
409 + | farewell: ::std::option::Option::None,
|
410 + | },
|
411 + | dialog_list: vec![],
|
412 + | dialog_map: ::std::collections::HashMap::new(),
|
413 + | };
|
414 + | Ok(output)
|
415 + | };
|
416 + | sender.send(()).await.expect("receiver dropped early");
|
417 + | result
|
418 + | }
|
419 + | },
|
420 + | )
|
421 + | .build_unchecked();
|
422 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
423 + | .await
|
424 + | .expect("unable to make an HTTP request");
|
425 + | assert!(
|
426 + | receiver.recv().await.is_some(),
|
427 + | "we expected operation handler to be invoked but it was not entered"
|
428 + | );
|
429 + | }
|
430 + |
|
431 + | /// Server populates nested default values when missing in response params.
|
432 + | /// Test ID: AwsJson10ServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams
|
433 + | #[::tokio::test]
|
434 + | #[::tracing_test::traced_test]
|
435 + | #[should_panic]
|
436 + | async fn aws_json10_server_populates_nested_default_values_when_missing_in_in_response_params_response(
|
437 + | ) {
|
438 + | let output = crate::output::OperationWithNestedStructureOutput {
|
439 + | dialog: crate::model::Dialog {
|
440 + | greeting: "".to_owned(),
|
441 + | language: ::std::option::Option::Some("en".to_owned()),
|
442 + | farewell: ::std::option::Option::None,
|
443 + | },
|
444 + | dialog_list: vec![
|
445 + | crate::model::Dialog {
|
446 + | greeting: "".to_owned(),
|
447 + | language: ::std::option::Option::None,
|
448 + | farewell: ::std::option::Option::None,
|
449 + | },
|
450 + | crate::model::Dialog {
|
451 + | greeting: "".to_owned(),
|
452 + | farewell: ::std::option::Option::Some(crate::model::Farewell {
|
453 + | phrase: "".to_owned(),
|
454 + | }),
|
455 + | language: ::std::option::Option::None,
|
456 + | },
|
457 + | crate::model::Dialog {
|
458 + | language: ::std::option::Option::Some("it".to_owned()),
|
459 + | greeting: "ciao".to_owned(),
|
460 + | farewell: ::std::option::Option::Some(crate::model::Farewell {
|
461 + | phrase: "arrivederci".to_owned(),
|
462 + | }),
|
463 + | },
|
464 + | ],
|
465 + | dialog_map: {
|
466 + | let mut ret = ::std::collections::HashMap::new();
|
467 + | ret.insert(
|
468 + | "emptyDialog".to_owned(),
|
469 + | crate::model::Dialog {
|
470 + | greeting: "".to_owned(),
|
471 + | language: ::std::option::Option::None,
|
472 + | farewell: ::std::option::Option::None,
|
473 + | },
|
474 + | );
|
475 + | ret.insert(
|
476 + | "partialEmptyDialog".to_owned(),
|
477 + | crate::model::Dialog {
|
478 + | greeting: "".to_owned(),
|
479 + | language: ::std::option::Option::Some("en".to_owned()),
|
480 + | farewell: ::std::option::Option::Some(crate::model::Farewell {
|
481 + | phrase: "".to_owned(),
|
482 + | }),
|
483 + | },
|
484 + | );
|
485 + | ret.insert(
|
486 + | "nonEmptyDialog".to_owned(),
|
487 + | crate::model::Dialog {
|
488 + | greeting: "konnichiwa".to_owned(),
|
489 + | farewell: ::std::option::Option::Some(crate::model::Farewell {
|
490 + | phrase: "sayonara".to_owned(),
|
491 + | }),
|
492 + | language: ::std::option::Option::None,
|
493 + | },
|
494 + | );
|
495 + | ret
|
496 + | },
|
497 + | };
|
498 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
499 + | let http_response = output.into_response();
|
500 + | ::pretty_assertions::assert_eq!(
|
501 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
502 + | http_response.status()
|
503 + | );
|
504 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
505 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
506 + | http_response.headers(),
|
507 + | expected_headers,
|
508 + | ));
|
509 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
510 + | .await
|
511 + | .expect("unable to extract body to bytes");
|
512 + | ::aws_smithy_protocol_test::assert_ok(
|
513 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"dialog\": {\n \"language\": \"en\",\n \"greeting\": \"hi\"\n },\n \"dialogList\": [\n {\n \"greeting\": \"hi\"\n },\n {\n \"greeting\": \"hi\",\n \"farewell\": {\n \"phrase\": \"bye\"\n }\n },\n {\n \"language\": \"it\",\n \"greeting\": \"ciao\",\n \"farewell\": {\n \"phrase\": \"arrivederci\"\n }\n }\n ],\n \"dialogMap\": {\n \"emptyDialog\": {\n \"greeting\": \"hi\"\n },\n \"partialEmptyDialog\": {\n \"language\": \"en\",\n \"greeting\": \"hi\",\n \"farewell\": {\n \"phrase\": \"bye\"\n }\n },\n \"nonEmptyDialog\": {\n \"greeting\": \"konnichiwa\",\n \"farewell\": {\n \"phrase\": \"sayonara\"\n }\n }\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
514 + | );
|
515 + | }
|
516 + | }
|
517 + |
|
518 + | ::pin_project_lite::pin_project! {
|
519 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
520 + | /// [`OperationWithRequiredMembersInput`](crate::input::OperationWithRequiredMembersInput) using modelled bindings.
|
521 + | pub struct OperationWithRequiredMembersInputFuture {
|
522 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithRequiredMembersInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
523 + | }
|
524 + | }
|
525 + |
|
526 + | impl std::future::Future for OperationWithRequiredMembersInputFuture {
|
527 + | type Output = Result<
|
528 + | crate::input::OperationWithRequiredMembersInput,
|
529 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
530 + | >;
|
531 + |
|
532 + | fn poll(
|
533 + | self: std::pin::Pin<&mut Self>,
|
534 + | cx: &mut std::task::Context<'_>,
|
535 + | ) -> std::task::Poll<Self::Output> {
|
536 + | let this = self.project();
|
537 + | this.inner.as_mut().poll(cx)
|
538 + | }
|
539 + | }
|
540 + |
|
541 + | impl<B>
|
542 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
543 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
544 + | B,
|
545 + | > for crate::input::OperationWithRequiredMembersInput
|
546 + | where
|
547 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
548 + | B: 'static,
|
549 + |
|
550 + | B::Data: Send,
|
551 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
552 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
553 + | {
|
554 + | type Rejection =
|
555 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
556 + | type Future = OperationWithRequiredMembersInputFuture;
|
557 + |
|
558 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
559 + | let fut = async move {
|
560 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
561 + | request.headers(),
|
562 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
563 + | ) {
|
564 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
565 + | }
|
566 + | crate::protocol_serde::shape_operation_with_required_members::de_operation_with_required_members_http_request(request)
|
567 + | .await
|
568 + | };
|
569 + | use ::futures_util::future::TryFutureExt;
|
570 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
571 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
572 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
573 + | });
|
574 + | OperationWithRequiredMembersInputFuture {
|
575 + | inner: Box::pin(fut),
|
576 + | }
|
577 + | }
|
578 + | }
|
579 + | impl
|
580 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
581 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
582 + | > for crate::output::OperationWithRequiredMembersOutput
|
583 + | {
|
584 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
585 + | match crate::protocol_serde::shape_operation_with_required_members::ser_operation_with_required_members_http_response(self) {
|
586 + | Ok(response) => response,
|
587 + | Err(e) => {
|
588 + | ::tracing::error!(error = %e, "failed to serialize response");
|
589 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
590 + | }
|
591 + | }
|
592 + | }
|
593 + | }
|
594 + |
|
595 + | ::pin_project_lite::pin_project! {
|
596 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
597 + | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
598 + | pub struct OperationWithDefaultsInputFuture {
|
599 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
600 + | }
|
601 + | }
|
602 + |
|
603 + | impl std::future::Future for OperationWithDefaultsInputFuture {
|
604 + | type Output = Result<
|
605 + | crate::input::OperationWithDefaultsInput,
|
606 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
607 + | >;
|
608 + |
|
609 + | fn poll(
|
610 + | self: std::pin::Pin<&mut Self>,
|
611 + | cx: &mut std::task::Context<'_>,
|
612 + | ) -> std::task::Poll<Self::Output> {
|
613 + | let this = self.project();
|
614 + | this.inner.as_mut().poll(cx)
|
615 + | }
|
616 + | }
|
617 + |
|
618 + | impl<B>
|
619 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
620 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
621 + | B,
|
622 + | > for crate::input::OperationWithDefaultsInput
|
623 + | where
|
624 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
625 + | B: 'static,
|
626 + |
|
627 + | B::Data: Send,
|
628 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
629 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
630 + | {
|
631 + | type Rejection =
|
632 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
633 + | type Future = OperationWithDefaultsInputFuture;
|
634 + |
|
635 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
636 + | let fut = async move {
|
637 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
638 + | request.headers(),
|
639 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
640 + | ) {
|
641 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
642 + | }
|
643 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
644 + | .await
|
645 + | };
|
646 + | use ::futures_util::future::TryFutureExt;
|
647 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
648 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
649 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
650 + | });
|
651 + | OperationWithDefaultsInputFuture {
|
652 + | inner: Box::pin(fut),
|
653 + | }
|
654 + | }
|
655 + | }
|
656 + | impl
|
657 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
658 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
659 + | > for crate::output::OperationWithDefaultsOutput
|
660 + | {
|
661 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
662 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_response(self) {
|
663 + | Ok(response) => response,
|
664 + | Err(e) => {
|
665 + | ::tracing::error!(error = %e, "failed to serialize response");
|
666 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
667 + | }
|
668 + | }
|
669 + | }
|
670 + | }
|
671 + | impl
|
672 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
673 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
674 + | > for crate::error::OperationWithDefaultsError
|
675 + | {
|
676 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
677 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_error(&self) {
|
678 + | Ok(mut response) => {
|
679 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
680 + | response
|
681 + | },
|
682 + | Err(e) => {
|
683 + | ::tracing::error!(error = %e, "failed to serialize response");
|
684 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
685 + | }
|
686 + | }
|
687 + | }
|
688 + | }
|
689 + |
|
690 + | #[allow(unreachable_code, unused_variables)]
|
691 + | #[cfg(test)]
|
692 + | mod operation_with_defaults_test {
|
693 + |
|
694 + | /// Server populates default values when missing in request body.
|
695 + | /// Test ID: AwsJson10ServerPopulatesDefaultsWhenMissingInRequestBody
|
696 + | #[::tokio::test]
|
697 + | #[::tracing_test::traced_test]
|
698 + | #[should_panic]
|
699 + | async fn aws_json10_server_populates_defaults_when_missing_in_request_body_request() {
|
700 + | #[allow(unused_mut)]
|
701 + | let mut http_request = ::http::Request::builder()
|
702 + | .uri("/")
|
703 + | .method("POST")
|
704 + | .header("Content-Type", "application/x-amz-json-1.0")
|
705 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
706 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
707 + | "{\n\"defaults\": {}\n}".as_bytes(),
|
708 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
709 + | )),
|
710 + | ))
|
711 + | .unwrap();
|
712 + | #[allow(unused_mut)]
|
713 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
714 + | let config = crate::service::JsonRpc10Config::builder().build();
|
715 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
716 + | .operation_with_defaults(move |input: crate::input::OperationWithDefaultsInput| {
|
717 + | let sender = sender.clone();
|
718 + | async move {
|
719 + | let result = {
|
720 + | let expected = crate::input::OperationWithDefaultsInput {
|
721 + | defaults: ::std::option::Option::Some(crate::model::Defaults {
|
722 + | default_string: "hi".to_owned(),
|
723 + | default_boolean: true,
|
724 + | default_list: vec![],
|
725 + | default_document_map: {
|
726 + | let json_bytes = br#"{}"#;
|
727 + | let mut tokens =
|
728 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
729 + | .peekable();
|
730 + | ::aws_smithy_json::deserialize::token::expect_document(
|
731 + | &mut tokens,
|
732 + | )
|
733 + | .expect("well formed json")
|
734 + | },
|
735 + | default_document_string: {
|
736 + | let json_bytes = br#""hi""#;
|
737 + | let mut tokens =
|
738 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
739 + | .peekable();
|
740 + | ::aws_smithy_json::deserialize::token::expect_document(
|
741 + | &mut tokens,
|
742 + | )
|
743 + | .expect("well formed json")
|
744 + | },
|
745 + | default_document_boolean: {
|
746 + | let json_bytes = br#"true"#;
|
747 + | let mut tokens =
|
748 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
749 + | .peekable();
|
750 + | ::aws_smithy_json::deserialize::token::expect_document(
|
751 + | &mut tokens,
|
752 + | )
|
753 + | .expect("well formed json")
|
754 + | },
|
755 + | default_document_list: {
|
756 + | let json_bytes = br#"[]"#;
|
757 + | let mut tokens =
|
758 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
759 + | .peekable();
|
760 + | ::aws_smithy_json::deserialize::token::expect_document(
|
761 + | &mut tokens,
|
762 + | )
|
763 + | .expect("well formed json")
|
764 + | },
|
765 + | default_timestamp:
|
766 + | ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
767 + | default_blob: ::aws_smithy_types::Blob::new("abc"),
|
768 + | default_byte: 1,
|
769 + | default_short: 1,
|
770 + | default_integer: 10,
|
771 + | default_long: 100,
|
772 + | default_float: 1.0_f32,
|
773 + | default_double: 1.0_f64,
|
774 + | default_map: ::std::collections::HashMap::new(),
|
775 + | default_enum: "FOO"
|
776 + | .parse::<crate::model::TestEnum>()
|
777 + | .expect("static value validated to member"),
|
778 + | default_int_enum: 1,
|
779 + | empty_string: "".to_owned(),
|
780 + | false_boolean: false,
|
781 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
782 + | zero_byte: 0,
|
783 + | zero_short: 0,
|
784 + | zero_integer: 0,
|
785 + | zero_long: 0,
|
786 + | zero_float: 0.0_f32,
|
787 + | zero_double: 0.0_f64,
|
788 + | default_null_document: ::std::option::Option::Some({
|
789 + | let json_bytes = br#"null"#;
|
790 + | let mut tokens =
|
791 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
792 + | .peekable();
|
793 + | ::aws_smithy_json::deserialize::token::expect_document(
|
794 + | &mut tokens,
|
795 + | )
|
796 + | .expect("well formed json")
|
797 + | }),
|
798 + | }),
|
799 + | top_level_default: "hi".to_owned(),
|
800 + | other_top_level_default: 0,
|
801 + | client_optional_defaults: ::std::option::Option::None,
|
802 + | };
|
803 + | ::pretty_assertions::assert_eq!(input, expected);
|
804 + | let output = crate::output::OperationWithDefaultsOutput {
|
805 + | default_string: "".to_owned(),
|
806 + | default_boolean: false,
|
807 + | default_list: vec![],
|
808 + | default_document_map: {
|
809 + | let json_bytes = br#"{}"#;
|
810 + | let mut tokens =
|
811 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
812 + | .peekable();
|
813 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
814 + | .expect("well formed json")
|
815 + | },
|
816 + | default_document_string: {
|
817 + | let json_bytes = br#"{}"#;
|
818 + | let mut tokens =
|
819 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
820 + | .peekable();
|
821 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
822 + | .expect("well formed json")
|
823 + | },
|
824 + | default_document_boolean: {
|
825 + | let json_bytes = br#"{}"#;
|
826 + | let mut tokens =
|
827 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
828 + | .peekable();
|
829 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
830 + | .expect("well formed json")
|
831 + | },
|
832 + | default_document_list: {
|
833 + | let json_bytes = br#"{}"#;
|
834 + | let mut tokens =
|
835 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
836 + | .peekable();
|
837 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
838 + | .expect("well formed json")
|
839 + | },
|
840 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
841 + | 0, 0_f64,
|
842 + | ),
|
843 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
844 + | default_byte: 0,
|
845 + | default_short: 0,
|
846 + | default_integer: 0,
|
847 + | default_long: 0,
|
848 + | default_float: 0_f32,
|
849 + | default_double: 0_f64,
|
850 + | default_map: ::std::collections::HashMap::new(),
|
851 + | default_enum: ""
|
852 + | .parse::<crate::model::TestEnum>()
|
853 + | .expect("static value validated to member"),
|
854 + | default_int_enum: 0,
|
855 + | empty_string: "".to_owned(),
|
856 + | false_boolean: false,
|
857 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
858 + | zero_byte: 0,
|
859 + | zero_short: 0,
|
860 + | zero_integer: 0,
|
861 + | zero_long: 0,
|
862 + | zero_float: 0_f32,
|
863 + | zero_double: 0_f64,
|
864 + | default_null_document: ::std::option::Option::Some({
|
865 + | let json_bytes = br#"null"#;
|
866 + | let mut tokens =
|
867 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes)
|
868 + | .peekable();
|
869 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
870 + | .expect("well formed json")
|
871 + | }),
|
872 + | };
|
873 + | Ok(output)
|
874 + | };
|
875 + | sender.send(()).await.expect("receiver dropped early");
|
876 + | result
|
877 + | }
|
878 + | })
|
879 + | .build_unchecked();
|
880 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
881 + | .await
|
882 + | .expect("unable to make an HTTP request");
|
883 + | assert!(
|
884 + | receiver.recv().await.is_some(),
|
885 + | "we expected operation handler to be invoked but it was not entered"
|
886 + | );
|
887 + | }
|
888 + |
|
889 + | /// Server populates default values in response when missing in params.
|
890 + | /// Test ID: AwsJson10ServerPopulatesDefaultsInResponseWhenMissingInParams
|
891 + | #[::tokio::test]
|
892 + | #[::tracing_test::traced_test]
|
893 + | #[should_panic]
|
894 + | async fn aws_json10_server_populates_defaults_in_response_when_missing_in_params_response() {
|
895 + | let output = crate::output::OperationWithDefaultsOutput {
|
896 + | default_string: "".to_owned(),
|
897 + | default_boolean: false,
|
898 + | default_list: vec![],
|
899 + | default_document_map: {
|
900 + | let json_bytes = br#"{}"#;
|
901 + | let mut tokens =
|
902 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
903 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
904 + | .expect("well formed json")
|
905 + | },
|
906 + | default_document_string: {
|
907 + | let json_bytes = br#"{}"#;
|
908 + | let mut tokens =
|
909 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
910 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
911 + | .expect("well formed json")
|
912 + | },
|
913 + | default_document_boolean: {
|
914 + | let json_bytes = br#"{}"#;
|
915 + | let mut tokens =
|
916 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
917 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
918 + | .expect("well formed json")
|
919 + | },
|
920 + | default_document_list: {
|
921 + | let json_bytes = br#"{}"#;
|
922 + | let mut tokens =
|
923 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
924 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
925 + | .expect("well formed json")
|
926 + | },
|
927 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
928 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
929 + | default_byte: 0,
|
930 + | default_short: 0,
|
931 + | default_integer: 0,
|
932 + | default_long: 0,
|
933 + | default_float: 0_f32,
|
934 + | default_double: 0_f64,
|
935 + | default_map: ::std::collections::HashMap::new(),
|
936 + | default_enum: ""
|
937 + | .parse::<crate::model::TestEnum>()
|
938 + | .expect("static value validated to member"),
|
939 + | default_int_enum: 0,
|
940 + | empty_string: "".to_owned(),
|
941 + | false_boolean: false,
|
942 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
943 + | zero_byte: 0,
|
944 + | zero_short: 0,
|
945 + | zero_integer: 0,
|
946 + | zero_long: 0,
|
947 + | zero_float: 0_f32,
|
948 + | zero_double: 0_f64,
|
949 + | default_null_document: ::std::option::Option::Some({
|
950 + | let json_bytes = br#"null"#;
|
951 + | let mut tokens =
|
952 + | ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
|
953 + | ::aws_smithy_json::deserialize::token::expect_document(&mut tokens)
|
954 + | .expect("well formed json")
|
955 + | }),
|
956 + | };
|
957 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
958 + | let http_response = output.into_response();
|
959 + | ::pretty_assertions::assert_eq!(
|
960 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
961 + | http_response.status()
|
962 + | );
|
963 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
964 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
965 + | http_response.headers(),
|
966 + | expected_headers,
|
967 + | ));
|
968 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
969 + | .await
|
970 + | .expect("unable to extract body to bytes");
|
971 + | ::aws_smithy_protocol_test::assert_ok(
|
972 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"defaultString\": \"hi\",\n \"defaultBoolean\": true,\n \"defaultList\": [],\n \"defaultDocumentMap\": {},\n \"defaultDocumentString\": \"hi\",\n \"defaultDocumentBoolean\": true,\n \"defaultDocumentList\": [],\n \"defaultTimestamp\": 0,\n \"defaultBlob\": \"YWJj\",\n \"defaultByte\": 1,\n \"defaultShort\": 1,\n \"defaultInteger\": 10,\n \"defaultLong\": 100,\n \"defaultFloat\": 1.0,\n \"defaultDouble\": 1.0,\n \"defaultMap\": {},\n \"defaultEnum\": \"FOO\",\n \"defaultIntEnum\": 1,\n \"emptyString\": \"\",\n \"falseBoolean\": false,\n \"emptyBlob\": \"\",\n \"zeroByte\": 0,\n \"zeroShort\": 0,\n \"zeroInteger\": 0,\n \"zeroLong\": 0,\n \"zeroFloat\": 0.0,\n \"zeroDouble\": 0.0\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
973 + | );
|
974 + | }
|
975 + | }
|
976 + |
|
977 + | ::pin_project_lite::pin_project! {
|
978 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
979 + | /// [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput) using modelled bindings.
|
980 + | pub struct ContentTypeParametersInputFuture {
|
981 + | 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>>
|
982 + | }
|
983 + | }
|
984 + |
|
985 + | impl std::future::Future for ContentTypeParametersInputFuture {
|
986 + | type Output = Result<
|
987 + | crate::input::ContentTypeParametersInput,
|
988 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
989 + | >;
|
990 + |
|
991 + | fn poll(
|
992 + | self: std::pin::Pin<&mut Self>,
|
993 + | cx: &mut std::task::Context<'_>,
|
994 + | ) -> std::task::Poll<Self::Output> {
|
995 + | let this = self.project();
|
996 + | this.inner.as_mut().poll(cx)
|
997 + | }
|
998 + | }
|
999 + |
|
1000 + | impl<B>
|
1001 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1002 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1003 + | B,
|
1004 + | > for crate::input::ContentTypeParametersInput
|
1005 + | where
|
1006 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1007 + | B: 'static,
|
1008 + |
|
1009 + | B::Data: Send,
|
1010 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1011 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1012 + | {
|
1013 + | type Rejection =
|
1014 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1015 + | type Future = ContentTypeParametersInputFuture;
|
1016 + |
|
1017 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1018 + | let fut = async move {
|
1019 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1020 + | request.headers(),
|
1021 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
1022 + | ) {
|
1023 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1024 + | }
|
1025 + | crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters_http_request(request)
|
1026 + | .await
|
1027 + | };
|
1028 + | use ::futures_util::future::TryFutureExt;
|
1029 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1030 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1031 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1032 + | });
|
1033 + | ContentTypeParametersInputFuture {
|
1034 + | inner: Box::pin(fut),
|
1035 + | }
|
1036 + | }
|
1037 + | }
|
1038 + | impl
|
1039 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1040 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1041 + | > for crate::output::ContentTypeParametersOutput
|
1042 + | {
|
1043 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1044 + | match crate::protocol_serde::shape_content_type_parameters::ser_content_type_parameters_http_response(self) {
|
1045 + | Ok(response) => response,
|
1046 + | Err(e) => {
|
1047 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1048 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1049 + | }
|
1050 + | }
|
1051 + | }
|
1052 + | }
|
1053 + |
|
1054 + | #[allow(unreachable_code, unused_variables)]
|
1055 + | #[cfg(test)]
|
1056 + | mod content_type_parameters_test {
|
1057 + |
|
1058 + | /// A server should ignore parameters added to the content type
|
1059 + | /// Test ID: AwsJson10MustSupportParametersInContentType
|
1060 + | #[::tokio::test]
|
1061 + | #[::tracing_test::traced_test]
|
1062 + | async fn aws_json10_must_support_parameters_in_content_type_request() {
|
1063 + | #[allow(unused_mut)]
|
1064 + | let mut http_request = ::http::Request::builder()
|
1065 + | .uri("/")
|
1066 + | .method("POST")
|
1067 + | .header("Content-Type", "application/x-amz-json-1.0; charset=utf-8")
|
1068 + | .header("X-Amz-Target", "JsonRpc10.ContentTypeParameters")
|
1069 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1070 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1071 + | "{\"value\":5}".as_bytes(),
|
1072 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1073 + | )),
|
1074 + | ))
|
1075 + | .unwrap();
|
1076 + | #[allow(unused_mut)]
|
1077 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1078 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1079 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1080 + | .content_type_parameters(move |input: crate::input::ContentTypeParametersInput| {
|
1081 + | let sender = sender.clone();
|
1082 + | async move {
|
1083 + | let result = {
|
1084 + | let expected = crate::input::ContentTypeParametersInput {
|
1085 + | value: ::std::option::Option::Some(5),
|
1086 + | };
|
1087 + | ::pretty_assertions::assert_eq!(input, expected);
|
1088 + | let output = crate::output::ContentTypeParametersOutput {};
|
1089 + | output
|
1090 + | };
|
1091 + | sender.send(()).await.expect("receiver dropped early");
|
1092 + | result
|
1093 + | }
|
1094 + | })
|
1095 + | .build_unchecked();
|
1096 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1097 + | .await
|
1098 + | .expect("unable to make an HTTP request");
|
1099 + | assert!(
|
1100 + | receiver.recv().await.is_some(),
|
1101 + | "we expected operation handler to be invoked but it was not entered"
|
1102 + | );
|
1103 + | }
|
1104 + | }
|
1105 + |
|
1106 + | ::pin_project_lite::pin_project! {
|
1107 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1108 + | /// [`PutWithContentEncodingInput`](crate::input::PutWithContentEncodingInput) using modelled bindings.
|
1109 + | pub struct PutWithContentEncodingInputFuture {
|
1110 + | 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>>
|
1111 + | }
|
1112 + | }
|
1113 + |
|
1114 + | impl std::future::Future for PutWithContentEncodingInputFuture {
|
1115 + | type Output = Result<
|
1116 + | crate::input::PutWithContentEncodingInput,
|
1117 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1118 + | >;
|
1119 + |
|
1120 + | fn poll(
|
1121 + | self: std::pin::Pin<&mut Self>,
|
1122 + | cx: &mut std::task::Context<'_>,
|
1123 + | ) -> std::task::Poll<Self::Output> {
|
1124 + | let this = self.project();
|
1125 + | this.inner.as_mut().poll(cx)
|
1126 + | }
|
1127 + | }
|
1128 + |
|
1129 + | impl<B>
|
1130 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1131 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1132 + | B,
|
1133 + | > for crate::input::PutWithContentEncodingInput
|
1134 + | where
|
1135 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1136 + | B: 'static,
|
1137 + |
|
1138 + | B::Data: Send,
|
1139 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1140 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1141 + | {
|
1142 + | type Rejection =
|
1143 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1144 + | type Future = PutWithContentEncodingInputFuture;
|
1145 + |
|
1146 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1147 + | let fut = async move {
|
1148 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1149 + | request.headers(),
|
1150 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
1151 + | ) {
|
1152 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1153 + | }
|
1154 + | crate::protocol_serde::shape_put_with_content_encoding::de_put_with_content_encoding_http_request(request)
|
1155 + | .await
|
1156 + | };
|
1157 + | use ::futures_util::future::TryFutureExt;
|
1158 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1159 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1160 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1161 + | });
|
1162 + | PutWithContentEncodingInputFuture {
|
1163 + | inner: Box::pin(fut),
|
1164 + | }
|
1165 + | }
|
1166 + | }
|
1167 + | impl
|
1168 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1169 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1170 + | > for crate::output::PutWithContentEncodingOutput
|
1171 + | {
|
1172 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1173 + | match crate::protocol_serde::shape_put_with_content_encoding::ser_put_with_content_encoding_http_response(self) {
|
1174 + | Ok(response) => response,
|
1175 + | Err(e) => {
|
1176 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1177 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1178 + | }
|
1179 + | }
|
1180 + | }
|
1181 + | }
|
1182 + |
|
1183 + | ::pin_project_lite::pin_project! {
|
1184 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1185 + | /// [`HostWithPathOperationInput`](crate::input::HostWithPathOperationInput) using modelled bindings.
|
1186 + | pub struct HostWithPathOperationInputFuture {
|
1187 + | 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>>
|
1188 + | }
|
1189 + | }
|
1190 + |
|
1191 + | impl std::future::Future for HostWithPathOperationInputFuture {
|
1192 + | type Output = Result<
|
1193 + | crate::input::HostWithPathOperationInput,
|
1194 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1195 + | >;
|
1196 + |
|
1197 + | fn poll(
|
1198 + | self: std::pin::Pin<&mut Self>,
|
1199 + | cx: &mut std::task::Context<'_>,
|
1200 + | ) -> std::task::Poll<Self::Output> {
|
1201 + | let this = self.project();
|
1202 + | this.inner.as_mut().poll(cx)
|
1203 + | }
|
1204 + | }
|
1205 + |
|
1206 + | impl<B>
|
1207 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1208 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1209 + | B,
|
1210 + | > for crate::input::HostWithPathOperationInput
|
1211 + | where
|
1212 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1213 + | B: 'static,
|
1214 + |
|
1215 + | B::Data: Send,
|
1216 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1217 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1218 + | {
|
1219 + | type Rejection =
|
1220 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1221 + | type Future = HostWithPathOperationInputFuture;
|
1222 + |
|
1223 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1224 + | let fut = async move {
|
1225 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1226 + | request.headers(),
|
1227 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
1228 + | ) {
|
1229 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1230 + | }
|
1231 + | crate::protocol_serde::shape_host_with_path_operation::de_host_with_path_operation_http_request(request)
|
1232 + | .await
|
1233 + | };
|
1234 + | use ::futures_util::future::TryFutureExt;
|
1235 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1236 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1237 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1238 + | });
|
1239 + | HostWithPathOperationInputFuture {
|
1240 + | inner: Box::pin(fut),
|
1241 + | }
|
1242 + | }
|
1243 + | }
|
1244 + | impl
|
1245 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1246 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1247 + | > for crate::output::HostWithPathOperationOutput
|
1248 + | {
|
1249 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1250 + | match crate::protocol_serde::shape_host_with_path_operation::ser_host_with_path_operation_http_response(self) {
|
1251 + | Ok(response) => response,
|
1252 + | Err(e) => {
|
1253 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1254 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1255 + | }
|
1256 + | }
|
1257 + | }
|
1258 + | }
|
1259 + |
|
1260 + | ::pin_project_lite::pin_project! {
|
1261 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1262 + | /// [`EndpointWithHostLabelOperationInput`](crate::input::EndpointWithHostLabelOperationInput) using modelled bindings.
|
1263 + | pub struct EndpointWithHostLabelOperationInputFuture {
|
1264 + | 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>>
|
1265 + | }
|
1266 + | }
|
1267 + |
|
1268 + | impl std::future::Future for EndpointWithHostLabelOperationInputFuture {
|
1269 + | type Output = Result<
|
1270 + | crate::input::EndpointWithHostLabelOperationInput,
|
1271 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1272 + | >;
|
1273 + |
|
1274 + | fn poll(
|
1275 + | self: std::pin::Pin<&mut Self>,
|
1276 + | cx: &mut std::task::Context<'_>,
|
1277 + | ) -> std::task::Poll<Self::Output> {
|
1278 + | let this = self.project();
|
1279 + | this.inner.as_mut().poll(cx)
|
1280 + | }
|
1281 + | }
|
1282 + |
|
1283 + | impl<B>
|
1284 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1285 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1286 + | B,
|
1287 + | > for crate::input::EndpointWithHostLabelOperationInput
|
1288 + | where
|
1289 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1290 + | B: 'static,
|
1291 + |
|
1292 + | B::Data: Send,
|
1293 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1294 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1295 + | {
|
1296 + | type Rejection =
|
1297 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1298 + | type Future = EndpointWithHostLabelOperationInputFuture;
|
1299 + |
|
1300 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1301 + | let fut = async move {
|
1302 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1303 + | request.headers(),
|
1304 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
1305 + | ) {
|
1306 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1307 + | }
|
1308 + | crate::protocol_serde::shape_endpoint_with_host_label_operation::de_endpoint_with_host_label_operation_http_request(request)
|
1309 + | .await
|
1310 + | };
|
1311 + | use ::futures_util::future::TryFutureExt;
|
1312 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1313 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1314 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1315 + | });
|
1316 + | EndpointWithHostLabelOperationInputFuture {
|
1317 + | inner: Box::pin(fut),
|
1318 + | }
|
1319 + | }
|
1320 + | }
|
1321 + | impl
|
1322 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1323 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1324 + | > for crate::output::EndpointWithHostLabelOperationOutput
|
1325 + | {
|
1326 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1327 + | match crate::protocol_serde::shape_endpoint_with_host_label_operation::ser_endpoint_with_host_label_operation_http_response(self) {
|
1328 + | Ok(response) => response,
|
1329 + | Err(e) => {
|
1330 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1331 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1332 + | }
|
1333 + | }
|
1334 + | }
|
1335 + | }
|
1336 + | impl
|
1337 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1338 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1339 + | > for crate::error::EndpointWithHostLabelOperationError
|
1340 + | {
|
1341 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1342 + | match crate::protocol_serde::shape_endpoint_with_host_label_operation::ser_endpoint_with_host_label_operation_http_error(&self) {
|
1343 + | Ok(mut response) => {
|
1344 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1345 + | response
|
1346 + | },
|
1347 + | Err(e) => {
|
1348 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1349 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1350 + | }
|
1351 + | }
|
1352 + | }
|
1353 + | }
|
1354 + |
|
1355 + | #[allow(unreachable_code, unused_variables)]
|
1356 + | #[cfg(test)]
|
1357 + | mod endpoint_with_host_label_operation_test {
|
1358 + |
|
1359 + | /// Operations can prepend to the given host if they define the
|
1360 + | /// endpoint trait, and can use the host label trait to define
|
1361 + | /// further customization based on user input.
|
1362 + | /// Test ID: AwsJson10EndpointTraitWithHostLabel
|
1363 + | #[::tokio::test]
|
1364 + | #[::tracing_test::traced_test]
|
1365 + | #[should_panic]
|
1366 + | async fn aws_json10_endpoint_trait_with_host_label_request() {
|
1367 + | #[allow(unused_mut)]
|
1368 + | let mut http_request = ::http::Request::builder()
|
1369 + | .uri("/")
|
1370 + | .method("POST")
|
1371 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1372 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1373 + | "{\"label\": \"bar\"}".as_bytes(),
|
1374 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1375 + | )),
|
1376 + | ))
|
1377 + | .unwrap();
|
1378 + | todo!("endpoint trait not supported yet");
|
1379 + | #[allow(unused_mut)]
|
1380 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1381 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1382 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1383 + | .endpoint_with_host_label_operation(
|
1384 + | move |input: crate::input::EndpointWithHostLabelOperationInput| {
|
1385 + | let sender = sender.clone();
|
1386 + | async move {
|
1387 + | let result = {
|
1388 + | let expected = crate::input::EndpointWithHostLabelOperationInput {
|
1389 + | label: "bar".to_owned(),
|
1390 + | };
|
1391 + | ::pretty_assertions::assert_eq!(input, expected);
|
1392 + | let output = crate::output::EndpointWithHostLabelOperationOutput {};
|
1393 + | Ok(output)
|
1394 + | };
|
1395 + | sender.send(()).await.expect("receiver dropped early");
|
1396 + | result
|
1397 + | }
|
1398 + | },
|
1399 + | )
|
1400 + | .build_unchecked();
|
1401 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1402 + | .await
|
1403 + | .expect("unable to make an HTTP request");
|
1404 + | assert!(
|
1405 + | receiver.recv().await.is_some(),
|
1406 + | "we expected operation handler to be invoked but it was not entered"
|
1407 + | );
|
1408 + | }
|
1409 + | }
|
1410 + |
|
1411 + | ::pin_project_lite::pin_project! {
|
1412 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1413 + | /// [`EndpointOperationInput`](crate::input::EndpointOperationInput) using modelled bindings.
|
1414 + | pub struct EndpointOperationInputFuture {
|
1415 + | 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>>
|
1416 + | }
|
1417 + | }
|
1418 + |
|
1419 + | impl std::future::Future for EndpointOperationInputFuture {
|
1420 + | type Output = Result<
|
1421 + | crate::input::EndpointOperationInput,
|
1422 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1423 + | >;
|
1424 + |
|
1425 + | fn poll(
|
1426 + | self: std::pin::Pin<&mut Self>,
|
1427 + | cx: &mut std::task::Context<'_>,
|
1428 + | ) -> std::task::Poll<Self::Output> {
|
1429 + | let this = self.project();
|
1430 + | this.inner.as_mut().poll(cx)
|
1431 + | }
|
1432 + | }
|
1433 + |
|
1434 + | impl<B>
|
1435 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1436 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1437 + | B,
|
1438 + | > for crate::input::EndpointOperationInput
|
1439 + | where
|
1440 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1441 + | B: 'static,
|
1442 + |
|
1443 + | B::Data: Send,
|
1444 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1445 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1446 + | {
|
1447 + | type Rejection =
|
1448 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1449 + | type Future = EndpointOperationInputFuture;
|
1450 + |
|
1451 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1452 + | let fut = async move {
|
1453 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1454 + | request.headers(),
|
1455 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
1456 + | ) {
|
1457 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1458 + | }
|
1459 + | crate::protocol_serde::shape_endpoint_operation::de_endpoint_operation_http_request(
|
1460 + | request,
|
1461 + | )
|
1462 + | .await
|
1463 + | };
|
1464 + | use ::futures_util::future::TryFutureExt;
|
1465 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1466 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1467 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1468 + | });
|
1469 + | EndpointOperationInputFuture {
|
1470 + | inner: Box::pin(fut),
|
1471 + | }
|
1472 + | }
|
1473 + | }
|
1474 + | impl
|
1475 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1476 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1477 + | > for crate::output::EndpointOperationOutput
|
1478 + | {
|
1479 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1480 + | match crate::protocol_serde::shape_endpoint_operation::ser_endpoint_operation_http_response(
|
1481 + | self,
|
1482 + | ) {
|
1483 + | Ok(response) => response,
|
1484 + | Err(e) => {
|
1485 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1486 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1487 + | }
|
1488 + | }
|
1489 + | }
|
1490 + | }
|
1491 + |
|
1492 + | #[allow(unreachable_code, unused_variables)]
|
1493 + | #[cfg(test)]
|
1494 + | mod endpoint_operation_test {
|
1495 + |
|
1496 + | /// Operations can prepend to the given host if they define the
|
1497 + | /// endpoint trait.
|
1498 + | /// Test ID: AwsJson10EndpointTrait
|
1499 + | #[::tokio::test]
|
1500 + | #[::tracing_test::traced_test]
|
1501 + | #[should_panic]
|
1502 + | async fn aws_json10_endpoint_trait_request() {
|
1503 + | #[allow(unused_mut)]
|
1504 + | let mut http_request = ::http::Request::builder()
|
1505 + | .uri("/")
|
1506 + | .method("POST")
|
1507 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1508 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1509 + | "{}".as_bytes(),
|
1510 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1511 + | )),
|
1512 + | ))
|
1513 + | .unwrap();
|
1514 + | todo!("endpoint trait not supported yet");
|
1515 + | #[allow(unused_mut)]
|
1516 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1517 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1518 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1519 + | .endpoint_operation(move |input: crate::input::EndpointOperationInput| {
|
1520 + | let sender = sender.clone();
|
1521 + | async move {
|
1522 + | let result = {
|
1523 + | let expected = crate::input::EndpointOperationInput {};
|
1524 + | ::pretty_assertions::assert_eq!(input, expected);
|
1525 + | let output = crate::output::EndpointOperationOutput {};
|
1526 + | output
|
1527 + | };
|
1528 + | sender.send(()).await.expect("receiver dropped early");
|
1529 + | result
|
1530 + | }
|
1531 + | })
|
1532 + | .build_unchecked();
|
1533 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1534 + | .await
|
1535 + | .expect("unable to make an HTTP request");
|
1536 + | assert!(
|
1537 + | receiver.recv().await.is_some(),
|
1538 + | "we expected operation handler to be invoked but it was not entered"
|
1539 + | );
|
1540 + | }
|
1541 + | }
|
1542 + |
|
1543 + | ::pin_project_lite::pin_project! {
|
1544 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1545 + | /// [`JsonUnionsInput`](crate::input::JsonUnionsInput) using modelled bindings.
|
1546 + | pub struct JsonUnionsInputFuture {
|
1547 + | 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>>
|
1548 + | }
|
1549 + | }
|
1550 + |
|
1551 + | impl std::future::Future for JsonUnionsInputFuture {
|
1552 + | type Output = Result<
|
1553 + | crate::input::JsonUnionsInput,
|
1554 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
1555 + | >;
|
1556 + |
|
1557 + | fn poll(
|
1558 + | self: std::pin::Pin<&mut Self>,
|
1559 + | cx: &mut std::task::Context<'_>,
|
1560 + | ) -> std::task::Poll<Self::Output> {
|
1561 + | let this = self.project();
|
1562 + | this.inner.as_mut().poll(cx)
|
1563 + | }
|
1564 + | }
|
1565 + |
|
1566 + | impl<B>
|
1567 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1568 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1569 + | B,
|
1570 + | > for crate::input::JsonUnionsInput
|
1571 + | where
|
1572 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1573 + | B: 'static,
|
1574 + |
|
1575 + | B::Data: Send,
|
1576 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
1577 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1578 + | {
|
1579 + | type Rejection =
|
1580 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
1581 + | type Future = JsonUnionsInputFuture;
|
1582 + |
|
1583 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1584 + | let fut = async move {
|
1585 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1586 + | request.headers(),
|
1587 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
1588 + | ) {
|
1589 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
1590 + | }
|
1591 + | crate::protocol_serde::shape_json_unions::de_json_unions_http_request(request).await
|
1592 + | };
|
1593 + | use ::futures_util::future::TryFutureExt;
|
1594 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
1595 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1596 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
1597 + | });
|
1598 + | JsonUnionsInputFuture {
|
1599 + | inner: Box::pin(fut),
|
1600 + | }
|
1601 + | }
|
1602 + | }
|
1603 + | impl
|
1604 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1605 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1606 + | > for crate::output::JsonUnionsOutput
|
1607 + | {
|
1608 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1609 + | match crate::protocol_serde::shape_json_unions::ser_json_unions_http_response(self) {
|
1610 + | Ok(response) => response,
|
1611 + | Err(e) => {
|
1612 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1613 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1614 + | }
|
1615 + | }
|
1616 + | }
|
1617 + | }
|
1618 + | impl
|
1619 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1620 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
1621 + | > for crate::error::JsonUnionsError
|
1622 + | {
|
1623 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1624 + | match crate::protocol_serde::shape_json_unions::ser_json_unions_http_error(&self) {
|
1625 + | Ok(mut response) => {
|
1626 + | response.extensions_mut().insert(
|
1627 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1628 + | self.name(),
|
1629 + | ),
|
1630 + | );
|
1631 + | response
|
1632 + | }
|
1633 + | Err(e) => {
|
1634 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1635 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
1636 + | }
|
1637 + | }
|
1638 + | }
|
1639 + | }
|
1640 + |
|
1641 + | #[allow(unreachable_code, unused_variables)]
|
1642 + | #[cfg(test)]
|
1643 + | mod json_unions_test {
|
1644 + |
|
1645 + | /// Serializes a string union value
|
1646 + | /// Test ID: AwsJson10SerializeStringUnionValue
|
1647 + | #[::tokio::test]
|
1648 + | #[::tracing_test::traced_test]
|
1649 + | async fn aws_json10_serialize_string_union_value_request() {
|
1650 + | #[allow(unused_mut)]
|
1651 + | let mut http_request = ::http::Request::builder()
|
1652 + | .uri("/")
|
1653 + | .method("POST")
|
1654 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1655 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1656 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1657 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1658 + | "{\n \"contents\": {\n \"stringValue\": \"foo\"\n }\n}".as_bytes(),
|
1659 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1660 + | )),
|
1661 + | ))
|
1662 + | .unwrap();
|
1663 + | #[allow(unused_mut)]
|
1664 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1665 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1666 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1667 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1668 + | let sender = sender.clone();
|
1669 + | async move {
|
1670 + | let result = {
|
1671 + | let expected = crate::input::JsonUnionsInput {
|
1672 + | contents: ::std::option::Option::Some(
|
1673 + | crate::model::MyUnion::StringValue("foo".to_owned()),
|
1674 + | ),
|
1675 + | };
|
1676 + | ::pretty_assertions::assert_eq!(input, expected);
|
1677 + | let output = crate::output::JsonUnionsOutput {
|
1678 + | contents: ::std::option::Option::None,
|
1679 + | };
|
1680 + | Ok(output)
|
1681 + | };
|
1682 + | sender.send(()).await.expect("receiver dropped early");
|
1683 + | result
|
1684 + | }
|
1685 + | })
|
1686 + | .build_unchecked();
|
1687 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1688 + | .await
|
1689 + | .expect("unable to make an HTTP request");
|
1690 + | assert!(
|
1691 + | receiver.recv().await.is_some(),
|
1692 + | "we expected operation handler to be invoked but it was not entered"
|
1693 + | );
|
1694 + | }
|
1695 + |
|
1696 + | /// Serializes a boolean union value
|
1697 + | /// Test ID: AwsJson10SerializeBooleanUnionValue
|
1698 + | #[::tokio::test]
|
1699 + | #[::tracing_test::traced_test]
|
1700 + | async fn aws_json10_serialize_boolean_union_value_request() {
|
1701 + | #[allow(unused_mut)]
|
1702 + | let mut http_request = ::http::Request::builder()
|
1703 + | .uri("/")
|
1704 + | .method("POST")
|
1705 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1706 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1707 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1708 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1709 + | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}".as_bytes(),
|
1710 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1711 + | )),
|
1712 + | ))
|
1713 + | .unwrap();
|
1714 + | #[allow(unused_mut)]
|
1715 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1716 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1717 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1718 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1719 + | let sender = sender.clone();
|
1720 + | async move {
|
1721 + | let result = {
|
1722 + | let expected = crate::input::JsonUnionsInput {
|
1723 + | contents: ::std::option::Option::Some(
|
1724 + | crate::model::MyUnion::BooleanValue(true),
|
1725 + | ),
|
1726 + | };
|
1727 + | ::pretty_assertions::assert_eq!(input, expected);
|
1728 + | let output = crate::output::JsonUnionsOutput {
|
1729 + | contents: ::std::option::Option::None,
|
1730 + | };
|
1731 + | Ok(output)
|
1732 + | };
|
1733 + | sender.send(()).await.expect("receiver dropped early");
|
1734 + | result
|
1735 + | }
|
1736 + | })
|
1737 + | .build_unchecked();
|
1738 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1739 + | .await
|
1740 + | .expect("unable to make an HTTP request");
|
1741 + | assert!(
|
1742 + | receiver.recv().await.is_some(),
|
1743 + | "we expected operation handler to be invoked but it was not entered"
|
1744 + | );
|
1745 + | }
|
1746 + |
|
1747 + | /// Serializes a number union value
|
1748 + | /// Test ID: AwsJson10SerializeNumberUnionValue
|
1749 + | #[::tokio::test]
|
1750 + | #[::tracing_test::traced_test]
|
1751 + | async fn aws_json10_serialize_number_union_value_request() {
|
1752 + | #[allow(unused_mut)]
|
1753 + | let mut http_request = ::http::Request::builder()
|
1754 + | .uri("/")
|
1755 + | .method("POST")
|
1756 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1757 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1758 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1759 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1760 + | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}".as_bytes(),
|
1761 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1762 + | )),
|
1763 + | ))
|
1764 + | .unwrap();
|
1765 + | #[allow(unused_mut)]
|
1766 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1767 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1768 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1769 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1770 + | let sender = sender.clone();
|
1771 + | async move {
|
1772 + | let result = {
|
1773 + | let expected = crate::input::JsonUnionsInput {
|
1774 + | contents: ::std::option::Option::Some(
|
1775 + | crate::model::MyUnion::NumberValue(1),
|
1776 + | ),
|
1777 + | };
|
1778 + | ::pretty_assertions::assert_eq!(input, expected);
|
1779 + | let output = crate::output::JsonUnionsOutput {
|
1780 + | contents: ::std::option::Option::None,
|
1781 + | };
|
1782 + | Ok(output)
|
1783 + | };
|
1784 + | sender.send(()).await.expect("receiver dropped early");
|
1785 + | result
|
1786 + | }
|
1787 + | })
|
1788 + | .build_unchecked();
|
1789 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1790 + | .await
|
1791 + | .expect("unable to make an HTTP request");
|
1792 + | assert!(
|
1793 + | receiver.recv().await.is_some(),
|
1794 + | "we expected operation handler to be invoked but it was not entered"
|
1795 + | );
|
1796 + | }
|
1797 + |
|
1798 + | /// Serializes a blob union value
|
1799 + | /// Test ID: AwsJson10SerializeBlobUnionValue
|
1800 + | #[::tokio::test]
|
1801 + | #[::tracing_test::traced_test]
|
1802 + | async fn aws_json10_serialize_blob_union_value_request() {
|
1803 + | #[allow(unused_mut)]
|
1804 + | let mut http_request = ::http::Request::builder()
|
1805 + | .uri("/")
|
1806 + | .method("POST")
|
1807 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1808 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1809 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1810 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1811 + | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}".as_bytes(),
|
1812 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1813 + | )),
|
1814 + | ))
|
1815 + | .unwrap();
|
1816 + | #[allow(unused_mut)]
|
1817 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1818 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1819 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1820 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1821 + | let sender = sender.clone();
|
1822 + | async move {
|
1823 + | let result = {
|
1824 + | let expected = crate::input::JsonUnionsInput {
|
1825 + | contents: ::std::option::Option::Some(
|
1826 + | crate::model::MyUnion::BlobValue(::aws_smithy_types::Blob::new(
|
1827 + | "foo",
|
1828 + | )),
|
1829 + | ),
|
1830 + | };
|
1831 + | ::pretty_assertions::assert_eq!(input, expected);
|
1832 + | let output = crate::output::JsonUnionsOutput {
|
1833 + | contents: ::std::option::Option::None,
|
1834 + | };
|
1835 + | Ok(output)
|
1836 + | };
|
1837 + | sender.send(()).await.expect("receiver dropped early");
|
1838 + | result
|
1839 + | }
|
1840 + | })
|
1841 + | .build_unchecked();
|
1842 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1843 + | .await
|
1844 + | .expect("unable to make an HTTP request");
|
1845 + | assert!(
|
1846 + | receiver.recv().await.is_some(),
|
1847 + | "we expected operation handler to be invoked but it was not entered"
|
1848 + | );
|
1849 + | }
|
1850 + |
|
1851 + | /// Serializes a timestamp union value
|
1852 + | /// Test ID: AwsJson10SerializeTimestampUnionValue
|
1853 + | #[::tokio::test]
|
1854 + | #[::tracing_test::traced_test]
|
1855 + | async fn aws_json10_serialize_timestamp_union_value_request() {
|
1856 + | #[allow(unused_mut)]
|
1857 + | let mut http_request = ::http::Request::builder()
|
1858 + | .uri("/")
|
1859 + | .method("POST")
|
1860 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1861 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1862 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1863 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1864 + | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}"
|
1865 + | .as_bytes(),
|
1866 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1867 + | )),
|
1868 + | ))
|
1869 + | .unwrap();
|
1870 + | #[allow(unused_mut)]
|
1871 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1872 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1873 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1874 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1875 + | let sender = sender.clone();
|
1876 + | async move {
|
1877 + | let result = {
|
1878 + | let expected = crate::input::JsonUnionsInput {
|
1879 + | contents: ::std::option::Option::Some(
|
1880 + | crate::model::MyUnion::TimestampValue(
|
1881 + | ::aws_smithy_types::DateTime::from_fractional_secs(
|
1882 + | 1398796238, 0_f64,
|
1883 + | ),
|
1884 + | ),
|
1885 + | ),
|
1886 + | };
|
1887 + | ::pretty_assertions::assert_eq!(input, expected);
|
1888 + | let output = crate::output::JsonUnionsOutput {
|
1889 + | contents: ::std::option::Option::None,
|
1890 + | };
|
1891 + | Ok(output)
|
1892 + | };
|
1893 + | sender.send(()).await.expect("receiver dropped early");
|
1894 + | result
|
1895 + | }
|
1896 + | })
|
1897 + | .build_unchecked();
|
1898 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1899 + | .await
|
1900 + | .expect("unable to make an HTTP request");
|
1901 + | assert!(
|
1902 + | receiver.recv().await.is_some(),
|
1903 + | "we expected operation handler to be invoked but it was not entered"
|
1904 + | );
|
1905 + | }
|
1906 + |
|
1907 + | /// Serializes an enum union value
|
1908 + | /// Test ID: AwsJson10SerializeEnumUnionValue
|
1909 + | #[::tokio::test]
|
1910 + | #[::tracing_test::traced_test]
|
1911 + | async fn aws_json10_serialize_enum_union_value_request() {
|
1912 + | #[allow(unused_mut)]
|
1913 + | let mut http_request = ::http::Request::builder()
|
1914 + | .uri("/")
|
1915 + | .method("POST")
|
1916 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1917 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1918 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1919 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1920 + | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}".as_bytes(),
|
1921 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1922 + | )),
|
1923 + | ))
|
1924 + | .unwrap();
|
1925 + | #[allow(unused_mut)]
|
1926 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1927 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1928 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1929 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1930 + | let sender = sender.clone();
|
1931 + | async move {
|
1932 + | let result = {
|
1933 + | let expected = crate::input::JsonUnionsInput {
|
1934 + | contents: ::std::option::Option::Some(
|
1935 + | crate::model::MyUnion::EnumValue(
|
1936 + | "Foo"
|
1937 + | .parse::<crate::model::FooEnum>()
|
1938 + | .expect("static value validated to member"),
|
1939 + | ),
|
1940 + | ),
|
1941 + | };
|
1942 + | ::pretty_assertions::assert_eq!(input, expected);
|
1943 + | let output = crate::output::JsonUnionsOutput {
|
1944 + | contents: ::std::option::Option::None,
|
1945 + | };
|
1946 + | Ok(output)
|
1947 + | };
|
1948 + | sender.send(()).await.expect("receiver dropped early");
|
1949 + | result
|
1950 + | }
|
1951 + | })
|
1952 + | .build_unchecked();
|
1953 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1954 + | .await
|
1955 + | .expect("unable to make an HTTP request");
|
1956 + | assert!(
|
1957 + | receiver.recv().await.is_some(),
|
1958 + | "we expected operation handler to be invoked but it was not entered"
|
1959 + | );
|
1960 + | }
|
1961 + |
|
1962 + | /// Serializes an intEnum union value
|
1963 + | /// Test ID: AwsJson10SerializeIntEnumUnionValue
|
1964 + | #[::tokio::test]
|
1965 + | #[::tracing_test::traced_test]
|
1966 + | async fn aws_json10_serialize_int_enum_union_value_request() {
|
1967 + | #[allow(unused_mut)]
|
1968 + | let mut http_request = ::http::Request::builder()
|
1969 + | .uri("/")
|
1970 + | .method("POST")
|
1971 + | .header("Content-Type", "application/x-amz-json-1.0")
|
1972 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
1973 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1974 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1975 + | "{\n \"contents\": {\n \"intEnumValue\": 1\n }\n}".as_bytes(),
|
1976 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1977 + | )),
|
1978 + | ))
|
1979 + | .unwrap();
|
1980 + | #[allow(unused_mut)]
|
1981 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1982 + | let config = crate::service::JsonRpc10Config::builder().build();
|
1983 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
1984 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
1985 + | let sender = sender.clone();
|
1986 + | async move {
|
1987 + | let result = {
|
1988 + | let expected = crate::input::JsonUnionsInput {
|
1989 + | contents: ::std::option::Option::Some(
|
1990 + | crate::model::MyUnion::IntEnumValue(1),
|
1991 + | ),
|
1992 + | };
|
1993 + | ::pretty_assertions::assert_eq!(input, expected);
|
1994 + | let output = crate::output::JsonUnionsOutput {
|
1995 + | contents: ::std::option::Option::None,
|
1996 + | };
|
1997 + | Ok(output)
|
1998 + | };
|
1999 + | sender.send(()).await.expect("receiver dropped early");
|
2000 + | result
|
2001 + | }
|
2002 + | })
|
2003 + | .build_unchecked();
|
2004 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2005 + | .await
|
2006 + | .expect("unable to make an HTTP request");
|
2007 + | assert!(
|
2008 + | receiver.recv().await.is_some(),
|
2009 + | "we expected operation handler to be invoked but it was not entered"
|
2010 + | );
|
2011 + | }
|
2012 + |
|
2013 + | /// Serializes a list union value
|
2014 + | /// Test ID: AwsJson10SerializeListUnionValue
|
2015 + | #[::tokio::test]
|
2016 + | #[::tracing_test::traced_test]
|
2017 + | async fn aws_json10_serialize_list_union_value_request() {
|
2018 + | #[allow(unused_mut)]
|
2019 + | let mut http_request = ::http::Request::builder()
|
2020 + | .uri("/")
|
2021 + | .method("POST")
|
2022 + | .header("Content-Type", "application/x-amz-json-1.0")
|
2023 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
2024 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2025 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2026 + | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}"
|
2027 + | .as_bytes(),
|
2028 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2029 + | )),
|
2030 + | ))
|
2031 + | .unwrap();
|
2032 + | #[allow(unused_mut)]
|
2033 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2034 + | let config = crate::service::JsonRpc10Config::builder().build();
|
2035 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
2036 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
2037 + | let sender = sender.clone();
|
2038 + | async move {
|
2039 + | let result = {
|
2040 + | let expected = crate::input::JsonUnionsInput {
|
2041 + | contents: ::std::option::Option::Some(
|
2042 + | crate::model::MyUnion::ListValue(vec![
|
2043 + | "foo".to_owned(),
|
2044 + | "bar".to_owned(),
|
2045 + | ]),
|
2046 + | ),
|
2047 + | };
|
2048 + | ::pretty_assertions::assert_eq!(input, expected);
|
2049 + | let output = crate::output::JsonUnionsOutput {
|
2050 + | contents: ::std::option::Option::None,
|
2051 + | };
|
2052 + | Ok(output)
|
2053 + | };
|
2054 + | sender.send(()).await.expect("receiver dropped early");
|
2055 + | result
|
2056 + | }
|
2057 + | })
|
2058 + | .build_unchecked();
|
2059 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2060 + | .await
|
2061 + | .expect("unable to make an HTTP request");
|
2062 + | assert!(
|
2063 + | receiver.recv().await.is_some(),
|
2064 + | "we expected operation handler to be invoked but it was not entered"
|
2065 + | );
|
2066 + | }
|
2067 + |
|
2068 + | /// Serializes a map union value
|
2069 + | /// Test ID: AwsJson10SerializeMapUnionValue
|
2070 + | #[::tokio::test]
|
2071 + | #[::tracing_test::traced_test]
|
2072 + | async fn aws_json10_serialize_map_union_value_request() {
|
2073 + | #[allow(unused_mut)]
|
2074 + | let mut http_request = ::http::Request::builder()
|
2075 + | .uri("/")
|
2076 + | .method("POST")
|
2077 + | .header("Content-Type", "application/x-amz-json-1.0")
|
2078 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
2079 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2080 + | ::bytes::Bytes::copy_from_slice(
|
2081 + | &::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"))
|
2082 + | )
|
2083 + | )).unwrap();
|
2084 + | #[allow(unused_mut)]
|
2085 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2086 + | let config = crate::service::JsonRpc10Config::builder().build();
|
2087 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
2088 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
2089 + | let sender = sender.clone();
|
2090 + | async move {
|
2091 + | let result = {
|
2092 + | let expected = crate::input::JsonUnionsInput {
|
2093 + | contents: ::std::option::Option::Some(crate::model::MyUnion::MapValue(
|
2094 + | {
|
2095 + | let mut ret = ::std::collections::HashMap::new();
|
2096 + | ret.insert("foo".to_owned(), "bar".to_owned());
|
2097 + | ret.insert("spam".to_owned(), "eggs".to_owned());
|
2098 + | ret
|
2099 + | },
|
2100 + | )),
|
2101 + | };
|
2102 + | ::pretty_assertions::assert_eq!(input, expected);
|
2103 + | let output = crate::output::JsonUnionsOutput {
|
2104 + | contents: ::std::option::Option::None,
|
2105 + | };
|
2106 + | Ok(output)
|
2107 + | };
|
2108 + | sender.send(()).await.expect("receiver dropped early");
|
2109 + | result
|
2110 + | }
|
2111 + | })
|
2112 + | .build_unchecked();
|
2113 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2114 + | .await
|
2115 + | .expect("unable to make an HTTP request");
|
2116 + | assert!(
|
2117 + | receiver.recv().await.is_some(),
|
2118 + | "we expected operation handler to be invoked but it was not entered"
|
2119 + | );
|
2120 + | }
|
2121 + |
|
2122 + | /// Serializes a structure union value
|
2123 + | /// Test ID: AwsJson10SerializeStructureUnionValue
|
2124 + | #[::tokio::test]
|
2125 + | #[::tracing_test::traced_test]
|
2126 + | async fn aws_json10_serialize_structure_union_value_request() {
|
2127 + | #[allow(unused_mut)]
|
2128 + | let mut http_request = ::http::Request::builder()
|
2129 + | .uri("/")
|
2130 + | .method("POST")
|
2131 + | .header("Content-Type", "application/x-amz-json-1.0")
|
2132 + | .header("X-Amz-Target", "JsonRpc10.JsonUnions")
|
2133 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2134 + | ::bytes::Bytes::copy_from_slice(
|
2135 + | &::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"))
|
2136 + | )
|
2137 + | )).unwrap();
|
2138 + | #[allow(unused_mut)]
|
2139 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2140 + | let config = crate::service::JsonRpc10Config::builder().build();
|
2141 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
2142 + | .json_unions(move |input: crate::input::JsonUnionsInput| {
|
2143 + | let sender = sender.clone();
|
2144 + | async move {
|
2145 + | let result = {
|
2146 + | let expected = crate::input::JsonUnionsInput {
|
2147 + | contents: ::std::option::Option::Some(
|
2148 + | crate::model::MyUnion::StructureValue(
|
2149 + | crate::model::GreetingStruct {
|
2150 + | hi: ::std::option::Option::Some("hello".to_owned()),
|
2151 + | },
|
2152 + | ),
|
2153 + | ),
|
2154 + | };
|
2155 + | ::pretty_assertions::assert_eq!(input, expected);
|
2156 + | let output = crate::output::JsonUnionsOutput {
|
2157 + | contents: ::std::option::Option::None,
|
2158 + | };
|
2159 + | Ok(output)
|
2160 + | };
|
2161 + | sender.send(()).await.expect("receiver dropped early");
|
2162 + | result
|
2163 + | }
|
2164 + | })
|
2165 + | .build_unchecked();
|
2166 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2167 + | .await
|
2168 + | .expect("unable to make an HTTP request");
|
2169 + | assert!(
|
2170 + | receiver.recv().await.is_some(),
|
2171 + | "we expected operation handler to be invoked but it was not entered"
|
2172 + | );
|
2173 + | }
|
2174 + |
|
2175 + | /// Deserializes a string union value
|
2176 + | /// Test ID: AwsJson10DeserializeStringUnionValue
|
2177 + | #[::tokio::test]
|
2178 + | #[::tracing_test::traced_test]
|
2179 + | async fn aws_json10_deserialize_string_union_value_response() {
|
2180 + | let output = crate::output::JsonUnionsOutput {
|
2181 + | contents: ::std::option::Option::Some(crate::model::MyUnion::StringValue(
|
2182 + | "foo".to_owned(),
|
2183 + | )),
|
2184 + | };
|
2185 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2186 + | let http_response = output.into_response();
|
2187 + | ::pretty_assertions::assert_eq!(
|
2188 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2189 + | http_response.status()
|
2190 + | );
|
2191 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2192 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2193 + | http_response.headers(),
|
2194 + | expected_headers,
|
2195 + | ));
|
2196 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2197 + | .await
|
2198 + | .expect("unable to extract body to bytes");
|
2199 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2200 + | &body,
|
2201 + | "{\n \"contents\": {\n \"stringValue\": \"foo\"\n }\n}",
|
2202 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2203 + | ));
|
2204 + | }
|
2205 + |
|
2206 + | /// Deserializes a boolean union value
|
2207 + | /// Test ID: AwsJson10DeserializeBooleanUnionValue
|
2208 + | #[::tokio::test]
|
2209 + | #[::tracing_test::traced_test]
|
2210 + | async fn aws_json10_deserialize_boolean_union_value_response() {
|
2211 + | let output = crate::output::JsonUnionsOutput {
|
2212 + | contents: ::std::option::Option::Some(crate::model::MyUnion::BooleanValue(true)),
|
2213 + | };
|
2214 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2215 + | let http_response = output.into_response();
|
2216 + | ::pretty_assertions::assert_eq!(
|
2217 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2218 + | http_response.status()
|
2219 + | );
|
2220 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2221 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2222 + | http_response.headers(),
|
2223 + | expected_headers,
|
2224 + | ));
|
2225 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2226 + | .await
|
2227 + | .expect("unable to extract body to bytes");
|
2228 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2229 + | &body,
|
2230 + | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}",
|
2231 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2232 + | ));
|
2233 + | }
|
2234 + |
|
2235 + | /// Deserializes a number union value
|
2236 + | /// Test ID: AwsJson10DeserializeNumberUnionValue
|
2237 + | #[::tokio::test]
|
2238 + | #[::tracing_test::traced_test]
|
2239 + | async fn aws_json10_deserialize_number_union_value_response() {
|
2240 + | let output = crate::output::JsonUnionsOutput {
|
2241 + | contents: ::std::option::Option::Some(crate::model::MyUnion::NumberValue(1)),
|
2242 + | };
|
2243 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2244 + | let http_response = output.into_response();
|
2245 + | ::pretty_assertions::assert_eq!(
|
2246 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2247 + | http_response.status()
|
2248 + | );
|
2249 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2250 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2251 + | http_response.headers(),
|
2252 + | expected_headers,
|
2253 + | ));
|
2254 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2255 + | .await
|
2256 + | .expect("unable to extract body to bytes");
|
2257 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2258 + | &body,
|
2259 + | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}",
|
2260 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2261 + | ));
|
2262 + | }
|
2263 + |
|
2264 + | /// Deserializes a blob union value
|
2265 + | /// Test ID: AwsJson10DeserializeBlobUnionValue
|
2266 + | #[::tokio::test]
|
2267 + | #[::tracing_test::traced_test]
|
2268 + | async fn aws_json10_deserialize_blob_union_value_response() {
|
2269 + | let output = crate::output::JsonUnionsOutput {
|
2270 + | contents: ::std::option::Option::Some(crate::model::MyUnion::BlobValue(
|
2271 + | ::aws_smithy_types::Blob::new("foo"),
|
2272 + | )),
|
2273 + | };
|
2274 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2275 + | let http_response = output.into_response();
|
2276 + | ::pretty_assertions::assert_eq!(
|
2277 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2278 + | http_response.status()
|
2279 + | );
|
2280 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2281 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2282 + | http_response.headers(),
|
2283 + | expected_headers,
|
2284 + | ));
|
2285 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2286 + | .await
|
2287 + | .expect("unable to extract body to bytes");
|
2288 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2289 + | &body,
|
2290 + | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}",
|
2291 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2292 + | ));
|
2293 + | }
|
2294 + |
|
2295 + | /// Deserializes a timestamp union value
|
2296 + | /// Test ID: AwsJson10DeserializeTimestampUnionValue
|
2297 + | #[::tokio::test]
|
2298 + | #[::tracing_test::traced_test]
|
2299 + | async fn aws_json10_deserialize_timestamp_union_value_response() {
|
2300 + | let output = crate::output::JsonUnionsOutput {
|
2301 + | contents: ::std::option::Option::Some(crate::model::MyUnion::TimestampValue(
|
2302 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2303 + | )),
|
2304 + | };
|
2305 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2306 + | let http_response = output.into_response();
|
2307 + | ::pretty_assertions::assert_eq!(
|
2308 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2309 + | http_response.status()
|
2310 + | );
|
2311 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2312 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2313 + | http_response.headers(),
|
2314 + | expected_headers,
|
2315 + | ));
|
2316 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2317 + | .await
|
2318 + | .expect("unable to extract body to bytes");
|
2319 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2320 + | &body,
|
2321 + | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}",
|
2322 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2323 + | ));
|
2324 + | }
|
2325 + |
|
2326 + | /// Deserializes an enum union value
|
2327 + | /// Test ID: AwsJson10DeserializeEnumUnionValue
|
2328 + | #[::tokio::test]
|
2329 + | #[::tracing_test::traced_test]
|
2330 + | async fn aws_json10_deserialize_enum_union_value_response() {
|
2331 + | let output = crate::output::JsonUnionsOutput {
|
2332 + | contents: ::std::option::Option::Some(crate::model::MyUnion::EnumValue(
|
2333 + | "Foo"
|
2334 + | .parse::<crate::model::FooEnum>()
|
2335 + | .expect("static value validated to member"),
|
2336 + | )),
|
2337 + | };
|
2338 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2339 + | let http_response = output.into_response();
|
2340 + | ::pretty_assertions::assert_eq!(
|
2341 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2342 + | http_response.status()
|
2343 + | );
|
2344 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2345 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2346 + | http_response.headers(),
|
2347 + | expected_headers,
|
2348 + | ));
|
2349 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2350 + | .await
|
2351 + | .expect("unable to extract body to bytes");
|
2352 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2353 + | &body,
|
2354 + | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}",
|
2355 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2356 + | ));
|
2357 + | }
|
2358 + |
|
2359 + | /// Deserializes an intEnum union value
|
2360 + | /// Test ID: AwsJson10DeserializeIntEnumUnionValue
|
2361 + | #[::tokio::test]
|
2362 + | #[::tracing_test::traced_test]
|
2363 + | async fn aws_json10_deserialize_int_enum_union_value_response() {
|
2364 + | let output = crate::output::JsonUnionsOutput {
|
2365 + | contents: ::std::option::Option::Some(crate::model::MyUnion::IntEnumValue(1)),
|
2366 + | };
|
2367 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2368 + | let http_response = output.into_response();
|
2369 + | ::pretty_assertions::assert_eq!(
|
2370 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2371 + | http_response.status()
|
2372 + | );
|
2373 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2374 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2375 + | http_response.headers(),
|
2376 + | expected_headers,
|
2377 + | ));
|
2378 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2379 + | .await
|
2380 + | .expect("unable to extract body to bytes");
|
2381 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2382 + | &body,
|
2383 + | "{\n \"contents\": {\n \"intEnumValue\": 1\n }\n}",
|
2384 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2385 + | ));
|
2386 + | }
|
2387 + |
|
2388 + | /// Deserializes a list union value
|
2389 + | /// Test ID: AwsJson10DeserializeListUnionValue
|
2390 + | #[::tokio::test]
|
2391 + | #[::tracing_test::traced_test]
|
2392 + | async fn aws_json10_deserialize_list_union_value_response() {
|
2393 + | let output = crate::output::JsonUnionsOutput {
|
2394 + | contents: ::std::option::Option::Some(crate::model::MyUnion::ListValue(vec![
|
2395 + | "foo".to_owned(),
|
2396 + | "bar".to_owned(),
|
2397 + | ])),
|
2398 + | };
|
2399 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2400 + | let http_response = output.into_response();
|
2401 + | ::pretty_assertions::assert_eq!(
|
2402 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2403 + | http_response.status()
|
2404 + | );
|
2405 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
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(::aws_smithy_protocol_test::validate_body(
|
2414 + | &body,
|
2415 + | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}",
|
2416 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2417 + | ));
|
2418 + | }
|
2419 + |
|
2420 + | /// Deserializes a map union value
|
2421 + | /// Test ID: AwsJson10DeserializeMapUnionValue
|
2422 + | #[::tokio::test]
|
2423 + | #[::tracing_test::traced_test]
|
2424 + | async fn aws_json10_deserialize_map_union_value_response() {
|
2425 + | let output = crate::output::JsonUnionsOutput {
|
2426 + | contents: ::std::option::Option::Some(crate::model::MyUnion::MapValue({
|
2427 + | let mut ret = ::std::collections::HashMap::new();
|
2428 + | ret.insert("foo".to_owned(), "bar".to_owned());
|
2429 + | ret.insert("spam".to_owned(), "eggs".to_owned());
|
2430 + | ret
|
2431 + | })),
|
2432 + | };
|
2433 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2434 + | let http_response = output.into_response();
|
2435 + | ::pretty_assertions::assert_eq!(
|
2436 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2437 + | http_response.status()
|
2438 + | );
|
2439 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2440 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2441 + | http_response.headers(),
|
2442 + | expected_headers,
|
2443 + | ));
|
2444 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2445 + | .await
|
2446 + | .expect("unable to extract body to bytes");
|
2447 + | ::aws_smithy_protocol_test::assert_ok(
|
2448 + | ::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"))
|
2449 + | );
|
2450 + | }
|
2451 + |
|
2452 + | /// Deserializes a structure union value
|
2453 + | /// Test ID: AwsJson10DeserializeStructureUnionValue
|
2454 + | #[::tokio::test]
|
2455 + | #[::tracing_test::traced_test]
|
2456 + | async fn aws_json10_deserialize_structure_union_value_response() {
|
2457 + | let output = crate::output::JsonUnionsOutput {
|
2458 + | contents: ::std::option::Option::Some(crate::model::MyUnion::StructureValue(
|
2459 + | crate::model::GreetingStruct {
|
2460 + | hi: ::std::option::Option::Some("hello".to_owned()),
|
2461 + | },
|
2462 + | )),
|
2463 + | };
|
2464 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2465 + | let http_response = output.into_response();
|
2466 + | ::pretty_assertions::assert_eq!(
|
2467 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2468 + | http_response.status()
|
2469 + | );
|
2470 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2471 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2472 + | http_response.headers(),
|
2473 + | expected_headers,
|
2474 + | ));
|
2475 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2476 + | .await
|
2477 + | .expect("unable to extract body to bytes");
|
2478 + | ::aws_smithy_protocol_test::assert_ok(
|
2479 + | ::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"))
|
2480 + | );
|
2481 + | }
|
2482 + | }
|
2483 + |
|
2484 + | ::pin_project_lite::pin_project! {
|
2485 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2486 + | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
2487 + | pub struct GreetingWithErrorsInputFuture {
|
2488 + | 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>>
|
2489 + | }
|
2490 + | }
|
2491 + |
|
2492 + | impl std::future::Future for GreetingWithErrorsInputFuture {
|
2493 + | type Output = Result<
|
2494 + | crate::input::GreetingWithErrorsInput,
|
2495 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2496 + | >;
|
2497 + |
|
2498 + | fn poll(
|
2499 + | self: std::pin::Pin<&mut Self>,
|
2500 + | cx: &mut std::task::Context<'_>,
|
2501 + | ) -> std::task::Poll<Self::Output> {
|
2502 + | let this = self.project();
|
2503 + | this.inner.as_mut().poll(cx)
|
2504 + | }
|
2505 + | }
|
2506 + |
|
2507 + | impl<B>
|
2508 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2509 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
2510 + | B,
|
2511 + | > for crate::input::GreetingWithErrorsInput
|
2512 + | where
|
2513 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2514 + | B: 'static,
|
2515 + |
|
2516 + | B::Data: Send,
|
2517 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2518 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2519 + | {
|
2520 + | type Rejection =
|
2521 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2522 + | type Future = GreetingWithErrorsInputFuture;
|
2523 + |
|
2524 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2525 + | let fut = async move {
|
2526 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2527 + | request.headers(),
|
2528 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
2529 + | ) {
|
2530 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2531 + | }
|
2532 + | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
2533 + | request,
|
2534 + | )
|
2535 + | .await
|
2536 + | };
|
2537 + | use ::futures_util::future::TryFutureExt;
|
2538 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2539 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2540 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2541 + | });
|
2542 + | GreetingWithErrorsInputFuture {
|
2543 + | inner: Box::pin(fut),
|
2544 + | }
|
2545 + | }
|
2546 + | }
|
2547 + | impl
|
2548 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2549 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
2550 + | > for crate::output::GreetingWithErrorsOutput
|
2551 + | {
|
2552 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2553 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
2554 + | Ok(response) => response,
|
2555 + | Err(e) => {
|
2556 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2557 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2558 + | }
|
2559 + | }
|
2560 + | }
|
2561 + | }
|
2562 + | impl
|
2563 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2564 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
2565 + | > for crate::error::GreetingWithErrorsError
|
2566 + | {
|
2567 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2568 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
2569 + | &self,
|
2570 + | ) {
|
2571 + | Ok(mut response) => {
|
2572 + | response.extensions_mut().insert(
|
2573 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
2574 + | self.name(),
|
2575 + | ),
|
2576 + | );
|
2577 + | response
|
2578 + | }
|
2579 + | Err(e) => {
|
2580 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2581 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2582 + | }
|
2583 + | }
|
2584 + | }
|
2585 + | }
|
2586 + |
|
2587 + | #[allow(unreachable_code, unused_variables)]
|
2588 + | #[cfg(test)]
|
2589 + | mod greeting_with_errors_test {
|
2590 + |
|
2591 + | /// Parses simple JSON errors
|
2592 + | /// Test ID: AwsJson10InvalidGreetingError
|
2593 + | #[::tokio::test]
|
2594 + | #[::tracing_test::traced_test]
|
2595 + | async fn aws_json10_invalid_greeting_error_response() {
|
2596 + | let output = crate::error::InvalidGreeting {
|
2597 + | message: ::std::option::Option::Some("Hi".to_owned()),
|
2598 + | };
|
2599 + | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
2600 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2601 + | let http_response = output.into_response();
|
2602 + | ::pretty_assertions::assert_eq!(
|
2603 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2604 + | http_response.status()
|
2605 + | );
|
2606 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2607 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2608 + | http_response.headers(),
|
2609 + | expected_headers,
|
2610 + | ));
|
2611 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2612 + | .await
|
2613 + | .expect("unable to extract body to bytes");
|
2614 + | ::aws_smithy_protocol_test::assert_ok(
|
2615 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"__type\": \"aws.protocoltests.json10#InvalidGreeting\",\n \"Message\": \"Hi\"\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2616 + | );
|
2617 + | }
|
2618 + |
|
2619 + | /// Parses a complex error with no message member
|
2620 + | /// Test ID: AwsJson10ComplexError
|
2621 + | #[::tokio::test]
|
2622 + | #[::tracing_test::traced_test]
|
2623 + | async fn aws_json10_complex_error_response() {
|
2624 + | let output = crate::error::ComplexError {
|
2625 + | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
2626 + | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
2627 + | foo: ::std::option::Option::Some("bar".to_owned()),
|
2628 + | }),
|
2629 + | };
|
2630 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
2631 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2632 + | let http_response = output.into_response();
|
2633 + | ::pretty_assertions::assert_eq!(
|
2634 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2635 + | http_response.status()
|
2636 + | );
|
2637 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2638 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2639 + | http_response.headers(),
|
2640 + | expected_headers,
|
2641 + | ));
|
2642 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2643 + | .await
|
2644 + | .expect("unable to extract body to bytes");
|
2645 + | ::aws_smithy_protocol_test::assert_ok(
|
2646 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"__type\": \"aws.protocoltests.json10#ComplexError\",\n \"TopLevel\": \"Top level\",\n \"Nested\": {\n \"Foo\": \"bar\"\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2647 + | );
|
2648 + | }
|
2649 + |
|
2650 + | /// Parses a complex error with an empty body
|
2651 + | /// Test ID: AwsJson10EmptyComplexError
|
2652 + | #[::tokio::test]
|
2653 + | #[::tracing_test::traced_test]
|
2654 + | async fn aws_json10_empty_complex_error_response() {
|
2655 + | let output = crate::error::ComplexError {
|
2656 + | top_level: ::std::option::Option::None,
|
2657 + | nested: ::std::option::Option::None,
|
2658 + | };
|
2659 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
2660 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2661 + | let http_response = output.into_response();
|
2662 + | ::pretty_assertions::assert_eq!(
|
2663 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2664 + | http_response.status()
|
2665 + | );
|
2666 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2667 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2668 + | http_response.headers(),
|
2669 + | expected_headers,
|
2670 + | ));
|
2671 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2672 + | .await
|
2673 + | .expect("unable to extract body to bytes");
|
2674 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2675 + | &body,
|
2676 + | "{\n \"__type\": \"aws.protocoltests.json10#ComplexError\"\n}",
|
2677 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2678 + | ));
|
2679 + | }
|
2680 + | }
|
2681 + |
|
2682 + | ::pin_project_lite::pin_project! {
|
2683 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2684 + | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
2685 + | pub struct SimpleScalarPropertiesInputFuture {
|
2686 + | 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>>
|
2687 + | }
|
2688 + | }
|
2689 + |
|
2690 + | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
2691 + | type Output = Result<
|
2692 + | crate::input::SimpleScalarPropertiesInput,
|
2693 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
2694 + | >;
|
2695 + |
|
2696 + | fn poll(
|
2697 + | self: std::pin::Pin<&mut Self>,
|
2698 + | cx: &mut std::task::Context<'_>,
|
2699 + | ) -> std::task::Poll<Self::Output> {
|
2700 + | let this = self.project();
|
2701 + | this.inner.as_mut().poll(cx)
|
2702 + | }
|
2703 + | }
|
2704 + |
|
2705 + | impl<B>
|
2706 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2707 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
2708 + | B,
|
2709 + | > for crate::input::SimpleScalarPropertiesInput
|
2710 + | where
|
2711 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2712 + | B: 'static,
|
2713 + |
|
2714 + | B::Data: Send,
|
2715 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
2716 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2717 + | {
|
2718 + | type Rejection =
|
2719 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
2720 + | type Future = SimpleScalarPropertiesInputFuture;
|
2721 + |
|
2722 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2723 + | let fut = async move {
|
2724 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2725 + | request.headers(),
|
2726 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
2727 + | ) {
|
2728 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
2729 + | }
|
2730 + | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
2731 + | .await
|
2732 + | };
|
2733 + | use ::futures_util::future::TryFutureExt;
|
2734 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
2735 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2736 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
2737 + | });
|
2738 + | SimpleScalarPropertiesInputFuture {
|
2739 + | inner: Box::pin(fut),
|
2740 + | }
|
2741 + | }
|
2742 + | }
|
2743 + | impl
|
2744 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2745 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
2746 + | > for crate::output::SimpleScalarPropertiesOutput
|
2747 + | {
|
2748 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2749 + | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
2750 + | Ok(response) => response,
|
2751 + | Err(e) => {
|
2752 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2753 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
2754 + | }
|
2755 + | }
|
2756 + | }
|
2757 + | }
|
2758 + |
|
2759 + | #[allow(unreachable_code, unused_variables)]
|
2760 + | #[cfg(test)]
|
2761 + | mod simple_scalar_properties_test {
|
2762 + |
|
2763 + | /// Supports handling NaN float values.
|
2764 + | /// Test ID: AwsJson10SupportsNaNFloatInputs
|
2765 + | #[::tokio::test]
|
2766 + | #[::tracing_test::traced_test]
|
2767 + | async fn aws_json10_supports_na_n_float_inputs_request() {
|
2768 + | #[allow(unused_mut)]
|
2769 + | let mut http_request = ::http::Request::builder()
|
2770 + | .uri("/")
|
2771 + | .method("POST")
|
2772 + | .header("Content-Type", "application/x-amz-json-1.0")
|
2773 + | .header("X-Amz-Target", "JsonRpc10.SimpleScalarProperties")
|
2774 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2775 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2776 + | "{\n \"floatValue\": \"NaN\",\n \"doubleValue\": \"NaN\"\n}".as_bytes(),
|
2777 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2778 + | )),
|
2779 + | ))
|
2780 + | .unwrap();
|
2781 + | #[allow(unused_mut)]
|
2782 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2783 + | let config = crate::service::JsonRpc10Config::builder().build();
|
2784 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
2785 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2786 + | let sender = sender.clone();
|
2787 + | async move {
|
2788 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
2789 + | let expected =
|
2790 + | crate::input::SimpleScalarPropertiesInput {
|
2791 + | float_value:
|
2792 + | ::std::option::Option::Some(
|
2793 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN").expect("invalid string for number")
|
2794 + | )
|
2795 + | ,
|
2796 + | double_value:
|
2797 + | ::std::option::Option::Some(
|
2798 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN").expect("invalid string for number")
|
2799 + | )
|
2800 + | ,
|
2801 + | }
|
2802 + | ;
|
2803 + | assert!(input.float_value.float_equals(&expected.float_value),
|
2804 + | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
2805 + | assert!(input.double_value.float_equals(&expected.double_value),
|
2806 + | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
2807 + | let output =
|
2808 + | crate::output::SimpleScalarPropertiesOutput {
|
2809 + | float_value:
|
2810 + | ::std::option::Option::None
|
2811 + | ,
|
2812 + | double_value:
|
2813 + | ::std::option::Option::None
|
2814 + | ,
|
2815 + | }
|
2816 + | ;
|
2817 + | output };
|
2818 + | sender.send(()).await.expect("receiver dropped early");
|
2819 + | result
|
2820 + | }
|
2821 + | })
|
2822 + | .build_unchecked();
|
2823 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2824 + | .await
|
2825 + | .expect("unable to make an HTTP request");
|
2826 + | assert!(
|
2827 + | receiver.recv().await.is_some(),
|
2828 + | "we expected operation handler to be invoked but it was not entered"
|
2829 + | );
|
2830 + | }
|
2831 + |
|
2832 + | /// Supports handling Infinity float values.
|
2833 + | /// Test ID: AwsJson10SupportsInfinityFloatInputs
|
2834 + | #[::tokio::test]
|
2835 + | #[::tracing_test::traced_test]
|
2836 + | async fn aws_json10_supports_infinity_float_inputs_request() {
|
2837 + | #[allow(unused_mut)]
|
2838 + | let mut http_request = ::http::Request::builder()
|
2839 + | .uri("/")
|
2840 + | .method("POST")
|
2841 + | .header("Content-Type", "application/x-amz-json-1.0")
|
2842 + | .header("X-Amz-Target", "JsonRpc10.SimpleScalarProperties")
|
2843 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2844 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2845 + | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}"
|
2846 + | .as_bytes(),
|
2847 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2848 + | )),
|
2849 + | ))
|
2850 + | .unwrap();
|
2851 + | #[allow(unused_mut)]
|
2852 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2853 + | let config = crate::service::JsonRpc10Config::builder().build();
|
2854 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
2855 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2856 + | let sender = sender.clone();
|
2857 + | async move {
|
2858 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
2859 + | let expected =
|
2860 + | crate::input::SimpleScalarPropertiesInput {
|
2861 + | float_value:
|
2862 + | ::std::option::Option::Some(
|
2863 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number")
|
2864 + | )
|
2865 + | ,
|
2866 + | double_value:
|
2867 + | ::std::option::Option::Some(
|
2868 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number")
|
2869 + | )
|
2870 + | ,
|
2871 + | }
|
2872 + | ;
|
2873 + | assert!(input.float_value.float_equals(&expected.float_value),
|
2874 + | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
2875 + | assert!(input.double_value.float_equals(&expected.double_value),
|
2876 + | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
2877 + | let output =
|
2878 + | crate::output::SimpleScalarPropertiesOutput {
|
2879 + | float_value:
|
2880 + | ::std::option::Option::None
|
2881 + | ,
|
2882 + | double_value:
|
2883 + | ::std::option::Option::None
|
2884 + | ,
|
2885 + | }
|
2886 + | ;
|
2887 + | output };
|
2888 + | sender.send(()).await.expect("receiver dropped early");
|
2889 + | result
|
2890 + | }
|
2891 + | })
|
2892 + | .build_unchecked();
|
2893 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2894 + | .await
|
2895 + | .expect("unable to make an HTTP request");
|
2896 + | assert!(
|
2897 + | receiver.recv().await.is_some(),
|
2898 + | "we expected operation handler to be invoked but it was not entered"
|
2899 + | );
|
2900 + | }
|
2901 + |
|
2902 + | /// Supports handling -Infinity float values.
|
2903 + | /// Test ID: AwsJson10SupportsNegativeInfinityFloatInputs
|
2904 + | #[::tokio::test]
|
2905 + | #[::tracing_test::traced_test]
|
2906 + | async fn aws_json10_supports_negative_infinity_float_inputs_request() {
|
2907 + | #[allow(unused_mut)]
|
2908 + | let mut http_request = ::http::Request::builder()
|
2909 + | .uri("/")
|
2910 + | .method("POST")
|
2911 + | .header("Content-Type", "application/x-amz-json-1.0")
|
2912 + | .header("X-Amz-Target", "JsonRpc10.SimpleScalarProperties")
|
2913 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2914 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2915 + | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}"
|
2916 + | .as_bytes(),
|
2917 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
2918 + | )),
|
2919 + | ))
|
2920 + | .unwrap();
|
2921 + | #[allow(unused_mut)]
|
2922 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2923 + | let config = crate::service::JsonRpc10Config::builder().build();
|
2924 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
2925 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2926 + | let sender = sender.clone();
|
2927 + | async move {
|
2928 + | let result = { use ::aws_smithy_protocol_test::FloatEquals;
|
2929 + | let expected =
|
2930 + | crate::input::SimpleScalarPropertiesInput {
|
2931 + | float_value:
|
2932 + | ::std::option::Option::Some(
|
2933 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number")
|
2934 + | )
|
2935 + | ,
|
2936 + | double_value:
|
2937 + | ::std::option::Option::Some(
|
2938 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number")
|
2939 + | )
|
2940 + | ,
|
2941 + | }
|
2942 + | ;
|
2943 + | assert!(input.float_value.float_equals(&expected.float_value),
|
2944 + | "Unexpected value for `float_value` {:?} vs. {:?}", expected.float_value, input.float_value);
|
2945 + | assert!(input.double_value.float_equals(&expected.double_value),
|
2946 + | "Unexpected value for `double_value` {:?} vs. {:?}", expected.double_value, input.double_value);
|
2947 + | let output =
|
2948 + | crate::output::SimpleScalarPropertiesOutput {
|
2949 + | float_value:
|
2950 + | ::std::option::Option::None
|
2951 + | ,
|
2952 + | double_value:
|
2953 + | ::std::option::Option::None
|
2954 + | ,
|
2955 + | }
|
2956 + | ;
|
2957 + | output };
|
2958 + | sender.send(()).await.expect("receiver dropped early");
|
2959 + | result
|
2960 + | }
|
2961 + | })
|
2962 + | .build_unchecked();
|
2963 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2964 + | .await
|
2965 + | .expect("unable to make an HTTP request");
|
2966 + | assert!(
|
2967 + | receiver.recv().await.is_some(),
|
2968 + | "we expected operation handler to be invoked but it was not entered"
|
2969 + | );
|
2970 + | }
|
2971 + |
|
2972 + | /// Supports handling NaN float values.
|
2973 + | /// Test ID: AwsJson10SupportsNaNFloatInputs
|
2974 + | #[::tokio::test]
|
2975 + | #[::tracing_test::traced_test]
|
2976 + | async fn aws_json10_supports_na_n_float_inputs_response() {
|
2977 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2978 + | float_value: ::std::option::Option::Some(
|
2979 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
2980 + | .expect("invalid string for number"),
|
2981 + | ),
|
2982 + | double_value: ::std::option::Option::Some(
|
2983 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
2984 + | .expect("invalid string for number"),
|
2985 + | ),
|
2986 + | };
|
2987 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2988 + | let http_response = output.into_response();
|
2989 + | ::pretty_assertions::assert_eq!(
|
2990 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2991 + | http_response.status()
|
2992 + | );
|
2993 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
2994 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2995 + | http_response.headers(),
|
2996 + | expected_headers,
|
2997 + | ));
|
2998 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2999 + | .await
|
3000 + | .expect("unable to extract body to bytes");
|
3001 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3002 + | &body,
|
3003 + | "{\n \"floatValue\": \"NaN\",\n \"doubleValue\": \"NaN\"\n}",
|
3004 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3005 + | ));
|
3006 + | }
|
3007 + |
|
3008 + | /// Supports handling Infinity float values.
|
3009 + | /// Test ID: AwsJson10SupportsInfinityFloatInputs
|
3010 + | #[::tokio::test]
|
3011 + | #[::tracing_test::traced_test]
|
3012 + | async fn aws_json10_supports_infinity_float_inputs_response() {
|
3013 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3014 + | float_value: ::std::option::Option::Some(
|
3015 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
3016 + | .expect("invalid string for number"),
|
3017 + | ),
|
3018 + | double_value: ::std::option::Option::Some(
|
3019 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
3020 + | .expect("invalid string for number"),
|
3021 + | ),
|
3022 + | };
|
3023 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3024 + | let http_response = output.into_response();
|
3025 + | ::pretty_assertions::assert_eq!(
|
3026 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3027 + | http_response.status()
|
3028 + | );
|
3029 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
3030 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3031 + | http_response.headers(),
|
3032 + | expected_headers,
|
3033 + | ));
|
3034 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3035 + | .await
|
3036 + | .expect("unable to extract body to bytes");
|
3037 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3038 + | &body,
|
3039 + | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}",
|
3040 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3041 + | ));
|
3042 + | }
|
3043 + |
|
3044 + | /// Supports handling -Infinity float values.
|
3045 + | /// Test ID: AwsJson10SupportsNegativeInfinityFloatInputs
|
3046 + | #[::tokio::test]
|
3047 + | #[::tracing_test::traced_test]
|
3048 + | async fn aws_json10_supports_negative_infinity_float_inputs_response() {
|
3049 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3050 + | float_value: ::std::option::Option::Some(
|
3051 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
3052 + | .expect("invalid string for number"),
|
3053 + | ),
|
3054 + | double_value: ::std::option::Option::Some(
|
3055 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
3056 + | .expect("invalid string for number"),
|
3057 + | ),
|
3058 + | };
|
3059 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3060 + | let http_response = output.into_response();
|
3061 + | ::pretty_assertions::assert_eq!(
|
3062 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3063 + | http_response.status()
|
3064 + | );
|
3065 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
3066 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3067 + | http_response.headers(),
|
3068 + | expected_headers,
|
3069 + | ));
|
3070 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3071 + | .await
|
3072 + | .expect("unable to extract body to bytes");
|
3073 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3074 + | &body,
|
3075 + | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}",
|
3076 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3077 + | ));
|
3078 + | }
|
3079 + | }
|
3080 + |
|
3081 + | ::pin_project_lite::pin_project! {
|
3082 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3083 + | /// [`EmptyInputAndEmptyOutputInput`](crate::input::EmptyInputAndEmptyOutputInput) using modelled bindings.
|
3084 + | pub struct EmptyInputAndEmptyOutputInputFuture {
|
3085 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputAndEmptyOutputInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
3086 + | }
|
3087 + | }
|
3088 + |
|
3089 + | impl std::future::Future for EmptyInputAndEmptyOutputInputFuture {
|
3090 + | type Output = Result<
|
3091 + | crate::input::EmptyInputAndEmptyOutputInput,
|
3092 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
3093 + | >;
|
3094 + |
|
3095 + | fn poll(
|
3096 + | self: std::pin::Pin<&mut Self>,
|
3097 + | cx: &mut std::task::Context<'_>,
|
3098 + | ) -> std::task::Poll<Self::Output> {
|
3099 + | let this = self.project();
|
3100 + | this.inner.as_mut().poll(cx)
|
3101 + | }
|
3102 + | }
|
3103 + |
|
3104 + | impl<B>
|
3105 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
3106 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
3107 + | B,
|
3108 + | > for crate::input::EmptyInputAndEmptyOutputInput
|
3109 + | where
|
3110 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
3111 + | B: 'static,
|
3112 + |
|
3113 + | B::Data: Send,
|
3114 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
3115 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
3116 + | {
|
3117 + | type Rejection =
|
3118 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
3119 + | type Future = EmptyInputAndEmptyOutputInputFuture;
|
3120 + |
|
3121 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3122 + | let fut = async move {
|
3123 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
3124 + | request.headers(),
|
3125 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
3126 + | ) {
|
3127 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
3128 + | }
|
3129 + | crate::protocol_serde::shape_empty_input_and_empty_output::de_empty_input_and_empty_output_http_request(request)
|
3130 + | .await
|
3131 + | };
|
3132 + | use ::futures_util::future::TryFutureExt;
|
3133 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
3134 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3135 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
3136 + | });
|
3137 + | EmptyInputAndEmptyOutputInputFuture {
|
3138 + | inner: Box::pin(fut),
|
3139 + | }
|
3140 + | }
|
3141 + | }
|
3142 + | impl
|
3143 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3144 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
3145 + | > for crate::output::EmptyInputAndEmptyOutputOutput
|
3146 + | {
|
3147 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3148 + | match crate::protocol_serde::shape_empty_input_and_empty_output::ser_empty_input_and_empty_output_http_response(self) {
|
3149 + | Ok(response) => response,
|
3150 + | Err(e) => {
|
3151 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3152 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
3153 + | }
|
3154 + | }
|
3155 + | }
|
3156 + | }
|
3157 + |
|
3158 + | #[allow(unreachable_code, unused_variables)]
|
3159 + | #[cfg(test)]
|
3160 + | mod empty_input_and_empty_output_test {
|
3161 + |
|
3162 + | /// Clients must always send an empty object if input is modeled.
|
3163 + | /// Test ID: AwsJson10EmptyInputAndEmptyOutput
|
3164 + | #[::tokio::test]
|
3165 + | #[::tracing_test::traced_test]
|
3166 + | async fn aws_json10_empty_input_and_empty_output_request() {
|
3167 + | #[allow(unused_mut)]
|
3168 + | let mut http_request = ::http::Request::builder()
|
3169 + | .uri("/")
|
3170 + | .method("POST")
|
3171 + | .header("Content-Type", "application/x-amz-json-1.0")
|
3172 + | .header("X-Amz-Target", "JsonRpc10.EmptyInputAndEmptyOutput")
|
3173 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3174 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3175 + | "{}".as_bytes(),
|
3176 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3177 + | )),
|
3178 + | ))
|
3179 + | .unwrap();
|
3180 + | #[allow(unused_mut)]
|
3181 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3182 + | let config = crate::service::JsonRpc10Config::builder().build();
|
3183 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
3184 + | .empty_input_and_empty_output(
|
3185 + | move |input: crate::input::EmptyInputAndEmptyOutputInput| {
|
3186 + | let sender = sender.clone();
|
3187 + | async move {
|
3188 + | let result = {
|
3189 + | let expected = crate::input::EmptyInputAndEmptyOutputInput {};
|
3190 + | ::pretty_assertions::assert_eq!(input, expected);
|
3191 + | let output = crate::output::EmptyInputAndEmptyOutputOutput {};
|
3192 + | output
|
3193 + | };
|
3194 + | sender.send(()).await.expect("receiver dropped early");
|
3195 + | result
|
3196 + | }
|
3197 + | },
|
3198 + | )
|
3199 + | .build_unchecked();
|
3200 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3201 + | .await
|
3202 + | .expect("unable to make an HTTP request");
|
3203 + | assert!(
|
3204 + | receiver.recv().await.is_some(),
|
3205 + | "we expected operation handler to be invoked but it was not entered"
|
3206 + | );
|
3207 + | }
|
3208 + |
|
3209 + | /// A service will always return a JSON object for operations with modeled output.
|
3210 + | /// Test ID: AwsJson10EmptyInputAndEmptyOutputSendJsonObject
|
3211 + | #[::tokio::test]
|
3212 + | #[::tracing_test::traced_test]
|
3213 + | async fn aws_json10_empty_input_and_empty_output_send_json_object_response() {
|
3214 + | let output = crate::output::EmptyInputAndEmptyOutputOutput {};
|
3215 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3216 + | let http_response = output.into_response();
|
3217 + | ::pretty_assertions::assert_eq!(
|
3218 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3219 + | http_response.status()
|
3220 + | );
|
3221 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
3222 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3223 + | http_response.headers(),
|
3224 + | expected_headers,
|
3225 + | ));
|
3226 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3227 + | .await
|
3228 + | .expect("unable to extract body to bytes");
|
3229 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3230 + | &body,
|
3231 + | "{}",
|
3232 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3233 + | ));
|
3234 + | }
|
3235 + | }
|
3236 + |
|
3237 + | ::pin_project_lite::pin_project! {
|
3238 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3239 + | /// [`NoInputAndOutputInput`](crate::input::NoInputAndOutputInput) using modelled bindings.
|
3240 + | pub struct NoInputAndOutputInputFuture {
|
3241 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputAndOutputInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
3242 + | }
|
3243 + | }
|
3244 + |
|
3245 + | impl std::future::Future for NoInputAndOutputInputFuture {
|
3246 + | type Output = Result<
|
3247 + | crate::input::NoInputAndOutputInput,
|
3248 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
3249 + | >;
|
3250 + |
|
3251 + | fn poll(
|
3252 + | self: std::pin::Pin<&mut Self>,
|
3253 + | cx: &mut std::task::Context<'_>,
|
3254 + | ) -> std::task::Poll<Self::Output> {
|
3255 + | let this = self.project();
|
3256 + | this.inner.as_mut().poll(cx)
|
3257 + | }
|
3258 + | }
|
3259 + |
|
3260 + | impl<B>
|
3261 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
3262 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
3263 + | B,
|
3264 + | > for crate::input::NoInputAndOutputInput
|
3265 + | where
|
3266 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
3267 + | B: 'static,
|
3268 + |
|
3269 + | B::Data: Send,
|
3270 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
3271 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
3272 + | {
|
3273 + | type Rejection =
|
3274 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
3275 + | type Future = NoInputAndOutputInputFuture;
|
3276 + |
|
3277 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3278 + | let fut = async move {
|
3279 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
3280 + | request.headers(),
|
3281 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
3282 + | ) {
|
3283 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
3284 + | }
|
3285 + | crate::protocol_serde::shape_no_input_and_output::de_no_input_and_output_http_request(
|
3286 + | request,
|
3287 + | )
|
3288 + | .await
|
3289 + | };
|
3290 + | use ::futures_util::future::TryFutureExt;
|
3291 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
3292 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3293 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
3294 + | });
|
3295 + | NoInputAndOutputInputFuture {
|
3296 + | inner: Box::pin(fut),
|
3297 + | }
|
3298 + | }
|
3299 + | }
|
3300 + | impl
|
3301 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3302 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
3303 + | > for crate::output::NoInputAndOutputOutput
|
3304 + | {
|
3305 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3306 + | match crate::protocol_serde::shape_no_input_and_output::ser_no_input_and_output_http_response(self) {
|
3307 + | Ok(response) => response,
|
3308 + | Err(e) => {
|
3309 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3310 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
3311 + | }
|
3312 + | }
|
3313 + | }
|
3314 + | }
|
3315 + |
|
3316 + | #[allow(unreachable_code, unused_variables)]
|
3317 + | #[cfg(test)]
|
3318 + | mod no_input_and_output_test {
|
3319 + |
|
3320 + | /// A client should always send and empty JSON object payload.
|
3321 + | /// Test ID: AwsJson10NoInputAndOutput
|
3322 + | #[::tokio::test]
|
3323 + | #[::tracing_test::traced_test]
|
3324 + | async fn aws_json10_no_input_and_output_request() {
|
3325 + | #[allow(unused_mut)]
|
3326 + | let mut http_request = ::http::Request::builder()
|
3327 + | .uri("/")
|
3328 + | .method("POST")
|
3329 + | .header("Content-Type", "application/x-amz-json-1.0")
|
3330 + | .header("X-Amz-Target", "JsonRpc10.NoInputAndOutput")
|
3331 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3332 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3333 + | "{}".as_bytes(),
|
3334 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3335 + | )),
|
3336 + | ))
|
3337 + | .unwrap();
|
3338 + | #[allow(unused_mut)]
|
3339 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3340 + | let config = crate::service::JsonRpc10Config::builder().build();
|
3341 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
3342 + | .no_input_and_output(move |input: crate::input::NoInputAndOutputInput| {
|
3343 + | let sender = sender.clone();
|
3344 + | async move {
|
3345 + | let result = {
|
3346 + | let expected = crate::input::NoInputAndOutputInput {};
|
3347 + | ::pretty_assertions::assert_eq!(input, expected);
|
3348 + | let output = crate::output::NoInputAndOutputOutput {};
|
3349 + | output
|
3350 + | };
|
3351 + | sender.send(()).await.expect("receiver dropped early");
|
3352 + | result
|
3353 + | }
|
3354 + | })
|
3355 + | .build_unchecked();
|
3356 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3357 + | .await
|
3358 + | .expect("unable to make an HTTP request");
|
3359 + | assert!(
|
3360 + | receiver.recv().await.is_some(),
|
3361 + | "we expected operation handler to be invoked but it was not entered"
|
3362 + | );
|
3363 + | }
|
3364 + |
|
3365 + | /// Empty output always serializes an empty object payload.
|
3366 + | /// Test ID: AwsJson10NoInputAndOutput
|
3367 + | #[::tokio::test]
|
3368 + | #[::tracing_test::traced_test]
|
3369 + | async fn aws_json10_no_input_and_output_response() {
|
3370 + | let output = crate::output::NoInputAndOutputOutput {};
|
3371 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3372 + | let http_response = output.into_response();
|
3373 + | ::pretty_assertions::assert_eq!(
|
3374 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3375 + | http_response.status()
|
3376 + | );
|
3377 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
3378 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3379 + | http_response.headers(),
|
3380 + | expected_headers,
|
3381 + | ));
|
3382 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3383 + | .await
|
3384 + | .expect("unable to extract body to bytes");
|
3385 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3386 + | &body,
|
3387 + | "{}",
|
3388 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3389 + | ));
|
3390 + | }
|
3391 + | }
|
3392 + |
|
3393 + | ::pin_project_lite::pin_project! {
|
3394 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3395 + | /// [`NoInputAndNoOutputInput`](crate::input::NoInputAndNoOutputInput) using modelled bindings.
|
3396 + | pub struct NoInputAndNoOutputInputFuture {
|
3397 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputAndNoOutputInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
|
3398 + | }
|
3399 + | }
|
3400 + |
|
3401 + | impl std::future::Future for NoInputAndNoOutputInputFuture {
|
3402 + | type Output = Result<
|
3403 + | crate::input::NoInputAndNoOutputInput,
|
3404 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
|
3405 + | >;
|
3406 + |
|
3407 + | fn poll(
|
3408 + | self: std::pin::Pin<&mut Self>,
|
3409 + | cx: &mut std::task::Context<'_>,
|
3410 + | ) -> std::task::Poll<Self::Output> {
|
3411 + | let this = self.project();
|
3412 + | this.inner.as_mut().poll(cx)
|
3413 + | }
|
3414 + | }
|
3415 + |
|
3416 + | impl<B>
|
3417 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
3418 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
3419 + | B,
|
3420 + | > for crate::input::NoInputAndNoOutputInput
|
3421 + | where
|
3422 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
3423 + | B: 'static,
|
3424 + |
|
3425 + | B::Data: Send,
|
3426 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
|
3427 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
3428 + | {
|
3429 + | type Rejection =
|
3430 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
|
3431 + | type Future = NoInputAndNoOutputInputFuture;
|
3432 + |
|
3433 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3434 + | let fut = async move {
|
3435 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
3436 + | request.headers(),
|
3437 + | &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
|
3438 + | ) {
|
3439 + | return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
|
3440 + | }
|
3441 + | crate::protocol_serde::shape_no_input_and_no_output::de_no_input_and_no_output_http_request(request)
|
3442 + | .await
|
3443 + | };
|
3444 + | use ::futures_util::future::TryFutureExt;
|
3445 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
|
3446 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3447 + | ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
|
3448 + | });
|
3449 + | NoInputAndNoOutputInputFuture {
|
3450 + | inner: Box::pin(fut),
|
3451 + | }
|
3452 + | }
|
3453 + | }
|
3454 + | impl
|
3455 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3456 + | ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
|
3457 + | > for crate::output::NoInputAndNoOutputOutput
|
3458 + | {
|
3459 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3460 + | match crate::protocol_serde::shape_no_input_and_no_output::ser_no_input_and_no_output_http_response(self) {
|
3461 + | Ok(response) => response,
|
3462 + | Err(e) => {
|
3463 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3464 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
|
3465 + | }
|
3466 + | }
|
3467 + | }
|
3468 + | }
|
3469 + |
|
3470 + | #[allow(unreachable_code, unused_variables)]
|
3471 + | #[cfg(test)]
|
3472 + | mod no_input_and_no_output_test {
|
3473 + |
|
3474 + | /// Clients must always send an empty JSON object payload for
|
3475 + | /// operations with no input (that is, `{}`). While AWS service
|
3476 + | /// implementations support requests with no payload or requests
|
3477 + | /// that send `{}`, always sending `{}` from the client is
|
3478 + | /// preferred for forward compatibility in case input is ever
|
3479 + | /// added to an operation.
|
3480 + | /// Test ID: AwsJson10MustAlwaysSendEmptyJsonPayload
|
3481 + | #[::tokio::test]
|
3482 + | #[::tracing_test::traced_test]
|
3483 + | async fn aws_json10_must_always_send_empty_json_payload_request() {
|
3484 + | #[allow(unused_mut)]
|
3485 + | let mut http_request = ::http::Request::builder()
|
3486 + | .uri("/")
|
3487 + | .method("POST")
|
3488 + | .header("Content-Type", "application/x-amz-json-1.0")
|
3489 + | .header("X-Amz-Target", "JsonRpc10.NoInputAndNoOutput")
|
3490 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3491 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3492 + | "{}".as_bytes(),
|
3493 + | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
3494 + | )),
|
3495 + | ))
|
3496 + | .unwrap();
|
3497 + | #[allow(unused_mut)]
|
3498 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3499 + | let config = crate::service::JsonRpc10Config::builder().build();
|
3500 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
3501 + | .no_input_and_no_output(move |input: crate::input::NoInputAndNoOutputInput| {
|
3502 + | let sender = sender.clone();
|
3503 + | async move {
|
3504 + | let result = {
|
3505 + | let expected = crate::input::NoInputAndNoOutputInput {};
|
3506 + | ::pretty_assertions::assert_eq!(input, expected);
|
3507 + | let output = crate::output::NoInputAndNoOutputOutput {};
|
3508 + | output
|
3509 + | };
|
3510 + | sender.send(()).await.expect("receiver dropped early");
|
3511 + | result
|
3512 + | }
|
3513 + | })
|
3514 + | .build_unchecked();
|
3515 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3516 + | .await
|
3517 + | .expect("unable to make an HTTP request");
|
3518 + | assert!(
|
3519 + | receiver.recv().await.is_some(),
|
3520 + | "we expected operation handler to be invoked but it was not entered"
|
3521 + | );
|
3522 + | }
|
3523 + |
|
3524 + | /// Service implementations must support no payload or an empty
|
3525 + | /// object payload for operations that define no input. However,
|
3526 + | /// despite the lack of a payload, a Content-Type header is still
|
3527 + | /// required in order for the service to properly detect the
|
3528 + | /// protocol.
|
3529 + | /// Test ID: AwsJson10ServiceSupportsNoPayloadForNoInput
|
3530 + | #[::tokio::test]
|
3531 + | #[::tracing_test::traced_test]
|
3532 + | async fn aws_json10_service_supports_no_payload_for_no_input_request() {
|
3533 + | #[allow(unused_mut)]
|
3534 + | let mut http_request = ::http::Request::builder()
|
3535 + | .uri("/")
|
3536 + | .method("POST")
|
3537 + | .header("Content-Type", "application/x-amz-json-1.0")
|
3538 + | .header("X-Amz-Target", "JsonRpc10.NoInputAndNoOutput")
|
3539 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3540 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3541 + | "".as_bytes(),
|
3542 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3543 + | )),
|
3544 + | ))
|
3545 + | .unwrap();
|
3546 + | #[allow(unused_mut)]
|
3547 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3548 + | let config = crate::service::JsonRpc10Config::builder().build();
|
3549 + | let service = crate::service::JsonRpc10::builder::<::hyper::body::Body, _, _, _>(config)
|
3550 + | .no_input_and_no_output(move |input: crate::input::NoInputAndNoOutputInput| {
|
3551 + | let sender = sender.clone();
|
3552 + | async move {
|
3553 + | let result = {
|
3554 + | let expected = crate::input::NoInputAndNoOutputInput {};
|
3555 + | ::pretty_assertions::assert_eq!(input, expected);
|
3556 + | let output = crate::output::NoInputAndNoOutputOutput {};
|
3557 + | output
|
3558 + | };
|
3559 + | sender.send(()).await.expect("receiver dropped early");
|
3560 + | result
|
3561 + | }
|
3562 + | })
|
3563 + | .build_unchecked();
|
3564 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3565 + | .await
|
3566 + | .expect("unable to make an HTTP request");
|
3567 + | assert!(
|
3568 + | receiver.recv().await.is_some(),
|
3569 + | "we expected operation handler to be invoked but it was not entered"
|
3570 + | );
|
3571 + | }
|
3572 + |
|
3573 + | /// When no output is defined, the service is expected to return
|
3574 + | /// an empty payload. Despite the lack of a payload, the service
|
3575 + | /// is expected to always send a Content-Type header. Clients must
|
3576 + | /// handle cases where a service returns a JSON object and where
|
3577 + | /// a service returns no JSON at all.
|
3578 + | /// Test ID: AwsJson10ServiceRespondsWithNoPayload
|
3579 + | #[::tokio::test]
|
3580 + | #[::tracing_test::traced_test]
|
3581 + | async fn aws_json10_service_responds_with_no_payload_response() {
|
3582 + | let output = crate::output::NoInputAndNoOutputOutput {};
|
3583 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3584 + | let http_response = output.into_response();
|
3585 + | ::pretty_assertions::assert_eq!(
|
3586 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3587 + | http_response.status()
|
3588 + | );
|
3589 + | let expected_headers = [("Content-Type", "application/x-amz-json-1.0")];
|
3590 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3591 + | http_response.headers(),
|
3592 + | expected_headers,
|
3593 + | ));
|
3594 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3595 + | .await
|
3596 + | .expect("unable to extract body to bytes");
|
3597 + | // No body.
|
3598 + | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
3599 + | }
|
3600 + | }
|