124 128 | crate::operation::json_unions::JsonUnionsError,
|
125 129 | >::new());
|
126 130 |
|
127 131 | ::std::borrow::Cow::Owned(rcb)
|
128 132 | }
|
129 133 | }
|
130 134 |
|
131 135 | #[derive(Debug)]
|
132 136 | struct JsonUnionsResponseDeserializer;
|
133 137 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for JsonUnionsResponseDeserializer {
|
134 - | fn deserialize_nonstreaming(
|
138 + | fn deserialize_nonstreaming_with_config(
|
135 139 | &self,
|
136 140 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
141 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
137 142 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
138 143 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
144 + | #[allow(unused_mut)]
|
145 + | let mut force_error = false;
|
146 + |
|
147 + | if !success && status != 200 || force_error {
|
139 148 | let headers = response.headers();
|
140 149 | let body = response.body().bytes().expect("body loaded");
|
141 150 | #[allow(unused_mut)]
|
142 - | let mut force_error = false;
|
151 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
152 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
153 + | })?;
|
143 154 |
|
144 - | let parse_result = if !success && status != 200 || force_error {
|
145 - | crate::protocol_serde::shape_json_unions::de_json_unions_http_error(status, headers, body)
|
155 + | let generic = generic_builder.build();
|
156 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
157 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(crate::operation::json_unions::JsonUnionsError::generic(
|
158 + | generic,
|
159 + | )),
|
160 + | ))
|
146 161 | } else {
|
147 - | crate::protocol_serde::shape_json_unions::de_json_unions_http_response(status, headers, body)
|
148 - | };
|
149 - | crate::protocol_serde::type_erase_result(parse_result)
|
162 + | let protocol = _cfg
|
163 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
164 + | .expect("a SharedClientProtocol is required");
|
165 + | let mut deser = protocol.deserialize_response(response, JsonUnions::OUTPUT_SCHEMA, _cfg).map_err(|e| {
|
166 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
167 + | })?;
|
168 + | let body = response.body().bytes().expect("body loaded");
|
169 + | let output = crate::operation::json_unions::JsonUnionsOutput::deserialize_with_response(
|
170 + | &mut *deser,
|
171 + | response.headers(),
|
172 + | response.status().into(),
|
173 + | body,
|
174 + | )
|
175 + | .map_err(|e| {
|
176 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
177 + | })?;
|
178 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
179 + | }
|
150 180 | }
|
151 181 | }
|
152 182 | #[derive(Debug)]
|
153 183 | struct JsonUnionsRequestSerializer;
|
154 184 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for JsonUnionsRequestSerializer {
|
155 185 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
156 186 | fn serialize_input(
|
157 187 | &self,
|
158 188 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
159 189 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
160 190 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
161 191 | let input = input.downcast::<crate::operation::json_unions::JsonUnionsInput>().expect("correct type");
|
162 - | let _header_serialization_settings = _cfg
|
163 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
164 - | .cloned()
|
165 - | .unwrap_or_default();
|
166 - | let mut request_builder = {
|
167 - | #[allow(clippy::uninlined_format_args)]
|
168 - | fn uri_base(
|
169 - | _input: &crate::operation::json_unions::JsonUnionsInput,
|
170 - | output: &mut ::std::string::String,
|
171 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
172 - | use ::std::fmt::Write as _;
|
173 - | ::std::write!(output, "/").expect("formatting should succeed");
|
174 - | ::std::result::Result::Ok(())
|
175 - | }
|
176 - | #[allow(clippy::unnecessary_wraps)]
|
177 - | fn update_http_builder(
|
178 - | input: &crate::operation::json_unions::JsonUnionsInput,
|
179 - | builder: ::http_1x::request::Builder,
|
180 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
181 - | let mut uri = ::std::string::String::new();
|
182 - | uri_base(input, &mut uri)?;
|
183 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
184 - | }
|
185 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
186 - | builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.1");
|
187 - | builder = _header_serialization_settings.set_default_header(
|
188 - | builder,
|
189 - | ::http_1x::header::HeaderName::from_static("x-amz-target"),
|
190 - | "JsonProtocol.JsonUnions",
|
191 - | );
|
192 - | builder
|
193 - | };
|
194 - | let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_json_unions::ser_json_unions_input(&input)?);
|
195 - | if let Some(content_length) = body.content_length() {
|
196 - | let content_length = content_length.to_string();
|
197 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
198 - | }
|
199 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
192 + | let protocol = _cfg
|
193 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
194 + | .expect("a SharedClientProtocol is required");
|
195 + | let mut request = protocol
|
196 + | .serialize_request(&input, JsonUnions::INPUT_SCHEMA, "", _cfg)
|
197 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
198 + |
|
199 + | return ::std::result::Result::Ok(request);
|
200 200 | }
|
201 201 | }
|
202 202 | #[derive(Debug)]
|
203 203 | struct JsonUnionsEndpointParamsInterceptor;
|
204 204 |
|
205 205 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for JsonUnionsEndpointParamsInterceptor {
|
206 206 | fn name(&self) -> &'static str {
|
207 207 | "JsonUnionsEndpointParamsInterceptor"
|
208 208 | }
|
209 209 |
|
617 617 | .expect("the config must have a deserializer");
|
618 618 |
|
619 619 | let parsed = de.deserialize_streaming(&mut http_response);
|
620 620 | let parsed = parsed.unwrap_or_else(|| {
|
621 621 | let http_response = http_response.map(|body| {
|
622 622 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
623 623 | body.bytes().unwrap(),
|
624 624 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
625 625 | )))
|
626 626 | });
|
627 - | de.deserialize_nonstreaming(&http_response)
|
627 + | // Build a config bag with the protocol for schema-based deserialization
|
628 + | #[allow(unused_mut)]
|
629 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
630 + | {
|
631 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
632 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
633 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
634 + | ));
|
635 + | test_cfg.push_shared_layer(layer.freeze());
|
636 + | }
|
637 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
628 638 | });
|
629 639 | let parsed = parsed
|
630 640 | .expect("should be successful response")
|
631 641 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
632 642 | .unwrap();
|
633 643 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
634 644 | }
|
635 645 |
|
636 646 | /// Deserializes a boolean union value
|
637 647 | /// Test ID: AwsJson11DeserializeBooleanUnionValue
|
638 648 | #[::tokio::test]
|
639 649 | #[::tracing_test::traced_test]
|
640 650 | async fn aws_json11_deserialize_boolean_union_value_response() {
|
641 651 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
642 652 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::BooleanValue(true)))
|
643 653 | .build();
|
644 654 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
645 655 | ::http_1x::response::Builder::new()
|
646 656 | .header("Content-Type", "application/x-amz-json-1.1")
|
647 657 | .status(200)
|
648 658 | .body(::aws_smithy_types::body::SdkBody::from(
|
649 659 | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}",
|
650 660 | ))
|
651 661 | .unwrap(),
|
652 662 | )
|
653 663 | .unwrap();
|
654 664 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
655 665 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
656 666 |
|
657 667 | let op = crate::operation::json_unions::JsonUnions::new();
|
658 668 | let config = op.config().expect("the operation has config");
|
659 669 | let de = config
|
660 670 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
661 671 | .expect("the config must have a deserializer");
|
662 672 |
|
663 673 | let parsed = de.deserialize_streaming(&mut http_response);
|
664 674 | let parsed = parsed.unwrap_or_else(|| {
|
665 675 | let http_response = http_response.map(|body| {
|
666 676 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
667 677 | body.bytes().unwrap(),
|
668 678 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
669 679 | )))
|
670 680 | });
|
671 - | de.deserialize_nonstreaming(&http_response)
|
681 + | // Build a config bag with the protocol for schema-based deserialization
|
682 + | #[allow(unused_mut)]
|
683 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
684 + | {
|
685 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
686 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
687 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
688 + | ));
|
689 + | test_cfg.push_shared_layer(layer.freeze());
|
690 + | }
|
691 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
672 692 | });
|
673 693 | let parsed = parsed
|
674 694 | .expect("should be successful response")
|
675 695 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
676 696 | .unwrap();
|
677 697 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
678 698 | }
|
679 699 |
|
680 700 | /// Deserializes a number union value
|
681 701 | /// Test ID: AwsJson11DeserializeNumberUnionValue
|
682 702 | #[::tokio::test]
|
683 703 | #[::tracing_test::traced_test]
|
684 704 | async fn aws_json11_deserialize_number_union_value_response() {
|
685 705 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
686 706 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::NumberValue(1)))
|
687 707 | .build();
|
688 708 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
689 709 | ::http_1x::response::Builder::new()
|
690 710 | .header("Content-Type", "application/x-amz-json-1.1")
|
691 711 | .status(200)
|
692 712 | .body(::aws_smithy_types::body::SdkBody::from(
|
693 713 | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}",
|
694 714 | ))
|
695 715 | .unwrap(),
|
696 716 | )
|
697 717 | .unwrap();
|
698 718 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
699 719 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
700 720 |
|
701 721 | let op = crate::operation::json_unions::JsonUnions::new();
|
702 722 | let config = op.config().expect("the operation has config");
|
703 723 | let de = config
|
704 724 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
705 725 | .expect("the config must have a deserializer");
|
706 726 |
|
707 727 | let parsed = de.deserialize_streaming(&mut http_response);
|
708 728 | let parsed = parsed.unwrap_or_else(|| {
|
709 729 | let http_response = http_response.map(|body| {
|
710 730 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
711 731 | body.bytes().unwrap(),
|
712 732 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
713 733 | )))
|
714 734 | });
|
715 - | de.deserialize_nonstreaming(&http_response)
|
735 + | // Build a config bag with the protocol for schema-based deserialization
|
736 + | #[allow(unused_mut)]
|
737 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
738 + | {
|
739 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
740 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
741 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
742 + | ));
|
743 + | test_cfg.push_shared_layer(layer.freeze());
|
744 + | }
|
745 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
716 746 | });
|
717 747 | let parsed = parsed
|
718 748 | .expect("should be successful response")
|
719 749 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
720 750 | .unwrap();
|
721 751 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
722 752 | }
|
723 753 |
|
724 754 | /// Deserializes a blob union value
|
725 755 | /// Test ID: AwsJson11DeserializeBlobUnionValue
|
726 756 | #[::tokio::test]
|
727 757 | #[::tracing_test::traced_test]
|
728 758 | async fn aws_json11_deserialize_blob_union_value_response() {
|
729 759 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
730 760 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::BlobValue(
|
731 761 | ::aws_smithy_types::Blob::new("foo"),
|
732 762 | )))
|
733 763 | .build();
|
734 764 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
735 765 | ::http_1x::response::Builder::new()
|
736 766 | .header("Content-Type", "application/x-amz-json-1.1")
|
737 767 | .status(200)
|
738 768 | .body(::aws_smithy_types::body::SdkBody::from(
|
739 769 | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}",
|
740 770 | ))
|
741 771 | .unwrap(),
|
742 772 | )
|
743 773 | .unwrap();
|
744 774 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
745 775 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
746 776 |
|
747 777 | let op = crate::operation::json_unions::JsonUnions::new();
|
748 778 | let config = op.config().expect("the operation has config");
|
749 779 | let de = config
|
750 780 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
751 781 | .expect("the config must have a deserializer");
|
752 782 |
|
753 783 | let parsed = de.deserialize_streaming(&mut http_response);
|
754 784 | let parsed = parsed.unwrap_or_else(|| {
|
755 785 | let http_response = http_response.map(|body| {
|
756 786 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
757 787 | body.bytes().unwrap(),
|
758 788 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
759 789 | )))
|
760 790 | });
|
761 - | de.deserialize_nonstreaming(&http_response)
|
791 + | // Build a config bag with the protocol for schema-based deserialization
|
792 + | #[allow(unused_mut)]
|
793 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
794 + | {
|
795 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
796 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
797 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
798 + | ));
|
799 + | test_cfg.push_shared_layer(layer.freeze());
|
800 + | }
|
801 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
762 802 | });
|
763 803 | let parsed = parsed
|
764 804 | .expect("should be successful response")
|
765 805 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
766 806 | .unwrap();
|
767 807 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
768 808 | }
|
769 809 |
|
770 810 | /// Deserializes a timestamp union value
|
771 811 | /// Test ID: AwsJson11DeserializeTimestampUnionValue
|
772 812 | #[::tokio::test]
|
773 813 | #[::tracing_test::traced_test]
|
774 814 | async fn aws_json11_deserialize_timestamp_union_value_response() {
|
775 815 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
776 816 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::TimestampValue(
|
777 817 | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
778 818 | )))
|
779 819 | .build();
|
780 820 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
781 821 | ::http_1x::response::Builder::new()
|
782 822 | .header("Content-Type", "application/x-amz-json-1.1")
|
783 823 | .status(200)
|
784 824 | .body(::aws_smithy_types::body::SdkBody::from(
|
785 825 | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}",
|
786 826 | ))
|
787 827 | .unwrap(),
|
788 828 | )
|
789 829 | .unwrap();
|
790 830 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
791 831 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
792 832 |
|
793 833 | let op = crate::operation::json_unions::JsonUnions::new();
|
794 834 | let config = op.config().expect("the operation has config");
|
795 835 | let de = config
|
796 836 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
797 837 | .expect("the config must have a deserializer");
|
798 838 |
|
799 839 | let parsed = de.deserialize_streaming(&mut http_response);
|
800 840 | let parsed = parsed.unwrap_or_else(|| {
|
801 841 | let http_response = http_response.map(|body| {
|
802 842 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
803 843 | body.bytes().unwrap(),
|
804 844 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
805 845 | )))
|
806 846 | });
|
807 - | de.deserialize_nonstreaming(&http_response)
|
847 + | // Build a config bag with the protocol for schema-based deserialization
|
848 + | #[allow(unused_mut)]
|
849 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
850 + | {
|
851 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
852 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
853 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
854 + | ));
|
855 + | test_cfg.push_shared_layer(layer.freeze());
|
856 + | }
|
857 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
808 858 | });
|
809 859 | let parsed = parsed
|
810 860 | .expect("should be successful response")
|
811 861 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
812 862 | .unwrap();
|
813 863 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
814 864 | }
|
815 865 |
|
816 866 | /// Deserializes an enum union value
|
817 867 | /// Test ID: AwsJson11DeserializeEnumUnionValue
|
818 868 | #[::tokio::test]
|
819 869 | #[::tracing_test::traced_test]
|
820 870 | async fn aws_json11_deserialize_enum_union_value_response() {
|
821 871 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
822 872 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::EnumValue(
|
823 873 | "Foo".parse::<crate::types::FooEnum>().expect("static value validated to member"),
|
824 874 | )))
|
825 875 | .build();
|
826 876 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
827 877 | ::http_1x::response::Builder::new()
|
828 878 | .header("Content-Type", "application/x-amz-json-1.1")
|
829 879 | .status(200)
|
830 880 | .body(::aws_smithy_types::body::SdkBody::from(
|
831 881 | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}",
|
832 882 | ))
|
833 883 | .unwrap(),
|
834 884 | )
|
835 885 | .unwrap();
|
836 886 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
837 887 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
838 888 |
|
839 889 | let op = crate::operation::json_unions::JsonUnions::new();
|
840 890 | let config = op.config().expect("the operation has config");
|
841 891 | let de = config
|
842 892 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
843 893 | .expect("the config must have a deserializer");
|
844 894 |
|
845 895 | let parsed = de.deserialize_streaming(&mut http_response);
|
846 896 | let parsed = parsed.unwrap_or_else(|| {
|
847 897 | let http_response = http_response.map(|body| {
|
848 898 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
849 899 | body.bytes().unwrap(),
|
850 900 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
851 901 | )))
|
852 902 | });
|
853 - | de.deserialize_nonstreaming(&http_response)
|
903 + | // Build a config bag with the protocol for schema-based deserialization
|
904 + | #[allow(unused_mut)]
|
905 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
906 + | {
|
907 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
908 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
909 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
910 + | ));
|
911 + | test_cfg.push_shared_layer(layer.freeze());
|
912 + | }
|
913 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
854 914 | });
|
855 915 | let parsed = parsed
|
856 916 | .expect("should be successful response")
|
857 917 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
858 918 | .unwrap();
|
859 919 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
860 920 | }
|
861 921 |
|
862 922 | /// Deserializes a list union value
|
863 923 | /// Test ID: AwsJson11DeserializeListUnionValue
|
864 924 | #[::tokio::test]
|
865 925 | #[::tracing_test::traced_test]
|
866 926 | async fn aws_json11_deserialize_list_union_value_response() {
|
867 927 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
868 928 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::ListValue(vec![
|
869 929 | "foo".to_owned(),
|
870 930 | "bar".to_owned(),
|
871 931 | ])))
|
872 932 | .build();
|
873 933 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
874 934 | ::http_1x::response::Builder::new()
|
875 935 | .header("Content-Type", "application/x-amz-json-1.1")
|
876 936 | .status(200)
|
877 937 | .body(::aws_smithy_types::body::SdkBody::from(
|
878 938 | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}",
|
879 939 | ))
|
880 940 | .unwrap(),
|
881 941 | )
|
882 942 | .unwrap();
|
883 943 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
884 944 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
885 945 |
|
886 946 | let op = crate::operation::json_unions::JsonUnions::new();
|
887 947 | let config = op.config().expect("the operation has config");
|
888 948 | let de = config
|
889 949 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
890 950 | .expect("the config must have a deserializer");
|
891 951 |
|
892 952 | let parsed = de.deserialize_streaming(&mut http_response);
|
893 953 | let parsed = parsed.unwrap_or_else(|| {
|
894 954 | let http_response = http_response.map(|body| {
|
895 955 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
896 956 | body.bytes().unwrap(),
|
897 957 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
898 958 | )))
|
899 959 | });
|
900 - | de.deserialize_nonstreaming(&http_response)
|
960 + | // Build a config bag with the protocol for schema-based deserialization
|
961 + | #[allow(unused_mut)]
|
962 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
963 + | {
|
964 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
965 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
966 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
967 + | ));
|
968 + | test_cfg.push_shared_layer(layer.freeze());
|
969 + | }
|
970 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
901 971 | });
|
902 972 | let parsed = parsed
|
903 973 | .expect("should be successful response")
|
904 974 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
905 975 | .unwrap();
|
906 976 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
907 977 | }
|
908 978 |
|
909 979 | /// Deserializes a map union value
|
910 980 | /// Test ID: AwsJson11DeserializeMapUnionValue
|
911 981 | #[::tokio::test]
|
912 982 | #[::tracing_test::traced_test]
|
913 983 | async fn aws_json11_deserialize_map_union_value_response() {
|
914 984 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
915 985 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::MapValue({
|
916 986 | let mut ret = ::std::collections::HashMap::new();
|
917 987 | ret.insert("foo".to_owned(), "bar".to_owned());
|
918 988 | ret.insert("spam".to_owned(), "eggs".to_owned());
|
919 989 | ret
|
920 990 | })))
|
921 991 | .build();
|
922 992 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
923 993 | .header("Content-Type", "application/x-amz-json-1.1")
|
924 994 | .status(200)
|
925 995 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"contents\": {\n \"mapValue\": {\n \"foo\": \"bar\",\n \"spam\": \"eggs\"\n }\n }\n}"))
|
926 996 | .unwrap()
|
927 997 | ).unwrap();
|
928 998 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
929 999 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
930 1000 |
|
931 1001 | let op = crate::operation::json_unions::JsonUnions::new();
|
932 1002 | let config = op.config().expect("the operation has config");
|
933 1003 | let de = config
|
934 1004 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
935 1005 | .expect("the config must have a deserializer");
|
936 1006 |
|
937 1007 | let parsed = de.deserialize_streaming(&mut http_response);
|
938 1008 | let parsed = parsed.unwrap_or_else(|| {
|
939 1009 | let http_response = http_response.map(|body| {
|
940 1010 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
941 1011 | body.bytes().unwrap(),
|
942 1012 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
943 1013 | )))
|
944 1014 | });
|
945 - | de.deserialize_nonstreaming(&http_response)
|
1015 + | // Build a config bag with the protocol for schema-based deserialization
|
1016 + | #[allow(unused_mut)]
|
1017 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
1018 + | {
|
1019 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
1020 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
1021 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
1022 + | ));
|
1023 + | test_cfg.push_shared_layer(layer.freeze());
|
1024 + | }
|
1025 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
946 1026 | });
|
947 1027 | let parsed = parsed
|
948 1028 | .expect("should be successful response")
|
949 1029 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
950 1030 | .unwrap();
|
951 1031 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
952 1032 | }
|
953 1033 |
|
954 1034 | /// Deserializes a structure union value
|
955 1035 | /// Test ID: AwsJson11DeserializeStructureUnionValue
|
956 1036 | #[::tokio::test]
|
957 1037 | #[::tracing_test::traced_test]
|
958 1038 | async fn aws_json11_deserialize_structure_union_value_response() {
|
959 1039 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
960 1040 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::StructureValue(
|
961 1041 | crate::types::GreetingStruct::builder()
|
962 1042 | .set_hi(::std::option::Option::Some("hello".to_owned()))
|
963 1043 | .build(),
|
964 1044 | )))
|
965 1045 | .build();
|
966 1046 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
967 1047 | ::http_1x::response::Builder::new()
|
968 1048 | .header("Content-Type", "application/x-amz-json-1.1")
|
969 1049 | .status(200)
|
970 1050 | .body(::aws_smithy_types::body::SdkBody::from(
|
971 1051 | "{\n \"contents\": {\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}",
|
972 1052 | ))
|
973 1053 | .unwrap(),
|
974 1054 | )
|
975 1055 | .unwrap();
|
976 1056 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
977 1057 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
978 1058 |
|
979 1059 | let op = crate::operation::json_unions::JsonUnions::new();
|
980 1060 | let config = op.config().expect("the operation has config");
|
981 1061 | let de = config
|
982 1062 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
983 1063 | .expect("the config must have a deserializer");
|
984 1064 |
|
985 1065 | let parsed = de.deserialize_streaming(&mut http_response);
|
986 1066 | let parsed = parsed.unwrap_or_else(|| {
|
987 1067 | let http_response = http_response.map(|body| {
|
988 1068 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
989 1069 | body.bytes().unwrap(),
|
990 1070 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
991 1071 | )))
|
992 1072 | });
|
993 - | de.deserialize_nonstreaming(&http_response)
|
1073 + | // Build a config bag with the protocol for schema-based deserialization
|
1074 + | #[allow(unused_mut)]
|
1075 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
1076 + | {
|
1077 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
1078 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
1079 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
1080 + | ));
|
1081 + | test_cfg.push_shared_layer(layer.freeze());
|
1082 + | }
|
1083 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
994 1084 | });
|
995 1085 | let parsed = parsed
|
996 1086 | .expect("should be successful response")
|
997 1087 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
998 1088 | .unwrap();
|
999 1089 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
1000 1090 | }
|
1001 1091 |
|
1002 1092 | /// Ignores an unrecognized __type property
|
1003 1093 | /// Test ID: AwsJson11DeserializeIgnoreType
|
1004 1094 | #[::tokio::test]
|
1005 1095 | #[::tracing_test::traced_test]
|
1006 1096 | async fn aws_json11_deserialize_ignore_type_response() {
|
1007 1097 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
1008 1098 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::StructureValue(
|
1009 1099 | crate::types::GreetingStruct::builder()
|
1010 1100 | .set_hi(::std::option::Option::Some("hello".to_owned()))
|
1011 1101 | .build(),
|
1012 1102 | )))
|
1013 1103 | .build();
|
1014 1104 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
1015 1105 | .header("Content-Type", "application/x-amz-json-1.1")
|
1016 1106 | .status(200)
|
1017 1107 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"contents\": {\n \"__type\": \"aws.protocoltests.json10#MyUnion\",\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}"))
|
1018 1108 | .unwrap()
|
1019 1109 | ).unwrap();
|
1020 1110 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
1021 1111 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
1022 1112 |
|
1023 1113 | let op = crate::operation::json_unions::JsonUnions::new();
|
1024 1114 | let config = op.config().expect("the operation has config");
|
1025 1115 | let de = config
|
1026 1116 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
1027 1117 | .expect("the config must have a deserializer");
|
1028 1118 |
|
1029 1119 | let parsed = de.deserialize_streaming(&mut http_response);
|
1030 1120 | let parsed = parsed.unwrap_or_else(|| {
|
1031 1121 | let http_response = http_response.map(|body| {
|
1032 1122 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1033 1123 | body.bytes().unwrap(),
|
1034 1124 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1035 1125 | )))
|
1036 1126 | });
|
1037 - | de.deserialize_nonstreaming(&http_response)
|
1127 + | // Build a config bag with the protocol for schema-based deserialization
|
1128 + | #[allow(unused_mut)]
|
1129 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
1130 + | {
|
1131 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
1132 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
1133 + | ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_1("JsonProtocol"),
|
1134 + | ));
|
1135 + | test_cfg.push_shared_layer(layer.freeze());
|
1136 + | }
|
1137 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
1038 1138 | });
|
1039 1139 | let parsed = parsed
|
1040 1140 | .expect("should be successful response")
|
1041 1141 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
1042 1142 | .unwrap();
|
1043 1143 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
1044 1144 | }
|
1045 1145 | }
|
1046 1146 |
|
1047 1147 | /// Error type for the `JsonUnionsError` operation.
|