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 - | /// [`HttpQueryParamsOnlyOperationInput`](crate::input::HttpQueryParamsOnlyOperationInput) using modelled bindings.
|
5 - | pub struct HttpQueryParamsOnlyOperationInputFuture {
|
6 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::HttpQueryParamsOnlyOperationInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7 - | }
|
8 - | }
|
9 - |
|
10 - | impl std::future::Future for HttpQueryParamsOnlyOperationInputFuture {
|
11 - | type Output = Result<
|
12 - | crate::input::HttpQueryParamsOnlyOperationInput,
|
13 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
14 - | >;
|
15 - |
|
16 - | fn poll(
|
17 - | self: std::pin::Pin<&mut Self>,
|
18 - | cx: &mut std::task::Context<'_>,
|
19 - | ) -> std::task::Poll<Self::Output> {
|
20 - | let this = self.project();
|
21 - | this.inner.as_mut().poll(cx)
|
22 - | }
|
23 - | }
|
24 - |
|
25 - | impl<B>
|
26 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
27 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
28 - | B,
|
29 - | > for crate::input::HttpQueryParamsOnlyOperationInput
|
30 - | where
|
31 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
32 - | B: 'static,
|
33 - |
|
34 - | B::Data: Send,
|
35 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
36 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
37 - | {
|
38 - | type Rejection =
|
39 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
40 - | type Future = HttpQueryParamsOnlyOperationInputFuture;
|
41 - |
|
42 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
43 - | let fut = async move {
|
44 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
45 - | request.headers(),
|
46 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
47 - | ) {
|
48 - | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
49 - | }
|
50 - | crate::protocol_serde::shape_http_query_params_only_operation::de_http_query_params_only_operation_http_request(request)
|
51 - | .await
|
52 - | };
|
53 - | use ::futures_util::future::TryFutureExt;
|
54 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
55 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
56 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
57 - | });
|
58 - | HttpQueryParamsOnlyOperationInputFuture {
|
59 - | inner: Box::pin(fut),
|
60 - | }
|
61 - | }
|
62 - | }
|
63 - | impl
|
64 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
65 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
66 - | > for crate::output::HttpQueryParamsOnlyOperationOutput
|
67 - | {
|
68 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
69 - | match crate::protocol_serde::shape_http_query_params_only_operation::ser_http_query_params_only_operation_http_response(self) {
|
70 - | Ok(response) => response,
|
71 - | Err(e) => {
|
72 - | ::tracing::error!(error = %e, "failed to serialize response");
|
73 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
74 - | }
|
75 - | }
|
76 - | }
|
77 - | }
|
78 - | impl
|
79 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
80 - | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
81 - | > for crate::error::HttpQueryParamsOnlyOperationError
|
82 - | {
|
83 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
84 - | match crate::protocol_serde::shape_http_query_params_only_operation::ser_http_query_params_only_operation_http_error(&self) {
|
85 - | Ok(mut response) => {
|
86 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
87 - | response
|
88 - | },
|
89 - | Err(e) => {
|
90 - | ::tracing::error!(error = %e, "failed to serialize response");
|
91 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
92 - | }
|
93 - | }
|
94 - | }
|
95 - | }
|
96 - |
|
97 - | #[allow(unreachable_code, unused_variables)]
|
98 - | #[cfg(test)]
|
99 - | mod http_query_params_only_operation_test {
|
100 - |
|
101 - | /// Upper case error modeled lower case.
|
102 - | /// Test ID: ServiceLevelErrorServer
|
103 - | #[::tokio::test]
|
104 - | #[::tracing_test::traced_test]
|
105 - | async fn service_level_error_server_response() {
|
106 - | let output = crate::error::ExtraError {};
|
107 - | let output = crate::error::HttpQueryParamsOnlyOperationError::ExtraError(output);
|
108 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
109 - | let http_response = output.into_response();
|
110 - | ::pretty_assertions::assert_eq!(
|
111 - | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
112 - | http_response.status()
|
113 - | );
|
114 - | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
115 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
116 - | http_response.headers(),
|
117 - | expected_headers,
|
118 - | ));
|
119 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
120 - | .await
|
121 - | .expect("unable to extract body to bytes");
|
122 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
123 - | &body,
|
124 - | "{}",
|
125 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
126 - | ));
|
127 - | }
|
128 - | }
|
129 - |
|
130 - | ::pin_project_lite::pin_project! {
|
131 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
132 - | /// [`QueryPrecedenceInput`](crate::input::QueryPrecedenceInput) using modelled bindings.
|
133 - | pub struct QueryPrecedenceInputFuture {
|
134 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::QueryPrecedenceInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
4 + | /// [`StringPayloadInput`](crate::input::StringPayloadInput) using modelled bindings.
|
5 + | pub struct StringPayloadInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StringPayloadInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
135 7 | }
|
136 8 | }
|
137 9 |
|
138 - | impl std::future::Future for QueryPrecedenceInputFuture {
|
10 + | impl std::future::Future for StringPayloadInputFuture {
|
139 11 | type Output = Result<
|
140 - | crate::input::QueryPrecedenceInput,
|
12 + | crate::input::StringPayloadInput,
|
141 13 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
142 14 | >;
|
143 15 |
|
144 16 | fn poll(
|
145 17 | self: std::pin::Pin<&mut Self>,
|
146 18 | cx: &mut std::task::Context<'_>,
|
147 19 | ) -> std::task::Poll<Self::Output> {
|
148 20 | let this = self.project();
|
149 21 | this.inner.as_mut().poll(cx)
|
150 22 | }
|
151 23 | }
|
152 24 |
|
153 25 | impl<B>
|
154 26 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
155 27 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
156 28 | B,
|
157 - | > for crate::input::QueryPrecedenceInput
|
29 + | > for crate::input::StringPayloadInput
|
158 30 | where
|
159 31 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
160 32 | B: 'static,
|
161 33 |
|
162 34 | B::Data: Send,
|
163 35 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
164 36 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
165 37 | {
|
166 38 | type Rejection =
|
167 39 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
168 - | type Future = QueryPrecedenceInputFuture;
|
40 + | type Future = StringPayloadInputFuture;
|
169 41 |
|
170 42 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
171 43 | let fut = async move {
|
172 44 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
173 45 | request.headers(),
|
174 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
46 + | &crate::mimes::CONTENT_TYPE_TEXT_PLAIN,
|
175 47 | ) {
|
176 48 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
177 49 | }
|
178 - | crate::protocol_serde::shape_query_precedence::de_query_precedence_http_request(request)
|
50 + | crate::protocol_serde::shape_string_payload::de_string_payload_http_request(request)
|
179 51 | .await
|
180 52 | };
|
181 53 | use ::futures_util::future::TryFutureExt;
|
182 54 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
183 55 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
184 56 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
185 57 | });
|
186 - | QueryPrecedenceInputFuture {
|
58 + | StringPayloadInputFuture {
|
187 59 | inner: Box::pin(fut),
|
188 60 | }
|
189 61 | }
|
190 62 | }
|
191 63 | impl
|
192 64 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
193 65 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
194 - | > for crate::output::QueryPrecedenceOutput
|
66 + | > for crate::output::StringPayloadOutput
|
195 67 | {
|
196 68 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
197 - | match crate::protocol_serde::shape_query_precedence::ser_query_precedence_http_response(
|
198 - | self,
|
199 - | ) {
|
69 + | match crate::protocol_serde::shape_string_payload::ser_string_payload_http_response(self) {
|
200 70 | Ok(response) => response,
|
201 71 | Err(e) => {
|
202 72 | ::tracing::error!(error = %e, "failed to serialize response");
|
203 73 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
204 74 | }
|
205 75 | }
|
206 76 | }
|
207 77 | }
|
208 78 | impl
|
209 79 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
210 80 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
211 - | > for crate::error::QueryPrecedenceError
|
81 + | > for crate::error::StringPayloadError
|
212 82 | {
|
213 83 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
214 - | match crate::protocol_serde::shape_query_precedence::ser_query_precedence_http_error(&self)
|
215 - | {
|
84 + | match crate::protocol_serde::shape_string_payload::ser_string_payload_http_error(&self) {
|
216 85 | Ok(mut response) => {
|
217 86 | response.extensions_mut().insert(
|
218 87 | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
219 88 | self.name(),
|
220 89 | ),
|
221 90 | );
|
222 91 | response
|
223 92 | }
|
224 93 | Err(e) => {
|
225 94 | ::tracing::error!(error = %e, "failed to serialize response");
|
226 95 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
227 96 | }
|
228 97 | }
|
229 98 | }
|
230 99 | }
|
231 100 |
|
232 101 | #[allow(unreachable_code, unused_variables)]
|
233 102 | #[cfg(test)]
|
234 - | mod query_precedence_test {
|
103 + | mod string_payload_test {
|
235 104 |
|
236 - | /// Servers put all query params in map
|
237 - | /// Test ID: RestJsonServersPutAllQueryParamsInMap
|
105 + | /// Test ID: StringPayload
|
238 106 | #[::tokio::test]
|
239 107 | #[::tracing_test::traced_test]
|
240 - | async fn rest_json_servers_put_all_query_params_in_map_request() {
|
108 + | async fn string_payload_request() {
|
241 109 | #[allow(unused_mut)]
|
242 110 | let mut http_request = ::http::Request::builder()
|
243 - | .uri("/Precedence")
|
111 + | .uri("/StringPayload")
|
244 112 | .method("POST")
|
113 + | .header("Content-Type", "text/plain")
|
245 114 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
246 115 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
247 - | "".as_bytes(),
|
116 + | "rawstring".as_bytes(),
|
248 117 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
249 118 | )),
|
250 119 | ))
|
251 120 | .unwrap();
|
252 - | *http_request.uri_mut() = "/Precedence?bar=named&qux=fromMap".parse().unwrap();
|
253 121 | #[allow(unused_mut)]
|
254 122 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
255 123 | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
256 124 | let service =
|
257 125 | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
258 - | .query_precedence(move |input: crate::input::QueryPrecedenceInput| {
|
126 + | .string_payload(move |input: crate::input::StringPayloadInput| {
|
259 127 | let sender = sender.clone();
|
260 128 | async move {
|
261 129 | let result = {
|
262 - | let expected = crate::input::QueryPrecedenceInput {
|
263 - | foo: ::std::option::Option::Some("named".to_owned()),
|
264 - | baz: ::std::option::Option::Some({
|
265 - | let mut ret = ::std::collections::HashMap::new();
|
266 - | ret.insert("bar".to_owned(), "named".to_owned());
|
267 - | ret.insert("qux".to_owned(), "fromMap".to_owned());
|
268 - | ret
|
269 - | }),
|
130 + | let expected = crate::input::StringPayloadInput {
|
131 + | payload: ::std::option::Option::Some("rawstring".to_owned()),
|
270 132 | };
|
271 133 | ::pretty_assertions::assert_eq!(input, expected);
|
272 - | let output = crate::output::QueryPrecedenceOutput {};
|
134 + | let output = crate::output::StringPayloadOutput {
|
135 + | payload: ::std::option::Option::None,
|
136 + | };
|
273 137 | Ok(output)
|
274 138 | };
|
275 139 | sender.send(()).await.expect("receiver dropped early");
|
276 140 | result
|
277 141 | }
|
278 142 | })
|
279 143 | .build_unchecked();
|
280 144 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
281 145 | .await
|
282 146 | .expect("unable to make an HTTP request");
|
283 147 | assert!(
|
284 148 | receiver.recv().await.is_some(),
|
285 149 | "we expected operation handler to be invoked but it was not entered"
|
286 150 | );
|
287 151 | }
|
288 152 |
|
289 153 | /// Upper case error modeled lower case.
|
290 154 | /// Test ID: ServiceLevelErrorServer
|
291 155 | #[::tokio::test]
|
292 156 | #[::tracing_test::traced_test]
|
293 157 | async fn service_level_error_server_response() {
|
294 158 | let output = crate::error::ExtraError {};
|
295 - | let output = crate::error::QueryPrecedenceError::ExtraError(output);
|
159 + | let output = crate::error::StringPayloadError::ExtraError(output);
|
296 160 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
297 161 | let http_response = output.into_response();
|
298 162 | ::pretty_assertions::assert_eq!(
|
299 163 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
300 164 | http_response.status()
|
301 165 | );
|
302 166 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
303 167 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
304 168 | http_response.headers(),
|
305 169 | expected_headers,
|
306 170 | ));
|
307 171 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
308 172 | .await
|
309 173 | .expect("unable to extract body to bytes");
|
310 174 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
311 175 | &body,
|
312 176 | "{}",
|
313 177 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
314 178 | ));
|
315 179 | }
|
316 180 | }
|
317 181 |
|
318 182 | ::pin_project_lite::pin_project! {
|
319 183 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
320 - | /// [`EmptyStructWithContentOnWireOpInput`](crate::input::EmptyStructWithContentOnWireOpInput) using modelled bindings.
|
321 - | pub struct EmptyStructWithContentOnWireOpInputFuture {
|
322 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyStructWithContentOnWireOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
184 + | /// [`PrimitiveIntHeaderInput`](crate::input::PrimitiveIntHeaderInput) using modelled bindings.
|
185 + | pub struct PrimitiveIntHeaderInputFuture {
|
186 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PrimitiveIntHeaderInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
323 187 | }
|
324 188 | }
|
325 189 |
|
326 - | impl std::future::Future for EmptyStructWithContentOnWireOpInputFuture {
|
190 + | impl std::future::Future for PrimitiveIntHeaderInputFuture {
|
327 191 | type Output = Result<
|
328 - | crate::input::EmptyStructWithContentOnWireOpInput,
|
192 + | crate::input::PrimitiveIntHeaderInput,
|
329 193 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
330 194 | >;
|
331 195 |
|
332 196 | fn poll(
|
333 197 | self: std::pin::Pin<&mut Self>,
|
334 198 | cx: &mut std::task::Context<'_>,
|
335 199 | ) -> std::task::Poll<Self::Output> {
|
336 200 | let this = self.project();
|
337 201 | this.inner.as_mut().poll(cx)
|
338 202 | }
|
339 203 | }
|
340 204 |
|
341 205 | impl<B>
|
342 206 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
343 207 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
344 208 | B,
|
345 - | > for crate::input::EmptyStructWithContentOnWireOpInput
|
209 + | > for crate::input::PrimitiveIntHeaderInput
|
346 210 | where
|
347 211 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
348 212 | B: 'static,
|
349 213 |
|
350 214 | B::Data: Send,
|
351 215 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
352 216 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
353 217 | {
|
354 218 | type Rejection =
|
355 219 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
356 - | type Future = EmptyStructWithContentOnWireOpInputFuture;
|
220 + | type Future = PrimitiveIntHeaderInputFuture;
|
357 221 |
|
358 222 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
359 223 | let fut = async move {
|
360 224 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
361 225 | request.headers(),
|
362 226 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
363 227 | ) {
|
364 228 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
365 229 | }
|
366 - | crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::de_empty_struct_with_content_on_wire_op_http_request(request)
|
230 + | crate::protocol_serde::shape_primitive_int_header::de_primitive_int_header_http_request(
|
231 + | request,
|
232 + | )
|
367 233 | .await
|
368 234 | };
|
369 235 | use ::futures_util::future::TryFutureExt;
|
370 236 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
371 237 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
372 238 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
373 239 | });
|
374 - | EmptyStructWithContentOnWireOpInputFuture {
|
240 + | PrimitiveIntHeaderInputFuture {
|
375 241 | inner: Box::pin(fut),
|
376 242 | }
|
377 243 | }
|
378 244 | }
|
379 245 | impl
|
380 246 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
381 247 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
382 - | > for crate::output::EmptyStructWithContentOnWireOpOutput
|
248 + | > for crate::output::PrimitiveIntHeaderOutput
|
383 249 | {
|
384 250 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
385 - | match crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::ser_empty_struct_with_content_on_wire_op_http_response(self) {
|
251 + | match crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_http_response(self) {
|
386 252 | Ok(response) => response,
|
387 253 | Err(e) => {
|
388 254 | ::tracing::error!(error = %e, "failed to serialize response");
|
389 255 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
390 256 | }
|
391 257 | }
|
392 258 | }
|
393 259 | }
|
394 260 | impl
|
395 261 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
396 262 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
397 - | > for crate::error::EmptyStructWithContentOnWireOpError
|
263 + | > for crate::error::PrimitiveIntHeaderError
|
398 264 | {
|
399 265 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
400 - | match crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::ser_empty_struct_with_content_on_wire_op_http_error(&self) {
|
266 + | match crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_http_error(
|
267 + | &self,
|
268 + | ) {
|
401 269 | Ok(mut response) => {
|
402 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
270 + | response.extensions_mut().insert(
|
271 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
272 + | self.name(),
|
273 + | ),
|
274 + | );
|
403 275 | response
|
404 - | },
|
276 + | }
|
405 277 | Err(e) => {
|
406 278 | ::tracing::error!(error = %e, "failed to serialize response");
|
407 279 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
408 280 | }
|
409 281 | }
|
410 282 | }
|
411 283 | }
|
412 284 |
|
413 285 | #[allow(unreachable_code, unused_variables)]
|
414 286 | #[cfg(test)]
|
415 - | mod empty_struct_with_content_on_wire_op_test {
|
287 + | mod primitive_int_header_test {
|
288 + |
|
289 + | /// Test ID: DeserPrimitiveHeader
|
290 + | #[::tokio::test]
|
291 + | #[::tracing_test::traced_test]
|
292 + | async fn deser_primitive_header_response() {
|
293 + | let output = crate::output::PrimitiveIntHeaderOutput { field: 123 };
|
294 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
295 + | let http_response = output.into_response();
|
296 + | ::pretty_assertions::assert_eq!(
|
297 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
298 + | http_response.status()
|
299 + | );
|
300 + | let expected_headers = [("x-field", "123")];
|
301 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
302 + | http_response.headers(),
|
303 + | expected_headers,
|
304 + | ));
|
305 + | }
|
306 + | /// Test ID: DeserPrimitiveHeaderMissing
|
307 + | #[::tokio::test]
|
308 + | #[::tracing_test::traced_test]
|
309 + | async fn deser_primitive_header_missing_response() {
|
310 + | let output = crate::output::PrimitiveIntHeaderOutput { field: 0 };
|
311 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
312 + | let http_response = output.into_response();
|
313 + | ::pretty_assertions::assert_eq!(
|
314 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
315 + | http_response.status()
|
316 + | );
|
317 + | }
|
416 318 |
|
417 319 | /// Upper case error modeled lower case.
|
418 320 | /// Test ID: ServiceLevelErrorServer
|
419 321 | #[::tokio::test]
|
420 322 | #[::tracing_test::traced_test]
|
421 323 | async fn service_level_error_server_response() {
|
422 324 | let output = crate::error::ExtraError {};
|
423 - | let output = crate::error::EmptyStructWithContentOnWireOpError::ExtraError(output);
|
325 + | let output = crate::error::PrimitiveIntHeaderError::ExtraError(output);
|
424 326 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
425 327 | let http_response = output.into_response();
|
426 328 | ::pretty_assertions::assert_eq!(
|
427 329 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
428 330 | http_response.status()
|
429 331 | );
|
430 332 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
431 333 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
432 334 | http_response.headers(),
|
433 335 | expected_headers,
|
434 336 | ));
|
435 337 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
436 338 | .await
|
437 339 | .expect("unable to extract body to bytes");
|
438 340 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
439 341 | &body,
|
440 342 | "{}",
|
441 343 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
442 344 | ));
|
443 345 | }
|
444 346 | }
|
445 347 |
|
446 348 | ::pin_project_lite::pin_project! {
|
447 349 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
448 - | /// [`CaseInsensitiveErrorOperationInput`](crate::input::CaseInsensitiveErrorOperationInput) using modelled bindings.
|
449 - | pub struct CaseInsensitiveErrorOperationInputFuture {
|
450 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::CaseInsensitiveErrorOperationInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
350 + | /// [`EnumQueryInput`](crate::input::EnumQueryInput) using modelled bindings.
|
351 + | pub struct EnumQueryInputFuture {
|
352 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EnumQueryInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
451 353 | }
|
452 354 | }
|
453 355 |
|
454 - | impl std::future::Future for CaseInsensitiveErrorOperationInputFuture {
|
356 + | impl std::future::Future for EnumQueryInputFuture {
|
455 357 | type Output = Result<
|
456 - | crate::input::CaseInsensitiveErrorOperationInput,
|
358 + | crate::input::EnumQueryInput,
|
457 359 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
458 360 | >;
|
459 361 |
|
460 362 | fn poll(
|
461 363 | self: std::pin::Pin<&mut Self>,
|
462 364 | cx: &mut std::task::Context<'_>,
|
463 365 | ) -> std::task::Poll<Self::Output> {
|
464 366 | let this = self.project();
|
465 367 | this.inner.as_mut().poll(cx)
|
466 368 | }
|
467 369 | }
|
468 370 |
|
469 371 | impl<B>
|
470 372 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
471 373 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
472 374 | B,
|
473 - | > for crate::input::CaseInsensitiveErrorOperationInput
|
375 + | > for crate::input::EnumQueryInput
|
474 376 | where
|
475 377 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
476 378 | B: 'static,
|
477 379 |
|
478 380 | B::Data: Send,
|
479 381 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
480 382 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
481 383 | {
|
482 384 | type Rejection =
|
483 385 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
484 - | type Future = CaseInsensitiveErrorOperationInputFuture;
|
386 + | type Future = EnumQueryInputFuture;
|
485 387 |
|
486 388 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
487 389 | let fut = async move {
|
488 390 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
489 391 | request.headers(),
|
490 392 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
491 393 | ) {
|
492 394 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
493 395 | }
|
494 - | crate::protocol_serde::shape_case_insensitive_error_operation::de_case_insensitive_error_operation_http_request(request)
|
495 - | .await
|
396 + | crate::protocol_serde::shape_enum_query::de_enum_query_http_request(request).await
|
496 397 | };
|
497 398 | use ::futures_util::future::TryFutureExt;
|
498 399 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
499 400 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
500 401 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
501 402 | });
|
502 - | CaseInsensitiveErrorOperationInputFuture {
|
403 + | EnumQueryInputFuture {
|
503 404 | inner: Box::pin(fut),
|
504 405 | }
|
505 406 | }
|
506 407 | }
|
507 408 | impl
|
508 409 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
509 410 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
510 - | > for crate::output::CaseInsensitiveErrorOperationOutput
|
411 + | > for crate::output::EnumQueryOutput
|
511 412 | {
|
512 413 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
513 - | match crate::protocol_serde::shape_case_insensitive_error_operation::ser_case_insensitive_error_operation_http_response(self) {
|
414 + | match crate::protocol_serde::shape_enum_query::ser_enum_query_http_response(self) {
|
514 415 | Ok(response) => response,
|
515 416 | Err(e) => {
|
516 417 | ::tracing::error!(error = %e, "failed to serialize response");
|
517 418 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
518 419 | }
|
519 420 | }
|
520 421 | }
|
521 422 | }
|
522 423 | impl
|
523 424 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
524 425 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
525 - | > for crate::error::CaseInsensitiveErrorOperationError
|
426 + | > for crate::error::EnumQueryError
|
526 427 | {
|
527 428 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
528 - | match crate::protocol_serde::shape_case_insensitive_error_operation::ser_case_insensitive_error_operation_http_error(&self) {
|
429 + | match crate::protocol_serde::shape_enum_query::ser_enum_query_http_error(&self) {
|
529 430 | Ok(mut response) => {
|
530 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
431 + | response.extensions_mut().insert(
|
432 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
433 + | self.name(),
|
434 + | ),
|
435 + | );
|
531 436 | response
|
532 - | },
|
437 + | }
|
533 438 | Err(e) => {
|
534 439 | ::tracing::error!(error = %e, "failed to serialize response");
|
535 440 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
536 441 | }
|
537 442 | }
|
538 443 | }
|
539 - | }
|
540 - |
|
541 - | #[allow(unreachable_code, unused_variables)]
|
542 - | #[cfg(test)]
|
543 - | mod case_insensitive_error_operation_test {
|
444 + | }
|
445 + |
|
446 + | #[allow(unreachable_code, unused_variables)]
|
447 + | #[cfg(test)]
|
448 + | mod enum_query_test {
|
449 + |
|
450 + | /// Test ID: EnumQueryRequest
|
451 + | #[::tokio::test]
|
452 + | #[::tracing_test::traced_test]
|
453 + | async fn enum_query_request_request() {
|
454 + | #[allow(unused_mut)]
|
455 + | let mut http_request = ::http::Request::builder()
|
456 + | .uri("/foo/enumvalue")
|
457 + | .method("GET")
|
458 + | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
459 + | .unwrap();
|
460 + | #[allow(unused_mut)]
|
461 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
462 + | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
463 + | let service =
|
464 + | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
465 + | .enum_query(move |input: crate::input::EnumQueryInput| {
|
466 + | let sender = sender.clone();
|
467 + | async move {
|
468 + | let result = {
|
469 + | let expected = crate::input::EnumQueryInput {
|
470 + | r#enum: "enumvalue"
|
471 + | .parse::<crate::model::StringEnum>()
|
472 + | .expect("static value validated to member"),
|
473 + | };
|
474 + | ::pretty_assertions::assert_eq!(input, expected);
|
475 + | let output = crate::output::EnumQueryOutput {};
|
476 + | Ok(output)
|
477 + | };
|
478 + | sender.send(()).await.expect("receiver dropped early");
|
479 + | result
|
480 + | }
|
481 + | })
|
482 + | .build_unchecked();
|
483 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
484 + | .await
|
485 + | .expect("unable to make an HTTP request");
|
486 + | assert!(
|
487 + | receiver.recv().await.is_some(),
|
488 + | "we expected operation handler to be invoked but it was not entered"
|
489 + | );
|
490 + | }
|
544 491 |
|
545 492 | /// Upper case error modeled lower case.
|
546 493 | /// Test ID: ServiceLevelErrorServer
|
547 494 | #[::tokio::test]
|
548 495 | #[::tracing_test::traced_test]
|
549 496 | async fn service_level_error_server_response() {
|
550 497 | let output = crate::error::ExtraError {};
|
551 - | let output = crate::error::CaseInsensitiveErrorOperationError::ExtraError(output);
|
498 + | let output = crate::error::EnumQueryError::ExtraError(output);
|
552 499 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
553 500 | let http_response = output.into_response();
|
554 501 | ::pretty_assertions::assert_eq!(
|
555 502 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
556 503 | http_response.status()
|
557 504 | );
|
558 505 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
559 506 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
560 507 | http_response.headers(),
|
561 508 | expected_headers,
|
562 509 | ));
|
563 510 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
564 511 | .await
|
565 512 | .expect("unable to extract body to bytes");
|
566 513 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
567 514 | &body,
|
568 515 | "{}",
|
569 516 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
570 517 | ));
|
571 518 | }
|
572 519 | }
|
573 520 |
|
574 521 | ::pin_project_lite::pin_project! {
|
575 522 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
576 - | /// [`NullInNonSparseInput`](crate::input::NullInNonSparseInput) using modelled bindings.
|
577 - | pub struct NullInNonSparseInputFuture {
|
578 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NullInNonSparseInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
523 + | /// [`StatusResponseInput`](crate::input::StatusResponseInput) using modelled bindings.
|
524 + | pub struct StatusResponseInputFuture {
|
525 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StatusResponseInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
579 526 | }
|
580 527 | }
|
581 528 |
|
582 - | impl std::future::Future for NullInNonSparseInputFuture {
|
529 + | impl std::future::Future for StatusResponseInputFuture {
|
583 530 | type Output = Result<
|
584 - | crate::input::NullInNonSparseInput,
|
531 + | crate::input::StatusResponseInput,
|
585 532 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
586 533 | >;
|
587 534 |
|
588 535 | fn poll(
|
589 536 | self: std::pin::Pin<&mut Self>,
|
590 537 | cx: &mut std::task::Context<'_>,
|
591 538 | ) -> std::task::Poll<Self::Output> {
|
592 539 | let this = self.project();
|
593 540 | this.inner.as_mut().poll(cx)
|
594 541 | }
|
595 542 | }
|
596 543 |
|
597 544 | impl<B>
|
598 545 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
599 546 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
600 547 | B,
|
601 - | > for crate::input::NullInNonSparseInput
|
548 + | > for crate::input::StatusResponseInput
|
602 549 | where
|
603 550 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
604 551 | B: 'static,
|
605 552 |
|
606 553 | B::Data: Send,
|
607 554 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
608 555 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
609 556 | {
|
610 557 | type Rejection =
|
611 558 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
612 - | type Future = NullInNonSparseInputFuture;
|
559 + | type Future = StatusResponseInputFuture;
|
613 560 |
|
614 561 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
615 562 | let fut = async move {
|
616 563 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
617 564 | request.headers(),
|
618 565 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
619 566 | ) {
|
620 567 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
621 568 | }
|
622 - | crate::protocol_serde::shape_null_in_non_sparse::de_null_in_non_sparse_http_request(
|
623 - | request,
|
624 - | )
|
569 + | crate::protocol_serde::shape_status_response::de_status_response_http_request(request)
|
625 570 | .await
|
626 571 | };
|
627 572 | use ::futures_util::future::TryFutureExt;
|
628 573 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
629 574 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
630 575 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
631 576 | });
|
632 - | NullInNonSparseInputFuture {
|
577 + | StatusResponseInputFuture {
|
633 578 | inner: Box::pin(fut),
|
634 579 | }
|
635 580 | }
|
636 581 | }
|
637 582 | impl
|
638 583 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
639 584 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
640 - | > for crate::output::NullInNonSparseOutput
|
585 + | > for crate::output::StatusResponseOutput
|
641 586 | {
|
642 587 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
643 - | match crate::protocol_serde::shape_null_in_non_sparse::ser_null_in_non_sparse_http_response(
|
644 - | self,
|
645 - | ) {
|
588 + | match crate::protocol_serde::shape_status_response::ser_status_response_http_response(self)
|
589 + | {
|
646 590 | Ok(response) => response,
|
647 591 | Err(e) => {
|
648 592 | ::tracing::error!(error = %e, "failed to serialize response");
|
649 593 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
650 594 | }
|
651 595 | }
|
652 596 | }
|
653 597 | }
|
654 598 | impl
|
655 599 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
656 600 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
657 - | > for crate::error::NullInNonSparseError
|
601 + | > for crate::error::StatusResponseError
|
658 602 | {
|
659 603 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
660 - | match crate::protocol_serde::shape_null_in_non_sparse::ser_null_in_non_sparse_http_error(
|
661 - | &self,
|
662 - | ) {
|
604 + | match crate::protocol_serde::shape_status_response::ser_status_response_http_error(&self) {
|
663 605 | Ok(mut response) => {
|
664 606 | response.extensions_mut().insert(
|
665 607 | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
666 608 | self.name(),
|
667 609 | ),
|
668 610 | );
|
669 611 | response
|
670 612 | }
|
671 613 | Err(e) => {
|
672 614 | ::tracing::error!(error = %e, "failed to serialize response");
|
673 615 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
674 616 | }
|
675 617 | }
|
676 618 | }
|
677 619 | }
|
678 620 |
|
679 621 | #[allow(unreachable_code, unused_variables)]
|
680 622 | #[cfg(test)]
|
681 - | mod null_in_non_sparse_test {
|
623 + | mod status_response_test {
|
682 624 |
|
683 625 | /// Upper case error modeled lower case.
|
684 626 | /// Test ID: ServiceLevelErrorServer
|
685 627 | #[::tokio::test]
|
686 628 | #[::tracing_test::traced_test]
|
687 629 | async fn service_level_error_server_response() {
|
688 630 | let output = crate::error::ExtraError {};
|
689 - | let output = crate::error::NullInNonSparseError::ExtraError(output);
|
631 + | let output = crate::error::StatusResponseError::ExtraError(output);
|
690 632 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
691 633 | let http_response = output.into_response();
|
692 634 | ::pretty_assertions::assert_eq!(
|
693 635 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
694 636 | http_response.status()
|
695 637 | );
|
696 638 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
697 639 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
698 640 | http_response.headers(),
|
699 641 | expected_headers,
|
700 642 | ));
|
701 643 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
702 644 | .await
|
703 645 | .expect("unable to extract body to bytes");
|
704 646 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
705 647 | &body,
|
706 648 | "{}",
|
707 649 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
708 650 | ));
|
709 651 | }
|
710 652 | }
|
711 653 |
|
712 654 | ::pin_project_lite::pin_project! {
|
713 655 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
714 - | /// [`EscapedStringValuesInput`](crate::input::EscapedStringValuesInput) using modelled bindings.
|
715 - | pub struct EscapedStringValuesInputFuture {
|
716 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EscapedStringValuesInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
656 + | /// [`MapWithEnumKeyOpInput`](crate::input::MapWithEnumKeyOpInput) using modelled bindings.
|
657 + | pub struct MapWithEnumKeyOpInputFuture {
|
658 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MapWithEnumKeyOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
717 659 | }
|
718 660 | }
|
719 661 |
|
720 - | impl std::future::Future for EscapedStringValuesInputFuture {
|
662 + | impl std::future::Future for MapWithEnumKeyOpInputFuture {
|
721 663 | type Output = Result<
|
722 - | crate::input::EscapedStringValuesInput,
|
664 + | crate::input::MapWithEnumKeyOpInput,
|
723 665 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
724 666 | >;
|
725 667 |
|
726 668 | fn poll(
|
727 669 | self: std::pin::Pin<&mut Self>,
|
728 670 | cx: &mut std::task::Context<'_>,
|
729 671 | ) -> std::task::Poll<Self::Output> {
|
730 672 | let this = self.project();
|
731 673 | this.inner.as_mut().poll(cx)
|
732 674 | }
|
733 675 | }
|
734 676 |
|
735 677 | impl<B>
|
736 678 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
737 679 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
738 680 | B,
|
739 - | > for crate::input::EscapedStringValuesInput
|
681 + | > for crate::input::MapWithEnumKeyOpInput
|
740 682 | where
|
741 683 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
742 684 | B: 'static,
|
743 685 |
|
744 686 | B::Data: Send,
|
745 687 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
746 688 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
747 689 | {
|
748 690 | type Rejection =
|
749 691 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
750 - | type Future = EscapedStringValuesInputFuture;
|
692 + | type Future = MapWithEnumKeyOpInputFuture;
|
751 693 |
|
752 694 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
753 695 | let fut = async move {
|
754 696 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
755 697 | request.headers(),
|
756 698 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
757 699 | ) {
|
758 700 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
759 701 | }
|
760 - | crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values_http_request(request)
|
702 + | crate::protocol_serde::shape_map_with_enum_key_op::de_map_with_enum_key_op_http_request(
|
703 + | request,
|
704 + | )
|
761 705 | .await
|
762 706 | };
|
763 707 | use ::futures_util::future::TryFutureExt;
|
764 708 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
765 709 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
766 710 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
767 711 | });
|
768 - | EscapedStringValuesInputFuture {
|
712 + | MapWithEnumKeyOpInputFuture {
|
769 713 | inner: Box::pin(fut),
|
770 714 | }
|
771 715 | }
|
772 716 | }
|
773 717 | impl
|
774 718 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
775 719 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
776 - | > for crate::output::EscapedStringValuesOutput
|
720 + | > for crate::output::MapWithEnumKeyOpOutput
|
777 721 | {
|
778 722 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
779 - | match crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_http_response(self) {
|
723 + | match crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_http_response(self) {
|
780 724 | Ok(response) => response,
|
781 725 | Err(e) => {
|
782 726 | ::tracing::error!(error = %e, "failed to serialize response");
|
783 727 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
784 728 | }
|
785 729 | }
|
786 730 | }
|
787 731 | }
|
788 732 | impl
|
789 733 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
790 734 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
791 - | > for crate::error::EscapedStringValuesError
|
735 + | > for crate::error::MapWithEnumKeyOpError
|
792 736 | {
|
793 737 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
794 - | match crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_http_error(&self) {
|
738 + | match crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_http_error(
|
739 + | &self,
|
740 + | ) {
|
795 741 | Ok(mut response) => {
|
796 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
742 + | response.extensions_mut().insert(
|
743 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
744 + | self.name(),
|
745 + | ),
|
746 + | );
|
797 747 | response
|
798 - | },
|
748 + | }
|
799 749 | Err(e) => {
|
800 750 | ::tracing::error!(error = %e, "failed to serialize response");
|
801 751 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
802 752 | }
|
803 753 | }
|
804 754 | }
|
805 755 | }
|
806 756 |
|
807 757 | #[allow(unreachable_code, unused_variables)]
|
808 758 | #[cfg(test)]
|
809 - | mod escaped_string_values_test {
|
759 + | mod map_with_enum_key_op_test {
|
810 760 |
|
811 - | /// Test ID: EscapedStringValuesRequest
|
761 + | /// Test ID: MapWithEnumKeyRequest
|
812 762 | #[::tokio::test]
|
813 763 | #[::tracing_test::traced_test]
|
814 - | async fn escaped_string_values_request_request() {
|
764 + | async fn map_with_enum_key_request_request() {
|
815 765 | #[allow(unused_mut)]
|
816 766 | let mut http_request = ::http::Request::builder()
|
817 - | .uri("/escaped-string-values")
|
767 + | .uri("/map-with-enum-key")
|
818 768 | .method("POST")
|
819 769 | .header("Content-Type", "application/json")
|
820 770 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
821 771 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
822 - | "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}".as_bytes(),
|
772 + | "{\"map\":{\"enumvalue\":\"something\"}}".as_bytes(),
|
823 773 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
824 774 | )),
|
825 775 | ))
|
826 776 | .unwrap();
|
827 777 | #[allow(unused_mut)]
|
828 778 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
829 779 | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
830 780 | let service =
|
831 781 | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
832 - | .escaped_string_values(move |input: crate::input::EscapedStringValuesInput| {
|
782 + | .map_with_enum_key_op(move |input: crate::input::MapWithEnumKeyOpInput| {
|
833 783 | let sender = sender.clone();
|
834 784 | async move {
|
835 785 | let result = {
|
836 - | let expected = crate::input::EscapedStringValuesInput {
|
837 - | r#enum: ::std::option::Option::Some(
|
838 - | "has\"quotes"
|
839 - | .parse::<crate::model::EnumWithEscapedChars>()
|
786 + | let expected = crate::input::MapWithEnumKeyOpInput {
|
787 + | map: ::std::option::Option::Some({
|
788 + | let mut ret = ::std::collections::HashMap::new();
|
789 + | ret.insert(
|
790 + | "enumvalue"
|
791 + | .parse::<crate::model::StringEnum>()
|
840 792 | .expect("static value validated to member"),
|
841 - | ),
|
842 - | some_string: ::std::option::Option::Some("test".to_owned()),
|
793 + | "something".to_owned(),
|
794 + | );
|
795 + | ret
|
796 + | }),
|
843 797 | };
|
844 798 | ::pretty_assertions::assert_eq!(input, expected);
|
845 - | let output = crate::output::EscapedStringValuesOutput {
|
846 - | r#enum: ::std::option::Option::None,
|
847 - | some_string: ::std::option::Option::None,
|
799 + | let output = crate::output::MapWithEnumKeyOpOutput {
|
800 + | map: ::std::option::Option::None,
|
848 801 | };
|
849 802 | Ok(output)
|
850 803 | };
|
851 804 | sender.send(()).await.expect("receiver dropped early");
|
852 805 | result
|
853 806 | }
|
854 807 | })
|
855 808 | .build_unchecked();
|
856 809 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
857 810 | .await
|
858 811 | .expect("unable to make an HTTP request");
|
859 812 | assert!(
|
860 813 | receiver.recv().await.is_some(),
|
861 814 | "we expected operation handler to be invoked but it was not entered"
|
862 815 | );
|
863 816 | }
|
864 - | /// Test ID: EscapedStringValuesResponse
|
817 + | /// Test ID: MapWithEnumKeyResponse
|
865 818 | #[::tokio::test]
|
866 819 | #[::tracing_test::traced_test]
|
867 - | async fn escaped_string_values_response_response() {
|
868 - | let output = crate::output::EscapedStringValuesOutput {
|
869 - | r#enum: ::std::option::Option::Some(
|
870 - | "has\"quotes"
|
871 - | .parse::<crate::model::EnumWithEscapedChars>()
|
820 + | async fn map_with_enum_key_response_response() {
|
821 + | let output = crate::output::MapWithEnumKeyOpOutput {
|
822 + | map: ::std::option::Option::Some({
|
823 + | let mut ret = ::std::collections::HashMap::new();
|
824 + | ret.insert(
|
825 + | "enumvalue"
|
826 + | .parse::<crate::model::StringEnum>()
|
872 827 | .expect("static value validated to member"),
|
873 - | ),
|
874 - | some_string: ::std::option::Option::Some("test".to_owned()),
|
828 + | "something".to_owned(),
|
829 + | );
|
830 + | ret
|
831 + | }),
|
875 832 | };
|
876 833 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
877 834 | let http_response = output.into_response();
|
878 835 | ::pretty_assertions::assert_eq!(
|
879 836 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
880 837 | http_response.status()
|
881 838 | );
|
882 839 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
883 840 | .await
|
884 841 | .expect("unable to extract body to bytes");
|
885 842 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
886 843 | &body,
|
887 - | "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}",
|
844 + | "{\"map\":{\"enumvalue\":\"something\"}}",
|
888 845 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
889 846 | ));
|
890 847 | }
|
891 848 |
|
892 849 | /// Upper case error modeled lower case.
|
893 850 | /// Test ID: ServiceLevelErrorServer
|
894 851 | #[::tokio::test]
|
895 852 | #[::tracing_test::traced_test]
|
896 853 | async fn service_level_error_server_response() {
|
897 854 | let output = crate::error::ExtraError {};
|
898 - | let output = crate::error::EscapedStringValuesError::ExtraError(output);
|
855 + | let output = crate::error::MapWithEnumKeyOpError::ExtraError(output);
|
899 856 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
900 857 | let http_response = output.into_response();
|
901 858 | ::pretty_assertions::assert_eq!(
|
902 859 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
903 860 | http_response.status()
|
904 861 | );
|
905 862 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
906 863 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
907 864 | http_response.headers(),
|
908 865 | expected_headers,
|
1048 1005 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1049 1006 | &body,
|
1050 1007 | "{}",
|
1051 1008 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1052 1009 | ));
|
1053 1010 | }
|
1054 1011 | }
|
1055 1012 |
|
1056 1013 | ::pin_project_lite::pin_project! {
|
1057 1014 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1058 - | /// [`MapWithEnumKeyOpInput`](crate::input::MapWithEnumKeyOpInput) using modelled bindings.
|
1059 - | pub struct MapWithEnumKeyOpInputFuture {
|
1060 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MapWithEnumKeyOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1015 + | /// [`EscapedStringValuesInput`](crate::input::EscapedStringValuesInput) using modelled bindings.
|
1016 + | pub struct EscapedStringValuesInputFuture {
|
1017 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EscapedStringValuesInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1061 1018 | }
|
1062 1019 | }
|
1063 1020 |
|
1064 - | impl std::future::Future for MapWithEnumKeyOpInputFuture {
|
1021 + | impl std::future::Future for EscapedStringValuesInputFuture {
|
1065 1022 | type Output = Result<
|
1066 - | crate::input::MapWithEnumKeyOpInput,
|
1023 + | crate::input::EscapedStringValuesInput,
|
1067 1024 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1068 1025 | >;
|
1069 1026 |
|
1070 1027 | fn poll(
|
1071 1028 | self: std::pin::Pin<&mut Self>,
|
1072 1029 | cx: &mut std::task::Context<'_>,
|
1073 1030 | ) -> std::task::Poll<Self::Output> {
|
1074 1031 | let this = self.project();
|
1075 1032 | this.inner.as_mut().poll(cx)
|
1076 1033 | }
|
1077 1034 | }
|
1078 1035 |
|
1079 1036 | impl<B>
|
1080 1037 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1081 1038 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1082 1039 | B,
|
1083 - | > for crate::input::MapWithEnumKeyOpInput
|
1040 + | > for crate::input::EscapedStringValuesInput
|
1084 1041 | where
|
1085 1042 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1086 1043 | B: 'static,
|
1087 1044 |
|
1088 1045 | B::Data: Send,
|
1089 1046 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1090 1047 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1091 1048 | {
|
1092 1049 | type Rejection =
|
1093 1050 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1094 - | type Future = MapWithEnumKeyOpInputFuture;
|
1051 + | type Future = EscapedStringValuesInputFuture;
|
1095 1052 |
|
1096 1053 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1097 1054 | let fut = async move {
|
1098 1055 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1099 1056 | request.headers(),
|
1100 1057 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1101 1058 | ) {
|
1102 1059 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1103 1060 | }
|
1104 - | crate::protocol_serde::shape_map_with_enum_key_op::de_map_with_enum_key_op_http_request(
|
1105 - | request,
|
1106 - | )
|
1061 + | crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values_http_request(request)
|
1107 1062 | .await
|
1108 1063 | };
|
1109 1064 | use ::futures_util::future::TryFutureExt;
|
1110 1065 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1111 1066 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1112 1067 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1113 1068 | });
|
1114 - | MapWithEnumKeyOpInputFuture {
|
1069 + | EscapedStringValuesInputFuture {
|
1115 1070 | inner: Box::pin(fut),
|
1116 1071 | }
|
1117 1072 | }
|
1118 1073 | }
|
1119 1074 | impl
|
1120 1075 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1121 1076 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1122 - | > for crate::output::MapWithEnumKeyOpOutput
|
1077 + | > for crate::output::EscapedStringValuesOutput
|
1123 1078 | {
|
1124 1079 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1125 - | match crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_http_response(self) {
|
1080 + | match crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_http_response(self) {
|
1126 1081 | Ok(response) => response,
|
1127 1082 | Err(e) => {
|
1128 1083 | ::tracing::error!(error = %e, "failed to serialize response");
|
1129 1084 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1130 1085 | }
|
1131 1086 | }
|
1132 1087 | }
|
1133 1088 | }
|
1134 1089 | impl
|
1135 1090 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1136 1091 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1137 - | > for crate::error::MapWithEnumKeyOpError
|
1092 + | > for crate::error::EscapedStringValuesError
|
1138 1093 | {
|
1139 1094 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1140 - | match crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_http_error(
|
1141 - | &self,
|
1142 - | ) {
|
1095 + | match crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_http_error(&self) {
|
1143 1096 | Ok(mut response) => {
|
1144 - | response.extensions_mut().insert(
|
1145 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1146 - | self.name(),
|
1147 - | ),
|
1148 - | );
|
1097 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1149 1098 | response
|
1150 - | }
|
1099 + | },
|
1151 1100 | Err(e) => {
|
1152 1101 | ::tracing::error!(error = %e, "failed to serialize response");
|
1153 1102 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1154 1103 | }
|
1155 1104 | }
|
1156 1105 | }
|
1157 1106 | }
|
1158 1107 |
|
1159 1108 | #[allow(unreachable_code, unused_variables)]
|
1160 1109 | #[cfg(test)]
|
1161 - | mod map_with_enum_key_op_test {
|
1110 + | mod escaped_string_values_test {
|
1162 1111 |
|
1163 - | /// Test ID: MapWithEnumKeyRequest
|
1112 + | /// Test ID: EscapedStringValuesRequest
|
1164 1113 | #[::tokio::test]
|
1165 1114 | #[::tracing_test::traced_test]
|
1166 - | async fn map_with_enum_key_request_request() {
|
1115 + | async fn escaped_string_values_request_request() {
|
1167 1116 | #[allow(unused_mut)]
|
1168 1117 | let mut http_request = ::http::Request::builder()
|
1169 - | .uri("/map-with-enum-key")
|
1118 + | .uri("/escaped-string-values")
|
1170 1119 | .method("POST")
|
1171 1120 | .header("Content-Type", "application/json")
|
1172 1121 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1173 1122 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1174 - | "{\"map\":{\"enumvalue\":\"something\"}}".as_bytes(),
|
1123 + | "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}".as_bytes(),
|
1175 1124 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1176 1125 | )),
|
1177 1126 | ))
|
1178 1127 | .unwrap();
|
1179 1128 | #[allow(unused_mut)]
|
1180 1129 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1181 1130 | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
1182 1131 | let service =
|
1183 1132 | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
1184 - | .map_with_enum_key_op(move |input: crate::input::MapWithEnumKeyOpInput| {
|
1133 + | .escaped_string_values(move |input: crate::input::EscapedStringValuesInput| {
|
1185 1134 | let sender = sender.clone();
|
1186 1135 | async move {
|
1187 1136 | let result = {
|
1188 - | let expected = crate::input::MapWithEnumKeyOpInput {
|
1189 - | map: ::std::option::Option::Some({
|
1190 - | let mut ret = ::std::collections::HashMap::new();
|
1191 - | ret.insert(
|
1192 - | "enumvalue"
|
1193 - | .parse::<crate::model::StringEnum>()
|
1137 + | let expected = crate::input::EscapedStringValuesInput {
|
1138 + | r#enum: ::std::option::Option::Some(
|
1139 + | "has\"quotes"
|
1140 + | .parse::<crate::model::EnumWithEscapedChars>()
|
1194 1141 | .expect("static value validated to member"),
|
1195 - | "something".to_owned(),
|
1196 - | );
|
1197 - | ret
|
1198 - | }),
|
1142 + | ),
|
1143 + | some_string: ::std::option::Option::Some("test".to_owned()),
|
1199 1144 | };
|
1200 1145 | ::pretty_assertions::assert_eq!(input, expected);
|
1201 - | let output = crate::output::MapWithEnumKeyOpOutput {
|
1202 - | map: ::std::option::Option::None,
|
1146 + | let output = crate::output::EscapedStringValuesOutput {
|
1147 + | r#enum: ::std::option::Option::None,
|
1148 + | some_string: ::std::option::Option::None,
|
1203 1149 | };
|
1204 1150 | Ok(output)
|
1205 1151 | };
|
1206 1152 | sender.send(()).await.expect("receiver dropped early");
|
1207 1153 | result
|
1208 1154 | }
|
1209 1155 | })
|
1210 1156 | .build_unchecked();
|
1211 1157 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1212 1158 | .await
|
1213 1159 | .expect("unable to make an HTTP request");
|
1214 1160 | assert!(
|
1215 1161 | receiver.recv().await.is_some(),
|
1216 1162 | "we expected operation handler to be invoked but it was not entered"
|
1217 1163 | );
|
1218 1164 | }
|
1219 - | /// Test ID: MapWithEnumKeyResponse
|
1165 + | /// Test ID: EscapedStringValuesResponse
|
1220 1166 | #[::tokio::test]
|
1221 1167 | #[::tracing_test::traced_test]
|
1222 - | async fn map_with_enum_key_response_response() {
|
1223 - | let output = crate::output::MapWithEnumKeyOpOutput {
|
1224 - | map: ::std::option::Option::Some({
|
1225 - | let mut ret = ::std::collections::HashMap::new();
|
1226 - | ret.insert(
|
1227 - | "enumvalue"
|
1228 - | .parse::<crate::model::StringEnum>()
|
1168 + | async fn escaped_string_values_response_response() {
|
1169 + | let output = crate::output::EscapedStringValuesOutput {
|
1170 + | r#enum: ::std::option::Option::Some(
|
1171 + | "has\"quotes"
|
1172 + | .parse::<crate::model::EnumWithEscapedChars>()
|
1229 1173 | .expect("static value validated to member"),
|
1230 - | "something".to_owned(),
|
1231 - | );
|
1232 - | ret
|
1233 - | }),
|
1174 + | ),
|
1175 + | some_string: ::std::option::Option::Some("test".to_owned()),
|
1234 1176 | };
|
1235 1177 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1236 1178 | let http_response = output.into_response();
|
1237 1179 | ::pretty_assertions::assert_eq!(
|
1238 1180 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1239 1181 | http_response.status()
|
1240 1182 | );
|
1241 1183 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1242 1184 | .await
|
1243 1185 | .expect("unable to extract body to bytes");
|
1244 1186 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1245 1187 | &body,
|
1246 - | "{\"map\":{\"enumvalue\":\"something\"}}",
|
1188 + | "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}",
|
1247 1189 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1248 1190 | ));
|
1249 1191 | }
|
1250 1192 |
|
1251 1193 | /// Upper case error modeled lower case.
|
1252 1194 | /// Test ID: ServiceLevelErrorServer
|
1253 1195 | #[::tokio::test]
|
1254 1196 | #[::tracing_test::traced_test]
|
1255 1197 | async fn service_level_error_server_response() {
|
1256 1198 | let output = crate::error::ExtraError {};
|
1257 - | let output = crate::error::MapWithEnumKeyOpError::ExtraError(output);
|
1199 + | let output = crate::error::EscapedStringValuesError::ExtraError(output);
|
1258 1200 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1259 1201 | let http_response = output.into_response();
|
1260 1202 | ::pretty_assertions::assert_eq!(
|
1261 1203 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1262 1204 | http_response.status()
|
1263 1205 | );
|
1264 1206 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1265 1207 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1266 1208 | http_response.headers(),
|
1267 1209 | expected_headers,
|
1268 1210 | ));
|
1269 1211 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1270 1212 | .await
|
1271 1213 | .expect("unable to extract body to bytes");
|
1272 1214 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1273 1215 | &body,
|
1274 1216 | "{}",
|
1275 1217 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1276 1218 | ));
|
1277 1219 | }
|
1278 1220 | }
|
1279 1221 |
|
1280 1222 | ::pin_project_lite::pin_project! {
|
1281 1223 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1282 - | /// [`StatusResponseInput`](crate::input::StatusResponseInput) using modelled bindings.
|
1283 - | pub struct StatusResponseInputFuture {
|
1284 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StatusResponseInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1224 + | /// [`NullInNonSparseInput`](crate::input::NullInNonSparseInput) using modelled bindings.
|
1225 + | pub struct NullInNonSparseInputFuture {
|
1226 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NullInNonSparseInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1285 1227 | }
|
1286 1228 | }
|
1287 1229 |
|
1288 - | impl std::future::Future for StatusResponseInputFuture {
|
1230 + | impl std::future::Future for NullInNonSparseInputFuture {
|
1289 1231 | type Output = Result<
|
1290 - | crate::input::StatusResponseInput,
|
1232 + | crate::input::NullInNonSparseInput,
|
1291 1233 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1292 1234 | >;
|
1293 1235 |
|
1294 1236 | fn poll(
|
1295 1237 | self: std::pin::Pin<&mut Self>,
|
1296 1238 | cx: &mut std::task::Context<'_>,
|
1297 1239 | ) -> std::task::Poll<Self::Output> {
|
1298 1240 | let this = self.project();
|
1299 1241 | this.inner.as_mut().poll(cx)
|
1300 1242 | }
|
1301 1243 | }
|
1302 1244 |
|
1303 1245 | impl<B>
|
1304 1246 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1305 1247 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1306 1248 | B,
|
1307 - | > for crate::input::StatusResponseInput
|
1249 + | > for crate::input::NullInNonSparseInput
|
1308 1250 | where
|
1309 1251 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1310 1252 | B: 'static,
|
1311 1253 |
|
1312 1254 | B::Data: Send,
|
1313 1255 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1314 1256 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1315 1257 | {
|
1316 1258 | type Rejection =
|
1317 1259 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1318 - | type Future = StatusResponseInputFuture;
|
1260 + | type Future = NullInNonSparseInputFuture;
|
1319 1261 |
|
1320 1262 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1321 1263 | let fut = async move {
|
1322 1264 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1323 1265 | request.headers(),
|
1324 1266 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1325 1267 | ) {
|
1326 1268 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1327 1269 | }
|
1328 - | crate::protocol_serde::shape_status_response::de_status_response_http_request(request)
|
1270 + | crate::protocol_serde::shape_null_in_non_sparse::de_null_in_non_sparse_http_request(
|
1271 + | request,
|
1272 + | )
|
1329 1273 | .await
|
1330 1274 | };
|
1331 1275 | use ::futures_util::future::TryFutureExt;
|
1332 1276 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1333 1277 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1334 1278 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1335 1279 | });
|
1336 - | StatusResponseInputFuture {
|
1280 + | NullInNonSparseInputFuture {
|
1337 1281 | inner: Box::pin(fut),
|
1338 1282 | }
|
1339 1283 | }
|
1340 1284 | }
|
1341 1285 | impl
|
1342 1286 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1343 1287 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1344 - | > for crate::output::StatusResponseOutput
|
1288 + | > for crate::output::NullInNonSparseOutput
|
1345 1289 | {
|
1346 1290 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1347 - | match crate::protocol_serde::shape_status_response::ser_status_response_http_response(self)
|
1348 - | {
|
1291 + | match crate::protocol_serde::shape_null_in_non_sparse::ser_null_in_non_sparse_http_response(
|
1292 + | self,
|
1293 + | ) {
|
1349 1294 | Ok(response) => response,
|
1350 1295 | Err(e) => {
|
1351 1296 | ::tracing::error!(error = %e, "failed to serialize response");
|
1352 1297 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1353 1298 | }
|
1354 1299 | }
|
1355 1300 | }
|
1356 1301 | }
|
1357 1302 | impl
|
1358 1303 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1359 1304 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1360 - | > for crate::error::StatusResponseError
|
1305 + | > for crate::error::NullInNonSparseError
|
1361 1306 | {
|
1362 1307 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1363 - | match crate::protocol_serde::shape_status_response::ser_status_response_http_error(&self) {
|
1308 + | match crate::protocol_serde::shape_null_in_non_sparse::ser_null_in_non_sparse_http_error(
|
1309 + | &self,
|
1310 + | ) {
|
1364 1311 | Ok(mut response) => {
|
1365 1312 | response.extensions_mut().insert(
|
1366 1313 | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1367 1314 | self.name(),
|
1368 1315 | ),
|
1369 1316 | );
|
1370 1317 | response
|
1371 1318 | }
|
1372 1319 | Err(e) => {
|
1373 1320 | ::tracing::error!(error = %e, "failed to serialize response");
|
1374 1321 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1375 1322 | }
|
1376 1323 | }
|
1377 1324 | }
|
1378 1325 | }
|
1379 1326 |
|
1380 1327 | #[allow(unreachable_code, unused_variables)]
|
1381 1328 | #[cfg(test)]
|
1382 - | mod status_response_test {
|
1329 + | mod null_in_non_sparse_test {
|
1383 1330 |
|
1384 1331 | /// Upper case error modeled lower case.
|
1385 1332 | /// Test ID: ServiceLevelErrorServer
|
1386 1333 | #[::tokio::test]
|
1387 1334 | #[::tracing_test::traced_test]
|
1388 1335 | async fn service_level_error_server_response() {
|
1389 1336 | let output = crate::error::ExtraError {};
|
1390 - | let output = crate::error::StatusResponseError::ExtraError(output);
|
1337 + | let output = crate::error::NullInNonSparseError::ExtraError(output);
|
1391 1338 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1392 1339 | let http_response = output.into_response();
|
1393 1340 | ::pretty_assertions::assert_eq!(
|
1394 1341 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1395 1342 | http_response.status()
|
1396 1343 | );
|
1397 1344 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1398 1345 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1399 1346 | http_response.headers(),
|
1400 1347 | expected_headers,
|
1401 1348 | ));
|
1402 1349 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1403 1350 | .await
|
1404 1351 | .expect("unable to extract body to bytes");
|
1405 1352 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1406 1353 | &body,
|
1407 1354 | "{}",
|
1408 1355 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1409 1356 | ));
|
1410 1357 | }
|
1411 1358 | }
|
1412 1359 |
|
1413 1360 | ::pin_project_lite::pin_project! {
|
1414 1361 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1415 - | /// [`EnumQueryInput`](crate::input::EnumQueryInput) using modelled bindings.
|
1416 - | pub struct EnumQueryInputFuture {
|
1417 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EnumQueryInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1362 + | /// [`CaseInsensitiveErrorOperationInput`](crate::input::CaseInsensitiveErrorOperationInput) using modelled bindings.
|
1363 + | pub struct CaseInsensitiveErrorOperationInputFuture {
|
1364 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::CaseInsensitiveErrorOperationInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1418 1365 | }
|
1419 1366 | }
|
1420 1367 |
|
1421 - | impl std::future::Future for EnumQueryInputFuture {
|
1368 + | impl std::future::Future for CaseInsensitiveErrorOperationInputFuture {
|
1422 1369 | type Output = Result<
|
1423 - | crate::input::EnumQueryInput,
|
1370 + | crate::input::CaseInsensitiveErrorOperationInput,
|
1424 1371 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1425 1372 | >;
|
1426 1373 |
|
1427 1374 | fn poll(
|
1428 1375 | self: std::pin::Pin<&mut Self>,
|
1429 1376 | cx: &mut std::task::Context<'_>,
|
1430 1377 | ) -> std::task::Poll<Self::Output> {
|
1431 1378 | let this = self.project();
|
1432 1379 | this.inner.as_mut().poll(cx)
|
1433 1380 | }
|
1434 1381 | }
|
1435 1382 |
|
1436 1383 | impl<B>
|
1437 1384 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1438 1385 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1439 1386 | B,
|
1440 - | > for crate::input::EnumQueryInput
|
1387 + | > for crate::input::CaseInsensitiveErrorOperationInput
|
1441 1388 | where
|
1442 1389 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1443 1390 | B: 'static,
|
1444 1391 |
|
1445 1392 | B::Data: Send,
|
1446 1393 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1447 1394 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1448 1395 | {
|
1449 1396 | type Rejection =
|
1450 1397 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1451 - | type Future = EnumQueryInputFuture;
|
1398 + | type Future = CaseInsensitiveErrorOperationInputFuture;
|
1452 1399 |
|
1453 1400 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1454 1401 | let fut = async move {
|
1455 1402 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1456 1403 | request.headers(),
|
1457 1404 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1458 1405 | ) {
|
1459 1406 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1460 1407 | }
|
1461 - | crate::protocol_serde::shape_enum_query::de_enum_query_http_request(request).await
|
1408 + | crate::protocol_serde::shape_case_insensitive_error_operation::de_case_insensitive_error_operation_http_request(request)
|
1409 + | .await
|
1462 1410 | };
|
1463 1411 | use ::futures_util::future::TryFutureExt;
|
1464 1412 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1465 1413 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1466 1414 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1467 1415 | });
|
1468 - | EnumQueryInputFuture {
|
1416 + | CaseInsensitiveErrorOperationInputFuture {
|
1469 1417 | inner: Box::pin(fut),
|
1470 1418 | }
|
1471 1419 | }
|
1472 1420 | }
|
1473 1421 | impl
|
1474 1422 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1475 1423 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1476 - | > for crate::output::EnumQueryOutput
|
1424 + | > for crate::output::CaseInsensitiveErrorOperationOutput
|
1477 1425 | {
|
1478 1426 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1479 - | match crate::protocol_serde::shape_enum_query::ser_enum_query_http_response(self) {
|
1427 + | match crate::protocol_serde::shape_case_insensitive_error_operation::ser_case_insensitive_error_operation_http_response(self) {
|
1480 1428 | Ok(response) => response,
|
1481 1429 | Err(e) => {
|
1482 1430 | ::tracing::error!(error = %e, "failed to serialize response");
|
1483 1431 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1484 1432 | }
|
1485 1433 | }
|
1486 1434 | }
|
1487 1435 | }
|
1488 1436 | impl
|
1489 1437 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1490 1438 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1491 - | > for crate::error::EnumQueryError
|
1439 + | > for crate::error::CaseInsensitiveErrorOperationError
|
1492 1440 | {
|
1493 1441 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1494 - | match crate::protocol_serde::shape_enum_query::ser_enum_query_http_error(&self) {
|
1442 + | match crate::protocol_serde::shape_case_insensitive_error_operation::ser_case_insensitive_error_operation_http_error(&self) {
|
1495 1443 | Ok(mut response) => {
|
1496 - | response.extensions_mut().insert(
|
1497 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1498 - | self.name(),
|
1499 - | ),
|
1500 - | );
|
1444 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1501 1445 | response
|
1502 - | }
|
1446 + | },
|
1503 1447 | Err(e) => {
|
1504 1448 | ::tracing::error!(error = %e, "failed to serialize response");
|
1505 1449 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1506 1450 | }
|
1507 1451 | }
|
1508 1452 | }
|
1509 1453 | }
|
1510 1454 |
|
1511 1455 | #[allow(unreachable_code, unused_variables)]
|
1512 1456 | #[cfg(test)]
|
1513 - | mod enum_query_test {
|
1514 - |
|
1515 - | /// Test ID: EnumQueryRequest
|
1516 - | #[::tokio::test]
|
1517 - | #[::tracing_test::traced_test]
|
1518 - | async fn enum_query_request_request() {
|
1519 - | #[allow(unused_mut)]
|
1520 - | let mut http_request = ::http::Request::builder()
|
1521 - | .uri("/foo/enumvalue")
|
1522 - | .method("GET")
|
1523 - | .body(::aws_smithy_legacy_http_server::body::Body::empty())
|
1524 - | .unwrap();
|
1525 - | #[allow(unused_mut)]
|
1526 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1527 - | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
1528 - | let service =
|
1529 - | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
1530 - | .enum_query(move |input: crate::input::EnumQueryInput| {
|
1531 - | let sender = sender.clone();
|
1532 - | async move {
|
1533 - | let result = {
|
1534 - | let expected = crate::input::EnumQueryInput {
|
1535 - | r#enum: "enumvalue"
|
1536 - | .parse::<crate::model::StringEnum>()
|
1537 - | .expect("static value validated to member"),
|
1538 - | };
|
1539 - | ::pretty_assertions::assert_eq!(input, expected);
|
1540 - | let output = crate::output::EnumQueryOutput {};
|
1541 - | Ok(output)
|
1542 - | };
|
1543 - | sender.send(()).await.expect("receiver dropped early");
|
1544 - | result
|
1545 - | }
|
1546 - | })
|
1547 - | .build_unchecked();
|
1548 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1549 - | .await
|
1550 - | .expect("unable to make an HTTP request");
|
1551 - | assert!(
|
1552 - | receiver.recv().await.is_some(),
|
1553 - | "we expected operation handler to be invoked but it was not entered"
|
1554 - | );
|
1555 - | }
|
1457 + | mod case_insensitive_error_operation_test {
|
1556 1458 |
|
1557 1459 | /// Upper case error modeled lower case.
|
1558 1460 | /// Test ID: ServiceLevelErrorServer
|
1559 1461 | #[::tokio::test]
|
1560 1462 | #[::tracing_test::traced_test]
|
1561 1463 | async fn service_level_error_server_response() {
|
1562 1464 | let output = crate::error::ExtraError {};
|
1563 - | let output = crate::error::EnumQueryError::ExtraError(output);
|
1465 + | let output = crate::error::CaseInsensitiveErrorOperationError::ExtraError(output);
|
1564 1466 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1565 1467 | let http_response = output.into_response();
|
1566 1468 | ::pretty_assertions::assert_eq!(
|
1567 1469 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1568 1470 | http_response.status()
|
1569 1471 | );
|
1570 1472 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1571 1473 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1572 1474 | http_response.headers(),
|
1573 1475 | expected_headers,
|
1574 1476 | ));
|
1575 1477 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1576 1478 | .await
|
1577 1479 | .expect("unable to extract body to bytes");
|
1578 1480 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1579 1481 | &body,
|
1580 1482 | "{}",
|
1581 1483 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1582 1484 | ));
|
1583 1485 | }
|
1584 1486 | }
|
1585 1487 |
|
1586 1488 | ::pin_project_lite::pin_project! {
|
1587 1489 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1588 - | /// [`PrimitiveIntHeaderInput`](crate::input::PrimitiveIntHeaderInput) using modelled bindings.
|
1589 - | pub struct PrimitiveIntHeaderInputFuture {
|
1590 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::PrimitiveIntHeaderInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1490 + | /// [`EmptyStructWithContentOnWireOpInput`](crate::input::EmptyStructWithContentOnWireOpInput) using modelled bindings.
|
1491 + | pub struct EmptyStructWithContentOnWireOpInputFuture {
|
1492 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyStructWithContentOnWireOpInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1591 1493 | }
|
1592 1494 | }
|
1593 1495 |
|
1594 - | impl std::future::Future for PrimitiveIntHeaderInputFuture {
|
1496 + | impl std::future::Future for EmptyStructWithContentOnWireOpInputFuture {
|
1595 1497 | type Output = Result<
|
1596 - | crate::input::PrimitiveIntHeaderInput,
|
1498 + | crate::input::EmptyStructWithContentOnWireOpInput,
|
1597 1499 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1598 1500 | >;
|
1599 1501 |
|
1600 1502 | fn poll(
|
1601 1503 | self: std::pin::Pin<&mut Self>,
|
1602 1504 | cx: &mut std::task::Context<'_>,
|
1603 1505 | ) -> std::task::Poll<Self::Output> {
|
1604 1506 | let this = self.project();
|
1605 1507 | this.inner.as_mut().poll(cx)
|
1606 1508 | }
|
1607 1509 | }
|
1608 1510 |
|
1609 1511 | impl<B>
|
1610 1512 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1611 1513 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1612 1514 | B,
|
1613 - | > for crate::input::PrimitiveIntHeaderInput
|
1515 + | > for crate::input::EmptyStructWithContentOnWireOpInput
|
1614 1516 | where
|
1615 1517 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1616 1518 | B: 'static,
|
1617 1519 |
|
1618 1520 | B::Data: Send,
|
1619 1521 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1620 1522 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1621 1523 | {
|
1622 1524 | type Rejection =
|
1623 1525 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1624 - | type Future = PrimitiveIntHeaderInputFuture;
|
1526 + | type Future = EmptyStructWithContentOnWireOpInputFuture;
|
1625 1527 |
|
1626 1528 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1627 1529 | let fut = async move {
|
1628 1530 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1629 1531 | request.headers(),
|
1630 1532 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1631 1533 | ) {
|
1632 1534 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1633 1535 | }
|
1634 - | crate::protocol_serde::shape_primitive_int_header::de_primitive_int_header_http_request(
|
1635 - | request,
|
1636 - | )
|
1536 + | crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::de_empty_struct_with_content_on_wire_op_http_request(request)
|
1637 1537 | .await
|
1638 1538 | };
|
1639 1539 | use ::futures_util::future::TryFutureExt;
|
1640 1540 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1641 1541 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1642 1542 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1643 1543 | });
|
1644 - | PrimitiveIntHeaderInputFuture {
|
1544 + | EmptyStructWithContentOnWireOpInputFuture {
|
1645 1545 | inner: Box::pin(fut),
|
1646 1546 | }
|
1647 1547 | }
|
1648 1548 | }
|
1649 1549 | impl
|
1650 1550 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1651 1551 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1652 - | > for crate::output::PrimitiveIntHeaderOutput
|
1552 + | > for crate::output::EmptyStructWithContentOnWireOpOutput
|
1653 1553 | {
|
1654 1554 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1655 - | match crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_http_response(self) {
|
1555 + | match crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::ser_empty_struct_with_content_on_wire_op_http_response(self) {
|
1656 1556 | Ok(response) => response,
|
1657 1557 | Err(e) => {
|
1658 1558 | ::tracing::error!(error = %e, "failed to serialize response");
|
1659 1559 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1660 1560 | }
|
1661 1561 | }
|
1662 1562 | }
|
1663 1563 | }
|
1664 1564 | impl
|
1665 1565 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1666 1566 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1667 - | > for crate::error::PrimitiveIntHeaderError
|
1567 + | > for crate::error::EmptyStructWithContentOnWireOpError
|
1668 1568 | {
|
1669 1569 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1670 - | match crate::protocol_serde::shape_primitive_int_header::ser_primitive_int_header_http_error(
|
1671 - | &self,
|
1672 - | ) {
|
1570 + | match crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::ser_empty_struct_with_content_on_wire_op_http_error(&self) {
|
1673 1571 | Ok(mut response) => {
|
1674 - | response.extensions_mut().insert(
|
1675 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1676 - | self.name(),
|
1677 - | ),
|
1678 - | );
|
1572 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1679 1573 | response
|
1680 - | }
|
1574 + | },
|
1681 1575 | Err(e) => {
|
1682 1576 | ::tracing::error!(error = %e, "failed to serialize response");
|
1683 1577 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1684 1578 | }
|
1685 1579 | }
|
1686 1580 | }
|
1687 1581 | }
|
1688 1582 |
|
1689 1583 | #[allow(unreachable_code, unused_variables)]
|
1690 1584 | #[cfg(test)]
|
1691 - | mod primitive_int_header_test {
|
1692 - |
|
1693 - | /// Test ID: DeserPrimitiveHeader
|
1694 - | #[::tokio::test]
|
1695 - | #[::tracing_test::traced_test]
|
1696 - | async fn deser_primitive_header_response() {
|
1697 - | let output = crate::output::PrimitiveIntHeaderOutput { field: 123 };
|
1698 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1699 - | let http_response = output.into_response();
|
1700 - | ::pretty_assertions::assert_eq!(
|
1701 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1702 - | http_response.status()
|
1703 - | );
|
1704 - | let expected_headers = [("x-field", "123")];
|
1705 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1706 - | http_response.headers(),
|
1707 - | expected_headers,
|
1708 - | ));
|
1709 - | }
|
1710 - | /// Test ID: DeserPrimitiveHeaderMissing
|
1711 - | #[::tokio::test]
|
1712 - | #[::tracing_test::traced_test]
|
1713 - | async fn deser_primitive_header_missing_response() {
|
1714 - | let output = crate::output::PrimitiveIntHeaderOutput { field: 0 };
|
1715 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1716 - | let http_response = output.into_response();
|
1717 - | ::pretty_assertions::assert_eq!(
|
1718 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1719 - | http_response.status()
|
1720 - | );
|
1721 - | }
|
1585 + | mod empty_struct_with_content_on_wire_op_test {
|
1722 1586 |
|
1723 1587 | /// Upper case error modeled lower case.
|
1724 1588 | /// Test ID: ServiceLevelErrorServer
|
1725 1589 | #[::tokio::test]
|
1726 1590 | #[::tracing_test::traced_test]
|
1727 1591 | async fn service_level_error_server_response() {
|
1728 1592 | let output = crate::error::ExtraError {};
|
1729 - | let output = crate::error::PrimitiveIntHeaderError::ExtraError(output);
|
1593 + | let output = crate::error::EmptyStructWithContentOnWireOpError::ExtraError(output);
|
1730 1594 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1731 1595 | let http_response = output.into_response();
|
1732 1596 | ::pretty_assertions::assert_eq!(
|
1733 1597 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1734 1598 | http_response.status()
|
1735 1599 | );
|
1736 1600 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1737 1601 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1738 1602 | http_response.headers(),
|
1739 1603 | expected_headers,
|
1740 1604 | ));
|
1741 1605 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1742 1606 | .await
|
1743 1607 | .expect("unable to extract body to bytes");
|
1744 1608 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1745 1609 | &body,
|
1746 1610 | "{}",
|
1747 1611 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1748 1612 | ));
|
1749 1613 | }
|
1750 1614 | }
|
1751 1615 |
|
1752 1616 | ::pin_project_lite::pin_project! {
|
1753 1617 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1754 - | /// [`StringPayloadInput`](crate::input::StringPayloadInput) using modelled bindings.
|
1755 - | pub struct StringPayloadInputFuture {
|
1756 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::StringPayloadInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1618 + | /// [`QueryPrecedenceInput`](crate::input::QueryPrecedenceInput) using modelled bindings.
|
1619 + | pub struct QueryPrecedenceInputFuture {
|
1620 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::QueryPrecedenceInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1757 1621 | }
|
1758 1622 | }
|
1759 1623 |
|
1760 - | impl std::future::Future for StringPayloadInputFuture {
|
1624 + | impl std::future::Future for QueryPrecedenceInputFuture {
|
1761 1625 | type Output = Result<
|
1762 - | crate::input::StringPayloadInput,
|
1626 + | crate::input::QueryPrecedenceInput,
|
1763 1627 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1764 1628 | >;
|
1765 1629 |
|
1766 1630 | fn poll(
|
1767 1631 | self: std::pin::Pin<&mut Self>,
|
1768 1632 | cx: &mut std::task::Context<'_>,
|
1769 1633 | ) -> std::task::Poll<Self::Output> {
|
1770 1634 | let this = self.project();
|
1771 1635 | this.inner.as_mut().poll(cx)
|
1772 1636 | }
|
1773 1637 | }
|
1774 1638 |
|
1775 1639 | impl<B>
|
1776 1640 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1777 1641 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1778 1642 | B,
|
1779 - | > for crate::input::StringPayloadInput
|
1643 + | > for crate::input::QueryPrecedenceInput
|
1780 1644 | where
|
1781 1645 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1782 1646 | B: 'static,
|
1783 1647 |
|
1784 1648 | B::Data: Send,
|
1785 1649 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1786 1650 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1787 1651 | {
|
1788 1652 | type Rejection =
|
1789 1653 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1790 - | type Future = StringPayloadInputFuture;
|
1654 + | type Future = QueryPrecedenceInputFuture;
|
1791 1655 |
|
1792 1656 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1793 1657 | let fut = async move {
|
1794 1658 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1795 1659 | request.headers(),
|
1796 - | &crate::mimes::CONTENT_TYPE_TEXT_PLAIN,
|
1660 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1797 1661 | ) {
|
1798 1662 | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1799 1663 | }
|
1800 - | crate::protocol_serde::shape_string_payload::de_string_payload_http_request(request)
|
1664 + | crate::protocol_serde::shape_query_precedence::de_query_precedence_http_request(request)
|
1801 1665 | .await
|
1802 1666 | };
|
1803 1667 | use ::futures_util::future::TryFutureExt;
|
1804 1668 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1805 1669 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1806 1670 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1807 1671 | });
|
1808 - | StringPayloadInputFuture {
|
1672 + | QueryPrecedenceInputFuture {
|
1809 1673 | inner: Box::pin(fut),
|
1810 1674 | }
|
1811 1675 | }
|
1812 1676 | }
|
1813 1677 | impl
|
1814 1678 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1815 1679 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1816 - | > for crate::output::StringPayloadOutput
|
1680 + | > for crate::output::QueryPrecedenceOutput
|
1817 1681 | {
|
1818 1682 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1819 - | match crate::protocol_serde::shape_string_payload::ser_string_payload_http_response(self) {
|
1683 + | match crate::protocol_serde::shape_query_precedence::ser_query_precedence_http_response(
|
1684 + | self,
|
1685 + | ) {
|
1820 1686 | Ok(response) => response,
|
1821 1687 | Err(e) => {
|
1822 1688 | ::tracing::error!(error = %e, "failed to serialize response");
|
1823 1689 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1824 1690 | }
|
1825 1691 | }
|
1826 1692 | }
|
1827 1693 | }
|
1828 1694 | impl
|
1829 1695 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1830 1696 | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1831 - | > for crate::error::StringPayloadError
|
1697 + | > for crate::error::QueryPrecedenceError
|
1832 1698 | {
|
1833 1699 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1834 - | match crate::protocol_serde::shape_string_payload::ser_string_payload_http_error(&self) {
|
1700 + | match crate::protocol_serde::shape_query_precedence::ser_query_precedence_http_error(&self)
|
1701 + | {
|
1835 1702 | Ok(mut response) => {
|
1836 1703 | response.extensions_mut().insert(
|
1837 1704 | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1838 1705 | self.name(),
|
1839 1706 | ),
|
1840 1707 | );
|
1841 1708 | response
|
1842 1709 | }
|
1843 1710 | Err(e) => {
|
1844 1711 | ::tracing::error!(error = %e, "failed to serialize response");
|
1845 1712 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1846 1713 | }
|
1847 1714 | }
|
1848 1715 | }
|
1849 1716 | }
|
1850 1717 |
|
1851 1718 | #[allow(unreachable_code, unused_variables)]
|
1852 1719 | #[cfg(test)]
|
1853 - | mod string_payload_test {
|
1720 + | mod query_precedence_test {
|
1854 1721 |
|
1855 - | /// Test ID: StringPayload
|
1722 + | /// Servers put all query params in map
|
1723 + | /// Test ID: RestJsonServersPutAllQueryParamsInMap
|
1856 1724 | #[::tokio::test]
|
1857 1725 | #[::tracing_test::traced_test]
|
1858 - | async fn string_payload_request() {
|
1726 + | async fn rest_json_servers_put_all_query_params_in_map_request() {
|
1859 1727 | #[allow(unused_mut)]
|
1860 1728 | let mut http_request = ::http::Request::builder()
|
1861 - | .uri("/StringPayload")
|
1729 + | .uri("/Precedence")
|
1862 1730 | .method("POST")
|
1863 - | .header("Content-Type", "text/plain")
|
1864 1731 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1865 1732 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1866 - | "rawstring".as_bytes(),
|
1733 + | "".as_bytes(),
|
1867 1734 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1868 1735 | )),
|
1869 1736 | ))
|
1870 1737 | .unwrap();
|
1738 + | *http_request.uri_mut() = "/Precedence?bar=named&qux=fromMap".parse().unwrap();
|
1871 1739 | #[allow(unused_mut)]
|
1872 1740 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1873 1741 | let config = crate::service::RestJsonExtrasConfig::builder().build();
|
1874 1742 | let service =
|
1875 1743 | crate::service::RestJsonExtras::builder::<::hyper::body::Body, _, _, _>(config)
|
1876 - | .string_payload(move |input: crate::input::StringPayloadInput| {
|
1744 + | .query_precedence(move |input: crate::input::QueryPrecedenceInput| {
|
1877 1745 | let sender = sender.clone();
|
1878 1746 | async move {
|
1879 1747 | let result = {
|
1880 - | let expected = crate::input::StringPayloadInput {
|
1881 - | payload: ::std::option::Option::Some("rawstring".to_owned()),
|
1748 + | let expected = crate::input::QueryPrecedenceInput {
|
1749 + | foo: ::std::option::Option::Some("named".to_owned()),
|
1750 + | baz: ::std::option::Option::Some({
|
1751 + | let mut ret = ::std::collections::HashMap::new();
|
1752 + | ret.insert("bar".to_owned(), "named".to_owned());
|
1753 + | ret.insert("qux".to_owned(), "fromMap".to_owned());
|
1754 + | ret
|
1755 + | }),
|
1882 1756 | };
|
1883 1757 | ::pretty_assertions::assert_eq!(input, expected);
|
1884 - | let output = crate::output::StringPayloadOutput {
|
1885 - | payload: ::std::option::Option::None,
|
1886 - | };
|
1758 + | let output = crate::output::QueryPrecedenceOutput {};
|
1887 1759 | Ok(output)
|
1888 1760 | };
|
1889 1761 | sender.send(()).await.expect("receiver dropped early");
|
1890 1762 | result
|
1891 1763 | }
|
1892 1764 | })
|
1893 1765 | .build_unchecked();
|
1894 1766 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1895 1767 | .await
|
1896 1768 | .expect("unable to make an HTTP request");
|
1897 1769 | assert!(
|
1898 1770 | receiver.recv().await.is_some(),
|
1899 1771 | "we expected operation handler to be invoked but it was not entered"
|
1900 1772 | );
|
1901 1773 | }
|
1902 1774 |
|
1903 1775 | /// Upper case error modeled lower case.
|
1904 1776 | /// Test ID: ServiceLevelErrorServer
|
1905 1777 | #[::tokio::test]
|
1906 1778 | #[::tracing_test::traced_test]
|
1907 1779 | async fn service_level_error_server_response() {
|
1908 1780 | let output = crate::error::ExtraError {};
|
1909 - | let output = crate::error::StringPayloadError::ExtraError(output);
|
1781 + | let output = crate::error::QueryPrecedenceError::ExtraError(output);
|
1910 1782 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1911 1783 | let http_response = output.into_response();
|
1912 1784 | ::pretty_assertions::assert_eq!(
|
1913 1785 | ::http::StatusCode::from_u16(500).expect("invalid expected HTTP status code"),
|
1914 1786 | http_response.status()
|
1915 1787 | );
|
1916 1788 | let expected_headers = [("X-Amzn-Errortype", "ExtraError")];
|
1917 1789 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1918 1790 | http_response.headers(),
|
1919 1791 | expected_headers,
|