Client Test

Client Test

rev. 96f5a1b4ad139d2f1ad1e8e40f300e1cd1ff574c (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/case_insensitive_error_operation/_case_insensitive_error_operation_input.rs

@@ -1,1 +75,89 @@
    5      5   
pub struct CaseInsensitiveErrorOperationInput {}
    6      6   
static CASEINSENSITIVEERROROPERATIONINPUT_SCHEMA_ID: ::aws_smithy_schema::ShapeId = ::aws_smithy_schema::ShapeId::from_static(
    7      7   
    "aws.protocoltests.restjson.synthetic#CaseInsensitiveErrorOperationInput",
    8      8   
    "aws.protocoltests.restjson.synthetic",
    9      9   
    "CaseInsensitiveErrorOperationInput",
   10     10   
);
   11     11   
static CASEINSENSITIVEERROROPERATIONINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   12     12   
    CASEINSENSITIVEERROROPERATIONINPUT_SCHEMA_ID,
   13     13   
    ::aws_smithy_schema::ShapeType::Structure,
   14     14   
    &[],
   15         -
);
          15  +
)
          16  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/error-sensitive", None));
   16     17   
impl CaseInsensitiveErrorOperationInput {
   17     18   
    /// The schema for this shape.
   18     19   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &CASEINSENSITIVEERROROPERATIONINPUT_SCHEMA;
   19     20   
}
   20     21   
impl ::aws_smithy_schema::serde::SerializableStruct for CaseInsensitiveErrorOperationInput {
   21     22   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   22     23   
    fn serialize_members(
   23     24   
        &self,
   24     25   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   25     26   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   26     27   
        Ok(())
   27     28   
    }
   28     29   
}
   29     30   
impl CaseInsensitiveErrorOperationInput {
   30     31   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   31         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   32         -
        deserializer: &mut D,
          32  +
    pub fn deserialize(
          33  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   33     34   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   34     35   
        #[allow(unused_variables, unused_mut)]
   35     36   
        let mut builder = Self::builder();
   36     37   
        #[allow(
   37     38   
            unused_variables,
   38     39   
            unreachable_code,
   39     40   
            clippy::single_match,
   40     41   
            clippy::match_single_binding,
   41     42   
            clippy::diverging_sub_expression
   42     43   
        )]
   43         -
        deserializer.read_struct(&CASEINSENSITIVEERROROPERATIONINPUT_SCHEMA, (), |_, member, deser| {
          44  +
        deserializer.read_struct(&CASEINSENSITIVEERROROPERATIONINPUT_SCHEMA, &mut |member, deser| {
   44     45   
            match member.member_index() {
   45     46   
                _ => {}
   46     47   
            }
   47     48   
            Ok(())
   48     49   
        })?;
   49     50   
        builder
   50     51   
            .build()
   51     52   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   52     53   
    }
   53     54   
}
          55  +
impl CaseInsensitiveErrorOperationInput {
          56  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          57  +
    pub fn deserialize_with_response(
          58  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          59  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          60  +
        _status: u16,
          61  +
        _body: &[u8],
          62  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          63  +
        Self::builder()
          64  +
            .build()
          65  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
          66  +
    }
          67  +
}
   54     68   
impl CaseInsensitiveErrorOperationInput {
   55     69   
    /// Creates a new builder-style object to manufacture [`CaseInsensitiveErrorOperationInput`](crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationInput).
   56     70   
    pub fn builder() -> crate::operation::case_insensitive_error_operation::builders::CaseInsensitiveErrorOperationInputBuilder {
   57     71   
        crate::operation::case_insensitive_error_operation::builders::CaseInsensitiveErrorOperationInputBuilder::default()
   58     72   
    }
   59     73   
}
   60     74   
   61     75   
/// A builder for [`CaseInsensitiveErrorOperationInput`](crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationInput).
   62     76   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   63     77   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/case_insensitive_error_operation/_case_insensitive_error_operation_output.rs

@@ -1,1 +68,79 @@
   21     21   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   22     22   
    fn serialize_members(
   23     23   
        &self,
   24     24   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   25     25   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   26     26   
        Ok(())
   27     27   
    }
   28     28   
}
   29     29   
impl CaseInsensitiveErrorOperationOutput {
   30     30   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   31         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   32         -
        deserializer: &mut D,
          31  +
    pub fn deserialize(
          32  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   33     33   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   34     34   
        #[allow(unused_variables, unused_mut)]
   35     35   
        let mut builder = Self::builder();
   36     36   
        #[allow(
   37     37   
            unused_variables,
   38     38   
            unreachable_code,
   39     39   
            clippy::single_match,
   40     40   
            clippy::match_single_binding,
   41     41   
            clippy::diverging_sub_expression
   42     42   
        )]
   43         -
        deserializer.read_struct(&CASEINSENSITIVEERROROPERATIONOUTPUT_SCHEMA, (), |_, member, deser| {
          43  +
        deserializer.read_struct(&CASEINSENSITIVEERROROPERATIONOUTPUT_SCHEMA, &mut |member, deser| {
   44     44   
            match member.member_index() {
   45     45   
                _ => {}
   46     46   
            }
   47     47   
            Ok(())
   48     48   
        })?;
   49     49   
        Ok(builder.build())
   50     50   
    }
   51     51   
}
          52  +
impl CaseInsensitiveErrorOperationOutput {
          53  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          54  +
    pub fn deserialize_with_response(
          55  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          56  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          57  +
        _status: u16,
          58  +
        _body: &[u8],
          59  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          60  +
        Ok(Self::builder().build())
          61  +
    }
          62  +
}
   52     63   
impl CaseInsensitiveErrorOperationOutput {
   53     64   
    /// Creates a new builder-style object to manufacture [`CaseInsensitiveErrorOperationOutput`](crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationOutput).
   54     65   
    pub fn builder() -> crate::operation::case_insensitive_error_operation::builders::CaseInsensitiveErrorOperationOutputBuilder {
   55     66   
        crate::operation::case_insensitive_error_operation::builders::CaseInsensitiveErrorOperationOutputBuilder::default()
   56     67   
    }
   57     68   
}
   58     69   
   59     70   
/// A builder for [`CaseInsensitiveErrorOperationOutput`](crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationOutput).
   60     71   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   61     72   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/empty_struct_with_content_on_wire_op.rs

@@ -1,1 +40,46 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
/// Orchestration and serialization glue logic for `EmptyStructWithContentOnWireOp`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct EmptyStructWithContentOnWireOp;
    6      6   
impl EmptyStructWithContentOnWireOp {
    7      7   
    /// Creates a new `EmptyStructWithContentOnWireOp`
    8      8   
    pub fn new() -> Self {
    9      9   
        Self
   10     10   
    }
          11  +
    /// The schema for this operation's input shape.
          12  +
    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          13  +
        crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          16  +
        crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpOutput::SCHEMA;
   11     17   
    pub(crate) async fn orchestrate(
   12     18   
        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
   13     19   
        input: crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -110,116 +232,280 @@
  130    136   
                crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError,
  131    137   
            >::new());
  132    138   
  133    139   
        ::std::borrow::Cow::Owned(rcb)
  134    140   
    }
  135    141   
}
  136    142   
  137    143   
#[derive(Debug)]
  138    144   
struct EmptyStructWithContentOnWireOpResponseDeserializer;
  139    145   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EmptyStructWithContentOnWireOpResponseDeserializer {
  140         -
    fn deserialize_nonstreaming(
         146  +
    fn deserialize_nonstreaming_with_config(
  141    147   
        &self,
  142    148   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
         149  +
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  143    150   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  144    151   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
         152  +
        #[allow(unused_mut)]
         153  +
        let mut force_error = false;
         154  +
         155  +
        if !success && status != 200 || force_error {
  145    156   
            let headers = response.headers();
  146    157   
            let body = response.body().bytes().expect("body loaded");
  147    158   
            #[allow(unused_mut)]
  148         -
        let mut force_error = false;
         159  +
            let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
         160  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         161  +
            })?;
  149    162   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::de_empty_struct_with_content_on_wire_op_http_error(
  152         -
                status, headers, body,
         163  +
            let generic = generic_builder.build();
         164  +
            let error_code = match generic.code() {
         165  +
                ::std::option::Option::Some(code) => code,
         166  +
                ::std::option::Option::None => {
         167  +
                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         168  +
                        ::aws_smithy_runtime_api::box_error::BoxError::from(
         169  +
                            crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError::unhandled(generic),
         170  +
                        ),
         171  +
                    ))
         172  +
                }
         173  +
            };
         174  +
            let _error_message = generic.message().map(|msg| msg.to_owned());
         175  +
            let protocol = _cfg
         176  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         177  +
                .expect("a SharedClientProtocol is required");
         178  +
            let err = match error_code {
         179  +
                "ExtraError" => crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError::ExtraError({
         180  +
                    let mut tmp = match protocol
         181  +
                        .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
         182  +
                        .and_then(|mut deser| {
         183  +
                            crate::types::error::ExtraError::deserialize_with_response(
         184  +
                                &mut *deser,
         185  +
                                response.headers(),
         186  +
                                response.status().into(),
         187  +
                                body,
  153    188   
                            )
         189  +
                        }) {
         190  +
                        ::std::result::Result::Ok(val) => val,
         191  +
                        ::std::result::Result::Err(e) => {
         192  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         193  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         194  +
                            ))
         195  +
                        }
         196  +
                    };
         197  +
                    tmp.meta = generic;
         198  +
                    if tmp.message.is_none() {
         199  +
                        tmp.message = _error_message;
         200  +
                    }
         201  +
                    tmp
         202  +
                }),
         203  +
                _ => crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError::generic(generic),
         204  +
            };
         205  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         206  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         207  +
            ))
  154    208   
        } else {
  155         -
            crate::protocol_serde::shape_empty_struct_with_content_on_wire_op::de_empty_struct_with_content_on_wire_op_http_response(
  156         -
                status, headers, body,
         209  +
            let protocol = _cfg
         210  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         211  +
                .expect("a SharedClientProtocol is required");
         212  +
            let mut deser = protocol
         213  +
                .deserialize_response(response, EmptyStructWithContentOnWireOp::OUTPUT_SCHEMA, _cfg)
         214  +
                .map_err(|e| {
         215  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         216  +
                })?;
         217  +
            let body = response.body().bytes().expect("body loaded");
         218  +
            let output = crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpOutput::deserialize_with_response(
         219  +
                &mut *deser,
         220  +
                response.headers(),
         221  +
                response.status().into(),
         222  +
                body,
  157    223   
            )
  158         -
        };
  159         -
        crate::protocol_serde::type_erase_result(parse_result)
         224  +
            .map_err(|e| {
         225  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         226  +
            })?;
         227  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         228  +
        }
  160    229   
    }
  161    230   
}
  162    231   
