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 138 | fn deserialize_nonstreaming(
|
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());
|
139 - | let headers = response.headers();
|
140 - | let body = response.body().bytes().expect("body loaded");
|
141 144 | #[allow(unused_mut)]
|
142 145 | let mut force_error = false;
|
143 146 |
|
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)
|
147 + | if !success && status != 200 || force_error {
|
148 + | let headers = response.headers();
|
149 + | let body = response.body().bytes().expect("body loaded");
|
150 + | #[allow(unused_mut)]
|
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 + | })?;
|
154 + |
|
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, "/JsonUnions").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("PUT").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/json");
|
187 - | builder
|
188 - | };
|
189 - | let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_json_unions::ser_json_unions_input(&input)?);
|
190 - | if let Some(content_length) = body.content_length() {
|
191 - | let content_length = content_length.to_string();
|
192 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
193 - | }
|
194 - | ::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);
|
195 200 | }
|
196 201 | }
|
197 202 | #[derive(Debug)]
|
198 203 | struct JsonUnionsEndpointParamsInterceptor;
|
199 204 |
|
200 205 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for JsonUnionsEndpointParamsInterceptor {
|
201 206 | fn name(&self) -> &'static str {
|
202 207 | "JsonUnionsEndpointParamsInterceptor"
|
203 208 | }
|
204 209 |
|
623 628 | .expect("the config must have a deserializer");
|
624 629 |
|
625 630 | let parsed = de.deserialize_streaming(&mut http_response);
|
626 631 | let parsed = parsed.unwrap_or_else(|| {
|
627 632 | let http_response = http_response.map(|body| {
|
628 633 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
629 634 | body.bytes().unwrap(),
|
630 635 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
631 636 | )))
|
632 637 | });
|
633 - | de.deserialize_nonstreaming(&http_response)
|
638 + | // Build a config bag with the protocol for schema-based deserialization
|
639 + | #[allow(unused_mut)]
|
640 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
641 + | {
|
642 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
643 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
644 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
645 + | ));
|
646 + | test_cfg.push_shared_layer(layer.freeze());
|
647 + | }
|
648 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
634 649 | });
|
635 650 | let parsed = parsed
|
636 651 | .expect("should be successful response")
|
637 652 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
638 653 | .unwrap();
|
639 654 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
640 655 | }
|
641 656 |
|
642 657 | /// Deserializes a boolean union value
|
643 658 | /// Test ID: RestJsonDeserializeBooleanUnionValue
|
644 659 | #[::tokio::test]
|
645 660 | #[::tracing_test::traced_test]
|
646 661 | async fn rest_json_deserialize_boolean_union_value_response() {
|
647 662 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
648 663 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::BooleanValue(true)))
|
649 664 | .build();
|
650 665 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
651 666 | ::http_1x::response::Builder::new()
|
652 667 | .header("Content-Type", "application/json")
|
653 668 | .status(200)
|
654 669 | .body(::aws_smithy_types::body::SdkBody::from(
|
655 670 | "{\n \"contents\": {\n \"booleanValue\": true\n }\n}",
|
656 671 | ))
|
657 672 | .unwrap(),
|
658 673 | )
|
659 674 | .unwrap();
|
660 675 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
661 676 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
662 677 |
|
663 678 | let op = crate::operation::json_unions::JsonUnions::new();
|
664 679 | let config = op.config().expect("the operation has config");
|
665 680 | let de = config
|
666 681 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
667 682 | .expect("the config must have a deserializer");
|
668 683 |
|
669 684 | let parsed = de.deserialize_streaming(&mut http_response);
|
670 685 | let parsed = parsed.unwrap_or_else(|| {
|
671 686 | let http_response = http_response.map(|body| {
|
672 687 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
673 688 | body.bytes().unwrap(),
|
674 689 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
675 690 | )))
|
676 691 | });
|
677 - | de.deserialize_nonstreaming(&http_response)
|
692 + | // Build a config bag with the protocol for schema-based deserialization
|
693 + | #[allow(unused_mut)]
|
694 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
695 + | {
|
696 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
697 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
698 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
699 + | ));
|
700 + | test_cfg.push_shared_layer(layer.freeze());
|
701 + | }
|
702 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
678 703 | });
|
679 704 | let parsed = parsed
|
680 705 | .expect("should be successful response")
|
681 706 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
682 707 | .unwrap();
|
683 708 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
684 709 | }
|
685 710 |
|
686 711 | /// Deserializes a number union value
|
687 712 | /// Test ID: RestJsonDeserializeNumberUnionValue
|
688 713 | #[::tokio::test]
|
689 714 | #[::tracing_test::traced_test]
|
690 715 | async fn rest_json_deserialize_number_union_value_response() {
|
691 716 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
692 717 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::NumberValue(1)))
|
693 718 | .build();
|
694 719 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
695 720 | ::http_1x::response::Builder::new()
|
696 721 | .header("Content-Type", "application/json")
|
697 722 | .status(200)
|
698 723 | .body(::aws_smithy_types::body::SdkBody::from(
|
699 724 | "{\n \"contents\": {\n \"numberValue\": 1\n }\n}",
|
700 725 | ))
|
701 726 | .unwrap(),
|
702 727 | )
|
703 728 | .unwrap();
|
704 729 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
705 730 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
706 731 |
|
707 732 | let op = crate::operation::json_unions::JsonUnions::new();
|
708 733 | let config = op.config().expect("the operation has config");
|
709 734 | let de = config
|
710 735 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
711 736 | .expect("the config must have a deserializer");
|
712 737 |
|
713 738 | let parsed = de.deserialize_streaming(&mut http_response);
|
714 739 | let parsed = parsed.unwrap_or_else(|| {
|
715 740 | let http_response = http_response.map(|body| {
|
716 741 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
717 742 | body.bytes().unwrap(),
|
718 743 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
719 744 | )))
|
720 745 | });
|
721 - | de.deserialize_nonstreaming(&http_response)
|
746 + | // Build a config bag with the protocol for schema-based deserialization
|
747 + | #[allow(unused_mut)]
|
748 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
749 + | {
|
750 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
751 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
752 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
753 + | ));
|
754 + | test_cfg.push_shared_layer(layer.freeze());
|
755 + | }
|
756 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
722 757 | });
|
723 758 | let parsed = parsed
|
724 759 | .expect("should be successful response")
|
725 760 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
726 761 | .unwrap();
|
727 762 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
728 763 | }
|
729 764 |
|
730 765 | /// Deserializes a blob union value
|
731 766 | /// Test ID: RestJsonDeserializeBlobUnionValue
|
732 767 | #[::tokio::test]
|
733 768 | #[::tracing_test::traced_test]
|
734 769 | async fn rest_json_deserialize_blob_union_value_response() {
|
735 770 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
736 771 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::BlobValue(
|
737 772 | ::aws_smithy_types::Blob::new("foo"),
|
738 773 | )))
|
739 774 | .build();
|
740 775 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
741 776 | ::http_1x::response::Builder::new()
|
742 777 | .header("Content-Type", "application/json")
|
743 778 | .status(200)
|
744 779 | .body(::aws_smithy_types::body::SdkBody::from(
|
745 780 | "{\n \"contents\": {\n \"blobValue\": \"Zm9v\"\n }\n}",
|
746 781 | ))
|
747 782 | .unwrap(),
|
748 783 | )
|
749 784 | .unwrap();
|
750 785 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
751 786 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
752 787 |
|
753 788 | let op = crate::operation::json_unions::JsonUnions::new();
|
754 789 | let config = op.config().expect("the operation has config");
|
755 790 | let de = config
|
756 791 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
757 792 | .expect("the config must have a deserializer");
|
758 793 |
|
759 794 | let parsed = de.deserialize_streaming(&mut http_response);
|
760 795 | let parsed = parsed.unwrap_or_else(|| {
|
761 796 | let http_response = http_response.map(|body| {
|
762 797 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
763 798 | body.bytes().unwrap(),
|
764 799 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
765 800 | )))
|
766 801 | });
|
767 - | de.deserialize_nonstreaming(&http_response)
|
802 + | // Build a config bag with the protocol for schema-based deserialization
|
803 + | #[allow(unused_mut)]
|
804 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
805 + | {
|
806 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
807 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
808 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
809 + | ));
|
810 + | test_cfg.push_shared_layer(layer.freeze());
|
811 + | }
|
812 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
768 813 | });
|
769 814 | let parsed = parsed
|
770 815 | .expect("should be successful response")
|
771 816 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
772 817 | .unwrap();
|
773 818 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
774 819 | }
|
775 820 |
|
776 821 | /// Deserializes a timestamp union value
|
777 822 | /// Test ID: RestJsonDeserializeTimestampUnionValue
|
778 823 | #[::tokio::test]
|
779 824 | #[::tracing_test::traced_test]
|
780 825 | async fn rest_json_deserialize_timestamp_union_value_response() {
|
781 826 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
782 827 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::TimestampValue(
|
783 828 | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
784 829 | )))
|
785 830 | .build();
|
786 831 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
787 832 | ::http_1x::response::Builder::new()
|
788 833 | .header("Content-Type", "application/json")
|
789 834 | .status(200)
|
790 835 | .body(::aws_smithy_types::body::SdkBody::from(
|
791 836 | "{\n \"contents\": {\n \"timestampValue\": 1398796238\n }\n}",
|
792 837 | ))
|
793 838 | .unwrap(),
|
794 839 | )
|
795 840 | .unwrap();
|
796 841 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
797 842 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
798 843 |
|
799 844 | let op = crate::operation::json_unions::JsonUnions::new();
|
800 845 | let config = op.config().expect("the operation has config");
|
801 846 | let de = config
|
802 847 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
803 848 | .expect("the config must have a deserializer");
|
804 849 |
|
805 850 | let parsed = de.deserialize_streaming(&mut http_response);
|
806 851 | let parsed = parsed.unwrap_or_else(|| {
|
807 852 | let http_response = http_response.map(|body| {
|
808 853 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
809 854 | body.bytes().unwrap(),
|
810 855 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
811 856 | )))
|
812 857 | });
|
813 - | de.deserialize_nonstreaming(&http_response)
|
858 + | // Build a config bag with the protocol for schema-based deserialization
|
859 + | #[allow(unused_mut)]
|
860 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
861 + | {
|
862 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
863 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
864 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
865 + | ));
|
866 + | test_cfg.push_shared_layer(layer.freeze());
|
867 + | }
|
868 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
814 869 | });
|
815 870 | let parsed = parsed
|
816 871 | .expect("should be successful response")
|
817 872 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
818 873 | .unwrap();
|
819 874 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
820 875 | }
|
821 876 |
|
822 877 | /// Deserializes an enum union value
|
823 878 | /// Test ID: RestJsonDeserializeEnumUnionValue
|
824 879 | #[::tokio::test]
|
825 880 | #[::tracing_test::traced_test]
|
826 881 | async fn rest_json_deserialize_enum_union_value_response() {
|
827 882 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
828 883 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::EnumValue(
|
829 884 | "Foo".parse::<crate::types::FooEnum>().expect("static value validated to member"),
|
830 885 | )))
|
831 886 | .build();
|
832 887 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
833 888 | ::http_1x::response::Builder::new()
|
834 889 | .header("Content-Type", "application/json")
|
835 890 | .status(200)
|
836 891 | .body(::aws_smithy_types::body::SdkBody::from(
|
837 892 | "{\n \"contents\": {\n \"enumValue\": \"Foo\"\n }\n}",
|
838 893 | ))
|
839 894 | .unwrap(),
|
840 895 | )
|
841 896 | .unwrap();
|
842 897 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
843 898 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
844 899 |
|
845 900 | let op = crate::operation::json_unions::JsonUnions::new();
|
846 901 | let config = op.config().expect("the operation has config");
|
847 902 | let de = config
|
848 903 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
849 904 | .expect("the config must have a deserializer");
|
850 905 |
|
851 906 | let parsed = de.deserialize_streaming(&mut http_response);
|
852 907 | let parsed = parsed.unwrap_or_else(|| {
|
853 908 | let http_response = http_response.map(|body| {
|
854 909 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
855 910 | body.bytes().unwrap(),
|
856 911 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
857 912 | )))
|
858 913 | });
|
859 - | de.deserialize_nonstreaming(&http_response)
|
914 + | // Build a config bag with the protocol for schema-based deserialization
|
915 + | #[allow(unused_mut)]
|
916 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
917 + | {
|
918 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
919 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
920 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
921 + | ));
|
922 + | test_cfg.push_shared_layer(layer.freeze());
|
923 + | }
|
924 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
860 925 | });
|
861 926 | let parsed = parsed
|
862 927 | .expect("should be successful response")
|
863 928 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
864 929 | .unwrap();
|
865 930 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
866 931 | }
|
867 932 |
|
868 933 | /// Deserializes a list union value
|
869 934 | /// Test ID: RestJsonDeserializeListUnionValue
|
870 935 | #[::tokio::test]
|
871 936 | #[::tracing_test::traced_test]
|
872 937 | async fn rest_json_deserialize_list_union_value_response() {
|
873 938 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
874 939 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::ListValue(vec![
|
875 940 | "foo".to_owned(),
|
876 941 | "bar".to_owned(),
|
877 942 | ])))
|
878 943 | .build();
|
879 944 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
880 945 | ::http_1x::response::Builder::new()
|
881 946 | .header("Content-Type", "application/json")
|
882 947 | .status(200)
|
883 948 | .body(::aws_smithy_types::body::SdkBody::from(
|
884 949 | "{\n \"contents\": {\n \"listValue\": [\"foo\", \"bar\"]\n }\n}",
|
885 950 | ))
|
886 951 | .unwrap(),
|
887 952 | )
|
888 953 | .unwrap();
|
889 954 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
890 955 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
891 956 |
|
892 957 | let op = crate::operation::json_unions::JsonUnions::new();
|
893 958 | let config = op.config().expect("the operation has config");
|
894 959 | let de = config
|
895 960 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
896 961 | .expect("the config must have a deserializer");
|
897 962 |
|
898 963 | let parsed = de.deserialize_streaming(&mut http_response);
|
899 964 | let parsed = parsed.unwrap_or_else(|| {
|
900 965 | let http_response = http_response.map(|body| {
|
901 966 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
902 967 | body.bytes().unwrap(),
|
903 968 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
904 969 | )))
|
905 970 | });
|
906 - | de.deserialize_nonstreaming(&http_response)
|
971 + | // Build a config bag with the protocol for schema-based deserialization
|
972 + | #[allow(unused_mut)]
|
973 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
974 + | {
|
975 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
976 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
977 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
978 + | ));
|
979 + | test_cfg.push_shared_layer(layer.freeze());
|
980 + | }
|
981 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
907 982 | });
|
908 983 | let parsed = parsed
|
909 984 | .expect("should be successful response")
|
910 985 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
911 986 | .unwrap();
|
912 987 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
913 988 | }
|
914 989 |
|
915 990 | /// Deserializes a map union value
|
916 991 | /// Test ID: RestJsonDeserializeMapUnionValue
|
917 992 | #[::tokio::test]
|
918 993 | #[::tracing_test::traced_test]
|
919 994 | async fn rest_json_deserialize_map_union_value_response() {
|
920 995 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
921 996 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::MapValue({
|
922 997 | let mut ret = ::std::collections::HashMap::new();
|
923 998 | ret.insert("foo".to_owned(), "bar".to_owned());
|
924 999 | ret.insert("spam".to_owned(), "eggs".to_owned());
|
925 1000 | ret
|
926 1001 | })))
|
927 1002 | .build();
|
928 1003 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
929 1004 | .header("Content-Type", "application/json")
|
930 1005 | .status(200)
|
931 1006 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"contents\": {\n \"mapValue\": {\n \"foo\": \"bar\",\n \"spam\": \"eggs\"\n }\n }\n}"))
|
932 1007 | .unwrap()
|
933 1008 | ).unwrap();
|
934 1009 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
935 1010 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
936 1011 |
|
937 1012 | let op = crate::operation::json_unions::JsonUnions::new();
|
938 1013 | let config = op.config().expect("the operation has config");
|
939 1014 | let de = config
|
940 1015 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
941 1016 | .expect("the config must have a deserializer");
|
942 1017 |
|
943 1018 | let parsed = de.deserialize_streaming(&mut http_response);
|
944 1019 | let parsed = parsed.unwrap_or_else(|| {
|
945 1020 | let http_response = http_response.map(|body| {
|
946 1021 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
947 1022 | body.bytes().unwrap(),
|
948 1023 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
949 1024 | )))
|
950 1025 | });
|
951 - | de.deserialize_nonstreaming(&http_response)
|
1026 + | // Build a config bag with the protocol for schema-based deserialization
|
1027 + | #[allow(unused_mut)]
|
1028 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
1029 + | {
|
1030 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
1031 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
1032 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
1033 + | ));
|
1034 + | test_cfg.push_shared_layer(layer.freeze());
|
1035 + | }
|
1036 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
952 1037 | });
|
953 1038 | let parsed = parsed
|
954 1039 | .expect("should be successful response")
|
955 1040 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
956 1041 | .unwrap();
|
957 1042 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
958 1043 | }
|
959 1044 |
|
960 1045 | /// Deserializes a structure union value
|
961 1046 | /// Test ID: RestJsonDeserializeStructureUnionValue
|
962 1047 | #[::tokio::test]
|
963 1048 | #[::tracing_test::traced_test]
|
964 1049 | async fn rest_json_deserialize_structure_union_value_response() {
|
965 1050 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
966 1051 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::StructureValue(
|
967 1052 | crate::types::GreetingStruct::builder()
|
968 1053 | .set_hi(::std::option::Option::Some("hello".to_owned()))
|
969 1054 | .build(),
|
970 1055 | )))
|
971 1056 | .build();
|
972 1057 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
973 1058 | ::http_1x::response::Builder::new()
|
974 1059 | .header("Content-Type", "application/json")
|
975 1060 | .status(200)
|
976 1061 | .body(::aws_smithy_types::body::SdkBody::from(
|
977 1062 | "{\n \"contents\": {\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}",
|
978 1063 | ))
|
979 1064 | .unwrap(),
|
980 1065 | )
|
981 1066 | .unwrap();
|
982 1067 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
983 1068 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
984 1069 |
|
985 1070 | let op = crate::operation::json_unions::JsonUnions::new();
|
986 1071 | let config = op.config().expect("the operation has config");
|
987 1072 | let de = config
|
988 1073 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
989 1074 | .expect("the config must have a deserializer");
|
990 1075 |
|
991 1076 | let parsed = de.deserialize_streaming(&mut http_response);
|
992 1077 | let parsed = parsed.unwrap_or_else(|| {
|
993 1078 | let http_response = http_response.map(|body| {
|
994 1079 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
995 1080 | body.bytes().unwrap(),
|
996 1081 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
997 1082 | )))
|
998 1083 | });
|
999 - | de.deserialize_nonstreaming(&http_response)
|
1084 + | // Build a config bag with the protocol for schema-based deserialization
|
1085 + | #[allow(unused_mut)]
|
1086 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
1087 + | {
|
1088 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
1089 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
1090 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
1091 + | ));
|
1092 + | test_cfg.push_shared_layer(layer.freeze());
|
1093 + | }
|
1094 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
1000 1095 | });
|
1001 1096 | let parsed = parsed
|
1002 1097 | .expect("should be successful response")
|
1003 1098 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
1004 1099 | .unwrap();
|
1005 1100 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
1006 1101 | }
|
1007 1102 |
|
1008 1103 | /// Ignores an unrecognized __type property
|
1009 1104 | /// Test ID: RestJsonDeserializeIgnoreType
|
1010 1105 | #[::tokio::test]
|
1011 1106 | #[::tracing_test::traced_test]
|
1012 1107 | async fn rest_json_deserialize_ignore_type_response() {
|
1013 1108 | let expected_output = crate::operation::json_unions::JsonUnionsOutput::builder()
|
1014 1109 | .set_contents(::std::option::Option::Some(crate::types::MyUnion::StructureValue(
|
1015 1110 | crate::types::GreetingStruct::builder()
|
1016 1111 | .set_hi(::std::option::Option::Some("hello".to_owned()))
|
1017 1112 | .build(),
|
1018 1113 | )))
|
1019 1114 | .build();
|
1020 1115 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
1021 1116 | .header("Content-Type", "application/json")
|
1022 1117 | .status(200)
|
1023 1118 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"contents\": {\n \"__type\": \"aws.protocoltests.json10#MyUnion\",\n \"structureValue\": {\n \"hi\": \"hello\"\n }\n }\n}"))
|
1024 1119 | .unwrap()
|
1025 1120 | ).unwrap();
|
1026 1121 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
1027 1122 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
1028 1123 |
|
1029 1124 | let op = crate::operation::json_unions::JsonUnions::new();
|
1030 1125 | let config = op.config().expect("the operation has config");
|
1031 1126 | let de = config
|
1032 1127 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
1033 1128 | .expect("the config must have a deserializer");
|
1034 1129 |
|
1035 1130 | let parsed = de.deserialize_streaming(&mut http_response);
|
1036 1131 | let parsed = parsed.unwrap_or_else(|| {
|
1037 1132 | let http_response = http_response.map(|body| {
|
1038 1133 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1039 1134 | body.bytes().unwrap(),
|
1040 1135 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
1041 1136 | )))
|
1042 1137 | });
|
1043 - | de.deserialize_nonstreaming(&http_response)
|
1138 + | // Build a config bag with the protocol for schema-based deserialization
|
1139 + | #[allow(unused_mut)]
|
1140 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
1141 + | {
|
1142 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
1143 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
1144 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
1145 + | ));
|
1146 + | test_cfg.push_shared_layer(layer.freeze());
|
1147 + | }
|
1148 + | de.deserialize_nonstreaming(&http_response, &test_cfg)
|
1044 1149 | });
|
1045 1150 | let parsed = parsed
|
1046 1151 | .expect("should be successful response")
|
1047 1152 | .downcast::<crate::operation::json_unions::JsonUnionsOutput>()
|
1048 1153 | .unwrap();
|
1049 1154 | ::pretty_assertions::assert_eq!(parsed.contents, expected_output.contents, "Unexpected value for `contents`");
|
1050 1155 | }
|
1051 1156 | }
|
1052 1157 |
|
1053 1158 | /// Error type for the `JsonUnionsError` operation.
|