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