#[derive(Debug)]
  163    232   
struct EmptyStructWithContentOnWireOpRequestSerializer;
  164    233   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EmptyStructWithContentOnWireOpRequestSerializer {
  165    234   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  166    235   
    fn serialize_input(
  167    236   
        &self,
  168    237   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  169    238   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  170    239   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  171    240   
        let input = input
  172    241   
            .downcast::<crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput>()
  173    242   
            .expect("correct type");
  174         -
        let _header_serialization_settings = _cfg
  175         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  176         -
            .cloned()
  177         -
            .unwrap_or_default();
  178         -
        let mut request_builder = {
  179         -
            #[allow(clippy::uninlined_format_args)]
  180         -
            fn uri_base(
  181         -
                _input: &crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput,
  182         -
                output: &mut ::std::string::String,
  183         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  184         -
                use ::std::fmt::Write as _;
  185         -
                ::std::write!(output, "/empty-struct-with-content-on-wire-op").expect("formatting should succeed");
  186         -
                ::std::result::Result::Ok(())
  187         -
            }
  188         -
            #[allow(clippy::unnecessary_wraps)]
  189         -
            fn update_http_builder(
  190         -
                input: &crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput,
  191         -
                builder: ::http_1x::request::Builder,
  192         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  193         -
                let mut uri = ::std::string::String::new();
  194         -
                uri_base(input, &mut uri)?;
  195         -
                ::std::result::Result::Ok(builder.method("GET").uri(uri))
  196         -
            }
  197         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  198         -
            builder
  199         -
        };
  200         -
        let body = ::aws_smithy_types::body::SdkBody::from("");
         243  +
        let protocol = _cfg
         244  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         245  +
            .expect("a SharedClientProtocol is required");
         246  +
        let mut request = protocol
         247  +
            .serialize_request(&input, EmptyStructWithContentOnWireOp::INPUT_SCHEMA, "", _cfg)
         248  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
  201    249   
  202         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         250  +
        return ::std::result::Result::Ok(request);
  203    251   
    }
  204    252   
}
  205    253   
#[derive(Debug)]
  206    254   
struct EmptyStructWithContentOnWireOpEndpointParamsInterceptor;
  207    255   
  208    256   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EmptyStructWithContentOnWireOpEndpointParamsInterceptor {
  209    257   
    fn name(&self) -> &'static str {
  210    258   
        "EmptyStructWithContentOnWireOpEndpointParamsInterceptor"
  211    259   
    }
  212    260   
@@ -245,293 +345,413 @@
  265    313   
            .expect("the config must have a deserializer");
  266    314   
  267    315   
        let parsed = de.deserialize_streaming(&mut http_response);
  268    316   
        let parsed = parsed.unwrap_or_else(|| {
  269    317   
            let http_response = http_response.map(|body| {
  270    318   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  271    319   
                    body.bytes().unwrap(),
  272    320   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  273    321   
                )))
  274    322   
            });
  275         -
            de.deserialize_nonstreaming(&http_response)
         323  +
            // Build a config bag with the protocol for schema-based deserialization
         324  +
            #[allow(unused_mut)]
         325  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         326  +
            {
         327  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         328  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         329  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         330  +
                ));
         331  +
                test_cfg.push_shared_layer(layer.freeze());
         332  +
            }
         333  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  276    334   
        });
  277    335   
        let parsed = parsed
  278    336   
            .expect("should be successful response")
  279    337   
            .downcast::<crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpOutput>()
  280    338   
            .unwrap();
  281    339   
        ::pretty_assertions::assert_eq!(parsed.empty, expected_output.empty, "Unexpected value for `empty`");
  282    340   
    }
  283    341   
  284    342   
    /// Upper case error modeled lower case
  285    343   
    /// Test ID: ServiceLevelErrorClient
  286    344   
    #[::tokio::test]
  287    345   
    #[::tracing_test::traced_test]
  288    346   
    async fn service_level_error_client_response() {
  289    347   
        let expected_output = crate::types::error::ExtraError::builder().build();
  290    348   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  291    349   
            ::http_1x::response::Builder::new()
  292    350   
                .header("X-Amzn-Errortype", "ExtraError")
  293    351   
                .status(500)
  294    352   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  295    353   
                .unwrap(),
  296    354   
        )
  297    355   
        .unwrap();
  298    356   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  299    357   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  300    358   
  301    359   
        let op = crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOp::new();
  302    360   
        let config = op.config().expect("the operation has config");
  303    361   
        let de = config
  304    362   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  305    363   
            .expect("the config must have a deserializer");
  306    364   
  307    365   
        let parsed = de.deserialize_streaming(&mut http_response);
  308    366   
        let parsed = parsed.unwrap_or_else(|| {
  309    367   
            let http_response = http_response.map(|body| {
  310    368   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  311    369   
                    body.bytes().unwrap(),
  312    370   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  313    371   
                )))
  314    372   
            });
  315         -
            de.deserialize_nonstreaming(&http_response)
         373  +
            // Build a config bag with the protocol for schema-based deserialization
         374  +
            #[allow(unused_mut)]
         375  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         376  +
            {
         377  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         378  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         379  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         380  +
                ));
         381  +
                test_cfg.push_shared_layer(layer.freeze());
         382  +
            }
         383  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  316    384   
        });
  317    385   
        let parsed = parsed.expect_err("should be error response");
  318    386   
        let parsed: &crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError =
  319    387   
            parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
  320    388   
        if let crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpError::ExtraError(parsed) = parsed {
  321    389   
            ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
  322    390   
        } else {
  323    391   
            panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
  324    392   
        }
  325    393   
    }

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/empty_struct_with_content_on_wire_op/_empty_struct_with_content_on_wire_op_input.rs

@@ -1,1 +75,93 @@
    5      5   
pub struct EmptyStructWithContentOnWireOpInput {}
    6      6   
static EMPTYSTRUCTWITHCONTENTONWIREOPINPUT_SCHEMA_ID: ::aws_smithy_schema::ShapeId = ::aws_smithy_schema::ShapeId::from_static(
    7      7   
    "aws.protocoltests.restjson.synthetic#EmptyStructWithContentOnWireOpInput",
    8      8   
    "aws.protocoltests.restjson.synthetic",
    9      9   
    "EmptyStructWithContentOnWireOpInput",
   10     10   
);
   11     11   
static EMPTYSTRUCTWITHCONTENTONWIREOPINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   12     12   
    EMPTYSTRUCTWITHCONTENTONWIREOPINPUT_SCHEMA_ID,
   13     13   
    ::aws_smithy_schema::ShapeType::Structure,
   14     14   
    &[],
   15         -
);
          15  +
)
          16  +
.with_http(aws_smithy_schema::traits::HttpTrait::new(
          17  +
    "GET",
          18  +
    "/empty-struct-with-content-on-wire-op",
          19  +
    None,
          20  +
));
   16     21   
impl EmptyStructWithContentOnWireOpInput {
   17     22   
    /// The schema for this shape.
   18     23   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &EMPTYSTRUCTWITHCONTENTONWIREOPINPUT_SCHEMA;
   19     24   
}
   20     25   
impl ::aws_smithy_schema::serde::SerializableStruct for EmptyStructWithContentOnWireOpInput {
   21     26   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   22     27   
    fn serialize_members(
   23     28   
        &self,
   24     29   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   25     30   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   26     31   
        Ok(())
   27     32   
    }
   28     33   
}
   29     34   
impl EmptyStructWithContentOnWireOpInput {
   30     35   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   31         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   32         -
        deserializer: &mut D,
          36  +
    pub fn deserialize(
          37  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   33     38   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   34     39   
        #[allow(unused_variables, unused_mut)]
   35     40   
        let mut builder = Self::builder();
   36     41   
        #[allow(
   37     42   
            unused_variables,
   38     43   
            unreachable_code,
   39     44   
            clippy::single_match,
   40     45   
            clippy::match_single_binding,
   41     46   
            clippy::diverging_sub_expression
   42     47   
        )]
   43         -
        deserializer.read_struct(&EMPTYSTRUCTWITHCONTENTONWIREOPINPUT_SCHEMA, (), |_, member, deser| {
          48  +
        deserializer.read_struct(&EMPTYSTRUCTWITHCONTENTONWIREOPINPUT_SCHEMA, &mut |member, deser| {
   44     49   
            match member.member_index() {
   45     50   
                _ => {}
   46     51   
            }
   47     52   
            Ok(())
   48     53   
        })?;
   49     54   
        builder
   50     55   
            .build()
   51     56   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   52     57   
    }
   53     58   
}
          59  +
impl EmptyStructWithContentOnWireOpInput {
          60  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          61  +
    pub fn deserialize_with_response(
          62  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          63  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          64  +
        _status: u16,
          65  +
        _body: &[u8],
          66  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          67  +
        Self::builder()
          68  +
            .build()
          69  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
          70  +
    }
          71  +
}
   54     72   
impl EmptyStructWithContentOnWireOpInput {
   55     73   
    /// Creates a new builder-style object to manufacture [`EmptyStructWithContentOnWireOpInput`](crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput).
   56     74   
    pub fn builder() -> crate::operation::empty_struct_with_content_on_wire_op::builders::EmptyStructWithContentOnWireOpInputBuilder {
   57     75   
        crate::operation::empty_struct_with_content_on_wire_op::builders::EmptyStructWithContentOnWireOpInputBuilder::default()
   58     76   
    }
   59     77   
}
   60     78   
   61     79   
/// A builder for [`EmptyStructWithContentOnWireOpInput`](crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpInput).
   62     80   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   63     81   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/empty_struct_with_content_on_wire_op/_empty_struct_with_content_on_wire_op_output.rs

@@ -23,23 +106,117 @@
   43     43   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   44     44   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   45     45   
        if let Some(ref val) = self.empty {
   46     46   
            ser.write_struct(&EMPTYSTRUCTWITHCONTENTONWIREOPOUTPUT_MEMBER_EMPTY, val)?;
   47     47   
        }
   48     48   
        Ok(())
   49     49   
    }
   50     50   
}
   51     51   
