1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | ::pin_project_lite::pin_project! {
|
3 3 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 - | /// [`StreamingOperationWithOptionalDataInput`](crate::input::StreamingOperationWithOptionalDataInput) using modelled bindings.
|
5 - | pub struct StreamingOperationWithOptionalDataInputFuture {
|
6 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationWithOptionalDataInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4 + | /// [`SimpleStructOperationInput`](crate::input::SimpleStructOperationInput) using modelled bindings.
|
5 + | pub struct SimpleStructOperationInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
7 7 | }
|
8 8 | }
|
9 9 |
|
10 - | impl std::future::Future for StreamingOperationWithOptionalDataInputFuture {
|
10 + | impl std::future::Future for SimpleStructOperationInputFuture {
|
11 11 | type Output = Result<
|
12 - | crate::input::StreamingOperationWithOptionalDataInput,
|
12 + | crate::input::SimpleStructOperationInput,
|
13 13 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
14 14 | >;
|
15 15 |
|
16 16 | fn poll(
|
17 17 | self: std::pin::Pin<&mut Self>,
|
18 18 | cx: &mut std::task::Context<'_>,
|
19 19 | ) -> std::task::Poll<Self::Output> {
|
20 20 | let this = self.project();
|
21 21 | this.inner.as_mut().poll(cx)
|
22 22 | }
|
23 23 | }
|
24 24 |
|
25 25 | impl<B>
|
26 26 | ::aws_smithy_http_server::request::FromRequest<
|
27 27 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
28 28 | B,
|
29 - | > for crate::input::StreamingOperationWithOptionalDataInput
|
29 + | > for crate::input::SimpleStructOperationInput
|
30 30 | where
|
31 31 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
32 32 | B: 'static,
|
33 33 |
|
34 - | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
35 - | + ::std::marker::Send
|
36 - | + ::std::marker::Sync
|
37 - | + 'static,
|
38 - | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
39 - |
|
40 34 | B::Data: Send,
|
41 35 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
42 36 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
43 37 | {
|
44 38 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
45 - | type Future = StreamingOperationWithOptionalDataInputFuture;
|
39 + | type Future = SimpleStructOperationInputFuture;
|
46 40 |
|
47 41 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
48 42 | let fut = async move {
|
49 43 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
50 - | request.headers(),
|
51 - | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
52 - | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
53 44 | request.headers(),
|
54 45 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
55 46 | ) {
|
56 47 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
57 48 | }
|
58 - | crate::protocol_serde::shape_streaming_operation_with_optional_data::de_streaming_operation_with_optional_data_http_request(request)
|
49 + | crate::protocol_serde::shape_simple_struct_operation::de_simple_struct_operation_http_request(request)
|
59 50 | .await
|
60 51 | };
|
61 52 | use ::futures_util::future::TryFutureExt;
|
62 53 | let fut = fut.map_err(
|
63 54 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
64 55 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
65 56 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
66 57 | e,
|
67 58 | )
|
68 59 | },
|
69 60 | );
|
70 - | StreamingOperationWithOptionalDataInputFuture {
|
61 + | SimpleStructOperationInputFuture {
|
71 62 | inner: Box::pin(fut),
|
72 63 | }
|
73 64 | }
|
74 65 | }
|
75 66 | impl
|
76 67 | ::aws_smithy_http_server::response::IntoResponse<
|
77 68 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
78 - | > for crate::output::StreamingOperationWithOptionalDataOutput
|
69 + | > for crate::output::SimpleStructOperationOutput
|
79 70 | {
|
80 71 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
81 - | match crate::protocol_serde::shape_streaming_operation_with_optional_data::ser_streaming_operation_with_optional_data_http_response(self) {
|
72 + | match crate::protocol_serde::shape_simple_struct_operation::ser_simple_struct_operation_http_response(self) {
|
82 73 | Ok(response) => response,
|
83 74 | Err(e) => {
|
84 75 | ::tracing::error!(error = %e, "failed to serialize response");
|
85 76 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
86 77 | }
|
87 78 | }
|
88 79 | }
|
89 80 | }
|
90 81 | impl
|
91 82 | ::aws_smithy_http_server::response::IntoResponse<
|
92 83 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
93 - | > for crate::error::StreamingOperationWithOptionalDataError
|
84 + | > for crate::error::SimpleStructOperationError
|
94 85 | {
|
95 86 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
96 - | match crate::protocol_serde::shape_streaming_operation_with_optional_data::ser_streaming_operation_with_optional_data_http_error(&self) {
|
87 + | match crate::protocol_serde::shape_simple_struct_operation::ser_simple_struct_operation_http_error(&self) {
|
97 88 | Ok(mut response) => {
|
98 89 | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
99 90 | response
|
100 91 | },
|
101 92 | Err(e) => {
|
102 93 | ::tracing::error!(error = %e, "failed to serialize response");
|
103 94 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
104 95 | }
|
105 96 | }
|
106 97 | }
|
107 98 | }
|
108 99 |
|
109 - | ::pin_project_lite::pin_project! {
|
110 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
111 - | /// [`StreamingOperationWithInitialResponseInput`](crate::input::StreamingOperationWithInitialResponseInput) using modelled bindings.
|
112 - | pub struct StreamingOperationWithInitialResponseInputFuture {
|
113 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationWithInitialResponseInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
114 - | }
|
115 - | }
|
116 - |
|
117 - | impl std::future::Future for StreamingOperationWithInitialResponseInputFuture {
|
118 - | type Output = Result<
|
119 - | crate::input::StreamingOperationWithInitialResponseInput,
|
120 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
121 - | >;
|
122 - |
|
123 - | fn poll(
|
124 - | self: std::pin::Pin<&mut Self>,
|
125 - | cx: &mut std::task::Context<'_>,
|
126 - | ) -> std::task::Poll<Self::Output> {
|
127 - | let this = self.project();
|
128 - | this.inner.as_mut().poll(cx)
|
129 - | }
|
130 - | }
|
131 - |
|
132 - | impl<B>
|
133 - | ::aws_smithy_http_server::request::FromRequest<
|
134 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
135 - | B,
|
136 - | > for crate::input::StreamingOperationWithInitialResponseInput
|
137 - | where
|
138 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
139 - | B: 'static,
|
140 - |
|
141 - | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
142 - | + ::std::marker::Send
|
143 - | + ::std::marker::Sync
|
144 - | + 'static,
|
145 - | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
146 - |
|
147 - | B::Data: Send,
|
148 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
149 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
150 - | {
|
151 - | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
152 - | type Future = StreamingOperationWithInitialResponseInputFuture;
|
100 + | #[allow(unreachable_code, unused_variables)]
|
101 + | #[cfg(test)]
|
102 + | mod simple_struct_operation_test {
|
153 103 |
|
154 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
155 - | let fut = async move {
|
156 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
157 - | request.headers(),
|
158 - | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
159 - | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
160 - | request.headers(),
|
161 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
162 - | ) {
|
163 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
104 + | /// Test ID: SimpleStruct
|
105 + | #[::tokio::test]
|
106 + | #[::tracing_test::traced_test]
|
107 + | async fn simple_struct_response() {
|
108 + | let output =crate::output::SimpleStructOperationOutput {
|
109 + | blob:
|
110 + | ::std::option::Option::Some(
|
111 + | ::aws_smithy_types::Blob::new("blobby blob")
|
112 + | )
|
113 + | ,
|
114 + | boolean:
|
115 + | ::std::option::Option::Some(
|
116 + | false
|
117 + | )
|
118 + | ,
|
119 + | string:
|
120 + | ::std::option::Option::Some(
|
121 + | "There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.".to_owned()
|
122 + | )
|
123 + | ,
|
124 + | byte:
|
125 + | ::std::option::Option::Some(
|
126 + | 69
|
127 + | )
|
128 + | ,
|
129 + | short:
|
130 + | ::std::option::Option::Some(
|
131 + | 70
|
132 + | )
|
133 + | ,
|
134 + | integer:
|
135 + | ::std::option::Option::Some(
|
136 + | 71
|
137 + | )
|
138 + | ,
|
139 + | long:
|
140 + | ::std::option::Option::Some(
|
141 + | 72
|
142 + | )
|
143 + | ,
|
144 + | float:
|
145 + | ::std::option::Option::Some(
|
146 + | 0.69_f32
|
147 + | )
|
148 + | ,
|
149 + | double:
|
150 + | ::std::option::Option::Some(
|
151 + | 0.6969_f64
|
152 + | )
|
153 + | ,
|
154 + | timestamp:
|
155 + | ::std::option::Option::Some(
|
156 + | ::aws_smithy_types::DateTime::from_fractional_secs(1546300800, 0_f64)
|
157 + | )
|
158 + | ,
|
159 + | r#enum:
|
160 + | ::std::option::Option::Some(
|
161 + | "DIAMOND".parse::<crate::model::Suit>().expect("static value validated to member")
|
162 + | )
|
163 + | ,
|
164 + | required_blob:
|
165 + | ::aws_smithy_types::Blob::new("blobby blob")
|
166 + | ,
|
167 + | required_boolean:
|
168 + | false
|
169 + | ,
|
170 + | required_string:
|
171 + | "There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.".to_owned()
|
172 + | ,
|
173 + | required_byte:
|
174 + | 69
|
175 + | ,
|
176 + | required_short:
|
177 + | 70
|
178 + | ,
|
179 + | required_integer:
|
180 + | 71
|
181 + | ,
|
182 + | required_long:
|
183 + | 72
|
184 + | ,
|
185 + | required_float:
|
186 + | 0.69_f32
|
187 + | ,
|
188 + | required_double:
|
189 + | 0.6969_f64
|
190 + | ,
|
191 + | required_timestamp:
|
192 + | ::aws_smithy_types::DateTime::from_fractional_secs(1546300800, 0_f64)
|
193 + | ,
|
194 + | required_enum:
|
195 + | "DIAMOND".parse::<crate::model::Suit>().expect("static value validated to member")
|
196 + | ,
|
164 197 | }
|
165 - | crate::protocol_serde::shape_streaming_operation_with_initial_response::de_streaming_operation_with_initial_response_http_request(request)
|
198 + | ;
|
199 + | use ::aws_smithy_http_server::response::IntoResponse;
|
200 + | let http_response = output.into_response();
|
201 + | ::pretty_assertions::assert_eq!(
|
202 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
203 + | http_response.status()
|
204 + | );
|
205 + | let expected_headers = [
|
206 + | ("Content-Type", "application/cbor"),
|
207 + | ("smithy-protocol", "rpc-v2-cbor"),
|
208 + | ];
|
209 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
210 + | http_response.headers(),
|
211 + | expected_headers,
|
212 + | ));
|
213 + | use ::http_body_util::BodyExt;
|
214 + | let body = http_response
|
215 + | .into_body()
|
216 + | .collect()
|
166 217 | .await
|
167 - | };
|
168 - | use ::futures_util::future::TryFutureExt;
|
169 - | let fut = fut.map_err(
|
170 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
171 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
172 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
173 - | e,
|
174 - | )
|
175 - | },
|
218 + | .expect("unable to collect body")
|
219 + | .to_bytes();
|
220 + | ::aws_smithy_protocol_test::assert_ok(
|
221 + | ::aws_smithy_protocol_test::validate_body(&body, "v2RibG9iS2Jsb2JieSBibG9iZ2Jvb2xlYW70ZnN0cmluZ3hwVGhlcmUgYXJlIHRocmVlIHRoaW5ncyBhbGwgd2lzZSBtZW4gZmVhcjogdGhlIHNlYSBpbiBzdG9ybSwgYSBuaWdodCB3aXRoIG5vIG1vb24sIGFuZCB0aGUgYW5nZXIgb2YgYSBnZW50bGUgbWFuLmRieXRlGEVlc2hvcnQYRmdpbnRlZ2VyGEdkbG9uZxhIZWZsb2F0+j8wo9dmZG91Ymxl+z/mTQE6kqMFaXRpbWVzdGFtcMH7QdcKq2AAAABkZW51bWdESUFNT05EbHJlcXVpcmVkQmxvYktibG9iYnkgYmxvYm9yZXF1aXJlZEJvb2xlYW70bnJlcXVpcmVkU3RyaW5neHBUaGVyZSBhcmUgdGhyZWUgdGhpbmdzIGFsbCB3aXNlIG1lbiBmZWFyOiB0aGUgc2VhIGluIHN0b3JtLCBhIG5pZ2h0IHdpdGggbm8gbW9vbiwgYW5kIHRoZSBhbmdlciBvZiBhIGdlbnRsZSBtYW4ubHJlcXVpcmVkQnl0ZRhFbXJlcXVpcmVkU2hvcnQYRm9yZXF1aXJlZEludGVnZXIYR2xyZXF1aXJlZExvbmcYSG1yZXF1aXJlZEZsb2F0+j8wo9ducmVxdWlyZWREb3VibGX7P+ZNATqSowVxcmVxdWlyZWRUaW1lc3RhbXDB+0HXCqtgAAAAbHJlcXVpcmVkRW51bWdESUFNT05E/w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
176 222 | );
|
177 - | StreamingOperationWithInitialResponseInputFuture {
|
178 - | inner: Box::pin(fut),
|
179 - | }
|
180 - | }
|
181 - | }
|
182 - | impl
|
183 - | ::aws_smithy_http_server::response::IntoResponse<
|
184 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
185 - | > for crate::output::StreamingOperationWithInitialResponseOutput
|
186 - | {
|
187 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
188 - | match crate::protocol_serde::shape_streaming_operation_with_initial_response::ser_streaming_operation_with_initial_response_http_response(self) {
|
189 - | Ok(response) => response,
|
190 - | Err(e) => {
|
191 - | ::tracing::error!(error = %e, "failed to serialize response");
|
192 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
193 - | }
|
194 - | }
|
195 - | }
|
196 - | }
|
197 - | impl
|
198 - | ::aws_smithy_http_server::response::IntoResponse<
|
199 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
200 - | > for crate::error::StreamingOperationWithInitialResponseError
|
201 - | {
|
202 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
203 - | match crate::protocol_serde::shape_streaming_operation_with_initial_response::ser_streaming_operation_with_initial_response_http_error(&self) {
|
204 - | Ok(mut response) => {
|
205 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
206 - | response
|
207 - | },
|
208 - | Err(e) => {
|
209 - | ::tracing::error!(error = %e, "failed to serialize response");
|
210 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
211 223 | }
|
212 - | }
|
213 - | }
|
214 - | }
|
215 - |
|
224 + | /// Test ID: SimpleStructWithOptionsSetToNone
|
225 + | #[::tokio::test]
|
226 + | #[::tracing_test::traced_test]
|
227 + | async fn simple_struct_with_options_set_to_none_response() {
|
228 + | let output =crate::output::SimpleStructOperationOutput {
|
229 + | required_blob:
|
230 + | ::aws_smithy_types::Blob::new("blobby blob")
|
231 + | ,
|
232 + | required_boolean:
|
233 + | false
|
234 + | ,
|
235 + | required_string:
|
236 + | "There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.".to_owned()
|
237 + | ,
|
238 + | required_byte:
|
239 + | 69
|
240 + | ,
|
241 + | required_short:
|
242 + | 70
|
243 + | ,
|
244 + | required_integer:
|
245 + | 71
|
246 + | ,
|
247 + | required_long:
|
248 + | 72
|
249 + | ,
|
250 + | required_float:
|
251 + | 0.69_f32
|
252 + | ,
|
253 + | required_double:
|
254 + | 0.6969_f64
|
255 + | ,
|
256 + | required_timestamp:
|
257 + | ::aws_smithy_types::DateTime::from_fractional_secs(1546300800, 0_f64)
|
258 + | ,
|
259 + | required_enum:
|
260 + | "DIAMOND".parse::<crate::model::Suit>().expect("static value validated to member")
|
261 + | ,
|
262 + | blob:
|
263 + | ::std::option::Option::None
|
264 + | ,
|
265 + | boolean:
|
266 + | ::std::option::Option::None
|
267 + | ,
|
268 + | string:
|
269 + | ::std::option::Option::None
|
270 + | ,
|
271 + | byte:
|
272 + | ::std::option::Option::None
|
273 + | ,
|
274 + | short:
|
275 + | ::std::option::Option::None
|
276 + | ,
|
277 + | integer:
|
278 + | ::std::option::Option::None
|
279 + | ,
|
280 + | long:
|
281 + | ::std::option::Option::None
|
282 + | ,
|
283 + | float:
|
284 + | ::std::option::Option::None
|
285 + | ,
|
286 + | double:
|
287 + | ::std::option::Option::None
|
288 + | ,
|
289 + | timestamp:
|
290 + | ::std::option::Option::None
|
291 + | ,
|
292 + | r#enum:
|
293 + | ::std::option::Option::None
|
294 + | ,
|
295 + | }
|
296 + | ;
|
297 + | use ::aws_smithy_http_server::response::IntoResponse;
|
298 + | let http_response = output.into_response();
|
299 + | ::pretty_assertions::assert_eq!(
|
300 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
301 + | http_response.status()
|
302 + | );
|
303 + | let expected_headers = [
|
304 + | ("Content-Type", "application/cbor"),
|
305 + | ("smithy-protocol", "rpc-v2-cbor"),
|
306 + | ];
|
307 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
308 + | http_response.headers(),
|
309 + | expected_headers,
|
310 + | ));
|
311 + | use ::http_body_util::BodyExt;
|
312 + | let body = http_response
|
313 + | .into_body()
|
314 + | .collect()
|
315 + | .await
|
316 + | .expect("unable to collect body")
|
317 + | .to_bytes();
|
318 + | ::aws_smithy_protocol_test::assert_ok(
|
319 + | ::aws_smithy_protocol_test::validate_body(&body, "v2xyZXF1aXJlZEJsb2JLYmxvYmJ5IGJsb2JvcmVxdWlyZWRCb29sZWFu9G5yZXF1aXJlZFN0cmluZ3hwVGhlcmUgYXJlIHRocmVlIHRoaW5ncyBhbGwgd2lzZSBtZW4gZmVhcjogdGhlIHNlYSBpbiBzdG9ybSwgYSBuaWdodCB3aXRoIG5vIG1vb24sIGFuZCB0aGUgYW5nZXIgb2YgYSBnZW50bGUgbWFuLmxyZXF1aXJlZEJ5dGUYRW1yZXF1aXJlZFNob3J0GEZvcmVxdWlyZWRJbnRlZ2VyGEdscmVxdWlyZWRMb25nGEhtcmVxdWlyZWRGbG9hdPo/MKPXbnJlcXVpcmVkRG91Ymxl+z/mTQE6kqMFcXJlcXVpcmVkVGltZXN0YW1wwftB1wqrYAAAAGxyZXF1aXJlZEVudW1nRElBTU9ORP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
320 + | );
|
321 + | }
|
322 + | }
|
323 + |
|
216 324 | ::pin_project_lite::pin_project! {
|
217 325 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
218 - | /// [`StreamingOperationWithInitialDataInput`](crate::input::StreamingOperationWithInitialDataInput) using modelled bindings.
|
219 - | pub struct StreamingOperationWithInitialDataInputFuture {
|
220 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationWithInitialDataInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
326 + | /// [`ErrorSerializationOperationInput`](crate::input::ErrorSerializationOperationInput) using modelled bindings.
|
327 + | pub struct ErrorSerializationOperationInputFuture {
|
328 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ErrorSerializationOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
221 329 | }
|
222 330 | }
|
223 331 |
|
224 - | impl std::future::Future for StreamingOperationWithInitialDataInputFuture {
|
332 + | impl std::future::Future for ErrorSerializationOperationInputFuture {
|
225 333 | type Output = Result<
|
226 - | crate::input::StreamingOperationWithInitialDataInput,
|
334 + | crate::input::ErrorSerializationOperationInput,
|
227 335 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
228 336 | >;
|
229 337 |
|
230 338 | fn poll(
|
231 339 | self: std::pin::Pin<&mut Self>,
|
232 340 | cx: &mut std::task::Context<'_>,
|
233 341 | ) -> std::task::Poll<Self::Output> {
|
234 342 | let this = self.project();
|
235 343 | this.inner.as_mut().poll(cx)
|
236 344 | }
|
237 345 | }
|
238 346 |
|
239 347 | impl<B>
|
240 348 | ::aws_smithy_http_server::request::FromRequest<
|
241 349 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
242 350 | B,
|
243 - | > for crate::input::StreamingOperationWithInitialDataInput
|
351 + | > for crate::input::ErrorSerializationOperationInput
|
244 352 | where
|
245 353 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
246 354 | B: 'static,
|
247 355 |
|
248 - | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
249 - | + ::std::marker::Send
|
250 - | + ::std::marker::Sync
|
251 - | + 'static,
|
252 - | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
253 - |
|
254 356 | B::Data: Send,
|
255 357 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
256 358 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
257 359 | {
|
258 360 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
259 - | type Future = StreamingOperationWithInitialDataInputFuture;
|
361 + | type Future = ErrorSerializationOperationInputFuture;
|
260 362 |
|
261 363 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
262 364 | let fut = async move {
|
263 365 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
264 - | request.headers(),
|
265 - | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
266 - | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
267 366 | request.headers(),
|
268 367 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
269 368 | ) {
|
270 369 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
271 370 | }
|
272 - | crate::protocol_serde::shape_streaming_operation_with_initial_data::de_streaming_operation_with_initial_data_http_request(request)
|
371 + | crate::protocol_serde::shape_error_serialization_operation::de_error_serialization_operation_http_request(request)
|
273 372 | .await
|
274 373 | };
|
275 374 | use ::futures_util::future::TryFutureExt;
|
276 375 | let fut = fut.map_err(
|
277 376 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
278 377 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
279 378 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
280 379 | e,
|
281 380 | )
|
282 381 | },
|
283 382 | );
|
284 - | StreamingOperationWithInitialDataInputFuture {
|
383 + | ErrorSerializationOperationInputFuture {
|
285 384 | inner: Box::pin(fut),
|
286 385 | }
|
287 386 | }
|
288 387 | }
|
289 388 | impl
|
290 389 | ::aws_smithy_http_server::response::IntoResponse<
|
291 390 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
292 - | > for crate::output::StreamingOperationWithInitialDataOutput
|
391 + | > for crate::output::ErrorSerializationOperationOutput
|
293 392 | {
|
294 393 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
295 - | match crate::protocol_serde::shape_streaming_operation_with_initial_data::ser_streaming_operation_with_initial_data_http_response(self) {
|
394 + | match crate::protocol_serde::shape_error_serialization_operation::ser_error_serialization_operation_http_response(self) {
|
296 395 | Ok(response) => response,
|
297 396 | Err(e) => {
|
298 397 | ::tracing::error!(error = %e, "failed to serialize response");
|
299 398 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
300 399 | }
|
301 400 | }
|
302 401 | }
|
303 402 | }
|
304 403 | impl
|
305 404 | ::aws_smithy_http_server::response::IntoResponse<
|
306 405 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
307 - | > for crate::error::StreamingOperationWithInitialDataError
|
406 + | > for crate::error::ErrorSerializationOperationError
|
308 407 | {
|
309 408 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
310 - | match crate::protocol_serde::shape_streaming_operation_with_initial_data::ser_streaming_operation_with_initial_data_http_error(&self) {
|
409 + | match crate::protocol_serde::shape_error_serialization_operation::ser_error_serialization_operation_http_error(&self) {
|
311 410 | Ok(mut response) => {
|
312 411 | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
313 412 | response
|
314 413 | },
|
315 414 | Err(e) => {
|
316 415 | ::tracing::error!(error = %e, "failed to serialize response");
|
317 416 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
318 417 | }
|
319 418 | }
|
320 419 | }
|
321 420 | }
|
322 421 |
|
422 + | #[allow(unreachable_code, unused_variables)]
|
423 + | #[cfg(test)]
|
424 + | mod error_serialization_operation_test {
|
425 + |
|
426 + | /// Despite the operation output being a structure shape with the `@error` trait,
|
427 + | /// `__type` field should, in a strict interpretation of the spec, not be included,
|
428 + | /// because we're not serializing a server error response. However, we do, because
|
429 + | /// there shouldn't™️ be any harm in doing so, and it greatly simplifies the
|
430 + | /// code generator. This test just pins this behavior in case we ever modify it.
|
431 + | /// Test ID: OperationOutputSerializationQuestionablyIncludesTypeField
|
432 + | #[::tokio::test]
|
433 + | #[::tracing_test::traced_test]
|
434 + | async fn operation_output_serialization_questionably_includes_type_field_response() {
|
435 + | let output = crate::output::ErrorSerializationOperationOutput {
|
436 + | error_shape: ::std::option::Option::Some(crate::error::ValidationException {
|
437 + | message: "ValidationException message field".to_owned(),
|
438 + | field_list: ::std::option::Option::None,
|
439 + | }),
|
440 + | };
|
441 + | use ::aws_smithy_http_server::response::IntoResponse;
|
442 + | let http_response = output.into_response();
|
443 + | ::pretty_assertions::assert_eq!(
|
444 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
445 + | http_response.status()
|
446 + | );
|
447 + | use ::http_body_util::BodyExt;
|
448 + | let body = http_response
|
449 + | .into_body()
|
450 + | .collect()
|
451 + | .await
|
452 + | .expect("unable to collect body")
|
453 + | .to_bytes();
|
454 + | ::aws_smithy_protocol_test::assert_ok(
|
455 + | ::aws_smithy_protocol_test::validate_body(&body, "v2plcnJvclNoYXBlv2ZfX3R5cGV4JHNtaXRoeS5mcmFtZXdvcmsjVmFsaWRhdGlvbkV4Y2VwdGlvbmdtZXNzYWdleCFWYWxpZGF0aW9uRXhjZXB0aW9uIG1lc3NhZ2UgZmllbGT//w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
456 + | );
|
457 + | }
|
458 + |
|
459 + | /// When invalid input is provided the request should be rejected with
|
460 + | /// a validation exception, and a `__type` field should be included
|
461 + | /// Test ID: ErrorSerializationIncludesTypeField
|
462 + | #[::tokio::test]
|
463 + | #[::tracing_test::traced_test]
|
464 + | async fn error_serialization_includes_type_field_malformed_request() {
|
465 + | {
|
466 + | #[allow(unused_mut)]
|
467 + | let mut http_request = ::http_1x::Request::builder()
|
468 + | .uri("/service/RpcV2CborService/operation/ErrorSerializationOperation")
|
469 + | .method("POST")
|
470 + | .header("smithy-protocol", "rpc-v2-cbor")
|
471 + | .header("Accept", "application/cbor")
|
472 + | .header("Content-Type", "application/cbor")
|
473 + | .body(::aws_smithy_http_server::body::boxed(
|
474 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
475 + | &::aws_smithy_protocol_test::decode_body_data(
|
476 + | "oA==".as_bytes(),
|
477 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
478 + | ),
|
479 + | )),
|
480 + | ))
|
481 + | .unwrap();
|
482 + | #[allow(unused_mut)]
|
483 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
484 + | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
485 + | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
486 + | .error_serialization_operation(move |input: crate::input::ErrorSerializationOperationInput| {
|
487 + | let sender = sender.clone();
|
488 + | async move {
|
489 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::ErrorSerializationOperationOutput, crate::error::ErrorSerializationOperationError> };
|
490 + | sender.send(()).await.expect("receiver dropped early");
|
491 + | result
|
492 + | }
|
493 + | })
|
494 + | .build_unchecked();
|
495 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
496 + | .await
|
497 + | .expect("unable to make an HTTP request");
|
498 + | ::pretty_assertions::assert_eq!(
|
499 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
500 + | http_response.status()
|
501 + | );
|
502 + | use ::http_body_util::BodyExt;
|
503 + | let body = http_response
|
504 + | .into_body()
|
505 + | .collect()
|
506 + | .await
|
507 + | .expect("unable to collect body")
|
508 + | .to_bytes();
|
509 + | ::aws_smithy_protocol_test::assert_ok(
|
510 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4JHNtaXRoeS5mcmFtZXdvcmsjVmFsaWRhdGlvbkV4Y2VwdGlvbmdtZXNzYWdleGsxIHZhbGlkYXRpb24gZXJyb3IgZGV0ZWN0ZWQuIFZhbHVlIGF0ICcvcmVxdWlyZWRCbG9iJyBmYWlsZWQgdG8gc2F0aXNmeSBjb25zdHJhaW50OiBNZW1iZXIgbXVzdCBub3QgYmUgbnVsbGlmaWVsZExpc3SBv2RwYXRobS9yZXF1aXJlZEJsb2JnbWVzc2FnZXhOVmFsdWUgYXQgJy9yZXF1aXJlZEJsb2InIGZhaWxlZCB0byBzYXRpc2Z5IGNvbnN0cmFpbnQ6IE1lbWJlciBtdXN0IG5vdCBiZSBudWxs//8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
511 + | );
|
512 + | }
|
513 + | }
|
514 + | }
|
515 + |
|
323 516 | ::pin_project_lite::pin_project! {
|
324 517 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
325 - | /// [`StreamingOperationInput`](crate::input::StreamingOperationInput) using modelled bindings.
|
326 - | pub struct StreamingOperationInputFuture {
|
327 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
518 + | /// [`ComplexStructOperationInput`](crate::input::ComplexStructOperationInput) using modelled bindings.
|
519 + | pub struct ComplexStructOperationInputFuture {
|
520 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ComplexStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
328 521 | }
|
329 522 | }
|
330 523 |
|
331 - | impl std::future::Future for StreamingOperationInputFuture {
|
524 + | impl std::future::Future for ComplexStructOperationInputFuture {
|
332 525 | type Output = Result<
|
333 - | crate::input::StreamingOperationInput,
|
526 + | crate::input::ComplexStructOperationInput,
|
334 527 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
335 528 | >;
|
336 529 |
|
337 530 | fn poll(
|
338 531 | self: std::pin::Pin<&mut Self>,
|
339 532 | cx: &mut std::task::Context<'_>,
|
340 533 | ) -> std::task::Poll<Self::Output> {
|
341 534 | let this = self.project();
|
342 535 | this.inner.as_mut().poll(cx)
|
343 536 | }
|
344 537 | }
|
345 538 |
|
346 539 | impl<B>
|
347 540 | ::aws_smithy_http_server::request::FromRequest<
|
348 541 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
349 542 | B,
|
350 - | > for crate::input::StreamingOperationInput
|
543 + | > for crate::input::ComplexStructOperationInput
|
351 544 | where
|
352 545 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
353 546 | B: 'static,
|
354 547 |
|
355 - | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
356 - | + ::std::marker::Send
|
357 - | + ::std::marker::Sync
|
358 - | + 'static,
|
359 - | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
360 - |
|
361 548 | B::Data: Send,
|
362 549 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
363 550 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
364 551 | {
|
365 552 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
366 - | type Future = StreamingOperationInputFuture;
|
553 + | type Future = ComplexStructOperationInputFuture;
|
367 554 |
|
368 555 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
369 556 | let fut = async move {
|
370 557 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
371 - | request.headers(),
|
372 - | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
373 - | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
374 558 | request.headers(),
|
375 559 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
376 560 | ) {
|
377 561 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
378 562 | }
|
379 - | crate::protocol_serde::shape_streaming_operation::de_streaming_operation_http_request(
|
380 - | request,
|
381 - | )
|
563 + | crate::protocol_serde::shape_complex_struct_operation::de_complex_struct_operation_http_request(request)
|
382 564 | .await
|
383 565 | };
|
384 566 | use ::futures_util::future::TryFutureExt;
|
385 567 | let fut = fut.map_err(
|
386 568 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
387 569 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
388 570 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
389 571 | e,
|
390 572 | )
|
391 573 | },
|
392 574 | );
|
393 - | StreamingOperationInputFuture {
|
575 + | ComplexStructOperationInputFuture {
|
394 576 | inner: Box::pin(fut),
|
395 577 | }
|
396 578 | }
|
397 579 | }
|
398 580 | impl
|
399 581 | ::aws_smithy_http_server::response::IntoResponse<
|
400 582 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
401 - | > for crate::output::StreamingOperationOutput
|
583 + | > for crate::output::ComplexStructOperationOutput
|
402 584 | {
|
403 585 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
404 - | match crate::protocol_serde::shape_streaming_operation::ser_streaming_operation_http_response(self) {
|
586 + | match crate::protocol_serde::shape_complex_struct_operation::ser_complex_struct_operation_http_response(self) {
|
405 587 | Ok(response) => response,
|
406 588 | Err(e) => {
|
407 589 | ::tracing::error!(error = %e, "failed to serialize response");
|
408 590 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
409 591 | }
|
410 592 | }
|
411 593 | }
|
412 594 | }
|
413 595 | impl
|
414 596 | ::aws_smithy_http_server::response::IntoResponse<
|
415 597 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
416 - | > for crate::error::StreamingOperationError
|
598 + | > for crate::error::ComplexStructOperationError
|
417 599 | {
|
418 600 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
419 - | match crate::protocol_serde::shape_streaming_operation::ser_streaming_operation_http_error(
|
420 - | &self,
|
421 - | ) {
|
601 + | match crate::protocol_serde::shape_complex_struct_operation::ser_complex_struct_operation_http_error(&self) {
|
422 602 | Ok(mut response) => {
|
423 - | response.extensions_mut().insert(
|
424 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
425 - | );
|
603 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
426 604 | response
|
427 - | }
|
605 + | },
|
428 606 | Err(e) => {
|
429 607 | ::tracing::error!(error = %e, "failed to serialize response");
|
430 608 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
431 609 | }
|
432 610 | }
|
433 611 | }
|
434 612 | }
|
435 613 |
|
436 614 | ::pin_project_lite::pin_project! {
|
437 615 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
438 - | /// [`RecursiveUnionOperationInput`](crate::input::RecursiveUnionOperationInput) using modelled bindings.
|
439 - | pub struct RecursiveUnionOperationInputFuture {
|
440 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveUnionOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
616 + | /// [`EmptyStructOperationInput`](crate::input::EmptyStructOperationInput) using modelled bindings.
|
617 + | pub struct EmptyStructOperationInputFuture {
|
618 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
441 619 | }
|
442 620 | }
|
443 621 |
|
444 - | impl std::future::Future for RecursiveUnionOperationInputFuture {
|
622 + | impl std::future::Future for EmptyStructOperationInputFuture {
|
445 623 | type Output = Result<
|
446 - | crate::input::RecursiveUnionOperationInput,
|
624 + | crate::input::EmptyStructOperationInput,
|
447 625 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
448 626 | >;
|
449 627 |
|
450 628 | fn poll(
|
451 629 | self: std::pin::Pin<&mut Self>,
|
452 630 | cx: &mut std::task::Context<'_>,
|
453 631 | ) -> std::task::Poll<Self::Output> {
|
454 632 | let this = self.project();
|
455 633 | this.inner.as_mut().poll(cx)
|
456 634 | }
|
457 635 | }
|
458 636 |
|
459 637 | impl<B>
|
460 638 | ::aws_smithy_http_server::request::FromRequest<
|
461 639 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
462 640 | B,
|
463 - | > for crate::input::RecursiveUnionOperationInput
|
641 + | > for crate::input::EmptyStructOperationInput
|
464 642 | where
|
465 643 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
466 644 | B: 'static,
|
467 645 |
|
468 646 | B::Data: Send,
|
469 647 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
470 648 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
471 649 | {
|
472 650 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
473 - | type Future = RecursiveUnionOperationInputFuture;
|
651 + | type Future = EmptyStructOperationInputFuture;
|
474 652 |
|
475 653 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
476 654 | let fut = async move {
|
477 655 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
478 656 | request.headers(),
|
479 657 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
480 658 | ) {
|
481 659 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
482 660 | }
|
483 - | crate::protocol_serde::shape_recursive_union_operation::de_recursive_union_operation_http_request(request)
|
661 + | crate::protocol_serde::shape_empty_struct_operation::de_empty_struct_operation_http_request(request)
|
484 662 | .await
|
485 663 | };
|
486 664 | use ::futures_util::future::TryFutureExt;
|
487 665 | let fut = fut.map_err(
|
488 666 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
489 667 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
490 668 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
491 669 | e,
|
492 670 | )
|
493 671 | },
|
494 672 | );
|
495 - | RecursiveUnionOperationInputFuture {
|
673 + | EmptyStructOperationInputFuture {
|
496 674 | inner: Box::pin(fut),
|
497 675 | }
|
498 676 | }
|
499 677 | }
|
500 678 | impl
|
501 679 | ::aws_smithy_http_server::response::IntoResponse<
|
502 680 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
503 - | > for crate::output::RecursiveUnionOperationOutput
|
681 + | > for crate::output::EmptyStructOperationOutput
|
504 682 | {
|
505 683 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
506 - | match crate::protocol_serde::shape_recursive_union_operation::ser_recursive_union_operation_http_response(self) {
|
684 + | match crate::protocol_serde::shape_empty_struct_operation::ser_empty_struct_operation_http_response(self) {
|
507 685 | Ok(response) => response,
|
508 686 | Err(e) => {
|
509 687 | ::tracing::error!(error = %e, "failed to serialize response");
|
510 688 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
511 689 | }
|
512 690 | }
|
513 691 | }
|
514 692 | }
|
515 693 |
|
516 694 | #[allow(unreachable_code, unused_variables)]
|
517 695 | #[cfg(test)]
|
518 - | mod recursive_union_operation_test {
|
696 + | mod empty_struct_operation_test {
|
519 697 |
|
520 - | /// Serializes recursive structures with union
|
521 - | /// Test ID: RpcV2CborRecursiveShapesWithUnion
|
698 + | /// When additional tokens are found past where we expect the end of the body,
|
699 + | /// the request should be rejected with a serialization exception.
|
700 + | /// Test ID: AdditionalTokensEmptyStruct
|
522 701 | #[::tokio::test]
|
523 702 | #[::tracing_test::traced_test]
|
524 - | async fn rpc_v2_cbor_recursive_shapes_with_union_response() {
|
525 - | let output =crate::output::RecursiveUnionOperationOutput {
|
526 - | nested:
|
527 - | ::std::option::Option::Some(
|
528 - | crate::model::RecursiveOperationInputOutputNested1 {
|
529 - | foo:
|
530 - | ::std::option::Option::Some(
|
531 - | "Foo1".to_owned()
|
532 - | )
|
533 - | ,
|
534 - | variant:
|
535 - | ::std::option::Option::Some(
|
536 - | crate::model::FooChoice::Choice1
|
537 - | (
|
538 - | "OuterChoice".to_owned()
|
539 - | )
|
540 - | )
|
541 - | ,
|
542 - | nested:
|
543 - | ::std::option::Option::Some(
|
544 - | ::std::boxed::Box::new(
|
545 - | crate::model::RecursiveOperationInputOutputNested2 {
|
546 - | bar:
|
547 - | ::std::option::Option::Some(
|
548 - | "Bar1".to_owned()
|
549 - | )
|
550 - | ,
|
551 - | recursive_member:
|
552 - | ::std::option::Option::Some(
|
553 - | crate::model::RecursiveOperationInputOutputNested1 {
|
554 - | foo:
|
555 - | ::std::option::Option::Some(
|
556 - | "Foo2".to_owned()
|
557 - | )
|
558 - | ,
|
559 - | variant:
|
560 - | ::std::option::Option::Some(
|
561 - | crate::model::FooChoice::Choice2
|
562 - | (
|
563 - | ::std::boxed::Box::new(
|
564 - | crate::model::RecursiveOperationInputOutputNested1 {
|
565 - | foo:
|
566 - | ::std::option::Option::Some(
|
567 - | "Foo3".to_owned()
|
568 - | )
|
569 - | ,
|
570 - | nested:
|
571 - | ::std::option::Option::Some(
|
572 - | ::std::boxed::Box::new(
|
573 - | crate::model::RecursiveOperationInputOutputNested2 {
|
574 - | bar:
|
575 - | ::std::option::Option::Some(
|
576 - | "Bar3".to_owned()
|
577 - | )
|
578 - | ,
|
579 - | recursive_member:
|
580 - | ::std::option::Option::Some(
|
581 - | crate::model::RecursiveOperationInputOutputNested1 {
|
582 - | foo:
|
583 - | ::std::option::Option::Some(
|
584 - | "Foo4".to_owned()
|
585 - | )
|
586 - | ,
|
587 - | variant:
|
588 - | ::std::option::Option::Some(
|
589 - | crate::model::FooChoice::Choice1
|
590 - | (
|
591 - | "InnerChoice".to_owned()
|
592 - | )
|
593 - | )
|
594 - | ,
|
595 - | nested:
|
596 - | ::std::option::Option::None
|
597 - | ,
|
598 - | }
|
599 - | )
|
600 - | ,
|
601 - | }
|
602 - | )
|
603 - | )
|
604 - | ,
|
605 - | variant:
|
606 - | ::std::option::Option::None
|
607 - | ,
|
608 - | }
|
609 - | )
|
610 - | )
|
611 - | )
|
612 - | ,
|
613 - | nested:
|
614 - | ::std::option::Option::Some(
|
615 - | ::std::boxed::Box::new(
|
616 - | crate::model::RecursiveOperationInputOutputNested2 {
|
617 - | bar:
|
618 - | ::std::option::Option::Some(
|
619 - | "Bar2".to_owned()
|
620 - | )
|
621 - | ,
|
622 - | recursive_member:
|
623 - | ::std::option::Option::None
|
624 - | ,
|
625 - | }
|
626 - | )
|
627 - | )
|
628 - | ,
|
629 - | }
|
630 - | )
|
631 - | ,
|
632 - | }
|
633 - | )
|
634 - | )
|
635 - | ,
|
636 - | }
|
637 - | )
|
638 - | ,
|
703 + | #[should_panic]
|
704 + | async fn additional_tokens_empty_struct_malformed_request() {
|
705 + | {
|
706 + | #[allow(unused_mut)]
|
707 + | let mut http_request = ::http_1x::Request::builder()
|
708 + | .uri("/service/RpcV2CborService/operation/EmptyStructOperation")
|
709 + | .method("POST")
|
710 + | .header("smithy-protocol", "rpc-v2-cbor")
|
711 + | .header("Accept", "application/cbor")
|
712 + | .header("Content-Type", "application/cbor")
|
713 + | .body(::aws_smithy_http_server::body::boxed(
|
714 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
715 + | &::aws_smithy_protocol_test::decode_body_data(
|
716 + | "v/+//w==".as_bytes(),
|
717 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
718 + | ),
|
719 + | )),
|
720 + | ))
|
721 + | .unwrap();
|
722 + | #[allow(unused_mut)]
|
723 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
724 + | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
725 + | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
726 + | .empty_struct_operation(move |input: crate::input::EmptyStructOperationInput| {
|
727 + | let sender = sender.clone();
|
728 + | async move {
|
729 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as crate::output::EmptyStructOperationOutput };
|
730 + | sender.send(()).await.expect("receiver dropped early");
|
731 + | result
|
639 732 | }
|
640 - | ;
|
641 - | use ::aws_smithy_http_server::response::IntoResponse;
|
642 - | let http_response = output.into_response();
|
733 + | })
|
734 + | .build_unchecked();
|
735 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
736 + | .await
|
737 + | .expect("unable to make an HTTP request");
|
643 738 | ::pretty_assertions::assert_eq!(
|
644 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
739 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
645 740 | http_response.status()
|
646 741 | );
|
647 - | let expected_headers = [
|
648 - | ("Content-Type", "application/cbor"),
|
649 - | ("smithy-protocol", "rpc-v2-cbor"),
|
650 - | ];
|
651 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
652 - | http_response.headers(),
|
653 - | expected_headers,
|
654 - | ));
|
655 742 | use ::http_body_util::BodyExt;
|
656 743 | let body = http_response
|
657 744 | .into_body()
|
658 745 | .collect()
|
659 746 | .await
|
660 747 | .expect("unable to collect body")
|
661 748 | .to_bytes();
|
662 - | ::aws_smithy_protocol_test::assert_ok(
|
663 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZ3ZhcmlhbnS/Z2Nob2ljZTFrT3V0ZXJDaG9pY2X/Zm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmd2YXJpYW50v2djaG9pY2Uyv2Nmb29kRm9vM2ZuZXN0ZWS/Y2JhcmRCYXIzb3JlY3Vyc2l2ZU1lbWJlcr9jZm9vZEZvbzRndmFyaWFudL9nY2hvaWNlMWtJbm5lckNob2ljZf//////Zm5lc3RlZL9jYmFyZEJhcjL//////w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
664 - | );
|
749 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
750 + | &body,
|
751 + | "oA==",
|
752 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
753 + | ));
|
754 + | }
|
665 755 | }
|
666 756 | }
|
667 757 |
|
668 758 | ::pin_project_lite::pin_project! {
|
669 759 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
670 760 | /// [`SingleMemberStructOperationInput`](crate::input::SingleMemberStructOperationInput) using modelled bindings.
|
671 761 | pub struct SingleMemberStructOperationInputFuture {
|
672 762 | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SingleMemberStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
673 763 | }
|
674 764 | }
|
803 893 | &body,
|
804 894 | "oA==",
|
805 895 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
806 896 | ));
|
807 897 | }
|
808 898 | }
|
809 899 | }
|
810 900 |
|
811 901 | ::pin_project_lite::pin_project! {
|
812 902 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
813 - | /// [`EmptyStructOperationInput`](crate::input::EmptyStructOperationInput) using modelled bindings.
|
814 - | pub struct EmptyStructOperationInputFuture {
|
815 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
903 + | /// [`RecursiveUnionOperationInput`](crate::input::RecursiveUnionOperationInput) using modelled bindings.
|
904 + | pub struct RecursiveUnionOperationInputFuture {
|
905 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveUnionOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
816 906 | }
|
817 907 | }
|
818 908 |
|
819 - | impl std::future::Future for EmptyStructOperationInputFuture {
|
909 + | impl std::future::Future for RecursiveUnionOperationInputFuture {
|
820 910 | type Output = Result<
|
821 - | crate::input::EmptyStructOperationInput,
|
911 + | crate::input::RecursiveUnionOperationInput,
|
822 912 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
823 913 | >;
|
824 914 |
|
825 915 | fn poll(
|
826 916 | self: std::pin::Pin<&mut Self>,
|
827 917 | cx: &mut std::task::Context<'_>,
|
828 918 | ) -> std::task::Poll<Self::Output> {
|
829 919 | let this = self.project();
|
830 920 | this.inner.as_mut().poll(cx)
|
831 921 | }
|
832 922 | }
|
833 923 |
|
834 924 | impl<B>
|
835 925 | ::aws_smithy_http_server::request::FromRequest<
|
836 926 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
837 927 | B,
|
838 - | > for crate::input::EmptyStructOperationInput
|
928 + | > for crate::input::RecursiveUnionOperationInput
|
839 929 | where
|
840 930 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
841 931 | B: 'static,
|
842 932 |
|
843 933 | B::Data: Send,
|
844 934 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
845 935 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
846 936 | {
|
847 937 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
848 - | type Future = EmptyStructOperationInputFuture;
|
938 + | type Future = RecursiveUnionOperationInputFuture;
|
849 939 |
|
850 940 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
851 941 | let fut = async move {
|
852 942 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
853 943 | request.headers(),
|
854 944 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
855 945 | ) {
|
856 946 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
857 947 | }
|
858 - | crate::protocol_serde::shape_empty_struct_operation::de_empty_struct_operation_http_request(request)
|
948 + | crate::protocol_serde::shape_recursive_union_operation::de_recursive_union_operation_http_request(request)
|
859 949 | .await
|
860 950 | };
|
861 951 | use ::futures_util::future::TryFutureExt;
|
862 952 | let fut = fut.map_err(
|
863 953 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
864 954 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
865 955 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
866 956 | e,
|
867 957 | )
|
868 958 | },
|
869 959 | );
|
870 - | EmptyStructOperationInputFuture {
|
960 + | RecursiveUnionOperationInputFuture {
|
871 961 | inner: Box::pin(fut),
|
872 962 | }
|
873 963 | }
|
874 964 | }
|
875 965 | impl
|
876 966 | ::aws_smithy_http_server::response::IntoResponse<
|
877 967 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
878 - | > for crate::output::EmptyStructOperationOutput
|
968 + | > for crate::output::RecursiveUnionOperationOutput
|
879 969 | {
|
880 970 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
881 - | match crate::protocol_serde::shape_empty_struct_operation::ser_empty_struct_operation_http_response(self) {
|
971 + | match crate::protocol_serde::shape_recursive_union_operation::ser_recursive_union_operation_http_response(self) {
|
882 972 | Ok(response) => response,
|
883 973 | Err(e) => {
|
884 974 | ::tracing::error!(error = %e, "failed to serialize response");
|
885 975 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
886 976 | }
|
887 977 | }
|
888 978 | }
|
889 979 | }
|
890 980 |
|
891 981 | #[allow(unreachable_code, unused_variables)]
|
892 982 | #[cfg(test)]
|
893 - | mod empty_struct_operation_test {
|
983 + | mod recursive_union_operation_test {
|
894 984 |
|
895 - | /// When additional tokens are found past where we expect the end of the body,
|
896 - | /// the request should be rejected with a serialization exception.
|
897 - | /// Test ID: AdditionalTokensEmptyStruct
|
985 + | /// Serializes recursive structures with union
|
986 + | /// Test ID: RpcV2CborRecursiveShapesWithUnion
|
898 987 | #[::tokio::test]
|
899 988 | #[::tracing_test::traced_test]
|
900 - | #[should_panic]
|
901 - | async fn additional_tokens_empty_struct_malformed_request() {
|
902 - | {
|
903 - | #[allow(unused_mut)]
|
904 - | let mut http_request = ::http_1x::Request::builder()
|
905 - | .uri("/service/RpcV2CborService/operation/EmptyStructOperation")
|
906 - | .method("POST")
|
907 - | .header("smithy-protocol", "rpc-v2-cbor")
|
908 - | .header("Accept", "application/cbor")
|
909 - | .header("Content-Type", "application/cbor")
|
910 - | .body(::aws_smithy_http_server::body::boxed(
|
911 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
912 - | &::aws_smithy_protocol_test::decode_body_data(
|
913 - | "v/+//w==".as_bytes(),
|
914 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
915 - | ),
|
916 - | )),
|
917 - | ))
|
918 - | .unwrap();
|
919 - | #[allow(unused_mut)]
|
920 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
921 - | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
922 - | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
923 - | .empty_struct_operation(move |input: crate::input::EmptyStructOperationInput| {
|
924 - | let sender = sender.clone();
|
925 - | async move {
|
926 - | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as crate::output::EmptyStructOperationOutput };
|
927 - | sender.send(()).await.expect("receiver dropped early");
|
928 - | result
|
989 + | async fn rpc_v2_cbor_recursive_shapes_with_union_response() {
|
990 + | let output =crate::output::RecursiveUnionOperationOutput {
|
991 + | nested:
|
992 + | ::std::option::Option::Some(
|
993 + | crate::model::RecursiveOperationInputOutputNested1 {
|
994 + | foo:
|
995 + | ::std::option::Option::Some(
|
996 + | "Foo1".to_owned()
|
997 + | )
|
998 + | ,
|
999 + | variant:
|
1000 + | ::std::option::Option::Some(
|
1001 + | crate::model::FooChoice::Choice1
|
1002 + | (
|
1003 + | "OuterChoice".to_owned()
|
1004 + | )
|
1005 + | )
|
1006 + | ,
|
1007 + | nested:
|
1008 + | ::std::option::Option::Some(
|
1009 + | ::std::boxed::Box::new(
|
1010 + | crate::model::RecursiveOperationInputOutputNested2 {
|
1011 + | bar:
|
1012 + | ::std::option::Option::Some(
|
1013 + | "Bar1".to_owned()
|
1014 + | )
|
1015 + | ,
|
1016 + | recursive_member:
|
1017 + | ::std::option::Option::Some(
|
1018 + | crate::model::RecursiveOperationInputOutputNested1 {
|
1019 + | foo:
|
1020 + | ::std::option::Option::Some(
|
1021 + | "Foo2".to_owned()
|
1022 + | )
|
1023 + | ,
|
1024 + | variant:
|
1025 + | ::std::option::Option::Some(
|
1026 + | crate::model::FooChoice::Choice2
|
1027 + | (
|
1028 + | ::std::boxed::Box::new(
|
1029 + | crate::model::RecursiveOperationInputOutputNested1 {
|
1030 + | foo:
|
1031 + | ::std::option::Option::Some(
|
1032 + | "Foo3".to_owned()
|
1033 + | )
|
1034 + | ,
|
1035 + | nested:
|
1036 + | ::std::option::Option::Some(
|
1037 + | ::std::boxed::Box::new(
|
1038 + | crate::model::RecursiveOperationInputOutputNested2 {
|
1039 + | bar:
|
1040 + | ::std::option::Option::Some(
|
1041 + | "Bar3".to_owned()
|
1042 + | )
|
1043 + | ,
|
1044 + | recursive_member:
|
1045 + | ::std::option::Option::Some(
|
1046 + | crate::model::RecursiveOperationInputOutputNested1 {
|
1047 + | foo:
|
1048 + | ::std::option::Option::Some(
|
1049 + | "Foo4".to_owned()
|
1050 + | )
|
1051 + | ,
|
1052 + | variant:
|
1053 + | ::std::option::Option::Some(
|
1054 + | crate::model::FooChoice::Choice1
|
1055 + | (
|
1056 + | "InnerChoice".to_owned()
|
1057 + | )
|
1058 + | )
|
1059 + | ,
|
1060 + | nested:
|
1061 + | ::std::option::Option::None
|
1062 + | ,
|
929 1063 | }
|
930 - | })
|
931 - | .build_unchecked();
|
932 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
933 - | .await
|
934 - | .expect("unable to make an HTTP request");
|
1064 + | )
|
1065 + | ,
|
1066 + | }
|
1067 + | )
|
1068 + | )
|
1069 + | ,
|
1070 + | variant:
|
1071 + | ::std::option::Option::None
|
1072 + | ,
|
1073 + | }
|
1074 + | )
|
1075 + | )
|
1076 + | )
|
1077 + | ,
|
1078 + | nested:
|
1079 + | ::std::option::Option::Some(
|
1080 + | ::std::boxed::Box::new(
|
1081 + | crate::model::RecursiveOperationInputOutputNested2 {
|
1082 + | bar:
|
1083 + | ::std::option::Option::Some(
|
1084 + | "Bar2".to_owned()
|
1085 + | )
|
1086 + | ,
|
1087 + | recursive_member:
|
1088 + | ::std::option::Option::None
|
1089 + | ,
|
1090 + | }
|
1091 + | )
|
1092 + | )
|
1093 + | ,
|
1094 + | }
|
1095 + | )
|
1096 + | ,
|
1097 + | }
|
1098 + | )
|
1099 + | )
|
1100 + | ,
|
1101 + | }
|
1102 + | )
|
1103 + | ,
|
1104 + | }
|
1105 + | ;
|
1106 + | use ::aws_smithy_http_server::response::IntoResponse;
|
1107 + | let http_response = output.into_response();
|
935 1108 | ::pretty_assertions::assert_eq!(
|
936 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1109 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
937 1110 | http_response.status()
|
938 1111 | );
|
1112 + | let expected_headers = [
|
1113 + | ("Content-Type", "application/cbor"),
|
1114 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1115 + | ];
|
1116 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1117 + | http_response.headers(),
|
1118 + | expected_headers,
|
1119 + | ));
|
939 1120 | use ::http_body_util::BodyExt;
|
940 1121 | let body = http_response
|
941 1122 | .into_body()
|
942 1123 | .collect()
|
943 1124 | .await
|
944 1125 | .expect("unable to collect body")
|
945 1126 | .to_bytes();
|
946 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
947 - | &body,
|
948 - | "oA==",
|
949 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
950 - | ));
|
951 - | }
|
1127 + | ::aws_smithy_protocol_test::assert_ok(
|
1128 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZ3ZhcmlhbnS/Z2Nob2ljZTFrT3V0ZXJDaG9pY2X/Zm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmd2YXJpYW50v2djaG9pY2Uyv2Nmb29kRm9vM2ZuZXN0ZWS/Y2JhcmRCYXIzb3JlY3Vyc2l2ZU1lbWJlcr9jZm9vZEZvbzRndmFyaWFudL9nY2hvaWNlMWtJbm5lckNob2ljZf//////Zm5lc3RlZL9jYmFyZEJhcjL//////w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1129 + | );
|
952 1130 | }
|
953 1131 | }
|
954 1132 |
|
955 1133 | ::pin_project_lite::pin_project! {
|
956 1134 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
957 - | /// [`ComplexStructOperationInput`](crate::input::ComplexStructOperationInput) using modelled bindings.
|
958 - | pub struct ComplexStructOperationInputFuture {
|
959 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ComplexStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1135 + | /// [`StreamingOperationInput`](crate::input::StreamingOperationInput) using modelled bindings.
|
1136 + | pub struct StreamingOperationInputFuture {
|
1137 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
960 1138 | }
|
961 1139 | }
|
962 1140 |
|
963 - | impl std::future::Future for ComplexStructOperationInputFuture {
|
1141 + | impl std::future::Future for StreamingOperationInputFuture {
|
964 1142 | type Output = Result<
|
965 - | crate::input::ComplexStructOperationInput,
|
1143 + | crate::input::StreamingOperationInput,
|
966 1144 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
967 1145 | >;
|
968 1146 |
|
969 1147 | fn poll(
|
970 1148 | self: std::pin::Pin<&mut Self>,
|
971 1149 | cx: &mut std::task::Context<'_>,
|
972 1150 | ) -> std::task::Poll<Self::Output> {
|
973 1151 | let this = self.project();
|
974 1152 | this.inner.as_mut().poll(cx)
|
975 1153 | }
|
976 1154 | }
|
977 1155 |
|
978 1156 | impl<B>
|
979 1157 | ::aws_smithy_http_server::request::FromRequest<
|
980 1158 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
981 1159 | B,
|
982 - | > for crate::input::ComplexStructOperationInput
|
1160 + | > for crate::input::StreamingOperationInput
|
983 1161 | where
|
984 1162 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
985 1163 | B: 'static,
|
986 1164 |
|
1165 + | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
1166 + | + ::std::marker::Send
|
1167 + | + ::std::marker::Sync
|
1168 + | + 'static,
|
1169 + | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
1170 + |
|
987 1171 | B::Data: Send,
|
988 1172 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
989 1173 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
990 1174 | {
|
991 1175 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
992 - | type Future = ComplexStructOperationInputFuture;
|
1176 + | type Future = StreamingOperationInputFuture;
|
993 1177 |
|
994 1178 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
995 1179 | let fut = async move {
|
996 1180 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1181 + | request.headers(),
|
1182 + | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
1183 + | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
997 1184 | request.headers(),
|
998 1185 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
999 1186 | ) {
|
1000 1187 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1001 1188 | }
|
1002 - | crate::protocol_serde::shape_complex_struct_operation::de_complex_struct_operation_http_request(request)
|
1189 + | crate::protocol_serde::shape_streaming_operation::de_streaming_operation_http_request(
|
1190 + | request,
|
1191 + | )
|
1003 1192 | .await
|
1004 1193 | };
|
1005 1194 | use ::futures_util::future::TryFutureExt;
|
1006 1195 | let fut = fut.map_err(
|
1007 1196 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1008 1197 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1009 1198 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
1010 1199 | e,
|
1011 1200 | )
|
1012 1201 | },
|
1013 1202 | );
|
1014 - | ComplexStructOperationInputFuture {
|
1203 + | StreamingOperationInputFuture {
|
1015 1204 | inner: Box::pin(fut),
|
1016 1205 | }
|
1017 1206 | }
|
1018 1207 | }
|
1019 1208 | impl
|
1020 1209 | ::aws_smithy_http_server::response::IntoResponse<
|
1021 1210 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1022 - | > for crate::output::ComplexStructOperationOutput
|
1211 + | > for crate::output::StreamingOperationOutput
|
1023 1212 | {
|
1024 1213 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1025 - | match crate::protocol_serde::shape_complex_struct_operation::ser_complex_struct_operation_http_response(self) {
|
1214 + | match crate::protocol_serde::shape_streaming_operation::ser_streaming_operation_http_response(self) {
|
1026 1215 | Ok(response) => response,
|
1027 1216 | Err(e) => {
|
1028 1217 | ::tracing::error!(error = %e, "failed to serialize response");
|
1029 1218 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1030 1219 | }
|
1031 1220 | }
|
1032 1221 | }
|
1033 1222 | }
|
1034 1223 | impl
|
1035 1224 | ::aws_smithy_http_server::response::IntoResponse<
|
1036 1225 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1037 - | > for crate::error::ComplexStructOperationError
|
1226 + | > for crate::error::StreamingOperationError
|
1038 1227 | {
|
1039 1228 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1040 - | match crate::protocol_serde::shape_complex_struct_operation::ser_complex_struct_operation_http_error(&self) {
|
1229 + | match crate::protocol_serde::shape_streaming_operation::ser_streaming_operation_http_error(
|
1230 + | &self,
|
1231 + | ) {
|
1041 1232 | Ok(mut response) => {
|
1042 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1233 + | response.extensions_mut().insert(
|
1234 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
1235 + | );
|
1043 1236 | response
|
1044 - | },
|
1237 + | }
|
1045 1238 | Err(e) => {
|
1046 1239 | ::tracing::error!(error = %e, "failed to serialize response");
|
1047 1240 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1048 1241 | }
|
1049 1242 | }
|
1050 1243 | }
|
1051 1244 | }
|
1052 1245 |
|
1053 1246 | ::pin_project_lite::pin_project! {
|
1054 1247 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1055 - | /// [`ErrorSerializationOperationInput`](crate::input::ErrorSerializationOperationInput) using modelled bindings.
|
1056 - | pub struct ErrorSerializationOperationInputFuture {
|
1057 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ErrorSerializationOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1248 + | /// [`StreamingOperationWithInitialDataInput`](crate::input::StreamingOperationWithInitialDataInput) using modelled bindings.
|
1249 + | pub struct StreamingOperationWithInitialDataInputFuture {
|
1250 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationWithInitialDataInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1058 1251 | }
|
1059 1252 | }
|
1060 1253 |
|
1061 - | impl std::future::Future for ErrorSerializationOperationInputFuture {
|
1254 + | impl std::future::Future for StreamingOperationWithInitialDataInputFuture {
|
1062 1255 | type Output = Result<
|
1063 - | crate::input::ErrorSerializationOperationInput,
|
1256 + | crate::input::StreamingOperationWithInitialDataInput,
|
1064 1257 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1065 1258 | >;
|
1066 1259 |
|
1067 1260 | fn poll(
|
1068 1261 | self: std::pin::Pin<&mut Self>,
|
1069 1262 | cx: &mut std::task::Context<'_>,
|
1070 1263 | ) -> std::task::Poll<Self::Output> {
|
1071 1264 | let this = self.project();
|
1072 1265 | this.inner.as_mut().poll(cx)
|
1073 1266 | }
|
1074 1267 | }
|
1075 1268 |
|
1076 1269 | impl<B>
|
1077 1270 | ::aws_smithy_http_server::request::FromRequest<
|
1078 1271 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1079 1272 | B,
|
1080 - | > for crate::input::ErrorSerializationOperationInput
|
1273 + | > for crate::input::StreamingOperationWithInitialDataInput
|
1081 1274 | where
|
1082 1275 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1083 1276 | B: 'static,
|
1084 1277 |
|
1278 + | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
1279 + | + ::std::marker::Send
|
1280 + | + ::std::marker::Sync
|
1281 + | + 'static,
|
1282 + | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
1283 + |
|
1085 1284 | B::Data: Send,
|
1086 1285 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1087 1286 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1088 1287 | {
|
1089 1288 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1090 - | type Future = ErrorSerializationOperationInputFuture;
|
1289 + | type Future = StreamingOperationWithInitialDataInputFuture;
|
1091 1290 |
|
1092 1291 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1093 1292 | let fut = async move {
|
1094 1293 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1294 + | request.headers(),
|
1295 + | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
1296 + | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1095 1297 | request.headers(),
|
1096 1298 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1097 1299 | ) {
|
1098 1300 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1099 1301 | }
|
1100 - | crate::protocol_serde::shape_error_serialization_operation::de_error_serialization_operation_http_request(request)
|
1302 + | crate::protocol_serde::shape_streaming_operation_with_initial_data::de_streaming_operation_with_initial_data_http_request(request)
|
1101 1303 | .await
|
1102 1304 | };
|
1103 1305 | use ::futures_util::future::TryFutureExt;
|
1104 1306 | let fut = fut.map_err(
|
1105 1307 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1106 1308 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1107 1309 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
1108 1310 | e,
|
1109 1311 | )
|
1110 1312 | },
|
1111 1313 | );
|
1112 - | ErrorSerializationOperationInputFuture {
|
1314 + | StreamingOperationWithInitialDataInputFuture {
|
1113 1315 | inner: Box::pin(fut),
|
1114 1316 | }
|
1115 1317 | }
|
1116 1318 | }
|
1117 1319 | impl
|
1118 1320 | ::aws_smithy_http_server::response::IntoResponse<
|
1119 1321 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1120 - | > for crate::output::ErrorSerializationOperationOutput
|
1322 + | > for crate::output::StreamingOperationWithInitialDataOutput
|
1121 1323 | {
|
1122 1324 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1123 - | match crate::protocol_serde::shape_error_serialization_operation::ser_error_serialization_operation_http_response(self) {
|
1325 + | match crate::protocol_serde::shape_streaming_operation_with_initial_data::ser_streaming_operation_with_initial_data_http_response(self) {
|
1124 1326 | Ok(response) => response,
|
1125 1327 | Err(e) => {
|
1126 1328 | ::tracing::error!(error = %e, "failed to serialize response");
|
1127 1329 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1128 1330 | }
|
1129 1331 | }
|
1130 1332 | }
|
1131 1333 | }
|
1132 1334 | impl
|
1133 1335 | ::aws_smithy_http_server::response::IntoResponse<
|
1134 1336 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1135 - | > for crate::error::ErrorSerializationOperationError
|
1337 + | > for crate::error::StreamingOperationWithInitialDataError
|
1136 1338 | {
|
1137 1339 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1138 - | match crate::protocol_serde::shape_error_serialization_operation::ser_error_serialization_operation_http_error(&self) {
|
1340 + | match crate::protocol_serde::shape_streaming_operation_with_initial_data::ser_streaming_operation_with_initial_data_http_error(&self) {
|
1139 1341 | Ok(mut response) => {
|
1140 1342 | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1141 1343 | response
|
1142 1344 | },
|
1143 1345 | Err(e) => {
|
1144 1346 | ::tracing::error!(error = %e, "failed to serialize response");
|
1145 1347 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1146 1348 | }
|
1147 1349 | }
|
1148 1350 | }
|
1149 1351 | }
|
1150 1352 |
|
1151 - | #[allow(unreachable_code, unused_variables)]
|
1152 - | #[cfg(test)]
|
1153 - | mod error_serialization_operation_test {
|
1353 + | ::pin_project_lite::pin_project! {
|
1354 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1355 + | /// [`StreamingOperationWithInitialResponseInput`](crate::input::StreamingOperationWithInitialResponseInput) using modelled bindings.
|
1356 + | pub struct StreamingOperationWithInitialResponseInputFuture {
|
1357 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationWithInitialResponseInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1358 + | }
|
1359 + | }
|
1154 1360 |
|
1155 - | /// Despite the operation output being a structure shape with the `@error` trait,
|
1156 - | /// `__type` field should, in a strict interpretation of the spec, not be included,
|
1157 - | /// because we're not serializing a server error response. However, we do, because
|
1158 - | /// there shouldn't™️ be any harm in doing so, and it greatly simplifies the
|
1159 - | /// code generator. This test just pins this behavior in case we ever modify it.
|
1160 - | /// Test ID: OperationOutputSerializationQuestionablyIncludesTypeField
|
1161 - | #[::tokio::test]
|
1162 - | #[::tracing_test::traced_test]
|
1163 - | async fn operation_output_serialization_questionably_includes_type_field_response() {
|
1164 - | let output = crate::output::ErrorSerializationOperationOutput {
|
1165 - | error_shape: ::std::option::Option::Some(crate::error::ValidationException {
|
1166 - | message: "ValidationException message field".to_owned(),
|
1167 - | field_list: ::std::option::Option::None,
|
1168 - | }),
|
1169 - | };
|
1170 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1171 - | let http_response = output.into_response();
|
1172 - | ::pretty_assertions::assert_eq!(
|
1173 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1174 - | http_response.status()
|
1175 - | );
|
1176 - | use ::http_body_util::BodyExt;
|
1177 - | let body = http_response
|
1178 - | .into_body()
|
1179 - | .collect()
|
1180 - | .await
|
1181 - | .expect("unable to collect body")
|
1182 - | .to_bytes();
|
1183 - | ::aws_smithy_protocol_test::assert_ok(
|
1184 - | ::aws_smithy_protocol_test::validate_body(&body, "v2plcnJvclNoYXBlv2ZfX3R5cGV4JHNtaXRoeS5mcmFtZXdvcmsjVmFsaWRhdGlvbkV4Y2VwdGlvbmdtZXNzYWdleCFWYWxpZGF0aW9uRXhjZXB0aW9uIG1lc3NhZ2UgZmllbGT//w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1185 - | );
|
1361 + | impl std::future::Future for StreamingOperationWithInitialResponseInputFuture {
|
1362 + | type Output = Result<
|
1363 + | crate::input::StreamingOperationWithInitialResponseInput,
|
1364 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1365 + | >;
|
1366 + |
|
1367 + | fn poll(
|
1368 + | self: std::pin::Pin<&mut Self>,
|
1369 + | cx: &mut std::task::Context<'_>,
|
1370 + | ) -> std::task::Poll<Self::Output> {
|
1371 + | let this = self.project();
|
1372 + | this.inner.as_mut().poll(cx)
|
1186 1373 | }
|
1374 + | }
|
1187 1375 |
|
1188 - | /// When invalid input is provided the request should be rejected with
|
1189 - | /// a validation exception, and a `__type` field should be included
|
1190 - | /// Test ID: ErrorSerializationIncludesTypeField
|
1191 - | #[::tokio::test]
|
1192 - | #[::tracing_test::traced_test]
|
1193 - | async fn error_serialization_includes_type_field_malformed_request() {
|
1194 - | {
|
1195 - | #[allow(unused_mut)]
|
1196 - | let mut http_request = ::http_1x::Request::builder()
|
1197 - | .uri("/service/RpcV2CborService/operation/ErrorSerializationOperation")
|
1198 - | .method("POST")
|
1199 - | .header("smithy-protocol", "rpc-v2-cbor")
|
1200 - | .header("Accept", "application/cbor")
|
1201 - | .header("Content-Type", "application/cbor")
|
1202 - | .body(::aws_smithy_http_server::body::boxed(
|
1203 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1204 - | &::aws_smithy_protocol_test::decode_body_data(
|
1205 - | "oA==".as_bytes(),
|
1206 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1207 - | ),
|
1208 - | )),
|
1209 - | ))
|
1210 - | .unwrap();
|
1211 - | #[allow(unused_mut)]
|
1212 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1213 - | let config = crate::service::RpcV2CborServiceConfig::builder().build();
|
1214 - | let service = crate::service::RpcV2CborService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1215 - | .error_serialization_operation(move |input: crate::input::ErrorSerializationOperationInput| {
|
1216 - | let sender = sender.clone();
|
1217 - | async move {
|
1218 - | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::ErrorSerializationOperationOutput, crate::error::ErrorSerializationOperationError> };
|
1219 - | sender.send(()).await.expect("receiver dropped early");
|
1220 - | result
|
1376 + | impl<B>
|
1377 + | ::aws_smithy_http_server::request::FromRequest<
|
1378 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1379 + | B,
|
1380 + | > for crate::input::StreamingOperationWithInitialResponseInput
|
1381 + | where
|
1382 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1383 + | B: 'static,
|
1384 + |
|
1385 + | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
1386 + | + ::std::marker::Send
|
1387 + | + ::std::marker::Sync
|
1388 + | + 'static,
|
1389 + | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
1390 + |
|
1391 + | B::Data: Send,
|
1392 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1393 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1394 + | {
|
1395 + | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1396 + | type Future = StreamingOperationWithInitialResponseInputFuture;
|
1397 + |
|
1398 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1399 + | let fut = async move {
|
1400 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1401 + | request.headers(),
|
1402 + | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
1403 + | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1404 + | request.headers(),
|
1405 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1406 + | ) {
|
1407 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1221 1408 | }
|
1222 - | })
|
1223 - | .build_unchecked();
|
1224 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1225 - | .await
|
1226 - | .expect("unable to make an HTTP request");
|
1227 - | ::pretty_assertions::assert_eq!(
|
1228 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1229 - | http_response.status()
|
1230 - | );
|
1231 - | use ::http_body_util::BodyExt;
|
1232 - | let body = http_response
|
1233 - | .into_body()
|
1234 - | .collect()
|
1409 + | crate::protocol_serde::shape_streaming_operation_with_initial_response::de_streaming_operation_with_initial_response_http_request(request)
|
1235 1410 | .await
|
1236 - | .expect("unable to collect body")
|
1237 - | .to_bytes();
|
1238 - | ::aws_smithy_protocol_test::assert_ok(
|
1239 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4JHNtaXRoeS5mcmFtZXdvcmsjVmFsaWRhdGlvbkV4Y2VwdGlvbmdtZXNzYWdleGsxIHZhbGlkYXRpb24gZXJyb3IgZGV0ZWN0ZWQuIFZhbHVlIGF0ICcvcmVxdWlyZWRCbG9iJyBmYWlsZWQgdG8gc2F0aXNmeSBjb25zdHJhaW50OiBNZW1iZXIgbXVzdCBub3QgYmUgbnVsbGlmaWVsZExpc3SBv2RwYXRobS9yZXF1aXJlZEJsb2JnbWVzc2FnZXhOVmFsdWUgYXQgJy9yZXF1aXJlZEJsb2InIGZhaWxlZCB0byBzYXRpc2Z5IGNvbnN0cmFpbnQ6IE1lbWJlciBtdXN0IG5vdCBiZSBudWxs//8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1411 + | };
|
1412 + | use ::futures_util::future::TryFutureExt;
|
1413 + | let fut = fut.map_err(
|
1414 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1415 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1416 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
1417 + | e,
|
1418 + | )
|
1419 + | },
|
1240 1420 | );
|
1421 + | StreamingOperationWithInitialResponseInputFuture {
|
1422 + | inner: Box::pin(fut),
|
1423 + | }
|
1424 + | }
|
1425 + | }
|
1426 + | impl
|
1427 + | ::aws_smithy_http_server::response::IntoResponse<
|
1428 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1429 + | > for crate::output::StreamingOperationWithInitialResponseOutput
|
1430 + | {
|
1431 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1432 + | match crate::protocol_serde::shape_streaming_operation_with_initial_response::ser_streaming_operation_with_initial_response_http_response(self) {
|
1433 + | Ok(response) => response,
|
1434 + | Err(e) => {
|
1435 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1436 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1437 + | }
|
1438 + | }
|
1439 + | }
|
1440 + | }
|
1441 + | impl
|
1442 + | ::aws_smithy_http_server::response::IntoResponse<
|
1443 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1444 + | > for crate::error::StreamingOperationWithInitialResponseError
|
1445 + | {
|
1446 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1447 + | match crate::protocol_serde::shape_streaming_operation_with_initial_response::ser_streaming_operation_with_initial_response_http_error(&self) {
|
1448 + | Ok(mut response) => {
|
1449 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1450 + | response
|
1451 + | },
|
1452 + | Err(e) => {
|
1453 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1454 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1455 + | }
|
1241 1456 | }
|
1242 1457 | }
|
1243 1458 | }
|
1244 1459 |
|
1245 1460 | ::pin_project_lite::pin_project! {
|
1246 1461 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1247 - | /// [`SimpleStructOperationInput`](crate::input::SimpleStructOperationInput) using modelled bindings.
|
1248 - | pub struct SimpleStructOperationInputFuture {
|
1249 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleStructOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1462 + | /// [`StreamingOperationWithOptionalDataInput`](crate::input::StreamingOperationWithOptionalDataInput) using modelled bindings.
|
1463 + | pub struct StreamingOperationWithOptionalDataInputFuture {
|
1464 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StreamingOperationWithOptionalDataInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1250 1465 | }
|
1251 1466 | }
|
1252 1467 |
|
1253 - | impl std::future::Future for SimpleStructOperationInputFuture {
|
1468 + | impl std::future::Future for StreamingOperationWithOptionalDataInputFuture {
|
1254 1469 | type Output = Result<
|
1255 - | crate::input::SimpleStructOperationInput,
|
1470 + | crate::input::StreamingOperationWithOptionalDataInput,
|
1256 1471 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1257 1472 | >;
|
1258 1473 |
|
1259 1474 | fn poll(
|
1260 1475 | self: std::pin::Pin<&mut Self>,
|
1261 1476 | cx: &mut std::task::Context<'_>,
|
1262 1477 | ) -> std::task::Poll<Self::Output> {
|
1263 1478 | let this = self.project();
|
1264 1479 | this.inner.as_mut().poll(cx)
|
1265 1480 | }
|
1266 1481 | }
|
1267 1482 |
|
1268 1483 | impl<B>
|
1269 1484 | ::aws_smithy_http_server::request::FromRequest<
|
1270 1485 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1271 1486 | B,
|
1272 - | > for crate::input::SimpleStructOperationInput
|
1487 + | > for crate::input::StreamingOperationWithOptionalDataInput
|
1273 1488 | where
|
1274 1489 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1275 1490 | B: 'static,
|
1276 1491 |
|
1492 + | B: ::http_body_1x::Body<Data = ::bytes::Bytes>
|
1493 + | + ::std::marker::Send
|
1494 + | + ::std::marker::Sync
|
1495 + | + 'static,
|
1496 + | B::Error: Into<::aws_smithy_types::body::Error> + 'static,
|
1497 + |
|
1277 1498 | B::Data: Send,
|
1278 1499 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1279 1500 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1280 1501 | {
|
1281 1502 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1282 - | type Future = SimpleStructOperationInputFuture;
|
1503 + | type Future = StreamingOperationWithOptionalDataInputFuture;
|
1283 1504 |
|
1284 1505 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1285 1506 | let fut = async move {
|
1286 1507 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1508 + | request.headers(),
|
1509 + | &crate::mimes::CONTENT_TYPE_APPLICATION_VND_AMAZON_EVENTSTREAM,
|
1510 + | ) && !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1287 1511 | request.headers(),
|
1288 1512 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1289 1513 | ) {
|
1290 1514 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1291 1515 | }
|
1292 - | crate::protocol_serde::shape_simple_struct_operation::de_simple_struct_operation_http_request(request)
|
1516 + | crate::protocol_serde::shape_streaming_operation_with_optional_data::de_streaming_operation_with_optional_data_http_request(request)
|
1293 1517 | .await
|
1294 1518 | };
|
1295 1519 | use ::futures_util::future::TryFutureExt;
|
1296 1520 | let fut = fut.map_err(
|
1297 1521 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1298 1522 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1299 1523 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
1300 1524 | e,
|
1301 1525 | )
|
1302 1526 | },
|
1303 1527 | );
|
1304 - | SimpleStructOperationInputFuture {
|
1528 + | StreamingOperationWithOptionalDataInputFuture {
|
1305 1529 | inner: Box::pin(fut),
|
1306 1530 | }
|
1307 1531 | }
|
1308 1532 | }
|
1309 1533 | impl
|
1310 1534 | ::aws_smithy_http_server::response::IntoResponse<
|
1311 1535 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1312 - | > for crate::output::SimpleStructOperationOutput
|
1536 + | > for crate::output::StreamingOperationWithOptionalDataOutput
|
1313 1537 | {
|
1314 1538 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1315 - | match crate::protocol_serde::shape_simple_struct_operation::ser_simple_struct_operation_http_response(self) {
|
1539 + | match crate::protocol_serde::shape_streaming_operation_with_optional_data::ser_streaming_operation_with_optional_data_http_response(self) {
|
1316 1540 | Ok(response) => response,
|
1317 1541 | Err(e) => {
|
1318 1542 | ::tracing::error!(error = %e, "failed to serialize response");
|
1319 1543 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1320 1544 | }
|
1321 1545 | }
|
1322 1546 | }
|
1323 1547 | }
|
1324 1548 | impl
|
1325 1549 | ::aws_smithy_http_server::response::IntoResponse<
|
1326 1550 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1327 - | > for crate::error::SimpleStructOperationError
|
1551 + | > for crate::error::StreamingOperationWithOptionalDataError
|
1328 1552 | {
|
1329 1553 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1330 - | match crate::protocol_serde::shape_simple_struct_operation::ser_simple_struct_operation_http_error(&self) {
|
1554 + | match crate::protocol_serde::shape_streaming_operation_with_optional_data::ser_streaming_operation_with_optional_data_http_error(&self) {
|
1331 1555 | Ok(mut response) => {
|
1332 1556 | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1333 1557 | response
|
1334 1558 | },
|
1335 1559 | Err(e) => {
|
1336 1560 | ::tracing::error!(error = %e, "failed to serialize response");
|
1337 1561 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1338 1562 | }
|
1339 1563 | }
|
1340 1564 | }
|
1341 1565 | }
|
1342 - |
|
1343 - | #[allow(unreachable_code, unused_variables)]
|
1344 - | #[cfg(test)]
|
1345 - | mod simple_struct_operation_test {
|
1346 - |
|
1347 - | /// Test ID: SimpleStruct
|
1348 - | #[::tokio::test]
|
1349 - | #[::tracing_test::traced_test]
|
1350 - | async fn simple_struct_response() {
|
1351 - | let output =crate::output::SimpleStructOperationOutput {
|
1352 - | blob:
|
1353 - | ::std::option::Option::Some(
|
1354 - | ::aws_smithy_types::Blob::new("blobby blob")
|
1355 - | )
|
1356 - | ,
|
1357 - | boolean:
|
1358 - | ::std::option::Option::Some(
|
1359 - | false
|
1360 - | )
|
1361 - | ,
|
1362 - | string:
|
1363 - | ::std::option::Option::Some(
|
1364 - | "There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.".to_owned()
|
1365 - | )
|
1366 - | ,
|
1367 - | byte:
|
1368 - | ::std::option::Option::Some(
|
1369 - | 69
|
1370 - | )
|
1371 - | ,
|
1372 - | short:
|
1373 - | ::std::option::Option::Some(
|
1374 - | 70
|
1375 - | )
|
1376 - | ,
|
1377 - | integer:
|
1378 - | ::std::option::Option::Some(
|
1379 - | 71
|
1380 - | )
|
1381 - | ,
|
1382 - | long:
|
1383 - | ::std::option::Option::Some(
|
1384 - | 72
|
1385 - | )
|
1386 - | ,
|
1387 - | float:
|
1388 - | ::std::option::Option::Some(
|
1389 - | 0.69_f32
|
1390 - | )
|
1391 - | ,
|
1392 - | double:
|
1393 - | ::std::option::Option::Some(
|
1394 - | 0.6969_f64
|
1395 - | )
|
1396 - | ,
|
1397 - | timestamp:
|
1398 - | ::std::option::Option::Some(
|
1399 - | ::aws_smithy_types::DateTime::from_fractional_secs(1546300800, 0_f64)
|
1400 - | )
|
1401 - | ,
|
1402 - | r#enum:
|
1403 - | ::std::option::Option::Some(
|
1404 - | "DIAMOND".parse::<crate::model::Suit>().expect("static value validated to member")
|
1405 - | )
|
1406 - | ,
|
1407 - | required_blob:
|
1408 - | ::aws_smithy_types::Blob::new("blobby blob")
|
1409 - | ,
|
1410 - | required_boolean:
|
1411 - | false
|
1412 - | ,
|
1413 - | required_string:
|
1414 - | "There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.".to_owned()
|
1415 - | ,
|
1416 - | required_byte:
|
1417 - | 69
|
1418 - | ,
|
1419 - | required_short:
|
1420 - | 70
|
1421 - | ,
|
1422 - | required_integer:
|
1423 - | 71
|
1424 - | ,
|
1425 - | required_long:
|
1426 - | 72
|
1427 - | ,
|
1428 - | required_float:
|
1429 - | 0.69_f32
|
1430 - | ,
|
1431 - | required_double:
|
1432 - | 0.6969_f64
|
1433 - | ,
|
1434 - | required_timestamp:
|
1435 - | ::aws_smithy_types::DateTime::from_fractional_secs(1546300800, 0_f64)
|
1436 - | ,
|
1437 - | required_enum:
|
1438 - | "DIAMOND".parse::<crate::model::Suit>().expect("static value validated to member")
|
1439 - | ,
|
1440 - | }
|
1441 - | ;
|
1442 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1443 - | let http_response = output.into_response();
|
1444 - | ::pretty_assertions::assert_eq!(
|
1445 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1446 - | http_response.status()
|
1447 - | );
|
1448 - | let expected_headers = [
|
1449 - | ("Content-Type", "application/cbor"),
|
1450 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1451 - | ];
|
1452 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1453 - | http_response.headers(),
|
1454 - | expected_headers,
|
1455 - | ));
|
1456 - | use ::http_body_util::BodyExt;
|
1457 - | let body = http_response
|
1458 - | .into_body()
|
1459 - | .collect()
|
1460 - | .await
|
1461 - | .expect("unable to collect body")
|
1462 - | .to_bytes();
|
1463 - | ::aws_smithy_protocol_test::assert_ok(
|
1464 - | ::aws_smithy_protocol_test::validate_body(&body, "v2RibG9iS2Jsb2JieSBibG9iZ2Jvb2xlYW70ZnN0cmluZ3hwVGhlcmUgYXJlIHRocmVlIHRoaW5ncyBhbGwgd2lzZSBtZW4gZmVhcjogdGhlIHNlYSBpbiBzdG9ybSwgYSBuaWdodCB3aXRoIG5vIG1vb24sIGFuZCB0aGUgYW5nZXIgb2YgYSBnZW50bGUgbWFuLmRieXRlGEVlc2hvcnQYRmdpbnRlZ2VyGEdkbG9uZxhIZWZsb2F0+j8wo9dmZG91Ymxl+z/mTQE6kqMFaXRpbWVzdGFtcMH7QdcKq2AAAABkZW51bWdESUFNT05EbHJlcXVpcmVkQmxvYktibG9iYnkgYmxvYm9yZXF1aXJlZEJvb2xlYW70bnJlcXVpcmVkU3RyaW5neHBUaGVyZSBhcmUgdGhyZWUgdGhpbmdzIGFsbCB3aXNlIG1lbiBmZWFyOiB0aGUgc2VhIGluIHN0b3JtLCBhIG5pZ2h0IHdpdGggbm8gbW9vbiwgYW5kIHRoZSBhbmdlciBvZiBhIGdlbnRsZSBtYW4ubHJlcXVpcmVkQnl0ZRhFbXJlcXVpcmVkU2hvcnQYRm9yZXF1aXJlZEludGVnZXIYR2xyZXF1aXJlZExvbmcYSG1yZXF1aXJlZEZsb2F0+j8wo9ducmVxdWlyZWREb3VibGX7P+ZNATqSowVxcmVxdWlyZWRUaW1lc3RhbXDB+0HXCqtgAAAAbHJlcXVpcmVkRW51bWdESUFNT05E/w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1465 - | );
|
1466 - | }
|
1467 - | /// Test ID: SimpleStructWithOptionsSetToNone
|
1468 - | #[::tokio::test]
|
1469 - | #[::tracing_test::traced_test]
|
1470 - | async fn simple_struct_with_options_set_to_none_response() {
|
1471 - | let output =crate::output::SimpleStructOperationOutput {
|
1472 - | required_blob:
|
1473 - | ::aws_smithy_types::Blob::new("blobby blob")
|
1474 - | ,
|
1475 - | required_boolean:
|
1476 - | false
|
1477 - | ,
|
1478 - | required_string:
|
1479 - | "There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.".to_owned()
|
1480 - | ,
|
1481 - | required_byte:
|
1482 - | 69
|
1483 - | ,
|
1484 - | required_short:
|
1485 - | 70
|
1486 - | ,
|
1487 - | required_integer:
|
1488 - | 71
|
1489 - | ,
|
1490 - | required_long:
|
1491 - | 72
|
1492 - | ,
|
1493 - | required_float:
|
1494 - | 0.69_f32
|
1495 - | ,
|
1496 - | required_double:
|
1497 - | 0.6969_f64
|
1498 - | ,
|
1499 - | required_timestamp:
|
1500 - | ::aws_smithy_types::DateTime::from_fractional_secs(1546300800, 0_f64)
|
1501 - | ,
|
1502 - | required_enum:
|
1503 - | "DIAMOND".parse::<crate::model::Suit>().expect("static value validated to member")
|
1504 - | ,
|
1505 - | blob:
|
1506 - | ::std::option::Option::None
|
1507 - | ,
|
1508 - | boolean:
|
1509 - | ::std::option::Option::None
|
1510 - | ,
|
1511 - | string:
|
1512 - | ::std::option::Option::None
|
1513 - | ,
|
1514 - | byte:
|
1515 - | ::std::option::Option::None
|
1516 - | ,
|
1517 - | short:
|
1518 - | ::std::option::Option::None
|
1519 - | ,
|
1520 - | integer:
|
1521 - | ::std::option::Option::None
|
1522 - | ,
|
1523 - | long:
|
1524 - | ::std::option::Option::None
|
1525 - | ,
|
1526 - | float:
|
1527 - | ::std::option::Option::None
|
1528 - | ,
|
1529 - | double:
|
1530 - | ::std::option::Option::None
|
1531 - | ,
|
1532 - | timestamp:
|
1533 - | ::std::option::Option::None
|
1534 - | ,
|
1535 - | r#enum:
|
1536 - | ::std::option::Option::None
|
1537 - | ,
|
1538 - | }
|
1539 - | ;
|
1540 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1541 - | let http_response = output.into_response();
|
1542 - | ::pretty_assertions::assert_eq!(
|
1543 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1544 - | http_response.status()
|
1545 - | );
|
1546 - | let expected_headers = [
|
1547 - | ("Content-Type", "application/cbor"),
|
1548 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1549 - | ];
|
1550 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1551 - | http_response.headers(),
|
1552 - | expected_headers,
|
1553 - | ));
|
1554 - | use ::http_body_util::BodyExt;
|
1555 - | let body = http_response
|
1556 - | .into_body()
|
1557 - | .collect()
|
1558 - | .await
|
1559 - | .expect("unable to collect body")
|
1560 - | .to_bytes();
|
1561 - | ::aws_smithy_protocol_test::assert_ok(
|
1562 - | ::aws_smithy_protocol_test::validate_body(&body, "v2xyZXF1aXJlZEJsb2JLYmxvYmJ5IGJsb2JvcmVxdWlyZWRCb29sZWFu9G5yZXF1aXJlZFN0cmluZ3hwVGhlcmUgYXJlIHRocmVlIHRoaW5ncyBhbGwgd2lzZSBtZW4gZmVhcjogdGhlIHNlYSBpbiBzdG9ybSwgYSBuaWdodCB3aXRoIG5vIG1vb24sIGFuZCB0aGUgYW5nZXIgb2YgYSBnZW50bGUgbWFuLmxyZXF1aXJlZEJ5dGUYRW1yZXF1aXJlZFNob3J0GEZvcmVxdWlyZWRJbnRlZ2VyGEdscmVxdWlyZWRMb25nGEhtcmVxdWlyZWRGbG9hdPo/MKPXbnJlcXVpcmVkRG91Ymxl+z/mTQE6kqMFcXJlcXVpcmVkVGltZXN0YW1wwftB1wqrYAAAAGxyZXF1aXJlZEVudW1nRElBTU9ORP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1563 - | );
|
1564 - | }
|
1565 - | }
|