130 134 | crate::operation::simple_scalar_properties::SimpleScalarPropertiesError,
|
131 135 | >::new());
|
132 136 |
|
133 137 | ::std::borrow::Cow::Owned(rcb)
|
134 138 | }
|
135 139 | }
|
136 140 |
|
137 141 | #[derive(Debug)]
|
138 142 | struct SimpleScalarPropertiesResponseDeserializer;
|
139 143 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for SimpleScalarPropertiesResponseDeserializer {
|
140 - | fn deserialize_nonstreaming(
|
144 + | fn deserialize_nonstreaming_with_config(
|
141 145 | &self,
|
142 146 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
147 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
143 148 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
144 149 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
150 + | #[allow(unused_mut)]
|
151 + | let mut force_error = false;
|
152 + |
|
153 + | if !success && status != 200 || force_error {
|
145 154 | let headers = response.headers();
|
146 155 | let body = response.body().bytes().expect("body loaded");
|
147 156 | #[allow(unused_mut)]
|
148 - | let mut force_error = false;
|
157 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
158 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
159 + | })?;
|
149 160 |
|
150 - | let parse_result = if !success && status != 200 || force_error {
|
151 - | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_error(status, headers, body)
|
161 + | let generic = generic_builder.build();
|
162 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
163 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
|
164 + | crate::operation::simple_scalar_properties::SimpleScalarPropertiesError::generic(generic),
|
165 + | ),
|
166 + | ))
|
152 167 | } else {
|
153 - | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_response(status, headers, body)
|
154 - | };
|
155 - | crate::protocol_serde::type_erase_result(parse_result)
|
168 + | let protocol = _cfg
|
169 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
170 + | .expect("a SharedClientProtocol is required");
|
171 + | let mut deser = protocol
|
172 + | .deserialize_response(response, SimpleScalarProperties::OUTPUT_SCHEMA, _cfg)
|
173 + | .map_err(|e| {
|
174 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
175 + | })?;
|
176 + | let body = response.body().bytes().expect("body loaded");
|
177 + | let output = crate::operation::simple_scalar_properties::SimpleScalarPropertiesOutput::deserialize_with_response(
|
178 + | &mut *deser,
|
179 + | response.headers(),
|
180 + | response.status().into(),
|
181 + | body,
|
182 + | )
|
183 + | .map_err(|e| {
|
184 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
185 + | })?;
|
186 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
187 + | }
|
156 188 | }
|
157 189 | }
|
158 190 | #[derive(Debug)]
|
159 191 | struct SimpleScalarPropertiesRequestSerializer;
|
160 192 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for SimpleScalarPropertiesRequestSerializer {
|
161 193 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
162 194 | fn serialize_input(
|
163 195 | &self,
|
164 196 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
165 197 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
166 198 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
167 199 | let input = input
|
168 200 | .downcast::<crate::operation::simple_scalar_properties::SimpleScalarPropertiesInput>()
|
169 201 | .expect("correct type");
|
170 - | let _header_serialization_settings = _cfg
|
171 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
172 - | .cloned()
|
173 - | .unwrap_or_default();
|
174 - | let mut request_builder = {
|
175 - | #[allow(clippy::uninlined_format_args)]
|
176 - | fn uri_base(
|
177 - | _input: &crate::operation::simple_scalar_properties::SimpleScalarPropertiesInput,
|
178 - | output: &mut ::std::string::String,
|
179 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
180 - | use ::std::fmt::Write as _;
|
181 - | ::std::write!(output, "/").expect("formatting should succeed");
|
182 - | ::std::result::Result::Ok(())
|
183 - | }
|
184 - | #[allow(clippy::unnecessary_wraps)]
|
185 - | fn update_http_builder(
|
186 - | input: &crate::operation::simple_scalar_properties::SimpleScalarPropertiesInput,
|
187 - | builder: ::http_1x::request::Builder,
|
188 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
189 - | let mut uri = ::std::string::String::new();
|
190 - | uri_base(input, &mut uri)?;
|
191 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
192 - | }
|
193 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
194 - | builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.1");
|
195 - | builder = _header_serialization_settings.set_default_header(
|
196 - | builder,
|
197 - | ::http_1x::header::HeaderName::from_static("x-amz-target"),
|
198 - | "JsonProtocol.SimpleScalarProperties",
|
199 - | );
|
200 - | builder
|
201 - | };
|
202 - | let body = ::aws_smithy_types::body::SdkBody::from(
|
203 - | crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_input(&input)?,
|
204 - | );
|
205 - | if let Some(content_length) = body.content_length() {
|
206 - | let content_length = content_length.to_string();
|
207 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
208 - | }
|
209 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
202 + | let protocol = _cfg
|
203 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
204 + | .expect("a SharedClientProtocol is required");
|
205 + | let mut request = protocol
|
206 + | .serialize_request(&input, SimpleScalarProperties::INPUT_SCHEMA, "", _cfg)
|
207 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
208 + |
|
209 + | return ::std::result::Result::Ok(request);
|
210 210 | }
|
211 211 | }
|
212 212 | #[derive(Debug)]
|
213 213 | struct SimpleScalarPropertiesEndpointParamsInterceptor;
|
214 214 |
|
215 215 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for SimpleScalarPropertiesEndpointParamsInterceptor {
|
216 216 | fn name(&self) -> &'static str {
|
217 217 | "SimpleScalarPropertiesEndpointParamsInterceptor"
|
218 218 | }
|
219 219 |
|
408 408 | .expect("the config must have a deserializer");
|
409 409 |
|
410 410 | let parsed = de.deserialize_streaming(&mut http_response);
|
411 411 | let parsed = parsed.unwrap_or_else(|| {
|
412 412 | let http_response = http_response.map(|body| {
|
413 413 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
414 414 | body.bytes().unwrap(),
|
415 415 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
416 416 | )))
|
417 417 | });
|
418 - | de.deserialize_nonstreaming(&http_response)
|
418 + | // Build a config bag with the protocol for schema-based deserialization
|
419 + | #[allow(unused_mut)]
|
420 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
421 + | {
|
422 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
423 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
424 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
425 + | ));
|
426 + | test_cfg.push_shared_layer(layer.freeze());
|
427 + | }
|
428 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
419 429 | });
|
420 430 | let parsed = parsed
|
421 431 | .expect("should be successful response")
|
422 432 | .downcast::<crate::operation::simple_scalar_properties::SimpleScalarPropertiesOutput>()
|
423 433 | .unwrap();
|
424 434 | assert!(
|
425 435 | parsed.float_value.float_equals(&expected_output.float_value),
|
426 436 | "Unexpected value for `float_value` {:?} vs. {:?}",
|
427 437 | expected_output.float_value,
|
428 438 | parsed.float_value
|
429 439 | );
|
430 440 | assert!(
|
431 441 | parsed.double_value.float_equals(&expected_output.double_value),
|
432 442 | "Unexpected value for `double_value` {:?} vs. {:?}",
|
433 443 | expected_output.double_value,
|
434 444 | parsed.double_value
|
435 445 | );
|
436 446 | }
|
437 447 |
|
438 448 | /// Supports handling Infinity float values.
|
439 449 | /// Test ID: AwsJson11SupportsInfinityFloatInputs
|
440 450 | #[::tokio::test]
|
441 451 | #[::tracing_test::traced_test]
|
442 452 | async fn aws_json11_supports_infinity_float_inputs_response() {
|
443 453 | let expected_output = crate::operation::simple_scalar_properties::SimpleScalarPropertiesOutput::builder()
|
444 454 | .set_float_value(::std::option::Option::Some(
|
445 455 | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number"),
|
446 456 | ))
|
447 457 | .set_double_value(::std::option::Option::Some(
|
448 458 | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity").expect("invalid string for number"),
|
449 459 | ))
|
450 460 | .build();
|
451 461 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
452 462 | ::http_1x::response::Builder::new()
|
453 463 | .header("Content-Type", "application/x-amz-json-1.1")
|
454 464 | .status(200)
|
455 465 | .body(::aws_smithy_types::body::SdkBody::from(
|
456 466 | "{\n \"floatValue\": \"Infinity\",\n \"doubleValue\": \"Infinity\"\n}",
|
457 467 | ))
|
458 468 | .unwrap(),
|
459 469 | )
|
460 470 | .unwrap();
|
461 471 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
462 472 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
463 473 |
|
464 474 | let op = crate::operation::simple_scalar_properties::SimpleScalarProperties::new();
|
465 475 | let config = op.config().expect("the operation has config");
|
466 476 | let de = config
|
467 477 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
468 478 | .expect("the config must have a deserializer");
|
469 479 |
|
470 480 | let parsed = de.deserialize_streaming(&mut http_response);
|
471 481 | let parsed = parsed.unwrap_or_else(|| {
|
472 482 | let http_response = http_response.map(|body| {
|
473 483 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
474 484 | body.bytes().unwrap(),
|
475 485 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
476 486 | )))
|
477 487 | });
|
478 - | de.deserialize_nonstreaming(&http_response)
|
488 + | // Build a config bag with the protocol for schema-based deserialization
|
489 + | #[allow(unused_mut)]
|
490 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
491 + | {
|
492 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
493 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
494 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
495 + | ));
|
496 + | test_cfg.push_shared_layer(layer.freeze());
|
497 + | }
|
498 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
479 499 | });
|
480 500 | let parsed = parsed
|
481 501 | .expect("should be successful response")
|
482 502 | .downcast::<crate::operation::simple_scalar_properties::SimpleScalarPropertiesOutput>()
|
483 503 | .unwrap();
|
484 504 | assert!(
|
485 505 | parsed.float_value.float_equals(&expected_output.float_value),
|
486 506 | "Unexpected value for `float_value` {:?} vs. {:?}",
|
487 507 | expected_output.float_value,
|
488 508 | parsed.float_value
|
489 509 | );
|
490 510 | assert!(
|
491 511 | parsed.double_value.float_equals(&expected_output.double_value),
|
492 512 | "Unexpected value for `double_value` {:?} vs. {:?}",
|
493 513 | expected_output.double_value,
|
494 514 | parsed.double_value
|
495 515 | );
|
496 516 | }
|
497 517 |
|
498 518 | /// Supports handling -Infinity float values.
|
499 519 | /// Test ID: AwsJson11SupportsNegativeInfinityFloatInputs
|
500 520 | #[::tokio::test]
|
501 521 | #[::tracing_test::traced_test]
|
502 522 | async fn aws_json11_supports_negative_infinity_float_inputs_response() {
|
503 523 | let expected_output = crate::operation::simple_scalar_properties::SimpleScalarPropertiesOutput::builder()
|
504 524 | .set_float_value(::std::option::Option::Some(
|
505 525 | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number"),
|
506 526 | ))
|
507 527 | .set_double_value(::std::option::Option::Some(
|
508 528 | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity").expect("invalid string for number"),
|
509 529 | ))
|
510 530 | .build();
|
511 531 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
512 532 | ::http_1x::response::Builder::new()
|
513 533 | .header("Content-Type", "application/x-amz-json-1.1")
|
514 534 | .status(200)
|
515 535 | .body(::aws_smithy_types::body::SdkBody::from(
|
516 536 | "{\n \"floatValue\": \"-Infinity\",\n \"doubleValue\": \"-Infinity\"\n}",
|
517 537 | ))
|
518 538 | .unwrap(),
|
519 539 | )
|
520 540 | .unwrap();
|
521 541 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
522 542 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
523 543 |
|
524 544 | let op = crate::operation::simple_scalar_properties::SimpleScalarProperties::new();
|
525 545 | let config = op.config().expect("the operation has config");
|
526 546 | let de = config
|
527 547 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
528 548 | .expect("the config must have a deserializer");
|
529 549 |
|
530 550 | let parsed = de.deserialize_streaming(&mut http_response);
|
531 551 | let parsed = parsed.unwrap_or_else(|| {
|
532 552 | let http_response = http_response.map(|body| {
|
533 553 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
534 554 | body.bytes().unwrap(),
|
535 555 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
536 556 | )))
|
537 557 | });
|
538 - | de.deserialize_nonstreaming(&http_response)
|
558 + | // Build a config bag with the protocol for schema-based deserialization
|
559 + | #[allow(unused_mut)]
|
560 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
561 + | {
|
562 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
563 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
564 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
565 + | ));
|
566 + | test_cfg.push_shared_layer(layer.freeze());
|
567 + | }
|
568 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
539 569 | });
|
540 570 | let parsed = parsed
|
541 571 | .expect("should be successful response")
|
542 572 | .downcast::<crate::operation::simple_scalar_properties::SimpleScalarPropertiesOutput>()
|
543 573 | .unwrap();
|
544 574 | assert!(
|
545 575 | parsed.float_value.float_equals(&expected_output.float_value),
|
546 576 | "Unexpected value for `float_value` {:?} vs. {:?}",
|
547 577 | expected_output.float_value,
|
548 578 | parsed.float_value
|