impl EmptyStructWithContentOnWireOpOutput {
   52     52   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   53         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   54         -
        deserializer: &mut D,
          53  +
    pub fn deserialize(
          54  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   55     55   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   56     56   
        #[allow(unused_variables, unused_mut)]
   57     57   
        let mut builder = Self::builder();
   58     58   
        #[allow(
   59     59   
            unused_variables,
   60     60   
            unreachable_code,
   61     61   
            clippy::single_match,
   62     62   
            clippy::match_single_binding,
   63     63   
            clippy::diverging_sub_expression
   64     64   
        )]
   65         -
        deserializer.read_struct(&EMPTYSTRUCTWITHCONTENTONWIREOPOUTPUT_SCHEMA, (), |_, member, deser| {
          65  +
        deserializer.read_struct(&EMPTYSTRUCTWITHCONTENTONWIREOPOUTPUT_SCHEMA, &mut |member, deser| {
   66     66   
            match member.member_index() {
   67     67   
                Some(0) => {
   68     68   
                    builder.empty = Some(crate::types::EmptyStruct::deserialize(deser)?);
   69     69   
                }
   70     70   
                _ => {}
   71     71   
            }
   72     72   
            Ok(())
   73     73   
        })?;
   74     74   
        Ok(builder.build())
   75     75   
    }
   76     76   
}
          77  +
impl EmptyStructWithContentOnWireOpOutput {
          78  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          79  +
    pub fn deserialize_with_response(
          80  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          81  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          82  +
        _status: u16,
          83  +
        _body: &[u8],
          84  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          85  +
        Self::deserialize(deserializer)
          86  +
    }
          87  +
}
   77     88   
impl EmptyStructWithContentOnWireOpOutput {
   78     89   
    /// Creates a new builder-style object to manufacture [`EmptyStructWithContentOnWireOpOutput`](crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpOutput).
   79     90   
    pub fn builder() -> crate::operation::empty_struct_with_content_on_wire_op::builders::EmptyStructWithContentOnWireOpOutputBuilder {
   80     91   
        crate::operation::empty_struct_with_content_on_wire_op::builders::EmptyStructWithContentOnWireOpOutputBuilder::default()
   81     92   
    }
   82     93   
}
   83     94   
   84     95   
/// A builder for [`EmptyStructWithContentOnWireOpOutput`](crate::operation::empty_struct_with_content_on_wire_op::EmptyStructWithContentOnWireOpOutput).
   85     96   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   86     97   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/enum_query.rs

@@ -1,1 +40,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
/// Orchestration and serialization glue logic for `EnumQuery`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct EnumQuery;
    6      6   
impl EnumQuery {
    7      7   
    /// Creates a new `EnumQuery`
    8      8   
    pub fn new() -> Self {
    9      9   
        Self
   10     10   
    }
          11  +
    /// The schema for this operation's input shape.
          12  +
    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::enum_query::EnumQueryInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::enum_query::EnumQueryOutput::SCHEMA;
   11     15   
    pub(crate) async fn orchestrate(
   12     16   
        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
   13     17   
        input: crate::operation::enum_query::EnumQueryInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::enum_query::EnumQueryOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::enum_query::EnumQueryError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -104,108 +231,287 @@
  124    128   
                crate::operation::enum_query::EnumQueryError,
  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 EnumQueryResponseDeserializer;
  133    137   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EnumQueryResponseDeserializer {
  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_enum_query::de_enum_query_http_error(status, headers, body)
  146         -
        } else {
  147         -
            crate::protocol_serde::shape_enum_query::de_enum_query_http_response(status, headers, body)
         155  +
            let generic = generic_builder.build();
         156  +
            let error_code = match generic.code() {
         157  +
                ::std::option::Option::Some(code) => code,
         158  +
                ::std::option::Option::None => {
         159  +
                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         160  +
                        ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::enum_query::EnumQueryError::unhandled(generic)),
         161  +
                    ))
         162  +
                }
  148    163   
            };
  149         -
        crate::protocol_serde::type_erase_result(parse_result)
         164  +
            let _error_message = generic.message().map(|msg| msg.to_owned());
         165  +
            let protocol = _cfg
         166  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         167  +
                .expect("a SharedClientProtocol is required");
         168  +
            let err = match error_code {
         169  +
                "ValidationException" => crate::operation::enum_query::EnumQueryError::ValidationError({
         170  +
                    let mut tmp = match protocol
         171  +
                        .deserialize_response(response, crate::types::error::ValidationError::SCHEMA, _cfg)
         172  +
                        .and_then(|mut deser| {
         173  +
                            crate::types::error::ValidationError::deserialize_with_response(
         174  +
                                &mut *deser,
         175  +
                                response.headers(),
         176  +
                                response.status().into(),
         177  +
                                body,
         178  +
                            )
         179  +
                        }) {
         180  +
                        ::std::result::Result::Ok(val) => val,
         181  +
                        ::std::result::Result::Err(e) => {
         182  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         183  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         184  +
                            ))
         185  +
                        }
         186  +
                    };
         187  +
                    tmp.meta = generic;
         188  +
                    tmp
         189  +
                }),
         190  +
                "ExtraError" => crate::operation::enum_query::EnumQueryError::ExtraError({
         191  +
                    let mut tmp = match protocol
         192  +
                        .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
         193  +
                        .and_then(|mut deser| {
         194  +
                            crate::types::error::ExtraError::deserialize_with_response(
         195  +
                                &mut *deser,
         196  +
                                response.headers(),
         197  +
                                response.status().into(),
         198  +
                                body,
         199  +
                            )
         200  +
                        }) {
         201  +
                        ::std::result::Result::Ok(val) => val,
         202  +
                        ::std::result::Result::Err(e) => {
         203  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         204  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         205  +
                            ))
         206  +
                        }
         207  +
                    };
         208  +
                    tmp.meta = generic;
         209  +
                    if tmp.message.is_none() {
         210  +
                        tmp.message = _error_message;
         211  +
                    }
         212  +
                    tmp
         213  +
                }),
         214  +
                _ => crate::operation::enum_query::EnumQueryError::generic(generic),
         215  +
            };
         216  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         217  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         218  +
            ))
         219  +
        } else {
         220  +
            let protocol = _cfg
         221  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         222  +
                .expect("a SharedClientProtocol is required");
         223  +
            let mut deser = protocol.deserialize_response(response, EnumQuery::OUTPUT_SCHEMA, _cfg).map_err(|e| {
         224  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         225  +
            })?;
         226  +
            let body = response.body().bytes().expect("body loaded");
         227  +
            let output = crate::operation::enum_query::EnumQueryOutput::deserialize_with_response(
         228  +
                &mut *deser,
         229  +
                response.headers(),
         230  +
                response.status().into(),
         231  +
                body,
         232  +
            )
         233  +
            .map_err(|e| {
         234  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         235  +
            })?;
         236  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         237  +
        }
  150    238   
    }
  151    239   
}
  152    240   
#[derive(Debug)]
  153    241   
struct EnumQueryRequestSerializer;
  154    242   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EnumQueryRequestSerializer {
  155    243   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  156    244   
    fn serialize_input(
  157    245   
        &self,
  158    246   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  159    247   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  160    248   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  161    249   
        let input = input.downcast::<crate::operation::enum_query::EnumQueryInput>().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::enum_query::EnumQueryInput,
  170         -
                output: &mut ::std::string::String,
  171         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  172         -
                use ::std::fmt::Write as _;
  173         -
                let input_1 = &_input.r#enum;
  174         -
                let input_1 = input_1
  175         -
                    .as_ref()
  176         -
                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("r#enum", "cannot be empty or unset"))?;
  177         -
                let r#enum = ::aws_smithy_http::label::fmt_string(input_1.as_str(), ::aws_smithy_http::label::EncodingStrategy::Default);
  178         -
                if r#enum.is_empty() {
  179         -
                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
  180         -
                        "r#enum",
  181         -
                        "cannot be empty or unset",
  182         -
                    ));
  183         -
                }
  184         -
                ::std::write!(output, "/foo/{enum}", enum = r#enum).expect("formatting should succeed");
  185         -
                ::std::result::Result::Ok(())
  186         -
            }
  187         -
            #[allow(clippy::unnecessary_wraps)]
  188         -
            fn update_http_builder(
  189         -
                input: &crate::operation::enum_query::EnumQueryInput,
  190         -
                builder: ::http_1x::request::Builder,
  191         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  192         -
                let mut uri = ::std::string::String::new();
  193         -
                uri_base(input, &mut uri)?;
  194         -
                ::std::result::Result::Ok(builder.method("GET").uri(uri))
  195         -
            }
  196         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  197         -
            builder
  198         -
        };
  199         -
        let body = ::aws_smithy_types::body::SdkBody::from("");
         250  +
        let protocol = _cfg
         251  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         252  +
            .expect("a SharedClientProtocol is required");
         253  +
        let mut request = protocol
         254  +
            .serialize_request(&input, EnumQuery::INPUT_SCHEMA, "", _cfg)
         255  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
  200    256   
  201         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         257  +
        return ::std::result::Result::Ok(request);
  202    258   
    }
  203    259   
}
  204    260   
#[derive(Debug)]
  205    261   
struct EnumQueryEndpointParamsInterceptor;
  206    262   
  207    263   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EnumQueryEndpointParamsInterceptor {
  208    264   
    fn name(&self) -> &'static str {
  209    265   
        "EnumQueryEndpointParamsInterceptor"
  210    266   
    }
  211    267   
@@ -271,327 +331,397 @@
  291    347   
            .expect("the config must have a deserializer");
  292    348   
  293    349   
        let parsed = de.deserialize_streaming(&mut http_response);
  294    350   
        let parsed = parsed.unwrap_or_else(|| {
  295    351   
            let http_response = http_response.map(|body| {
  296    352   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  297    353   
                    body.bytes().unwrap(),
  298    354   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  299    355   
                )))
  300    356   
            });
  301         -
            de.deserialize_nonstreaming(&http_response)
         357  +
            // Build a config bag with the protocol for schema-based deserialization
         358  +
            #[allow(unused_mut)]
         359  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         360  +
            {
         361  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         362  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         363  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         364  +
                ));
         365  +
                test_cfg.push_shared_layer(layer.freeze());
         366  +
            }
         367  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  302    368   
        });
  303    369   
        let parsed = parsed.expect_err("should be error response");
  304    370   
        let parsed: &crate::operation::enum_query::EnumQueryError = parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
  305    371   
        if let crate::operation::enum_query::EnumQueryError::ExtraError(parsed) = parsed {
  306    372   
            ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
  307    373   
        } else {
  308    374   
            panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
  309    375   
        }
  310    376   
    }
  311    377   
}

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/enum_query/_enum_query_input.rs

@@ -1,1 +109,121 @@
   17     17   
    "aws.protocoltests.restjson.synthetic",
   18     18   
    "EnumQueryInput",
   19     19   
);
   20     20   
static ENUMQUERYINPUT_MEMBER_ENUM: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   21     21   
    ::aws_smithy_schema::ShapeId::from_static(
   22     22   
        "aws.protocoltests.restjson.synthetic#EnumQueryInput$enum",
   23     23   
        "aws.protocoltests.restjson.synthetic",
   24     24   
        "EnumQueryInput",
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::String,
   27         -
    "r##enum",
          27  +
    "enum",
   28     28   
    0,
   29     29   
)
   30     30   
.with_http_label();
   31     31   
static ENUMQUERYINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   32     32   
    ENUMQUERYINPUT_SCHEMA_ID,
   33     33   
    ::aws_smithy_schema::ShapeType::Structure,
   34     34   
    &[&ENUMQUERYINPUT_MEMBER_ENUM],
   35         -
);
          35  +
)
          36  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("GET", "/foo/{enum}", None));
   36     37   
impl EnumQueryInput {
   37     38   
    /// The schema for this shape.
   38     39   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &ENUMQUERYINPUT_SCHEMA;
   39     40   
}
   40     41   
impl ::aws_smithy_schema::serde::SerializableStruct for EnumQueryInput {
   41     42   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   42     43   
    fn serialize_members(
   43     44   
        &self,
   44     45   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   45     46   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   46     47   
        if let Some(ref val) = self.r#enum {
   47     48   
            ser.write_string(&ENUMQUERYINPUT_MEMBER_ENUM, val.as_str())?;
   48     49   
        }
   49     50   
        Ok(())
   50     51   
    }
   51     52   
}
   52     53   
impl EnumQueryInput {
   53     54   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   54         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   55         -
        deserializer: &mut D,
          55  +
    pub fn deserialize(
          56  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   56     57   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   57     58   
        #[allow(unused_variables, unused_mut)]
   58     59   
        let mut builder = Self::builder();
   59     60   
        #[allow(
   60     61   
            unused_variables,
   61     62   
            unreachable_code,
   62     63   
            clippy::single_match,
   63     64   
            clippy::match_single_binding,
   64     65   
            clippy::diverging_sub_expression
   65     66   
        )]
   66         -
        deserializer.read_struct(&ENUMQUERYINPUT_SCHEMA, (), |_, member, deser| {
          67  +
        deserializer.read_struct(&ENUMQUERYINPUT_SCHEMA, &mut |member, deser| {
   67     68   
            match member.member_index() {
   68     69   
                Some(0) => {
   69     70   
                    builder.r#enum = Some(crate::types::StringEnum::from(deser.read_string(member)?.as_str()));
   70     71   
                }
   71     72   
                _ => {}
   72     73   
            }
   73     74   
            Ok(())
   74     75   
        })?;
   75     76   
        builder
   76     77   
            .build()
   77     78   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   78     79   
    }
   79     80   
}
          81  +
impl EnumQueryInput {
          82  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          83  +
    pub fn deserialize_with_response(
          84  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          85  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          86  +
        _status: u16,
          87  +
        _body: &[u8],
          88  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          89  +
        Self::deserialize(deserializer)
          90  +
    }
          91  +
}
   80     92   
impl EnumQueryInput {
   81     93   
    /// Creates a new builder-style object to manufacture [`EnumQueryInput`](crate::operation::enum_query::EnumQueryInput).
   82     94   
    pub fn builder() -> crate::operation::enum_query::builders::EnumQueryInputBuilder {
   83     95   
        crate::operation::enum_query::builders::EnumQueryInputBuilder::default()
   84     96   
    }
   85     97   
}
   86     98   
   87     99   
/// A builder for [`EnumQueryInput`](crate::operation::enum_query::EnumQueryInput).
   88    100   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   89    101   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/enum_query/_enum_query_output.rs

@@ -1,1 +65,76 @@
   18     18   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   19     19   
    fn serialize_members(
   20     20   
        &self,
   21     21   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   22     22   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   23     23   
        Ok(())
   24     24   
    }
   25     25   
}
   26     26   
impl EnumQueryOutput {
   27     27   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   28         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   29         -
        deserializer: &mut D,
          28  +
    pub fn deserialize(
          29  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   30     30   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   31     31   
        #[allow(unused_variables, unused_mut)]
   32     32   
        let mut builder = Self::builder();
   33     33   
        #[allow(
   34     34   
            unused_variables,
   35     35   
            unreachable_code,
   36     36   
            clippy::single_match,
   37     37   
            clippy::match_single_binding,
   38     38   
            clippy::diverging_sub_expression
   39     39   
        )]
   40         -
        deserializer.read_struct(&ENUMQUERYOUTPUT_SCHEMA, (), |_, member, deser| {
          40  +
        deserializer.read_struct(&ENUMQUERYOUTPUT_SCHEMA, &mut |member, deser| {
   41     41   
            match member.member_index() {
   42     42   
                _ => {}
   43     43   
            }
   44     44   
            Ok(())
   45     45   
        })?;
   46     46   
        Ok(builder.build())
   47     47   
    }
   48     48   
}
          49  +
impl EnumQueryOutput {
          50  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          51  +
    pub fn deserialize_with_response(
          52  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          53  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          54  +
        _status: u16,
          55  +
        _body: &[u8],
          56  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          57  +
        Ok(Self::builder().build())
          58  +
    }
          59  +
}
   49     60   
impl EnumQueryOutput {
   50     61   
    /// Creates a new builder-style object to manufacture [`EnumQueryOutput`](crate::operation::enum_query::EnumQueryOutput).
   51     62   
    pub fn builder() -> crate::operation::enum_query::builders::EnumQueryOutputBuilder {
   52     63   
        crate::operation::enum_query::builders::EnumQueryOutputBuilder::default()
   53     64   
    }
   54     65   
}
   55     66   
   56     67   
/// A builder for [`EnumQueryOutput`](crate::operation::enum_query::EnumQueryOutput).
   57     68   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   58     69   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/escaped_string_values.rs

@@ -1,1 +40,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
/// Orchestration and serialization glue logic for `EscapedStringValues`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct EscapedStringValues;
    6      6   
impl EscapedStringValues {
    7      7   
    /// Creates a new `EscapedStringValues`
    8      8   
    pub fn new() -> Self {
    9      9   
        Self
   10     10   
    }
          11  +
    /// The schema for this operation's input shape.
          12  +
    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::escaped_string_values::EscapedStringValuesInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::escaped_string_values::EscapedStringValuesOutput::SCHEMA;
   11     15   
    pub(crate) async fn orchestrate(
   12     16   
        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
   13     17   
        input: crate::operation::escaped_string_values::EscapedStringValuesInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::escaped_string_values::EscapedStringValuesOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::escaped_string_values::EscapedStringValuesError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +234,299 @@
  130    134   
                crate::operation::escaped_string_values::EscapedStringValuesError,
  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 EscapedStringValuesResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EscapedStringValuesResponseDeserializer {
  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_escaped_string_values::de_escaped_string_values_http_error(status, headers, body)
  152         -
        } else {
  153         -
            crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values_http_response(status, headers, body)
         161  +
            let generic = generic_builder.build();
         162  +
            let error_code = match generic.code() {
         163  +
                ::std::option::Option::Some(code) => code,
         164  +
                ::std::option::Option::None => {
         165  +
                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         166  +
                        ::aws_smithy_runtime_api::box_error::BoxError::from(
         167  +
                            crate::operation::escaped_string_values::EscapedStringValuesError::unhandled(generic),
         168  +
                        ),
         169  +
                    ))
         170  +
                }
         171  +
            };
         172  +
            let _error_message = generic.message().map(|msg| msg.to_owned());
         173  +
            let protocol = _cfg
         174  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         175  +
                .expect("a SharedClientProtocol is required");
         176  +
            let err = match error_code {
         177  +
                "ValidationException" => crate::operation::escaped_string_values::EscapedStringValuesError::ValidationError({
         178  +
                    let mut tmp = match protocol
         179  +
                        .deserialize_response(response, crate::types::error::ValidationError::SCHEMA, _cfg)
         180  +
                        .and_then(|mut deser| {
         181  +
                            crate::types::error::ValidationError::deserialize_with_response(
         182  +
                                &mut *deser,
         183  +
                                response.headers(),
         184  +
                                response.status().into(),
         185  +
                                body,
         186  +
                            )
         187  +
                        }) {
         188  +
                        ::std::result::Result::Ok(val) => val,
         189  +
                        ::std::result::Result::Err(e) => {
         190  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         191  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         192  +
                            ))
         193  +
                        }
         194  +
                    };
         195  +
                    tmp.meta = generic;
         196  +
                    tmp
         197  +
                }),
         198  +
                "ExtraError" => crate::operation::escaped_string_values::EscapedStringValuesError::ExtraError({
         199  +
                    let mut tmp = match protocol
         200  +
                        .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
         201  +
                        .and_then(|mut deser| {
         202  +
                            crate::types::error::ExtraError::deserialize_with_response(
         203  +
                                &mut *deser,
         204  +
                                response.headers(),
         205  +
                                response.status().into(),
         206  +
                                body,
         207  +
                            )
         208  +
                        }) {
         209  +
                        ::std::result::Result::Ok(val) => val,
         210  +
                        ::std::result::Result::Err(e) => {
         211  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         212  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         213  +
                            ))
         214  +
                        }
  154    215   
                    };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         216  +
                    tmp.meta = generic;
         217  +
                    if tmp.message.is_none() {
         218  +
                        tmp.message = _error_message;
         219  +
                    }
         220  +
                    tmp
         221  +
                }),
         222  +
                _ => crate::operation::escaped_string_values::EscapedStringValuesError::generic(generic),
         223  +
            };
         224  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         225  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         226  +
            ))
         227  +
        } else {
         228  +
            let protocol = _cfg
         229  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         230  +
                .expect("a SharedClientProtocol is required");
         231  +
            let mut deser = protocol
         232  +
                .deserialize_response(response, EscapedStringValues::OUTPUT_SCHEMA, _cfg)
         233  +
                .map_err(|e| {
         234  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         235  +
                })?;
         236  +
            let body = response.body().bytes().expect("body loaded");
         237  +
            let output = crate::operation::escaped_string_values::EscapedStringValuesOutput::deserialize_with_response(
         238  +
                &mut *deser,
         239  +
                response.headers(),
         240  +
                response.status().into(),
         241  +
                body,
         242  +
            )
         243  +
            .map_err(|e| {
         244  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         245  +
            })?;
         246  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         247  +
        }
  156    248   
    }
  157    249   
}
  158    250   
#[derive(Debug)]
  159    251   
struct EscapedStringValuesRequestSerializer;
  160    252   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EscapedStringValuesRequestSerializer {
  161    253   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    254   
    fn serialize_input(
  163    255   
        &self,
  164    256   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    257   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    258   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    259   
        let input = input
  168    260   
            .downcast::<crate::operation::escaped_string_values::EscapedStringValuesInput>()
  169    261   
            .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::escaped_string_values::EscapedStringValuesInput,
  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, "/escaped-string-values").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::escaped_string_values::EscapedStringValuesInput,
  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/json");
  195         -
            builder
  196         -
        };
  197         -
        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_escaped_string_values::ser_escaped_string_values_input(
  198         -
            &input,
  199         -
        )?);
  200         -
        if let Some(content_length) = body.content_length() {
  201         -
            let content_length = content_length.to_string();
  202         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
  203         -
        }
  204         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         262  +
        let protocol = _cfg
         263  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         264  +
            .expect("a SharedClientProtocol is required");
         265  +
        let mut request = protocol
         266  +
            .serialize_request(&input, EscapedStringValues::INPUT_SCHEMA, "", _cfg)
         267  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         268  +
         269  +
        return ::std::result::Result::Ok(request);
  205    270   
    }
  206    271   
}
  207    272   
#[derive(Debug)]
  208    273   
struct EscapedStringValuesEndpointParamsInterceptor;
  209    274   
  210    275   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EscapedStringValuesEndpointParamsInterceptor {
  211    276   
    fn name(&self) -> &'static str {
  212    277   
        "EscapedStringValuesEndpointParamsInterceptor"
  213    278   
    }
  214    279   
@@ -291,356 +392,477 @@
  311    376   
            .expect("the config must have a deserializer");
  312    377   
  313    378   
        let parsed = de.deserialize_streaming(&mut http_response);
  314    379   
        let parsed = parsed.unwrap_or_else(|| {
  315    380   
            let http_response = http_response.map(|body| {
  316    381   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  317    382   
                    body.bytes().unwrap(),
  318    383   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  319    384   
                )))
  320    385   
            });
  321         -
            de.deserialize_nonstreaming(&http_response)
         386  +
            // Build a config bag with the protocol for schema-based deserialization
         387  +
            #[allow(unused_mut)]
         388  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         389  +
            {
         390  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         391  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         392  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         393  +
                ));
         394  +
                test_cfg.push_shared_layer(layer.freeze());
         395  +
            }
         396  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  322    397   
        });
  323    398   
        let parsed = parsed
  324    399   
            .expect("should be successful response")
  325    400   
            .downcast::<crate::operation::escaped_string_values::EscapedStringValuesOutput>()
  326    401   
            .unwrap();
  327    402   
        ::pretty_assertions::assert_eq!(parsed.r#enum, expected_output.r#enum, "Unexpected value for `r#enum`");
  328    403   
        ::pretty_assertions::assert_eq!(parsed.some_string, expected_output.some_string, "Unexpected value for `some_string`");
  329    404   
    }
  330    405   
  331    406   
    /// Upper case error modeled lower case
  332    407   
    /// Test ID: ServiceLevelErrorClient
  333    408   
    #[::tokio::test]
  334    409   
    #[::tracing_test::traced_test]
  335    410   
    async fn service_level_error_client_response() {
  336    411   
        let expected_output = crate::types::error::ExtraError::builder().build();
  337    412   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  338    413   
            ::http_1x::response::Builder::new()
  339    414   
                .header("X-Amzn-Errortype", "ExtraError")
  340    415   
                .status(500)
  341    416   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  342    417   
                .unwrap(),
  343    418   
        )
  344    419   
        .unwrap();
  345    420   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  346    421   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  347    422   
  348    423   
        let op = crate::operation::escaped_string_values::EscapedStringValues::new();
  349    424   
        let config = op.config().expect("the operation has config");
  350    425   
        let de = config
  351    426   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  352    427   
            .expect("the config must have a deserializer");
  353    428   
  354    429   
        let parsed = de.deserialize_streaming(&mut http_response);
  355    430   
        let parsed = parsed.unwrap_or_else(|| {
  356    431   
            let http_response = http_response.map(|body| {
  357    432   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  358    433   
                    body.bytes().unwrap(),
  359    434   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  360    435   
                )))
  361    436   
            });
  362         -
            de.deserialize_nonstreaming(&http_response)
         437  +
            // Build a config bag with the protocol for schema-based deserialization
         438  +
            #[allow(unused_mut)]
         439  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         440  +
            {
         441  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         442  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         443  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         444  +
                ));
         445  +
                test_cfg.push_shared_layer(layer.freeze());
         446  +
            }
         447  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  363    448   
        });
  364    449   
        let parsed = parsed.expect_err("should be error response");
  365    450   
        let parsed: &crate::operation::escaped_string_values::EscapedStringValuesError =
  366    451   
            parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
  367    452   
        if let crate::operation::escaped_string_values::EscapedStringValuesError::ExtraError(parsed) = parsed {
  368    453   
            ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
  369    454   
        } else {
  370    455   
            panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
  371    456   
        }
  372    457   
    }

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/escaped_string_values/_escaped_string_values_input.rs

@@ -3,3 +131,143 @@
   23     23   
    "aws.protocoltests.restjson.synthetic",
   24     24   
    "EscapedStringValuesInput",
   25     25   
);
   26     26   
static ESCAPEDSTRINGVALUESINPUT_MEMBER_ENUM: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   27     27   
    ::aws_smithy_schema::ShapeId::from_static(
   28     28   
        "aws.protocoltests.restjson.synthetic#EscapedStringValuesInput$enum",
   29     29   
        "aws.protocoltests.restjson.synthetic",
   30     30   
        "EscapedStringValuesInput",
   31     31   
    ),
   32     32   
    ::aws_smithy_schema::ShapeType::String,
   33         -
    "r##enum",
          33  +
    "enum",
   34     34   
    0,
   35     35   
);
   36     36   
static ESCAPEDSTRINGVALUESINPUT_MEMBER_SOME_STRING: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   37     37   
    ::aws_smithy_schema::ShapeId::from_static(
   38     38   
        "aws.protocoltests.restjson.synthetic#EscapedStringValuesInput$someString",
   39     39   
        "aws.protocoltests.restjson.synthetic",
   40     40   
        "EscapedStringValuesInput",
   41     41   
    ),
   42     42   
    ::aws_smithy_schema::ShapeType::String,
   43         -
    "some_string",
          43  +
    "someString",
   44     44   
    1,
   45     45   
)
   46     46   
.with_json_name("also\"has\"quotes");
   47     47   
static ESCAPEDSTRINGVALUESINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   48     48   
    ESCAPEDSTRINGVALUESINPUT_SCHEMA_ID,
   49     49   
    ::aws_smithy_schema::ShapeType::Structure,
   50     50   
    &[&ESCAPEDSTRINGVALUESINPUT_MEMBER_ENUM, &ESCAPEDSTRINGVALUESINPUT_MEMBER_SOME_STRING],
   51         -
);
          51  +
)
          52  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/escaped-string-values", None));
   52     53   
impl EscapedStringValuesInput {
   53     54   
    /// The schema for this shape.
   54     55   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &ESCAPEDSTRINGVALUESINPUT_SCHEMA;
   55     56   
}
   56     57   
impl ::aws_smithy_schema::serde::SerializableStruct for EscapedStringValuesInput {
   57     58   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   58     59   
    fn serialize_members(
   59     60   
        &self,
   60     61   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   61     62   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   62     63   
        if let Some(ref val) = self.r#enum {
   63     64   
            ser.write_string(&ESCAPEDSTRINGVALUESINPUT_MEMBER_ENUM, val.as_str())?;
   64     65   
        }
   65     66   
        if let Some(ref val) = self.some_string {
   66     67   
            ser.write_string(&ESCAPEDSTRINGVALUESINPUT_MEMBER_SOME_STRING, val)?;
   67     68   
        }
   68     69   
        Ok(())
   69     70   
    }
   70     71   
}
   71     72   
impl EscapedStringValuesInput {
   72     73   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   73         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   74         -
        deserializer: &mut D,
          74  +
    pub fn deserialize(
          75  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   75     76   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   76     77   
        #[allow(unused_variables, unused_mut)]
   77     78   
        let mut builder = Self::builder();
   78     79   
        #[allow(
   79     80   
            unused_variables,
   80     81   
            unreachable_code,
   81     82   
            clippy::single_match,
   82     83   
            clippy::match_single_binding,
   83     84   
            clippy::diverging_sub_expression
   84     85   
        )]
   85         -
        deserializer.read_struct(&ESCAPEDSTRINGVALUESINPUT_SCHEMA, (), |_, member, deser| {
          86  +
        deserializer.read_struct(&ESCAPEDSTRINGVALUESINPUT_SCHEMA, &mut |member, deser| {
   86     87   
            match member.member_index() {
   87     88   
                Some(0) => {
   88     89   
                    builder.r#enum = Some(crate::types::EnumWithEscapedChars::from(deser.read_string(member)?.as_str()));
   89     90   
                }
   90     91   
                Some(1) => {
   91     92   
                    builder.some_string = Some(deser.read_string(member)?);
   92     93   
                }
   93     94   
                _ => {}
   94     95   
            }
   95     96   
            Ok(())
   96     97   
        })?;
   97     98   
        builder
   98     99   
            .build()
   99    100   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  100    101   
    }
  101    102   
}
         103  +
impl EscapedStringValuesInput {
         104  +
    /// Deserializes this structure from a body deserializer and HTTP response.
         105  +
    pub fn deserialize_with_response(
         106  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         107  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
         108  +
        _status: u16,
         109  +
        _body: &[u8],
         110  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         111  +
        Self::deserialize(deserializer)
         112  +
    }
         113  +
}
  102    114   
impl EscapedStringValuesInput {
  103    115   
    /// Creates a new builder-style object to manufacture [`EscapedStringValuesInput`](crate::operation::escaped_string_values::EscapedStringValuesInput).
  104    116   
    pub fn builder() -> crate::operation::escaped_string_values::builders::EscapedStringValuesInputBuilder {
  105    117   
        crate::operation::escaped_string_values::builders::EscapedStringValuesInputBuilder::default()
  106    118   
    }
  107    119   
}
  108    120   
  109    121   
/// A builder for [`EscapedStringValuesInput`](crate::operation::escaped_string_values::EscapedStringValuesInput).
  110    122   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  111    123   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/escaped_string_values/_escaped_string_values_output.rs

@@ -3,3 +129,140 @@
   23     23   
    "aws.protocoltests.restjson.synthetic",
   24     24   
    "EscapedStringValuesOutput",
   25     25   
);
   26     26   
static ESCAPEDSTRINGVALUESOUTPUT_MEMBER_ENUM: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   27     27   
    ::aws_smithy_schema::ShapeId::from_static(
   28     28   
        "aws.protocoltests.restjson.synthetic#EscapedStringValuesOutput$enum",
   29     29   
        "aws.protocoltests.restjson.synthetic",
   30     30   
        "EscapedStringValuesOutput",
   31     31   
    ),
   32     32   
    ::aws_smithy_schema::ShapeType::String,
   33         -
    "r##enum",
          33  +
    "enum",
   34     34   
    0,
   35     35   
);
   36     36   
static ESCAPEDSTRINGVALUESOUTPUT_MEMBER_SOME_STRING: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   37     37   
    ::aws_smithy_schema::ShapeId::from_static(
   38     38   
        "aws.protocoltests.restjson.synthetic#EscapedStringValuesOutput$someString",
   39     39   
        "aws.protocoltests.restjson.synthetic",
   40     40   
        "EscapedStringValuesOutput",
   41     41   
    ),
   42     42   
    ::aws_smithy_schema::ShapeType::String,
   43         -
    "some_string",
          43  +
    "someString",
   44     44   
    1,
   45     45   
)
   46     46   
.with_json_name("also\"has\"quotes");
   47     47   
static ESCAPEDSTRINGVALUESOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   48     48   
    ESCAPEDSTRINGVALUESOUTPUT_SCHEMA_ID,
   49     49   
    ::aws_smithy_schema::ShapeType::Structure,
   50     50   
    &[&ESCAPEDSTRINGVALUESOUTPUT_MEMBER_ENUM, &ESCAPEDSTRINGVALUESOUTPUT_MEMBER_SOME_STRING],
   51     51   
);
   52     52   
impl EscapedStringValuesOutput {
   53     53   
    /// The schema for this shape.
   54     54   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &ESCAPEDSTRINGVALUESOUTPUT_SCHEMA;
   55     55   
}
   56     56   
impl ::aws_smithy_schema::serde::SerializableStruct for EscapedStringValuesOutput {
   57     57   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   58     58   
    fn serialize_members(
   59     59   
        &self,
   60     60   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   61     61   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   62     62   
        if let Some(ref val) = self.r#enum {
   63     63   
            ser.write_string(&ESCAPEDSTRINGVALUESOUTPUT_MEMBER_ENUM, val.as_str())?;
   64     64   
        }
   65     65   
        if let Some(ref val) = self.some_string {
   66     66   
            ser.write_string(&ESCAPEDSTRINGVALUESOUTPUT_MEMBER_SOME_STRING, val)?;
   67     67   
        }
   68     68   
        Ok(())
   69     69   
    }
   70     70   
}
   71     71   
impl EscapedStringValuesOutput {
   72     72   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   73         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   74         -
        deserializer: &mut D,
          73  +
    pub fn deserialize(
          74  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   75     75   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   76     76   
        #[allow(unused_variables, unused_mut)]
   77     77   
        let mut builder = Self::builder();
   78     78   
        #[allow(
   79     79   
            unused_variables,
   80     80   
            unreachable_code,
   81     81   
            clippy::single_match,
   82     82   
            clippy::match_single_binding,
   83     83   
            clippy::diverging_sub_expression
   84     84   
        )]
   85         -
        deserializer.read_struct(&ESCAPEDSTRINGVALUESOUTPUT_SCHEMA, (), |_, member, deser| {
          85  +
        deserializer.read_struct(&ESCAPEDSTRINGVALUESOUTPUT_SCHEMA, &mut |member, deser| {
   86     86   
            match member.member_index() {
   87     87   
                Some(0) => {
   88     88   
                    builder.r#enum = Some(crate::types::EnumWithEscapedChars::from(deser.read_string(member)?.as_str()));
   89     89   
                }
   90     90   
                Some(1) => {
   91     91   
                    builder.some_string = Some(deser.read_string(member)?);
   92     92   
                }
   93     93   
                _ => {}
   94     94   
            }
   95     95   
            Ok(())
   96     96   
        })?;
   97     97   
        Ok(builder.build())
   98     98   
    }
   99     99   
}
         100  +
impl EscapedStringValuesOutput {
         101  +
    /// Deserializes this structure from a body deserializer and HTTP response.
         102  +
    pub fn deserialize_with_response(
         103  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         104  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
         105  +
        _status: u16,
         106  +
        _body: &[u8],
         107  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         108  +
        Self::deserialize(deserializer)
         109  +
    }
         110  +
}
  100    111   
impl EscapedStringValuesOutput {
  101    112   
    /// Creates a new builder-style object to manufacture [`EscapedStringValuesOutput`](crate::operation::escaped_string_values::EscapedStringValuesOutput).
  102    113   
    pub fn builder() -> crate::operation::escaped_string_values::builders::EscapedStringValuesOutputBuilder {
  103    114   
        crate::operation::escaped_string_values::builders::EscapedStringValuesOutputBuilder::default()
  104    115   
    }
  105    116   
}
  106    117   
  107    118   
/// A builder for [`EscapedStringValuesOutput`](crate::operation::escaped_string_values::EscapedStringValuesOutput).
  108    119   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  109    120   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/map_with_enum_key_op.rs

@@ -1,1 +40,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
/// Orchestration and serialization glue logic for `MapWithEnumKeyOp`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct MapWithEnumKeyOp;
    6      6   
impl MapWithEnumKeyOp {
    7      7   
    /// Creates a new `MapWithEnumKeyOp`
    8      8   
    pub fn new() -> Self {
    9      9   
        Self
   10     10   
    }
          11  +
    /// The schema for this operation's input shape.
          12  +
    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::map_with_enum_key_op::MapWithEnumKeyOpInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::map_with_enum_key_op::MapWithEnumKeyOpOutput::SCHEMA;
   11     15   
    pub(crate) async fn orchestrate(
   12     16   
        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
   13     17   
        input: crate::operation::map_with_enum_key_op::MapWithEnumKeyOpInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::map_with_enum_key_op::MapWithEnumKeyOpOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +233,299 @@
  130    134   
                crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError,
  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 MapWithEnumKeyOpResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for MapWithEnumKeyOpResponseDeserializer {
  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_map_with_enum_key_op::de_map_with_enum_key_op_http_error(status, headers, body)
  152         -
        } else {
  153         -
            crate::protocol_serde::shape_map_with_enum_key_op::de_map_with_enum_key_op_http_response(status, headers, body)
         161  +
            let generic = generic_builder.build();
         162  +
            let error_code = match generic.code() {
         163  +
                ::std::option::Option::Some(code) => code,
         164  +
                ::std::option::Option::None => {
         165  +
                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         166  +
                        ::aws_smithy_runtime_api::box_error::BoxError::from(
         167  +
                            crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError::unhandled(generic),
         168  +
                        ),
         169  +
                    ))
         170  +
                }
         171  +
            };
         172  +
            let _error_message = generic.message().map(|msg| msg.to_owned());
         173  +
            let protocol = _cfg
         174  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         175  +
                .expect("a SharedClientProtocol is required");
         176  +
            let err = match error_code {
         177  +
                "ValidationException" => crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError::ValidationError({
         178  +
                    let mut tmp = match protocol
         179  +
                        .deserialize_response(response, crate::types::error::ValidationError::SCHEMA, _cfg)
         180  +
                        .and_then(|mut deser| {
         181  +
                            crate::types::error::ValidationError::deserialize_with_response(
         182  +
                                &mut *deser,
         183  +
                                response.headers(),
         184  +
                                response.status().into(),
         185  +
                                body,
         186  +
                            )
         187  +
                        }) {
         188  +
                        ::std::result::Result::Ok(val) => val,
         189  +
                        ::std::result::Result::Err(e) => {
         190  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         191  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         192  +
                            ))
         193  +
                        }
         194  +
                    };
         195  +
                    tmp.meta = generic;
         196  +
                    tmp
         197  +
                }),
         198  +
                "ExtraError" => crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError::ExtraError({
         199  +
                    let mut tmp = match protocol
         200  +
                        .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
         201  +
                        .and_then(|mut deser| {
         202  +
                            crate::types::error::ExtraError::deserialize_with_response(
         203  +
                                &mut *deser,
         204  +
                                response.headers(),
         205  +
                                response.status().into(),
         206  +
                                body,
         207  +
                            )
         208  +
                        }) {
         209  +
                        ::std::result::Result::Ok(val) => val,
         210  +
                        ::std::result::Result::Err(e) => {
         211  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         212  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         213  +
                            ))
         214  +
                        }
  154    215   
                    };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         216  +
                    tmp.meta = generic;
         217  +
                    if tmp.message.is_none() {
         218  +
                        tmp.message = _error_message;
         219  +
                    }
         220  +
                    tmp
         221  +
                }),
         222  +
                _ => crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError::generic(generic),
         223  +
            };
         224  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         225  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         226  +
            ))
         227  +
        } else {
         228  +
            let protocol = _cfg
         229  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         230  +
                .expect("a SharedClientProtocol is required");
         231  +
            let mut deser = protocol
         232  +
                .deserialize_response(response, MapWithEnumKeyOp::OUTPUT_SCHEMA, _cfg)
         233  +
                .map_err(|e| {
         234  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         235  +
                })?;
         236  +
            let body = response.body().bytes().expect("body loaded");
         237  +
            let output = crate::operation::map_with_enum_key_op::MapWithEnumKeyOpOutput::deserialize_with_response(
         238  +
                &mut *deser,
         239  +
                response.headers(),
         240  +
                response.status().into(),
         241  +
                body,
         242  +
            )
         243  +
            .map_err(|e| {
         244  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         245  +
            })?;
         246  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         247  +
        }
  156    248   
    }
  157    249   
}
  158    250   
#[derive(Debug)]
  159    251   
struct MapWithEnumKeyOpRequestSerializer;
  160    252   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for MapWithEnumKeyOpRequestSerializer {
  161    253   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    254   
    fn serialize_input(
  163    255   
        &self,
  164    256   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    257   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    258   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    259   
        let input = input
  168    260   
            .downcast::<crate::operation::map_with_enum_key_op::MapWithEnumKeyOpInput>()
  169    261   
            .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::map_with_enum_key_op::MapWithEnumKeyOpInput,
  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, "/map-with-enum-key").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::map_with_enum_key_op::MapWithEnumKeyOpInput,
  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/json");
  195         -
            builder
  196         -
        };
  197         -
        let body =
  198         -
            ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_map_with_enum_key_op::ser_map_with_enum_key_op_input(&input)?);
  199         -
        if let Some(content_length) = body.content_length() {
  200         -
            let content_length = content_length.to_string();
  201         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
  202         -
        }
  203         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         262  +
        let protocol = _cfg
         263  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         264  +
            .expect("a SharedClientProtocol is required");
         265  +
        let mut request = protocol
         266  +
            .serialize_request(&input, MapWithEnumKeyOp::INPUT_SCHEMA, "", _cfg)
         267  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         268  +
         269  +
        return ::std::result::Result::Ok(request);
  204    270   
    }
  205    271   
}
  206    272   
#[derive(Debug)]
  207    273   
struct MapWithEnumKeyOpEndpointParamsInterceptor;
  208    274   
  209    275   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for MapWithEnumKeyOpEndpointParamsInterceptor {
  210    276   
    fn name(&self) -> &'static str {
  211    277   
        "MapWithEnumKeyOpEndpointParamsInterceptor"
  212    278   
    }
  213    279   
@@ -292,358 +392,478 @@
  312    378   
            .expect("the config must have a deserializer");
  313    379   
  314    380   
        let parsed = de.deserialize_streaming(&mut http_response);
  315    381   
        let parsed = parsed.unwrap_or_else(|| {
  316    382   
            let http_response = http_response.map(|body| {
  317    383   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  318    384   
                    body.bytes().unwrap(),
  319    385   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  320    386   
                )))
  321    387   
            });
  322         -
            de.deserialize_nonstreaming(&http_response)
         388  +
            // Build a config bag with the protocol for schema-based deserialization
         389  +
            #[allow(unused_mut)]
         390  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         391  +
            {
         392  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         393  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         394  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         395  +
                ));
         396  +
                test_cfg.push_shared_layer(layer.freeze());
         397  +
            }
         398  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  323    399   
        });
  324    400   
        let parsed = parsed
  325    401   
            .expect("should be successful response")
  326    402   
            .downcast::<crate::operation::map_with_enum_key_op::MapWithEnumKeyOpOutput>()
  327    403   
            .unwrap();
  328    404   
        ::pretty_assertions::assert_eq!(parsed.map, expected_output.map, "Unexpected value for `map`");
  329    405   
    }
  330    406   
  331    407   
    /// Upper case error modeled lower case
  332    408   
    /// Test ID: ServiceLevelErrorClient
  333    409   
    #[::tokio::test]
  334    410   
    #[::tracing_test::traced_test]
  335    411   
    async fn service_level_error_client_response() {
  336    412   
        let expected_output = crate::types::error::ExtraError::builder().build();
  337    413   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  338    414   
            ::http_1x::response::Builder::new()
  339    415   
                .header("X-Amzn-Errortype", "ExtraError")
  340    416   
                .status(500)
  341    417   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  342    418   
                .unwrap(),
  343    419   
        )
  344    420   
        .unwrap();
  345    421   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  346    422   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  347    423   
  348    424   
        let op = crate::operation::map_with_enum_key_op::MapWithEnumKeyOp::new();
  349    425   
        let config = op.config().expect("the operation has config");
  350    426   
        let de = config
  351    427   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  352    428   
            .expect("the config must have a deserializer");
  353    429   
  354    430   
        let parsed = de.deserialize_streaming(&mut http_response);
  355    431   
        let parsed = parsed.unwrap_or_else(|| {
  356    432   
            let http_response = http_response.map(|body| {
  357    433   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  358    434   
                    body.bytes().unwrap(),
  359    435   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  360    436   
                )))
  361    437   
            });
  362         -
            de.deserialize_nonstreaming(&http_response)
         438  +
            // Build a config bag with the protocol for schema-based deserialization
         439  +
            #[allow(unused_mut)]
         440  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         441  +
            {
         442  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         443  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         444  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         445  +
                ));
         446  +
                test_cfg.push_shared_layer(layer.freeze());
         447  +
            }
         448  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  363    449   
        });
  364    450   
        let parsed = parsed.expect_err("should be error response");
  365    451   
        let parsed: &crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError =
  366    452   
            parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
  367    453   
        if let crate::operation::map_with_enum_key_op::MapWithEnumKeyOpError::ExtraError(parsed) = parsed {
  368    454   
            ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
  369    455   
        } else {
  370    456   
            panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
  371    457   
        }
  372    458   
    }

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/map_with_enum_key_op/_map_with_enum_key_op_input.rs

@@ -4,4 +127,136 @@
   24     24   
        "MapWithEnumKeyOpInput",
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::Map,
   27     27   
    "map",
   28     28   
    0,
   29     29   
);
   30     30   
static MAPWITHENUMKEYOPINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   31     31   
    MAPWITHENUMKEYOPINPUT_SCHEMA_ID,
   32     32   
    ::aws_smithy_schema::ShapeType::Structure,
   33     33   
    &[&MAPWITHENUMKEYOPINPUT_MEMBER_MAP],
   34         -
);
          34  +
)
          35  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/map-with-enum-key", None));
   35     36   
impl MapWithEnumKeyOpInput {
   36     37   
    /// The schema for this shape.
   37     38   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &MAPWITHENUMKEYOPINPUT_SCHEMA;
   38     39   
}
   39     40   
impl ::aws_smithy_schema::serde::SerializableStruct for MapWithEnumKeyOpInput {
   40     41   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   41     42   
    fn serialize_members(
   42     43   
        &self,
   43     44   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   44     45   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   45     46   
        if let Some(ref val) = self.map {
   46     47   
            ser.write_map(
   47     48   
                &MAPWITHENUMKEYOPINPUT_MEMBER_MAP,
   48     49   
                &|ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer| {
   49     50   
                    for (key, value) in val {
   50     51   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, key.as_str())?;
   51     52   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, value)?;
   52     53   
                    }
   53     54   
                    Ok(())
   54     55   
                },
   55     56   
            )?;
   56     57   
        }
   57     58   
        Ok(())
   58     59   
    }
   59     60   
}
   60     61   
impl MapWithEnumKeyOpInput {
   61     62   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   62         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   63         -
        deserializer: &mut D,
          63  +
    pub fn deserialize(
          64  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   64     65   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   65     66   
        #[allow(unused_variables, unused_mut)]
   66     67   
        let mut builder = Self::builder();
   67     68   
        #[allow(
   68     69   
            unused_variables,
   69     70   
            unreachable_code,
   70     71   
            clippy::single_match,
   71     72   
            clippy::match_single_binding,
   72     73   
            clippy::diverging_sub_expression
   73     74   
        )]
   74         -
        deserializer.read_struct(&MAPWITHENUMKEYOPINPUT_SCHEMA, (), |_, member, deser| {
          75  +
        deserializer.read_struct(&MAPWITHENUMKEYOPINPUT_SCHEMA, &mut |member, deser| {
   75     76   
            match member.member_index() {
   76     77   
                Some(0) => {
   77     78   
                    builder.map = Some({
   78         -
                        let container = if let Some(cap) = deser.container_size() {
   79         -
                            std::collections::HashMap::with_capacity(cap)
   80         -
                        } else {
   81         -
                            std::collections::HashMap::new()
   82         -
                        };
   83         -
                        deser.read_map(member, container, |mut map, key, deser| {
   84         -
                            map.insert(crate::types::StringEnum::from(key.as_str()), deser.read_string(member)?);
   85         -
                            Ok(map)
   86         -
                        })?
          79  +
                        let mut container = std::collections::HashMap::new();
          80  +
                        deser.read_map(member, &mut |key, deser| {
          81  +
                            container.insert(crate::types::StringEnum::from(key.as_str()), deser.read_string(member)?);
          82  +
                            Ok(())
          83  +
                        })?;
          84  +
                        container
   87     85   
                    });
   88     86   
                }
   89     87   
                _ => {}
   90     88   
            }
   91     89   
            Ok(())
   92     90   
        })?;
   93     91   
        builder
   94     92   
            .build()
   95     93   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   96     94   
    }
   97     95   
}
          96  +
impl MapWithEnumKeyOpInput {
          97  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          98  +
    pub fn deserialize_with_response(
          99  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         100  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
         101  +
        _status: u16,
         102  +
        _body: &[u8],
         103  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         104  +
        Self::deserialize(deserializer)
         105  +
    }
         106  +
}
   98    107   
impl MapWithEnumKeyOpInput {
   99    108   
    /// Creates a new builder-style object to manufacture [`MapWithEnumKeyOpInput`](crate::operation::map_with_enum_key_op::MapWithEnumKeyOpInput).
  100    109   
    pub fn builder() -> crate::operation::map_with_enum_key_op::builders::MapWithEnumKeyOpInputBuilder {
  101    110   
        crate::operation::map_with_enum_key_op::builders::MapWithEnumKeyOpInputBuilder::default()
  102    111   
    }
  103    112   
}
  104    113   
  105    114   
/// A builder for [`MapWithEnumKeyOpInput`](crate::operation::map_with_enum_key_op::MapWithEnumKeyOpInput).
  106    115   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  107    116   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/map_with_enum_key_op/_map_with_enum_key_op_output.rs

@@ -32,32 +125,133 @@
   52     52   
                    }
   53     53   
                    Ok(())
   54     54   
                },
   55     55   
            )?;
   56     56   
        }
   57     57   
        Ok(())
   58     58   
    }
   59     59   
}
   60     60   
impl MapWithEnumKeyOpOutput {
   61     61   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   62         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   63         -
        deserializer: &mut D,
          62  +
    pub fn deserialize(
          63  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   64     64   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   65     65   
        #[allow(unused_variables, unused_mut)]
   66     66   
        let mut builder = Self::builder();
   67     67   
        #[allow(
   68     68   
            unused_variables,
   69     69   
            unreachable_code,
   70     70   
            clippy::single_match,
   71     71   
            clippy::match_single_binding,
   72     72   
            clippy::diverging_sub_expression
   73     73   
        )]
   74         -
        deserializer.read_struct(&MAPWITHENUMKEYOPOUTPUT_SCHEMA, (), |_, member, deser| {
          74  +
        deserializer.read_struct(&MAPWITHENUMKEYOPOUTPUT_SCHEMA, &mut |member, deser| {
   75     75   
            match member.member_index() {
   76     76   
                Some(0) => {
   77     77   
                    builder.map = Some({
   78         -
                        let container = if let Some(cap) = deser.container_size() {
   79         -
                            std::collections::HashMap::with_capacity(cap)
   80         -
                        } else {
   81         -
                            std::collections::HashMap::new()
   82         -
                        };
   83         -
                        deser.read_map(member, container, |mut map, key, deser| {
   84         -
                            map.insert(crate::types::StringEnum::from(key.as_str()), deser.read_string(member)?);
   85         -
                            Ok(map)
   86         -
                        })?
          78  +
                        let mut container = std::collections::HashMap::new();
          79  +
                        deser.read_map(member, &mut |key, deser| {
          80  +
                            container.insert(crate::types::StringEnum::from(key.as_str()), deser.read_string(member)?);
          81  +
                            Ok(())
          82  +
                        })?;
          83  +
                        container
   87     84   
                    });
   88     85   
                }
   89     86   
                _ => {}
   90     87   
            }
   91     88   
            Ok(())
   92     89   
        })?;
   93     90   
        Ok(builder.build())
   94     91   
    }
   95     92   
}
          93  +
impl MapWithEnumKeyOpOutput {
          94  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          95  +
    pub fn deserialize_with_response(
          96  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          97  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          98  +
        _status: u16,
          99  +
        _body: &[u8],
         100  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         101  +
        Self::deserialize(deserializer)
         102  +
    }
         103  +
}
   96    104   
impl MapWithEnumKeyOpOutput {
   97    105   
    /// Creates a new builder-style object to manufacture [`MapWithEnumKeyOpOutput`](crate::operation::map_with_enum_key_op::MapWithEnumKeyOpOutput).
   98    106   
    pub fn builder() -> crate::operation::map_with_enum_key_op::builders::MapWithEnumKeyOpOutputBuilder {
   99    107   
        crate::operation::map_with_enum_key_op::builders::MapWithEnumKeyOpOutputBuilder::default()
  100    108   
    }
  101    109   
}
  102    110   
  103    111   
/// A builder for [`MapWithEnumKeyOpOutput`](crate::operation::map_with_enum_key_op::MapWithEnumKeyOpOutput).
  104    112   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  105    113   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json_extras/rust-client-codegen/src/operation/null_in_non_sparse.rs

@@ -1,1 +40,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
/// Orchestration and serialization glue logic for `NullInNonSparse`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct NullInNonSparse;
    6      6   
impl NullInNonSparse {
    7      7   
    /// Creates a new `NullInNonSparse`
    8      8   
    pub fn new() -> Self {
    9      9   
        Self
   10     10   
    }
          11  +
    /// The schema for this operation's input shape.
          12  +
    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::null_in_non_sparse::NullInNonSparseInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::null_in_non_sparse::NullInNonSparseOutput::SCHEMA;
   11     15   
    pub(crate) async fn orchestrate(
   12     16   
        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
   13     17   
        input: crate::operation::null_in_non_sparse::NullInNonSparseInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::null_in_non_sparse::NullInNonSparseOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::null_in_non_sparse::NullInNonSparseError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +228,278 @@
  130    134   
                crate::operation::null_in_non_sparse::NullInNonSparseError,
  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 NullInNonSparseResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for NullInNonSparseResponseDeserializer {
  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_null_in_non_sparse::de_null_in_non_sparse_http_error(status, headers, body)
  152         -
        } else {
  153         -
            crate::protocol_serde::shape_null_in_non_sparse::de_null_in_non_sparse_http_response(status, headers, body)
         161  +
            let generic = generic_builder.build();
         162  +
            let error_code = match generic.code() {
         163  +
                ::std::option::Option::Some(code) => code,
         164  +
                ::std::option::Option::None => {
         165  +
                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         166  +
                        ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::null_in_non_sparse::NullInNonSparseError::unhandled(
         167  +
                            generic,
         168  +
                        )),
         169  +
                    ))
         170  +
                }
  154    171   
            };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         172  +
            let _error_message = generic.message().map(|msg| msg.to_owned());
         173  +
            let protocol = _cfg
         174  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         175  +
                .expect("a SharedClientProtocol is required");
         176  +
            let err = match error_code {
         177  +
                "ExtraError" => crate::operation::null_in_non_sparse::NullInNonSparseError::ExtraError({
         178  +
                    let mut tmp = match protocol
         179  +
                        .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
         180  +
                        .and_then(|mut deser| {
         181  +
                            crate::types::error::ExtraError::deserialize_with_response(
         182  +
                                &mut *deser,
         183  +
                                response.headers(),
         184  +
                                response.status().into(),
         185  +
                                body,
         186  +
                            )
         187  +
                        }) {
         188  +
                        ::std::result::Result::Ok(val) => val,
         189  +
                        ::std::result::Result::Err(e) => {
         190  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         191  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         192  +
                            ))
         193  +
                        }
         194  +
                    };
         195  +
                    tmp.meta = generic;
         196  +
                    if tmp.message.is_none() {
         197  +
                        tmp.message = _error_message;
         198  +
                    }
         199  +
                    tmp
         200  +
                }),
         201  +
                _ => crate::operation::null_in_non_sparse::NullInNonSparseError::generic(generic),
         202  +
            };
         203  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         204  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         205  +
            ))
         206  +
        } else {
         207  +
            let protocol = _cfg
         208  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         209  +
                .expect("a SharedClientProtocol is required");
         210  +
            let mut deser = protocol
         211  +
                .deserialize_response(response, NullInNonSparse::OUTPUT_SCHEMA, _cfg)
         212  +
                .map_err(|e| {
         213  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         214  +
                })?;
         215  +
            let body = response.body().bytes().expect("body loaded");
         216  +
            let output = crate::operation::null_in_non_sparse::NullInNonSparseOutput::deserialize_with_response(
         217  +
                &mut *deser,
         218  +
                response.headers(),
         219  +
                response.status().into(),
         220  +
                body,
         221  +
            )
         222  +
            .map_err(|e| {
         223  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         224  +
            })?;
         225  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         226  +
        }
  156    227   
    }
  157    228   
}
  158    229   
#[derive(Debug)]
  159    230   
struct NullInNonSparseRequestSerializer;
  160    231   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for NullInNonSparseRequestSerializer {
  161    232   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    233   
    fn serialize_input(
  163    234   
        &self,
  164    235   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    236   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    237   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    238   
        let input = input
  168    239   
            .downcast::<crate::operation::null_in_non_sparse::NullInNonSparseInput>()
  169    240   
            .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::null_in_non_sparse::NullInNonSparseInput,
  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, "/null-in-non-sparse").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::null_in_non_sparse::NullInNonSparseInput,
  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
  195         -
        };
  196         -
        let body = ::aws_smithy_types::body::SdkBody::from("");
         241  +
        let protocol = _cfg
         242  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         243  +
            .expect("a SharedClientProtocol is required");
         244  +
        let mut request = protocol
         245  +
            .serialize_request(&input, NullInNonSparse::INPUT_SCHEMA, "", _cfg)
         246  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
  197    247   
  198         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         248  +
        return ::std::result::Result::Ok(request);
  199    249   
    }
  200    250   
}
  201    251   
#[derive(Debug)]
  202    252   
struct NullInNonSparseEndpointParamsInterceptor;
  203    253   
  204    254   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for NullInNonSparseEndpointParamsInterceptor {
  205    255   
    fn name(&self) -> &'static str {
  206    256   
        "NullInNonSparseEndpointParamsInterceptor"
  207    257   
    }
  208    258   
@@ -249,299 +351,421 @@
  269    319   
            .expect("the config must have a deserializer");
  270    320   
  271    321   
        let parsed = de.deserialize_streaming(&mut http_response);
  272    322   
        let parsed = parsed.unwrap_or_else(|| {
  273    323   
            let http_response = http_response.map(|body| {
  274    324   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  275    325   
                    body.bytes().unwrap(),
  276    326   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  277    327   
                )))
  278    328   
            });
  279         -
            de.deserialize_nonstreaming(&http_response)
         329  +
            // Build a config bag with the protocol for schema-based deserialization
         330  +
            #[allow(unused_mut)]
         331  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         332  +
            {
         333  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         334  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         335  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         336  +
                ));
         337  +
                test_cfg.push_shared_layer(layer.freeze());
         338  +
            }
         339  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  280    340   
        });
  281    341   
        let parsed = parsed
  282    342   
            .expect("should be successful response")
  283    343   
            .downcast::<crate::operation::null_in_non_sparse::NullInNonSparseOutput>()
  284    344   
            .unwrap();
  285    345   
        ::pretty_assertions::assert_eq!(parsed.list, expected_output.list, "Unexpected value for `list`");
  286    346   
        ::pretty_assertions::assert_eq!(parsed.map, expected_output.map, "Unexpected value for `map`");
  287    347   
        ::pretty_assertions::assert_eq!(parsed.union, expected_output.union, "Unexpected value for `union`");
  288    348   
    }
  289    349   
  290    350   
    /// Upper case error modeled lower case
  291    351   
    /// Test ID: ServiceLevelErrorClient
  292    352   
    #[::tokio::test]
  293    353   
    #[::tracing_test::traced_test]
  294    354   
    async fn service_level_error_client_response() {
  295    355   
        let expected_output = crate::types::error::ExtraError::builder().build();
  296    356   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  297    357   
            ::http_1x::response::Builder::new()
  298    358   
                .header("X-Amzn-Errortype", "ExtraError")
  299    359   
                .status(500)
  300    360   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  301    361   
                .unwrap(),
  302    362   
        )
  303    363   
        .unwrap();
  304    364   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  305    365   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  306    366   
  307    367   
        let op = crate::operation::null_in_non_sparse::NullInNonSparse::new();
  308    368   
        let config = op.config().expect("the operation has config");
  309    369   
        let de = config
  310    370   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  311    371   
            .expect("the config must have a deserializer");
  312    372   
  313    373   
        let parsed = de.deserialize_streaming(&mut http_response);
  314    374   
        let parsed = parsed.unwrap_or_else(|| {
  315    375   
            let http_response = http_response.map(|body| {
  316    376   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  317    377   
                    body.bytes().unwrap(),
  318    378   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  319    379   
                )))
  320    380   
            });
  321         -
            de.deserialize_nonstreaming(&http_response)
         381  +
            // Build a config bag with the protocol for schema-based deserialization
         382  +
            #[allow(unused_mut)]
         383  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         384  +
            {
         385  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         386  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         387  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         388  +
                ));
         389  +
                test_cfg.push_shared_layer(layer.freeze());
         390  +
            }
         391  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  322    392   
        });
  323    393   
        let parsed = parsed.expect_err("should be error response");
  324    394   
        let parsed: &crate::operation::null_in_non_sparse::NullInNonSparseError =
  325    395   
            parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
  326    396   
        if let crate::operation::null_in_non_sparse::NullInNonSparseError::ExtraError(parsed) = parsed {
  327    397   
            ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
  328    398   
        } else {
  329    399   
            panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
  330    400   
        }
  331    401   
    }