Client Test

Client Test

rev. 32b1b3c3761061baed26023be3219639e42d7d12

Files changed:

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_checksum_required/_http_checksum_required_input.rs

@@ -4,4 +108,120 @@
   24     24   
        "HttpChecksumRequiredInput",
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::String,
   27     27   
    "foo",
   28     28   
    0,
   29     29   
);
   30     30   
static HTTPCHECKSUMREQUIREDINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   31     31   
    HTTPCHECKSUMREQUIREDINPUT_SCHEMA_ID,
   32     32   
    ::aws_smithy_schema::ShapeType::Structure,
   33     33   
    &[&HTTPCHECKSUMREQUIREDINPUT_MEMBER_FOO],
   34         -
);
          34  +
)
          35  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/HttpChecksumRequired", None));
   35     36   
impl HttpChecksumRequiredInput {
   36     37   
    /// The schema for this shape.
   37     38   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPCHECKSUMREQUIREDINPUT_SCHEMA;
   38     39   
}
   39     40   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpChecksumRequiredInput {
   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.foo {
   46     47   
            ser.write_string(&HTTPCHECKSUMREQUIREDINPUT_MEMBER_FOO, val)?;
   47     48   
        }
   48     49   
        Ok(())
   49     50   
    }
   50     51   
}
   51     52   
impl HttpChecksumRequiredInput {
   52     53   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   53         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   54         -
        deserializer: &mut D,
          54  +
    pub fn deserialize(
          55  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   55     56   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   56     57   
        #[allow(unused_variables, unused_mut)]
   57     58   
        let mut builder = Self::builder();
   58     59   
        #[allow(
   59     60   
            unused_variables,
   60     61   
            unreachable_code,
   61     62   
            clippy::single_match,
   62     63   
            clippy::match_single_binding,
   63     64   
            clippy::diverging_sub_expression
   64     65   
        )]
   65         -
        deserializer.read_struct(&HTTPCHECKSUMREQUIREDINPUT_SCHEMA, (), |_, member, deser| {
          66  +
        deserializer.read_struct(&HTTPCHECKSUMREQUIREDINPUT_SCHEMA, &mut |member, deser| {
   66     67   
            match member.member_index() {
   67     68   
                Some(0) => {
   68     69   
                    builder.foo = Some(deser.read_string(member)?);
   69     70   
                }
   70     71   
                _ => {}
   71     72   
            }
   72     73   
            Ok(())
   73     74   
        })?;
   74     75   
        builder
   75     76   
            .build()
   76     77   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   77     78   
    }
   78     79   
}
          80  +
impl HttpChecksumRequiredInput {
          81  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          82  +
    pub fn deserialize_with_response(
          83  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          84  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          85  +
        _status: u16,
          86  +
        _body: &[u8],
          87  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          88  +
        Self::deserialize(deserializer)
          89  +
    }
          90  +
}
   79     91   
impl HttpChecksumRequiredInput {
   80     92   
    /// Creates a new builder-style object to manufacture [`HttpChecksumRequiredInput`](crate::operation::http_checksum_required::HttpChecksumRequiredInput).
   81     93   
    pub fn builder() -> crate::operation::http_checksum_required::builders::HttpChecksumRequiredInputBuilder {
   82     94   
        crate::operation::http_checksum_required::builders::HttpChecksumRequiredInputBuilder::default()
   83     95   
    }
   84     96   
}
   85     97   
   86     98   
/// A builder for [`HttpChecksumRequiredInput`](crate::operation::http_checksum_required::HttpChecksumRequiredInput).
   87     99   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   88    100   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_checksum_required/_http_checksum_required_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.foo {
   46     46   
            ser.write_string(&HTTPCHECKSUMREQUIREDOUTPUT_MEMBER_FOO, val)?;
   47     47   
        }
   48     48   
        Ok(())
   49     49   
    }
   50     50   
}
   51     51   
impl HttpChecksumRequiredOutput {
   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(&HTTPCHECKSUMREQUIREDOUTPUT_SCHEMA, (), |_, member, deser| {
          65  +
        deserializer.read_struct(&HTTPCHECKSUMREQUIREDOUTPUT_SCHEMA, &mut |member, deser| {
   66     66   
            match member.member_index() {
   67     67   
                Some(0) => {
   68     68   
                    builder.foo = Some(deser.read_string(member)?);
   69     69   
                }
   70     70   
                _ => {}
   71     71   
            }
   72     72   
            Ok(())
   73     73   
        })?;
   74     74   
        Ok(builder.build())
   75     75   
    }
   76     76   
}
          77  +
impl HttpChecksumRequiredOutput {
          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 HttpChecksumRequiredOutput {
   78     89   
    /// Creates a new builder-style object to manufacture [`HttpChecksumRequiredOutput`](crate::operation::http_checksum_required::HttpChecksumRequiredOutput).
   79     90   
    pub fn builder() -> crate::operation::http_checksum_required::builders::HttpChecksumRequiredOutputBuilder {
   80     91   
        crate::operation::http_checksum_required::builders::HttpChecksumRequiredOutputBuilder::default()
   81     92   
    }
   82     93   
}
   83     94   
   84     95   
/// A builder for [`HttpChecksumRequiredOutput`](crate::operation::http_checksum_required::HttpChecksumRequiredOutput).
   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/rust-client-codegen/src/operation/http_empty_prefix_headers.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 `HttpEmptyPrefixHeaders`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct HttpEmptyPrefixHeaders;
    6      6   
impl HttpEmptyPrefixHeaders {
    7      7   
    /// Creates a new `HttpEmptyPrefixHeaders`
    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::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersOutput::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::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +275,319 @@
  130    134   
                crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersError,
  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 HttpEmptyPrefixHeadersResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for HttpEmptyPrefixHeadersResponseDeserializer {
  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());
  145         -
        let headers = response.headers();
  146         -
        let body = response.body().bytes().expect("body loaded");
  147    150   
        #[allow(unused_mut)]
  148    151   
        let mut force_error = false;
  149    152   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_http_empty_prefix_headers::de_http_empty_prefix_headers_http_error(status, headers, body)
         153  +
        if !success && status != 200 || force_error {
         154  +
            let headers = response.headers();
         155  +
            let body = response.body().bytes().expect("body loaded");
         156  +
            #[allow(unused_mut)]
         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  +
            })?;
         160  +
         161  +
            let generic = generic_builder.build();
         162  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         163  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         164  +
                    crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersError::generic(generic),
         165  +
                ),
         166  +
            ))
  152    167   
        } else {
  153         -
            crate::protocol_serde::shape_http_empty_prefix_headers::de_http_empty_prefix_headers_http_response(status, headers, body)
  154         -
        };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         168  +
            let protocol = _cfg
         169  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         170  +
                .expect("a SharedClientProtocol is required");
         171  +
            let mut deser = protocol
         172  +
                .deserialize_response(response, HttpEmptyPrefixHeaders::OUTPUT_SCHEMA, _cfg)
         173  +
                .map_err(|e| {
         174  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         175  +
                })?;
         176  +
            let body = response.body().bytes().expect("body loaded");
         177  +
            let output = crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersOutput::deserialize_with_response(
         178  +
                &mut *deser,
         179  +
                response.headers(),
         180  +
                response.status().into(),
         181  +
                body,
         182  +
            )
         183  +
            .map_err(|e| {
         184  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         185  +
            })?;
         186  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         187  +
        }
  156    188   
    }
  157    189   
}
  158    190   
#[derive(Debug)]
  159    191   
struct HttpEmptyPrefixHeadersRequestSerializer;
  160    192   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for HttpEmptyPrefixHeadersRequestSerializer {
  161    193   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    194   
    fn serialize_input(
  163    195   
        &self,
  164    196   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    197   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    198   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    199   
        let input = input
  168    200   
            .downcast::<crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput>()
  169    201   
            .expect("correct type");
  170         -
        let _header_serialization_settings = _cfg
  171         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  172         -
            .cloned()
  173         -
            .unwrap_or_default();
  174         -
        let mut request_builder = {
  175         -
            #[allow(clippy::uninlined_format_args)]
  176         -
            fn uri_base(
  177         -
                _input: &crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput,
  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, "/HttpEmptyPrefixHeaders").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput,
  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         -
                let builder = crate::protocol_serde::shape_http_empty_prefix_headers::ser_http_empty_prefix_headers_headers(input, builder)?;
  192         -
                ::std::result::Result::Ok(builder.method("GET").uri(uri))
         202  +
        let protocol = _cfg
         203  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         204  +
            .expect("a SharedClientProtocol is required");
         205  +
        if protocol.supports_http_bindings() {
         206  +
            let mut request = protocol
         207  +
                .serialize_body(&input, HttpEmptyPrefixHeaders::INPUT_SCHEMA, "", _cfg)
         208  +
                .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         209  +
            {
         210  +
                let mut uri = "/HttpEmptyPrefixHeaders".to_string();
         211  +
                let mut query_params: Vec<(String, String)> = Vec::new();
         212  +
                if let Some(ref map) = input.prefix_headers {
         213  +
                    for (k, v) in map {
         214  +
                        request.headers_mut().insert(k.to_string(), v.to_string());
         215  +
                    }
         216  +
                }
         217  +
                if let Some(ref val) = input.specific_header {
         218  +
                    request.headers_mut().insert("hello", val.to_string());
         219  +
                }
         220  +
                if !query_params.is_empty() {
         221  +
                    uri.push(if uri.contains('?') { '&' } else { '?' });
         222  +
                    let pairs: Vec<String> = query_params
         223  +
                        .iter()
         224  +
                        .map(|(k, v)| {
         225  +
                            format!(
         226  +
                                "{}={}",
         227  +
                                ::aws_smithy_schema::http_protocol::percent_encode(k),
         228  +
                                ::aws_smithy_schema::http_protocol::percent_encode(v)
         229  +
                            )
         230  +
                        })
         231  +
                        .collect();
         232  +
                    uri.push_str(&pairs.join("&"));
         233  +
                }
         234  +
                request.set_uri(uri.as_str()).expect("valid URI");
  193    235   
            }
  194         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  195         -
            builder
  196         -
        };
  197         -
        let body = ::aws_smithy_types::body::SdkBody::from("");
  198    236   
  199         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         237  +
            return ::std::result::Result::Ok(request);
         238  +
        } else {
         239  +
            let mut request = protocol
         240  +
                .serialize_request(&input, HttpEmptyPrefixHeaders::INPUT_SCHEMA, "", _cfg)
         241  +
                .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         242  +
         243  +
            return ::std::result::Result::Ok(request);
         244  +
        }
  200    245   
    }
  201    246   
}
  202    247   
#[derive(Debug)]
  203    248   
struct HttpEmptyPrefixHeadersEndpointParamsInterceptor;
  204    249   
  205    250   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HttpEmptyPrefixHeadersEndpointParamsInterceptor {
  206    251   
    fn name(&self) -> &'static str {
  207    252   
        "HttpEmptyPrefixHeadersEndpointParamsInterceptor"
  208    253   
    }
  209    254   
  210    255   
    fn read_before_execution(
  211    256   
        &self,
  212    257   
        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
  213    258   
            '_,
  214    259   
            ::aws_smithy_runtime_api::client::interceptors::context::Input,
  215    260   
            ::aws_smithy_runtime_api::client::interceptors::context::Output,
  216    261   
            ::aws_smithy_runtime_api::client::interceptors::context::Error,
  217    262   
        >,
  218    263   
        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  219    264   
    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
  220    265   
        let _input = context
  221    266   
            .input()
  222    267   
            .downcast_ref::<HttpEmptyPrefixHeadersInput>()
  223    268   
            .ok_or("failed to downcast to HttpEmptyPrefixHeadersInput")?;
  224    269   
  225    270   
        let params = crate::config::endpoint::Params::builder().build().map_err(|err| {
  226    271   
            ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
  227    272   
        })?;
  228    273   
        cfg.interceptor_state()
  229    274   
            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
  230    275   
        ::std::result::Result::Ok(())
  231    276   
    }
  232    277   
}
  233    278   
  234    279   
// The get_* functions below are generated from JMESPath expressions in the
  235    280   
// operationContextParams trait. They target the operation's input shape.
  236    281   
  237    282   
#[allow(unreachable_code, unused_variables)]
  238    283   
#[cfg(test)]
  239    284   
mod http_empty_prefix_headers_test {
  240    285   
  241    286   
    /// Serializes all request headers, using specific when present
  242    287   
    /// Test ID: RestJsonHttpEmptyPrefixHeadersRequestClient
  243    288   
    #[::tokio::test]
  244    289   
    #[::tracing_test::traced_test]
  245         -
    #[should_panic]
  246    290   
    async fn rest_json_http_empty_prefix_headers_request_client_request() {
  247    291   
        let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
  248    292   
        let config_builder = crate::config::Config::builder()
  249    293   
            .with_test_defaults()
  250    294   
            // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
  251    295   
            //  Until the incorrect separation is addressed, we need to rely on this workaround.
  252    296   
            .allow_no_auth()
  253    297   
            .endpoint_url("https://example.com");
  254    298   
  255    299   
        let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
@@ -289,333 +349,403 @@
  309    353   
            .expect("the config must have a deserializer");
  310    354   
  311    355   
        let parsed = de.deserialize_streaming(&mut http_response);
  312    356   
        let parsed = parsed.unwrap_or_else(|| {
  313    357   
            let http_response = http_response.map(|body| {
  314    358   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  315    359   
                    body.bytes().unwrap(),
  316    360   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  317    361   
                )))
  318    362   
            });
  319         -
            de.deserialize_nonstreaming(&http_response)
         363  +
            // Build a config bag with the protocol for schema-based deserialization
         364  +
            #[allow(unused_mut)]
         365  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         366  +
            {
         367  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         368  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         369  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         370  +
                ));
         371  +
                test_cfg.push_shared_layer(layer.freeze());
         372  +
            }
         373  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  320    374   
        });
  321    375   
        let parsed = parsed
  322    376   
            .expect("should be successful response")
  323    377   
            .downcast::<crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersOutput>()
  324    378   
            .unwrap();
  325    379   
        ::pretty_assertions::assert_eq!(
  326    380   
            parsed.prefix_headers,
  327    381   
            expected_output.prefix_headers,
  328    382   
            "Unexpected value for `prefix_headers`"
  329    383   
        );

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_empty_prefix_headers/_http_empty_prefix_headers_input.rs

@@ -3,3 +154,176 @@
   23     23   
    "aws.protocoltests.restjson.synthetic",
   24     24   
    "HttpEmptyPrefixHeadersInput",
   25     25   
);
   26     26   
static HTTPEMPTYPREFIXHEADERSINPUT_MEMBER_PREFIX_HEADERS: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   27     27   
    ::aws_smithy_schema::ShapeId::from_static(
   28     28   
        "aws.protocoltests.restjson.synthetic#HttpEmptyPrefixHeadersInput$prefixHeaders",
   29     29   
        "aws.protocoltests.restjson.synthetic",
   30     30   
        "HttpEmptyPrefixHeadersInput",
   31     31   
    ),
   32     32   
    ::aws_smithy_schema::ShapeType::Map,
   33         -
    "prefix_headers",
          33  +
    "prefixHeaders",
   34     34   
    0,
   35     35   
)
   36     36   
.with_http_prefix_headers("");
   37     37   
static HTTPEMPTYPREFIXHEADERSINPUT_MEMBER_SPECIFIC_HEADER: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   38     38   
    ::aws_smithy_schema::ShapeId::from_static(
   39     39   
        "aws.protocoltests.restjson.synthetic#HttpEmptyPrefixHeadersInput$specificHeader",
   40     40   
        "aws.protocoltests.restjson.synthetic",
   41     41   
        "HttpEmptyPrefixHeadersInput",
   42     42   
    ),
   43     43   
    ::aws_smithy_schema::ShapeType::String,
   44         -
    "specific_header",
          44  +
    "specificHeader",
   45     45   
    1,
   46     46   
)
   47     47   
.with_http_header("hello");
   48     48   
static HTTPEMPTYPREFIXHEADERSINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   49     49   
    HTTPEMPTYPREFIXHEADERSINPUT_SCHEMA_ID,
   50     50   
    ::aws_smithy_schema::ShapeType::Structure,
   51     51   
    &[
   52     52   
        &HTTPEMPTYPREFIXHEADERSINPUT_MEMBER_PREFIX_HEADERS,
   53     53   
        &HTTPEMPTYPREFIXHEADERSINPUT_MEMBER_SPECIFIC_HEADER,
   54     54   
    ],
   55         -
);
          55  +
)
          56  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("GET", "/HttpEmptyPrefixHeaders", None));
   56     57   
impl HttpEmptyPrefixHeadersInput {
   57     58   
    /// The schema for this shape.
   58     59   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPEMPTYPREFIXHEADERSINPUT_SCHEMA;
   59     60   
}
   60     61   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpEmptyPrefixHeadersInput {
   61     62   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   62     63   
    fn serialize_members(
   63     64   
        &self,
   64     65   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   65     66   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   66     67   
        if let Some(ref val) = self.prefix_headers {
   67     68   
            ser.write_map(
   68     69   
                &HTTPEMPTYPREFIXHEADERSINPUT_MEMBER_PREFIX_HEADERS,
   69     70   
                &|ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer| {
   70     71   
                    for (key, value) in val {
   71     72   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, key)?;
   72     73   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, value)?;
   73     74   
                    }
   74     75   
                    Ok(())
   75     76   
                },
   76     77   
            )?;
   77     78   
        }
   78     79   
        if let Some(ref val) = self.specific_header {
   79     80   
            ser.write_string(&HTTPEMPTYPREFIXHEADERSINPUT_MEMBER_SPECIFIC_HEADER, val)?;
   80     81   
        }
   81     82   
        Ok(())
   82     83   
    }
   83     84   
}
   84     85   
impl HttpEmptyPrefixHeadersInput {
   85     86   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   86         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   87         -
        deserializer: &mut D,
          87  +
    pub fn deserialize(
          88  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   88     89   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   89     90   
        #[allow(unused_variables, unused_mut)]
   90     91   
        let mut builder = Self::builder();
   91     92   
        #[allow(
   92     93   
            unused_variables,
   93     94   
            unreachable_code,
   94     95   
            clippy::single_match,
   95     96   
            clippy::match_single_binding,
   96     97   
            clippy::diverging_sub_expression
   97     98   
        )]
   98         -
        deserializer.read_struct(&HTTPEMPTYPREFIXHEADERSINPUT_SCHEMA, (), |_, member, deser| {
          99  +
        deserializer.read_struct(&HTTPEMPTYPREFIXHEADERSINPUT_SCHEMA, &mut |member, deser| {
   99    100   
            match member.member_index() {
  100    101   
                Some(0) => {
  101         -
                    builder.prefix_headers = Some({
  102         -
                        let container = if let Some(cap) = deser.container_size() {
  103         -
                            std::collections::HashMap::with_capacity(cap)
  104         -
                        } else {
  105         -
                            std::collections::HashMap::new()
  106         -
                        };
  107         -
                        deser.read_map(member, container, |mut map, key, deser| {
  108         -
                            map.insert(key, deser.read_string(member)?);
  109         -
                            Ok(map)
  110         -
                        })?
  111         -
                    });
         102  +
                    builder.prefix_headers = Some(deser.read_string_string_map(member)?);
  112    103   
                }
  113    104   
                Some(1) => {
  114    105   
                    builder.specific_header = Some(deser.read_string(member)?);
  115    106   
                }
  116    107   
                _ => {}
  117    108   
            }
  118    109   
            Ok(())
  119    110   
        })?;
  120    111   
        builder
  121    112   
            .build()
  122    113   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  123    114   
    }
  124    115   
}
         116  +
impl HttpEmptyPrefixHeadersInput {
         117  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         118  +
    /// Header-bound members are read directly from headers, avoiding runtime
         119  +
    /// member iteration overhead. Body members are read via the deserializer.
         120  +
    pub fn deserialize_with_response(
         121  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         122  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         123  +
        _status: u16,
         124  +
        _body: &[u8],
         125  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         126  +
        #[allow(unused_variables, unused_mut)]
         127  +
        let mut builder = Self::builder();
         128  +
        if let Some(val) = headers.get("hello") {
         129  +
            builder.specific_header = Some(val.to_string());
         130  +
        }
         131  +
        {
         132  +
            let mut map = ::std::collections::HashMap::new();
         133  +
            for (key, val) in headers.iter() {
         134  +
                if let Some(suffix) = key.strip_prefix("") {
         135  +
                    map.insert(suffix.to_string(), val.to_string());
         136  +
                }
         137  +
            }
         138  +
            if !map.is_empty() {
         139  +
                builder.prefix_headers = Some(map);
         140  +
            }
         141  +
        }
         142  +
        builder
         143  +
            .build()
         144  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
         145  +
    }
         146  +
}
  125    147   
impl HttpEmptyPrefixHeadersInput {
  126    148   
    /// Creates a new builder-style object to manufacture [`HttpEmptyPrefixHeadersInput`](crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput).
  127    149   
    pub fn builder() -> crate::operation::http_empty_prefix_headers::builders::HttpEmptyPrefixHeadersInputBuilder {
  128    150   
        crate::operation::http_empty_prefix_headers::builders::HttpEmptyPrefixHeadersInputBuilder::default()
  129    151   
    }
  130    152   
}
  131    153   
  132    154   
/// A builder for [`HttpEmptyPrefixHeadersInput`](crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersInput).
  133    155   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  134    156   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_empty_prefix_headers/_http_empty_prefix_headers_output.rs

@@ -3,3 +152,171 @@
   23     23   
    "aws.protocoltests.restjson.synthetic",
   24     24   
    "HttpEmptyPrefixHeadersOutput",
   25     25   
);
   26     26   
static HTTPEMPTYPREFIXHEADERSOUTPUT_MEMBER_PREFIX_HEADERS: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   27     27   
    ::aws_smithy_schema::ShapeId::from_static(
   28     28   
        "aws.protocoltests.restjson.synthetic#HttpEmptyPrefixHeadersOutput$prefixHeaders",
   29     29   
        "aws.protocoltests.restjson.synthetic",
   30     30   
        "HttpEmptyPrefixHeadersOutput",
   31     31   
    ),
   32     32   
    ::aws_smithy_schema::ShapeType::Map,
   33         -
    "prefix_headers",
          33  +
    "prefixHeaders",
   34     34   
    0,
   35     35   
)
   36     36   
.with_http_prefix_headers("");
   37     37   
static HTTPEMPTYPREFIXHEADERSOUTPUT_MEMBER_SPECIFIC_HEADER: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   38     38   
    ::aws_smithy_schema::ShapeId::from_static(
   39     39   
        "aws.protocoltests.restjson.synthetic#HttpEmptyPrefixHeadersOutput$specificHeader",
   40     40   
        "aws.protocoltests.restjson.synthetic",
   41     41   
        "HttpEmptyPrefixHeadersOutput",
   42     42   
    ),
   43     43   
    ::aws_smithy_schema::ShapeType::String,
   44         -
    "specific_header",
          44  +
    "specificHeader",
   45     45   
    1,
   46     46   
)
   47     47   
.with_http_header("hello");
   48     48   
static HTTPEMPTYPREFIXHEADERSOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   49     49   
    HTTPEMPTYPREFIXHEADERSOUTPUT_SCHEMA_ID,
   50     50   
    ::aws_smithy_schema::ShapeType::Structure,
   51     51   
    &[
   52     52   
        &HTTPEMPTYPREFIXHEADERSOUTPUT_MEMBER_PREFIX_HEADERS,
   53     53   
        &HTTPEMPTYPREFIXHEADERSOUTPUT_MEMBER_SPECIFIC_HEADER,
   54     54   
    ],
   55     55   
);
   56     56   
impl HttpEmptyPrefixHeadersOutput {
   57     57   
    /// The schema for this shape.
   58     58   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPEMPTYPREFIXHEADERSOUTPUT_SCHEMA;
   59     59   
}
   60     60   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpEmptyPrefixHeadersOutput {
   61     61   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   62     62   
    fn serialize_members(
   63     63   
        &self,
   64     64   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   65     65   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   66     66   
        if let Some(ref val) = self.prefix_headers {
   67     67   
            ser.write_map(
   68     68   
                &HTTPEMPTYPREFIXHEADERSOUTPUT_MEMBER_PREFIX_HEADERS,
   69     69   
                &|ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer| {
   70     70   
                    for (key, value) in val {
   71     71   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, key)?;
   72     72   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, value)?;
   73     73   
                    }
   74     74   
                    Ok(())
   75     75   
                },
   76     76   
            )?;
   77     77   
        }
   78     78   
        if let Some(ref val) = self.specific_header {
   79     79   
            ser.write_string(&HTTPEMPTYPREFIXHEADERSOUTPUT_MEMBER_SPECIFIC_HEADER, val)?;
   80     80   
        }
   81     81   
        Ok(())
   82     82   
    }
   83     83   
}
   84     84   
impl HttpEmptyPrefixHeadersOutput {
   85     85   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   86         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   87         -
        deserializer: &mut D,
          86  +
    pub fn deserialize(
          87  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   88     88   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   89     89   
        #[allow(unused_variables, unused_mut)]
   90     90   
        let mut builder = Self::builder();
   91     91   
        #[allow(
   92     92   
            unused_variables,
   93     93   
            unreachable_code,
   94     94   
            clippy::single_match,
   95     95   
            clippy::match_single_binding,
   96     96   
            clippy::diverging_sub_expression
   97     97   
        )]
   98         -
        deserializer.read_struct(&HTTPEMPTYPREFIXHEADERSOUTPUT_SCHEMA, (), |_, member, deser| {
          98  +
        deserializer.read_struct(&HTTPEMPTYPREFIXHEADERSOUTPUT_SCHEMA, &mut |member, deser| {
   99     99   
            match member.member_index() {
  100    100   
                Some(0) => {
  101         -
                    builder.prefix_headers = Some({
  102         -
                        let container = if let Some(cap) = deser.container_size() {
  103         -
                            std::collections::HashMap::with_capacity(cap)
  104         -
                        } else {
  105         -
                            std::collections::HashMap::new()
  106         -
                        };
  107         -
                        deser.read_map(member, container, |mut map, key, deser| {
  108         -
                            map.insert(key, deser.read_string(member)?);
  109         -
                            Ok(map)
  110         -
                        })?
  111         -
                    });
         101  +
                    builder.prefix_headers = Some(deser.read_string_string_map(member)?);
  112    102   
                }
  113    103   
                Some(1) => {
  114    104   
                    builder.specific_header = Some(deser.read_string(member)?);
  115    105   
                }
  116    106   
                _ => {}
  117    107   
            }
  118    108   
            Ok(())
  119    109   
        })?;
  120    110   
        Ok(builder.build())
  121    111   
    }
  122    112   
}
         113  +
impl HttpEmptyPrefixHeadersOutput {
         114  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         115  +
    /// Header-bound members are read directly from headers, avoiding runtime
         116  +
    /// member iteration overhead. Body members are read via the deserializer.
         117  +
    pub fn deserialize_with_response(
         118  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         119  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         120  +
        _status: u16,
         121  +
        _body: &[u8],
         122  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         123  +
        #[allow(unused_variables, unused_mut)]
         124  +
        let mut builder = Self::builder();
         125  +
        if let Some(val) = headers.get("hello") {
         126  +
            builder.specific_header = Some(val.to_string());
         127  +
        }
         128  +
        {
         129  +
            let mut map = ::std::collections::HashMap::new();
         130  +
            for (key, val) in headers.iter() {
         131  +
                if let Some(suffix) = key.strip_prefix("") {
         132  +
                    map.insert(suffix.to_string(), val.to_string());
         133  +
                }
         134  +
            }
         135  +
            if !map.is_empty() {
         136  +
                builder.prefix_headers = Some(map);
         137  +
            }
         138  +
        }
         139  +
        Ok(builder.build())
         140  +
    }
         141  +
}
  123    142   
impl HttpEmptyPrefixHeadersOutput {
  124    143   
    /// Creates a new builder-style object to manufacture [`HttpEmptyPrefixHeadersOutput`](crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersOutput).
  125    144   
    pub fn builder() -> crate::operation::http_empty_prefix_headers::builders::HttpEmptyPrefixHeadersOutputBuilder {
  126    145   
        crate::operation::http_empty_prefix_headers::builders::HttpEmptyPrefixHeadersOutputBuilder::default()
  127    146   
    }
  128    147   
}
  129    148   
  130    149   
/// A builder for [`HttpEmptyPrefixHeadersOutput`](crate::operation::http_empty_prefix_headers::HttpEmptyPrefixHeadersOutput).
  131    150   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  132    151   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_enum_payload.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 `HttpEnumPayload`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct HttpEnumPayload;
    6      6   
impl HttpEnumPayload {
    7      7   
    /// Creates a new `HttpEnumPayload`
    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::http_enum_payload::HttpEnumPayloadInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::http_enum_payload::HttpEnumPayloadOutput::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::http_enum_payload::HttpEnumPayloadInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::http_enum_payload::HttpEnumPayloadOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::http_enum_payload::HttpEnumPayloadError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +234,248 @@
  130    134   
                crate::operation::http_enum_payload::HttpEnumPayloadError,
  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 HttpEnumPayloadResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for HttpEnumPayloadResponseDeserializer {
  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());
  145         -
        let headers = response.headers();
  146         -
        let body = response.body().bytes().expect("body loaded");
  147    150   
        #[allow(unused_mut)]
  148    151   
        let mut force_error = false;
  149    152   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_http_enum_payload::de_http_enum_payload_http_error(status, headers, body)
         153  +
        if !success && status != 200 || force_error {
         154  +
            let headers = response.headers();
         155  +
            let body = response.body().bytes().expect("body loaded");
         156  +
            #[allow(unused_mut)]
         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  +
            })?;
         160  +
         161  +
            let generic = generic_builder.build();
         162  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         163  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         164  +
                    crate::operation::http_enum_payload::HttpEnumPayloadError::generic(generic),
         165  +
                ),
         166  +
            ))
  152    167   
        } else {
  153         -
            crate::protocol_serde::shape_http_enum_payload::de_http_enum_payload_http_response(status, headers, body)
  154         -
        };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         168  +
            let protocol = _cfg
         169  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         170  +
                .expect("a SharedClientProtocol is required");
         171  +
            let mut deser = protocol
         172  +
                .deserialize_response(response, HttpEnumPayload::OUTPUT_SCHEMA, _cfg)
         173  +
                .map_err(|e| {
         174  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         175  +
                })?;
         176  +
            let body = response.body().bytes().expect("body loaded");
         177  +
            let output = crate::operation::http_enum_payload::HttpEnumPayloadOutput::deserialize_with_response(
         178  +
                &mut *deser,
         179  +
                response.headers(),
         180  +
                response.status().into(),
         181  +
                body,
         182  +
            )
         183  +
            .map_err(|e| {
         184  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         185  +
            })?;
         186  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         187  +
        }
  156    188   
    }
  157    189   
}
  158    190   
#[derive(Debug)]
  159    191   
struct HttpEnumPayloadRequestSerializer;
  160    192   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for HttpEnumPayloadRequestSerializer {
  161    193   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    194   
    fn serialize_input(
  163    195   
        &self,
  164    196   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    197   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    198   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    199   
        let input = input
  168    200   
            .downcast::<crate::operation::http_enum_payload::HttpEnumPayloadInput>()
  169    201   
            .expect("correct type");
  170         -
        let _header_serialization_settings = _cfg
  171         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  172         -
            .cloned()
  173         -
            .unwrap_or_default();
  174         -
        let mut request_builder = {
  175         -
            #[allow(clippy::uninlined_format_args)]
  176         -
            fn uri_base(
  177         -
                _input: &crate::operation::http_enum_payload::HttpEnumPayloadInput,
  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, "/EnumPayload").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
         202  +
        let protocol = _cfg
         203  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         204  +
            .expect("a SharedClientProtocol is required");
         205  +
        let mut input = input;
         206  +
        let payload = input.payload.take();
         207  +
        let mut request = protocol
         208  +
            .serialize_request(&input, HttpEnumPayload::INPUT_SCHEMA, "", _cfg)
         209  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         210  +
        if let ::std::option::Option::Some(payload) = payload {
         211  +
            *request.body_mut() = ::aws_smithy_types::body::SdkBody::from(payload.as_str().as_bytes().to_vec());
         212  +
            request.headers_mut().insert("Content-Type", "text/plain");
         213  +
            if let ::std::option::Option::Some(content_length) = request.body().content_length() {
         214  +
                request.headers_mut().insert("Content-Length", content_length.to_string());
  183    215   
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::http_enum_payload::HttpEnumPayloadInput,
  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, "text/plain");
  195         -
            builder
  196         -
        };
  197         -
        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_http_enum_payload_input::ser_payload_http_payload(
  198         -
            input.payload,
  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    216   
        }
  204         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         217  +
         218  +
        return ::std::result::Result::Ok(request);
  205    219   
    }
  206    220   
}
  207    221   
#[derive(Debug)]
  208    222   
struct HttpEnumPayloadEndpointParamsInterceptor;
  209    223   
  210    224   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HttpEnumPayloadEndpointParamsInterceptor {
  211    225   
    fn name(&self) -> &'static str {
  212    226   
        "HttpEnumPayloadEndpointParamsInterceptor"
  213    227   
    }
  214    228   
@@ -284,298 +344,368 @@
  304    318   
            .expect("the config must have a deserializer");
  305    319   
  306    320   
        let parsed = de.deserialize_streaming(&mut http_response);
  307    321   
        let parsed = parsed.unwrap_or_else(|| {
  308    322   
            let http_response = http_response.map(|body| {
  309    323   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  310    324   
                    body.bytes().unwrap(),
  311    325   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  312    326   
                )))
  313    327   
            });
  314         -
            de.deserialize_nonstreaming(&http_response)
         328  +
            // Build a config bag with the protocol for schema-based deserialization
         329  +
            #[allow(unused_mut)]
         330  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         331  +
            {
         332  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         333  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         334  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         335  +
                ));
         336  +
                test_cfg.push_shared_layer(layer.freeze());
         337  +
            }
         338  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  315    339   
        });
  316    340   
        let parsed = parsed
  317    341   
            .expect("should be successful response")
  318    342   
            .downcast::<crate::operation::http_enum_payload::HttpEnumPayloadOutput>()
  319    343   
            .unwrap();
  320    344   
        ::pretty_assertions::assert_eq!(parsed.payload, expected_output.payload, "Unexpected value for `payload`");
  321    345   
    }
  322    346   
}
  323    347   
  324    348   
/// Error type for the `HttpEnumPayloadError` operation.

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_enum_payload/_http_enum_payload_input.rs

@@ -5,5 +109,131 @@
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::String,
   27     27   
    "payload",
   28     28   
    0,
   29     29   
)
   30     30   
.with_http_payload();
   31     31   
static HTTPENUMPAYLOADINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   32     32   
    HTTPENUMPAYLOADINPUT_SCHEMA_ID,
   33     33   
    ::aws_smithy_schema::ShapeType::Structure,
   34     34   
    &[&HTTPENUMPAYLOADINPUT_MEMBER_PAYLOAD],
   35         -
);
          35  +
)
          36  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/EnumPayload", None));
   36     37   
impl HttpEnumPayloadInput {
   37     38   
    /// The schema for this shape.
   38     39   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPENUMPAYLOADINPUT_SCHEMA;
   39     40   
}
   40     41   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpEnumPayloadInput {
   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.payload {
   47     48   
            ser.write_string(&HTTPENUMPAYLOADINPUT_MEMBER_PAYLOAD, val.as_str())?;
   48     49   
        }
   49     50   
        Ok(())
   50     51   
    }
   51     52   
}
   52     53   
impl HttpEnumPayloadInput {
   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(&HTTPENUMPAYLOADINPUT_SCHEMA, (), |_, member, deser| {
          67  +
        deserializer.read_struct(&HTTPENUMPAYLOADINPUT_SCHEMA, &mut |member, deser| {
   67     68   
            match member.member_index() {
   68     69   
                Some(0) => {
   69     70   
                    builder.payload = 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 HttpEnumPayloadInput {
          82  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
          83  +
    /// Header-bound members are read directly from headers, avoiding runtime
          84  +
    /// member iteration overhead. Body members are read via the deserializer.
          85  +
    pub fn deserialize_with_response(
          86  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          87  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          88  +
        _status: u16,
          89  +
        body: &[u8],
          90  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          91  +
        #[allow(unused_variables, unused_mut)]
          92  +
        let mut builder = Self::builder();
          93  +
        if !body.is_empty() {
          94  +
            let s = ::std::string::String::from_utf8_lossy(body).into_owned();
          95  +
            builder.payload = Some(crate::types::StringEnum::from(s.as_str()));
          96  +
        }
          97  +
        builder
          98  +
            .build()
          99  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
         100  +
    }
         101  +
}
   80    102   
impl HttpEnumPayloadInput {
   81    103   
    /// Creates a new builder-style object to manufacture [`HttpEnumPayloadInput`](crate::operation::http_enum_payload::HttpEnumPayloadInput).
   82    104   
    pub fn builder() -> crate::operation::http_enum_payload::builders::HttpEnumPayloadInputBuilder {
   83    105   
        crate::operation::http_enum_payload::builders::HttpEnumPayloadInputBuilder::default()
   84    106   
    }
   85    107   
}
   86    108   
   87    109   
/// A builder for [`HttpEnumPayloadInput`](crate::operation::http_enum_payload::HttpEnumPayloadInput).
   88    110   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   89    111   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_enum_payload/_http_enum_payload_output.rs

@@ -24,24 +107,126 @@
   44     44   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   45     45   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   46     46   
        if let Some(ref val) = self.payload {
   47     47   
            ser.write_string(&HTTPENUMPAYLOADOUTPUT_MEMBER_PAYLOAD, val.as_str())?;
   48     48   
        }
   49     49   
        Ok(())
   50     50   
    }
   51     51   
}
   52     52   
impl HttpEnumPayloadOutput {
   53     53   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   54         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   55         -
        deserializer: &mut D,
          54  +
    pub fn deserialize(
          55  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   56     56   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   57     57   
        #[allow(unused_variables, unused_mut)]
   58     58   
        let mut builder = Self::builder();
   59     59   
        #[allow(
   60     60   
            unused_variables,
   61     61   
            unreachable_code,
   62     62   
            clippy::single_match,
   63     63   
            clippy::match_single_binding,
   64     64   
            clippy::diverging_sub_expression
   65     65   
        )]
   66         -
        deserializer.read_struct(&HTTPENUMPAYLOADOUTPUT_SCHEMA, (), |_, member, deser| {
          66  +
        deserializer.read_struct(&HTTPENUMPAYLOADOUTPUT_SCHEMA, &mut |member, deser| {
   67     67   
            match member.member_index() {
   68     68   
                Some(0) => {
   69     69   
                    builder.payload = Some(crate::types::StringEnum::from(deser.read_string(member)?.as_str()));
   70     70   
                }
   71     71   
                _ => {}
   72     72   
            }
   73     73   
            Ok(())
   74     74   
        })?;
   75     75   
        Ok(builder.build())
   76     76   
    }
   77     77   
}
          78  +
impl HttpEnumPayloadOutput {
          79  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
          80  +
    /// Header-bound members are read directly from headers, avoiding runtime
          81  +
    /// member iteration overhead. Body members are read via the deserializer.
          82  +
    pub fn deserialize_with_response(
          83  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          84  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          85  +
        _status: u16,
          86  +
        body: &[u8],
          87  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          88  +
        #[allow(unused_variables, unused_mut)]
          89  +
        let mut builder = Self::builder();
          90  +
        if !body.is_empty() {
          91  +
            let s = ::std::string::String::from_utf8_lossy(body).into_owned();
          92  +
            builder.payload = Some(crate::types::StringEnum::from(s.as_str()));
          93  +
        }
          94  +
        Ok(builder.build())
          95  +
    }
          96  +
}
   78     97   
impl HttpEnumPayloadOutput {
   79     98   
    /// Creates a new builder-style object to manufacture [`HttpEnumPayloadOutput`](crate::operation::http_enum_payload::HttpEnumPayloadOutput).
   80     99   
    pub fn builder() -> crate::operation::http_enum_payload::builders::HttpEnumPayloadOutputBuilder {
   81    100   
        crate::operation::http_enum_payload::builders::HttpEnumPayloadOutputBuilder::default()
   82    101   
    }
   83    102   
}
   84    103   
   85    104   
/// A builder for [`HttpEnumPayloadOutput`](crate::operation::http_enum_payload::HttpEnumPayloadOutput).
   86    105   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   87    106   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_traits.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 `HttpPayloadTraits`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct HttpPayloadTraits;
    6      6   
impl HttpPayloadTraits {
    7      7   
    /// Creates a new `HttpPayloadTraits`
    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::http_payload_traits::HttpPayloadTraitsInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::http_payload_traits::HttpPayloadTraitsOutput::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::http_payload_traits::HttpPayloadTraitsInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::http_payload_traits::HttpPayloadTraitsOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::http_payload_traits::HttpPayloadTraitsError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +234,278 @@
  130    134   
                crate::operation::http_payload_traits::HttpPayloadTraitsError,
  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 HttpPayloadTraitsResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for HttpPayloadTraitsResponseDeserializer {
  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());
  145         -
        let headers = response.headers();
  146         -
        let body = response.body().bytes().expect("body loaded");
  147    150   
        #[allow(unused_mut)]
  148    151   
        let mut force_error = false;
  149    152   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_http_payload_traits::de_http_payload_traits_http_error(status, headers, body)
         153  +
        if !success && status != 200 || force_error {
         154  +
            let headers = response.headers();
         155  +
            let body = response.body().bytes().expect("body loaded");
         156  +
            #[allow(unused_mut)]
         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  +
            })?;
         160  +
         161  +
            let generic = generic_builder.build();
         162  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         163  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         164  +
                    crate::operation::http_payload_traits::HttpPayloadTraitsError::generic(generic),
         165  +
                ),
         166  +
            ))
  152    167   
        } else {
  153         -
            crate::protocol_serde::shape_http_payload_traits::de_http_payload_traits_http_response(status, headers, body)
  154         -
        };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         168  +
            let protocol = _cfg
         169  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         170  +
                .expect("a SharedClientProtocol is required");
         171  +
            let mut deser = protocol
         172  +
                .deserialize_response(response, HttpPayloadTraits::OUTPUT_SCHEMA, _cfg)
         173  +
                .map_err(|e| {
         174  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         175  +
                })?;
         176  +
            let body = response.body().bytes().expect("body loaded");
         177  +
            let output = crate::operation::http_payload_traits::HttpPayloadTraitsOutput::deserialize_with_response(
         178  +
                &mut *deser,
         179  +
                response.headers(),
         180  +
                response.status().into(),
         181  +
                body,
         182  +
            )
         183  +
            .map_err(|e| {
         184  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         185  +
            })?;
         186  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         187  +
        }
  156    188   
    }
  157    189   
}
  158    190   
#[derive(Debug)]
  159    191   
struct HttpPayloadTraitsRequestSerializer;
  160    192   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for HttpPayloadTraitsRequestSerializer {
  161    193   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    194   
    fn serialize_input(
  163    195   
        &self,
  164    196   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    197   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    198   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    199   
        let input = input
  168    200   
            .downcast::<crate::operation::http_payload_traits::HttpPayloadTraitsInput>()
  169    201   
            .expect("correct type");
  170         -
        let _header_serialization_settings = _cfg
  171         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  172         -
            .cloned()
  173         -
            .unwrap_or_default();
  174         -
        let mut request_builder = {
  175         -
            #[allow(clippy::uninlined_format_args)]
  176         -
            fn uri_base(
  177         -
                _input: &crate::operation::http_payload_traits::HttpPayloadTraitsInput,
  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, "/HttpPayloadTraits").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
         202  +
        let protocol = _cfg
         203  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         204  +
            .expect("a SharedClientProtocol is required");
         205  +
        if protocol.supports_http_bindings() {
         206  +
            let mut input = input;
         207  +
            let payload = input.blob.take();
         208  +
            let mut request = protocol
         209  +
                .serialize_body(&input, HttpPayloadTraits::INPUT_SCHEMA, "", _cfg)
         210  +
                .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         211  +
            if let ::std::option::Option::Some(payload) = payload {
         212  +
                *request.body_mut() = ::aws_smithy_types::body::SdkBody::from(payload.into_inner());
         213  +
                request.headers_mut().insert("Content-Type", "application/octet-stream");
         214  +
                if let ::std::option::Option::Some(content_length) = request.body().content_length() {
         215  +
                    request.headers_mut().insert("Content-Length", content_length.to_string());
         216  +
                }
  183    217   
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::http_payload_traits::HttpPayloadTraitsInput,
  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         -
                let builder = crate::protocol_serde::shape_http_payload_traits::ser_http_payload_traits_headers(input, builder)?;
  192         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
         218  +
            {
         219  +
                let mut uri = "/HttpPayloadTraits".to_string();
         220  +
                let mut query_params: Vec<(String, String)> = Vec::new();
         221  +
                if let Some(ref val) = input.foo {
         222  +
                    request.headers_mut().insert("X-Foo", val.to_string());
         223  +
                }
         224  +
                if !query_params.is_empty() {
         225  +
                    uri.push(if uri.contains('?') { '&' } else { '?' });
         226  +
                    let pairs: Vec<String> = query_params
         227  +
                        .iter()
         228  +
                        .map(|(k, v)| {
         229  +
                            format!(
         230  +
                                "{}={}",
         231  +
                                ::aws_smithy_schema::http_protocol::percent_encode(k),
         232  +
                                ::aws_smithy_schema::http_protocol::percent_encode(v)
         233  +
                            )
         234  +
                        })
         235  +
                        .collect();
         236  +
                    uri.push_str(&pairs.join("&"));
         237  +
                }
         238  +
                request.set_uri(uri.as_str()).expect("valid URI");
  193    239   
            }
  194         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  195         -
            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/octet-stream");
  196         -
            builder
  197         -
        };
  198         -
        let body =
  199         -
            ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_http_payload_traits_input::ser_blob_http_payload(input.blob)?);
  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);
         240  +
         241  +
            return ::std::result::Result::Ok(request);
         242  +
        } else {
         243  +
            let mut request = protocol
         244  +
                .serialize_request(&input, HttpPayloadTraits::INPUT_SCHEMA, "", _cfg)
         245  +
                .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         246  +
         247  +
            return ::std::result::Result::Ok(request);
  203    248   
        }
  204         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
  205    249   
    }
  206    250   
}
  207    251   
#[derive(Debug)]
  208    252   
struct HttpPayloadTraitsEndpointParamsInterceptor;
  209    253   
  210    254   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HttpPayloadTraitsEndpointParamsInterceptor {
  211    255   
    fn name(&self) -> &'static str {
  212    256   
        "HttpPayloadTraitsEndpointParamsInterceptor"
  213    257   
    }
  214    258   
@@ -318,362 +421,485 @@
  338    382   
            .expect("the config must have a deserializer");
  339    383   
  340    384   
        let parsed = de.deserialize_streaming(&mut http_response);
  341    385   
        let parsed = parsed.unwrap_or_else(|| {
  342    386   
            let http_response = http_response.map(|body| {
  343    387   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  344    388   
                    body.bytes().unwrap(),
  345    389   
                    ::aws_smithy_protocol_test::MediaType::from("application/octet-stream"),
  346    390   
                )))
  347    391   
            });
  348         -
            de.deserialize_nonstreaming(&http_response)
         392  +
            // Build a config bag with the protocol for schema-based deserialization
         393  +
            #[allow(unused_mut)]
         394  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         395  +
            {
         396  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         397  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         398  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         399  +
                ));
         400  +
                test_cfg.push_shared_layer(layer.freeze());
         401  +
            }
         402  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  349    403   
        });
  350    404   
        let parsed = parsed
  351    405   
            .expect("should be successful response")
  352    406   
            .downcast::<crate::operation::http_payload_traits::HttpPayloadTraitsOutput>()
  353    407   
            .unwrap();
  354    408   
        ::pretty_assertions::assert_eq!(parsed.foo, expected_output.foo, "Unexpected value for `foo`");
  355    409   
        ::pretty_assertions::assert_eq!(parsed.blob, expected_output.blob, "Unexpected value for `blob`");
  356    410   
    }
  357    411   
  358    412   
    /// Serializes an empty blob in the HTTP payload
  359    413   
    /// Test ID: RestJsonHttpPayloadTraitsWithNoBlobBody
  360    414   
    #[::tokio::test]
  361    415   
    #[::tracing_test::traced_test]
  362    416   
    async fn rest_json_http_payload_traits_with_no_blob_body_response() {
  363    417   
        let expected_output = crate::operation::http_payload_traits::HttpPayloadTraitsOutput::builder()
  364    418   
            .set_foo(::std::option::Option::Some("Foo".to_owned()))
  365    419   
            .build();
  366    420   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  367    421   
            ::http_1x::response::Builder::new()
  368    422   
                .header("X-Foo", "Foo")
  369    423   
                .status(200)
  370    424   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  371    425   
                .unwrap(),
  372    426   
        )
  373    427   
        .unwrap();
  374    428   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  375    429   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  376    430   
  377    431   
        let op = crate::operation::http_payload_traits::HttpPayloadTraits::new();
  378    432   
        let config = op.config().expect("the operation has config");
  379    433   
        let de = config
  380    434   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  381    435   
            .expect("the config must have a deserializer");
  382    436   
  383    437   
        let parsed = de.deserialize_streaming(&mut http_response);
  384    438   
        let parsed = parsed.unwrap_or_else(|| {
  385    439   
            let http_response = http_response.map(|body| {
  386    440   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  387    441   
                    body.bytes().unwrap(),
  388    442   
                    ::aws_smithy_protocol_test::MediaType::from("application/octet-stream"),
  389    443   
                )))
  390    444   
            });
  391         -
            de.deserialize_nonstreaming(&http_response)
         445  +
            // Build a config bag with the protocol for schema-based deserialization
         446  +
            #[allow(unused_mut)]
         447  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         448  +
            {
         449  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         450  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         451  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         452  +
                ));
         453  +
                test_cfg.push_shared_layer(layer.freeze());
         454  +
            }
         455  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  392    456   
        });
  393    457   
        let parsed = parsed
  394    458   
            .expect("should be successful response")
  395    459   
            .downcast::<crate::operation::http_payload_traits::HttpPayloadTraitsOutput>()
  396    460   
            .unwrap();
  397    461   
        ::pretty_assertions::assert_eq!(parsed.foo, expected_output.foo, "Unexpected value for `foo`");
  398    462   
        ::pretty_assertions::assert_eq!(parsed.blob, expected_output.blob, "Unexpected value for `blob`");
  399    463   
    }
  400    464   
}
  401    465   

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_traits/_http_payload_traits_input.rs

@@ -22,22 +132,156 @@
   42     42   
    ),
   43     43   
    ::aws_smithy_schema::ShapeType::Blob,
   44     44   
    "blob",
   45     45   
    1,
   46     46   
)
   47     47   
.with_http_payload();
   48     48   
static HTTPPAYLOADTRAITSINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   49     49   
    HTTPPAYLOADTRAITSINPUT_SCHEMA_ID,
   50     50   
    ::aws_smithy_schema::ShapeType::Structure,
   51     51   
    &[&HTTPPAYLOADTRAITSINPUT_MEMBER_FOO, &HTTPPAYLOADTRAITSINPUT_MEMBER_BLOB],
   52         -
);
          52  +
)
          53  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/HttpPayloadTraits", None));
   53     54   
impl HttpPayloadTraitsInput {
   54     55   
    /// The schema for this shape.
   55     56   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPPAYLOADTRAITSINPUT_SCHEMA;
   56     57   
}
   57     58   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpPayloadTraitsInput {
   58     59   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   59     60   
    fn serialize_members(
   60     61   
        &self,
   61     62   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   62     63   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   63     64   
        if let Some(ref val) = self.foo {
   64     65   
            ser.write_string(&HTTPPAYLOADTRAITSINPUT_MEMBER_FOO, val)?;
   65     66   
        }
   66     67   
        if let Some(ref val) = self.blob {
   67     68   
            ser.write_blob(&HTTPPAYLOADTRAITSINPUT_MEMBER_BLOB, val)?;
   68     69   
        }
   69     70   
        Ok(())
   70     71   
    }
   71     72   
}
   72     73   
impl HttpPayloadTraitsInput {
   73     74   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   74         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   75         -
        deserializer: &mut D,
          75  +
    pub fn deserialize(
          76  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   76     77   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   77     78   
        #[allow(unused_variables, unused_mut)]
   78     79   
        let mut builder = Self::builder();
   79     80   
        #[allow(
   80     81   
            unused_variables,
   81     82   
            unreachable_code,
   82     83   
            clippy::single_match,
   83     84   
            clippy::match_single_binding,
   84     85   
            clippy::diverging_sub_expression
   85     86   
        )]
   86         -
        deserializer.read_struct(&HTTPPAYLOADTRAITSINPUT_SCHEMA, (), |_, member, deser| {
          87  +
        deserializer.read_struct(&HTTPPAYLOADTRAITSINPUT_SCHEMA, &mut |member, deser| {
   87     88   
            match member.member_index() {
   88     89   
                Some(0) => {
   89     90   
                    builder.foo = Some(deser.read_string(member)?);
   90     91   
                }
   91     92   
                Some(1) => {
   92     93   
                    builder.blob = Some(deser.read_blob(member)?);
   93     94   
                }
   94     95   
                _ => {}
   95     96   
            }
   96     97   
            Ok(())
   97     98   
        })?;
   98     99   
        builder
   99    100   
            .build()
  100    101   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  101    102   
    }
  102    103   
}
         104  +
impl HttpPayloadTraitsInput {
         105  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         106  +
    /// Header-bound members are read directly from headers, avoiding runtime
         107  +
    /// member iteration overhead. Body members are read via the deserializer.
         108  +
    pub fn deserialize_with_response(
         109  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         110  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         111  +
        _status: u16,
         112  +
        body: &[u8],
         113  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         114  +
        #[allow(unused_variables, unused_mut)]
         115  +
        let mut builder = Self::builder();
         116  +
        if let Some(val) = headers.get("X-Foo") {
         117  +
            builder.foo = Some(val.to_string());
         118  +
        }
         119  +
        if !body.is_empty() {
         120  +
            builder.blob = Some(::aws_smithy_types::Blob::new(body.to_vec()));
         121  +
        }
         122  +
        builder
         123  +
            .build()
         124  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
         125  +
    }
         126  +
}
  103    127   
impl HttpPayloadTraitsInput {
  104    128   
    /// Creates a new builder-style object to manufacture [`HttpPayloadTraitsInput`](crate::operation::http_payload_traits::HttpPayloadTraitsInput).
  105    129   
    pub fn builder() -> crate::operation::http_payload_traits::builders::HttpPayloadTraitsInputBuilder {
  106    130   
        crate::operation::http_payload_traits::builders::HttpPayloadTraitsInputBuilder::default()
  107    131   
    }
  108    132   
}
  109    133   
  110    134   
/// A builder for [`HttpPayloadTraitsInput`](crate::operation::http_payload_traits::HttpPayloadTraitsInput).
  111    135   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  112    136   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_traits/_http_payload_traits_output.rs

@@ -44,44 +130,151 @@
   64     64   
            ser.write_string(&HTTPPAYLOADTRAITSOUTPUT_MEMBER_FOO, val)?;
   65     65   
        }
   66     66   
        if let Some(ref val) = self.blob {
   67     67   
            ser.write_blob(&HTTPPAYLOADTRAITSOUTPUT_MEMBER_BLOB, val)?;
   68     68   
        }
   69     69   
        Ok(())
   70     70   
    }
   71     71   
}
   72     72   
impl HttpPayloadTraitsOutput {
   73     73   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   74         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   75         -
        deserializer: &mut D,
          74  +
    pub fn deserialize(
          75  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   76     76   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   77     77   
        #[allow(unused_variables, unused_mut)]
   78     78   
        let mut builder = Self::builder();
   79     79   
        #[allow(
   80     80   
            unused_variables,
   81     81   
            unreachable_code,
   82     82   
            clippy::single_match,
   83     83   
            clippy::match_single_binding,
   84     84   
            clippy::diverging_sub_expression
   85     85   
        )]
   86         -
        deserializer.read_struct(&HTTPPAYLOADTRAITSOUTPUT_SCHEMA, (), |_, member, deser| {
          86  +
        deserializer.read_struct(&HTTPPAYLOADTRAITSOUTPUT_SCHEMA, &mut |member, deser| {
   87     87   
            match member.member_index() {
   88     88   
                Some(0) => {
   89     89   
                    builder.foo = Some(deser.read_string(member)?);
   90     90   
                }
   91     91   
                Some(1) => {
   92     92   
                    builder.blob = Some(deser.read_blob(member)?);
   93     93   
                }
   94     94   
                _ => {}
   95     95   
            }
   96     96   
            Ok(())
   97     97   
        })?;
   98     98   
        Ok(builder.build())
   99     99   
    }
  100    100   
}
         101  +
impl HttpPayloadTraitsOutput {
         102  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         103  +
    /// Header-bound members are read directly from headers, avoiding runtime
         104  +
    /// member iteration overhead. Body members are read via the deserializer.
         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  +
        #[allow(unused_variables, unused_mut)]
         112  +
        let mut builder = Self::builder();
         113  +
        if let Some(val) = headers.get("X-Foo") {
         114  +
            builder.foo = Some(val.to_string());
         115  +
        }
         116  +
        if !body.is_empty() {
         117  +
            builder.blob = Some(::aws_smithy_types::Blob::new(body.to_vec()));
         118  +
        }
         119  +
        Ok(builder.build())
         120  +
    }
         121  +
}
  101    122   
impl HttpPayloadTraitsOutput {
  102    123   
    /// Creates a new builder-style object to manufacture [`HttpPayloadTraitsOutput`](crate::operation::http_payload_traits::HttpPayloadTraitsOutput).
  103    124   
    pub fn builder() -> crate::operation::http_payload_traits::builders::HttpPayloadTraitsOutputBuilder {
  104    125   
        crate::operation::http_payload_traits::builders::HttpPayloadTraitsOutputBuilder::default()
  105    126   
    }
  106    127   
}
  107    128   
  108    129   
/// A builder for [`HttpPayloadTraitsOutput`](crate::operation::http_payload_traits::HttpPayloadTraitsOutput).
  109    130   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  110    131   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_traits_with_media_type.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 `HttpPayloadTraitsWithMediaType`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct HttpPayloadTraitsWithMediaType;
    6      6   
impl HttpPayloadTraitsWithMediaType {
    7      7   
    /// Creates a new `HttpPayloadTraitsWithMediaType`
    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::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          16  +
        crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeOutput::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::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -110,116 +239,280 @@
  130    136   
                crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeError,
  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 HttpPayloadTraitsWithMediaTypeResponseDeserializer;
  139    145   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for HttpPayloadTraitsWithMediaTypeResponseDeserializer {
  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());
  145         -
        let headers = response.headers();
  146         -
        let body = response.body().bytes().expect("body loaded");
  147    152   
        #[allow(unused_mut)]
  148    153   
        let mut force_error = false;
  149    154   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_http_payload_traits_with_media_type::de_http_payload_traits_with_media_type_http_error(status, headers, body)
         155  +
        if !success && status != 200 || force_error {
         156  +
            let headers = response.headers();
         157  +
            let body = response.body().bytes().expect("body loaded");
         158  +
            #[allow(unused_mut)]
         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  +
            })?;
         162  +
         163  +
            let generic = generic_builder.build();
         164  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         165  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         166  +
                    crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeError::generic(generic),
         167  +
                ),
         168  +
            ))
  152    169   
        } else {
  153         -
            crate::protocol_serde::shape_http_payload_traits_with_media_type::de_http_payload_traits_with_media_type_http_response(
  154         -
                status, headers, body,
         170  +
            let protocol = _cfg
         171  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         172  +
                .expect("a SharedClientProtocol is required");
         173  +
            let mut deser = protocol
         174  +
                .deserialize_response(response, HttpPayloadTraitsWithMediaType::OUTPUT_SCHEMA, _cfg)
         175  +
                .map_err(|e| {
         176  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         177  +
                })?;
         178  +
            let body = response.body().bytes().expect("body loaded");
         179  +
            let output = crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeOutput::deserialize_with_response(
         180  +
                &mut *deser,
         181  +
                response.headers(),
         182  +
                response.status().into(),
         183  +
                body,
  155    184   
            )
  156         -
        };
  157         -
        crate::protocol_serde::type_erase_result(parse_result)
         185  +
            .map_err(|e| {
         186  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         187  +
            })?;
         188  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         189  +
        }
  158    190   
    }
  159    191   
}
  160    192   
#[derive(Debug)]
  161    193   
struct HttpPayloadTraitsWithMediaTypeRequestSerializer;
  162    194   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for HttpPayloadTraitsWithMediaTypeRequestSerializer {
  163    195   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  164    196   
    fn serialize_input(
  165    197   
        &self,
  166    198   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  167    199   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  168    200   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  169    201   
        let input = input
  170    202   
            .downcast::<crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput>()
  171    203   
            .expect("correct type");
  172         -
        let _header_serialization_settings = _cfg
  173         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  174         -
            .cloned()
  175         -
            .unwrap_or_default();
  176         -
        let mut request_builder = {
  177         -
            #[allow(clippy::uninlined_format_args)]
  178         -
            fn uri_base(
  179         -
                _input: &crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput,
  180         -
                output: &mut ::std::string::String,
  181         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  182         -
                use ::std::fmt::Write as _;
  183         -
                ::std::write!(output, "/HttpPayloadTraitsWithMediaType").expect("formatting should succeed");
  184         -
                ::std::result::Result::Ok(())
         204  +
        let protocol = _cfg
         205  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         206  +
            .expect("a SharedClientProtocol is required");
         207  +
        if protocol.supports_http_bindings() {
         208  +
            let mut input = input;
         209  +
            let payload = input.blob.take();
         210  +
            let mut request = protocol
         211  +
                .serialize_body(&input, HttpPayloadTraitsWithMediaType::INPUT_SCHEMA, "", _cfg)
         212  +
                .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         213  +
            if let ::std::option::Option::Some(payload) = payload {
         214  +
                *request.body_mut() = ::aws_smithy_types::body::SdkBody::from(payload.into_inner());
         215  +
                request.headers_mut().insert("Content-Type", "text/plain");
         216  +
                if let ::std::option::Option::Some(content_length) = request.body().content_length() {
         217  +
                    request.headers_mut().insert("Content-Length", content_length.to_string());
         218  +
                }
  185    219   
            }
  186         -
            #[allow(clippy::unnecessary_wraps)]
  187         -
            fn update_http_builder(
  188         -
                input: &crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput,
  189         -
                builder: ::http_1x::request::Builder,
  190         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  191         -
                let mut uri = ::std::string::String::new();
  192         -
                uri_base(input, &mut uri)?;
  193         -
                let builder = crate::protocol_serde::shape_http_payload_traits_with_media_type::ser_http_payload_traits_with_media_type_headers(
  194         -
                    input, builder,
  195         -
                )?;
  196         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
         220  +
            {
         221  +
                let mut uri = "/HttpPayloadTraitsWithMediaType".to_string();
         222  +
                let mut query_params: Vec<(String, String)> = Vec::new();
         223  +
                if let Some(ref val) = input.foo {
         224  +
                    request.headers_mut().insert("X-Foo", val.to_string());
         225  +
                }
         226  +
                if !query_params.is_empty() {
         227  +
                    uri.push(if uri.contains('?') { '&' } else { '?' });
         228  +
                    let pairs: Vec<String> = query_params
         229  +
                        .iter()
         230  +
                        .map(|(k, v)| {
         231  +
                            format!(
         232  +
                                "{}={}",
         233  +
                                ::aws_smithy_schema::http_protocol::percent_encode(k),
         234  +
                                ::aws_smithy_schema::http_protocol::percent_encode(v)
         235  +
                            )
         236  +
                        })
         237  +
                        .collect();
         238  +
                    uri.push_str(&pairs.join("&"));
         239  +
                }
         240  +
                request.set_uri(uri.as_str()).expect("valid URI");
  197    241   
            }
  198         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  199         -
            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "text/plain");
  200         -
            builder
  201         -
        };
  202         -
        let body = ::aws_smithy_types::body::SdkBody::from(
  203         -
            crate::protocol_serde::shape_http_payload_traits_with_media_type_input::ser_blob_http_payload(input.blob)?,
  204         -
        );
  205         -
        if let Some(content_length) = body.content_length() {
  206         -
            let content_length = content_length.to_string();
  207         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
         242  +
         243  +
            return ::std::result::Result::Ok(request);
         244  +
        } else {
         245  +
            let mut request = protocol
         246  +
                .serialize_request(&input, HttpPayloadTraitsWithMediaType::INPUT_SCHEMA, "", _cfg)
         247  +
                .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         248  +
         249  +
            return ::std::result::Result::Ok(request);
  208    250   
        }
  209         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
  210    251   
    }
  211    252   
}
  212    253   
#[derive(Debug)]
  213    254   
struct HttpPayloadTraitsWithMediaTypeEndpointParamsInterceptor;
  214    255   
  215    256   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HttpPayloadTraitsWithMediaTypeEndpointParamsInterceptor {
  216    257   
    fn name(&self) -> &'static str {
  217    258   
        "HttpPayloadTraitsWithMediaTypeEndpointParamsInterceptor"
  218    259   
    }
  219    260   
@@ -293,334 +353,404 @@
  313    354   
            .expect("the config must have a deserializer");
  314    355   
  315    356   
        let parsed = de.deserialize_streaming(&mut http_response);
  316    357   
        let parsed = parsed.unwrap_or_else(|| {
  317    358   
            let http_response = http_response.map(|body| {
  318    359   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  319    360   
                    body.bytes().unwrap(),
  320    361   
                    ::aws_smithy_protocol_test::MediaType::from("application/octet-stream"),
  321    362   
                )))
  322    363   
            });
  323         -
            de.deserialize_nonstreaming(&http_response)
         364  +
            // Build a config bag with the protocol for schema-based deserialization
         365  +
            #[allow(unused_mut)]
         366  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         367  +
            {
         368  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         369  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         370  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         371  +
                ));
         372  +
                test_cfg.push_shared_layer(layer.freeze());
         373  +
            }
         374  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  324    375   
        });
  325    376   
        let parsed = parsed
  326    377   
            .expect("should be successful response")
  327    378   
            .downcast::<crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeOutput>()
  328    379   
            .unwrap();
  329    380   
        ::pretty_assertions::assert_eq!(parsed.foo, expected_output.foo, "Unexpected value for `foo`");
  330    381   
        ::pretty_assertions::assert_eq!(parsed.blob, expected_output.blob, "Unexpected value for `blob`");
  331    382   
    }
  332    383   
}
  333    384   

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_traits_with_media_type/_http_payload_traits_with_media_type_input.rs

@@ -25,25 +135,159 @@
   45     45   
    1,
   46     46   
)
   47     47   
.with_http_payload();
   48     48   
static HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   49     49   
    HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_SCHEMA_ID,
   50     50   
    ::aws_smithy_schema::ShapeType::Structure,
   51     51   
    &[
   52     52   
        &HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_MEMBER_FOO,
   53     53   
        &HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_MEMBER_BLOB,
   54     54   
    ],
   55         -
);
          55  +
)
          56  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("POST", "/HttpPayloadTraitsWithMediaType", None));
   56     57   
impl HttpPayloadTraitsWithMediaTypeInput {
   57     58   
    /// The schema for this shape.
   58     59   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_SCHEMA;
   59     60   
}
   60     61   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpPayloadTraitsWithMediaTypeInput {
   61     62   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   62     63   
    fn serialize_members(
   63     64   
        &self,
   64     65   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   65     66   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   66     67   
        if let Some(ref val) = self.foo {
   67     68   
            ser.write_string(&HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_MEMBER_FOO, val)?;
   68     69   
        }
   69     70   
        if let Some(ref val) = self.blob {
   70     71   
            ser.write_blob(&HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_MEMBER_BLOB, val)?;
   71     72   
        }
   72     73   
        Ok(())
   73     74   
    }
   74     75   
}
   75     76   
impl HttpPayloadTraitsWithMediaTypeInput {
   76     77   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   77         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   78         -
        deserializer: &mut D,
          78  +
    pub fn deserialize(
          79  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   79     80   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   80     81   
        #[allow(unused_variables, unused_mut)]
   81     82   
        let mut builder = Self::builder();
   82     83   
        #[allow(
   83     84   
            unused_variables,
   84     85   
            unreachable_code,
   85     86   
            clippy::single_match,
   86     87   
            clippy::match_single_binding,
   87     88   
            clippy::diverging_sub_expression
   88     89   
        )]
   89         -
        deserializer.read_struct(&HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_SCHEMA, (), |_, member, deser| {
          90  +
        deserializer.read_struct(&HTTPPAYLOADTRAITSWITHMEDIATYPEINPUT_SCHEMA, &mut |member, deser| {
   90     91   
            match member.member_index() {
   91     92   
                Some(0) => {
   92     93   
                    builder.foo = Some(deser.read_string(member)?);
   93     94   
                }
   94     95   
                Some(1) => {
   95     96   
                    builder.blob = Some(deser.read_blob(member)?);
   96     97   
                }
   97     98   
                _ => {}
   98     99   
            }
   99    100   
            Ok(())
  100    101   
        })?;
  101    102   
        builder
  102    103   
            .build()
  103    104   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  104    105   
    }
  105    106   
}
         107  +
impl HttpPayloadTraitsWithMediaTypeInput {
         108  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         109  +
    /// Header-bound members are read directly from headers, avoiding runtime
         110  +
    /// member iteration overhead. Body members are read via the deserializer.
         111  +
    pub fn deserialize_with_response(
         112  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         113  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         114  +
        _status: u16,
         115  +
        body: &[u8],
         116  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         117  +
        #[allow(unused_variables, unused_mut)]
         118  +
        let mut builder = Self::builder();
         119  +
        if let Some(val) = headers.get("X-Foo") {
         120  +
            builder.foo = Some(val.to_string());
         121  +
        }
         122  +
        if !body.is_empty() {
         123  +
            builder.blob = Some(::aws_smithy_types::Blob::new(body.to_vec()));
         124  +
        }
         125  +
        builder
         126  +
            .build()
         127  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
         128  +
    }
         129  +
}
  106    130   
impl HttpPayloadTraitsWithMediaTypeInput {
  107    131   
    /// Creates a new builder-style object to manufacture [`HttpPayloadTraitsWithMediaTypeInput`](crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput).
  108    132   
    pub fn builder() -> crate::operation::http_payload_traits_with_media_type::builders::HttpPayloadTraitsWithMediaTypeInputBuilder {
  109    133   
        crate::operation::http_payload_traits_with_media_type::builders::HttpPayloadTraitsWithMediaTypeInputBuilder::default()
  110    134   
    }
  111    135   
}
  112    136   
  113    137   
/// A builder for [`HttpPayloadTraitsWithMediaTypeInput`](crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeInput).
  114    138   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  115    139   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_traits_with_media_type/_http_payload_traits_with_media_type_output.rs

@@ -47,47 +133,154 @@
   67     67   
            ser.write_string(&HTTPPAYLOADTRAITSWITHMEDIATYPEOUTPUT_MEMBER_FOO, val)?;
   68     68   
        }
   69     69   
        if let Some(ref val) = self.blob {
   70     70   
            ser.write_blob(&HTTPPAYLOADTRAITSWITHMEDIATYPEOUTPUT_MEMBER_BLOB, val)?;
   71     71   
        }
   72     72   
        Ok(())
   73     73   
    }
   74     74   
}
   75     75   
impl HttpPayloadTraitsWithMediaTypeOutput {
   76     76   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   77         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   78         -
        deserializer: &mut D,
          77  +
    pub fn deserialize(
          78  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   79     79   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   80     80   
        #[allow(unused_variables, unused_mut)]
   81     81   
        let mut builder = Self::builder();
   82     82   
        #[allow(
   83     83   
            unused_variables,
   84     84   
            unreachable_code,
   85     85   
            clippy::single_match,
   86     86   
            clippy::match_single_binding,
   87     87   
            clippy::diverging_sub_expression
   88     88   
        )]
   89         -
        deserializer.read_struct(&HTTPPAYLOADTRAITSWITHMEDIATYPEOUTPUT_SCHEMA, (), |_, member, deser| {
          89  +
        deserializer.read_struct(&HTTPPAYLOADTRAITSWITHMEDIATYPEOUTPUT_SCHEMA, &mut |member, deser| {
   90     90   
            match member.member_index() {
   91     91   
                Some(0) => {
   92     92   
                    builder.foo = Some(deser.read_string(member)?);
   93     93   
                }
   94     94   
                Some(1) => {
   95     95   
                    builder.blob = Some(deser.read_blob(member)?);
   96     96   
                }
   97     97   
                _ => {}
   98     98   
            }
   99     99   
            Ok(())
  100    100   
        })?;
  101    101   
        Ok(builder.build())
  102    102   
    }
  103    103   
}
         104  +
impl HttpPayloadTraitsWithMediaTypeOutput {
         105  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         106  +
    /// Header-bound members are read directly from headers, avoiding runtime
         107  +
    /// member iteration overhead. Body members are read via the deserializer.
         108  +
    pub fn deserialize_with_response(
         109  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         110  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         111  +
        _status: u16,
         112  +
        body: &[u8],
         113  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         114  +
        #[allow(unused_variables, unused_mut)]
         115  +
        let mut builder = Self::builder();
         116  +
        if let Some(val) = headers.get("X-Foo") {
         117  +
            builder.foo = Some(val.to_string());
         118  +
        }
         119  +
        if !body.is_empty() {
         120  +
            builder.blob = Some(::aws_smithy_types::Blob::new(body.to_vec()));
         121  +
        }
         122  +
        Ok(builder.build())
         123  +
    }
         124  +
}
  104    125   
impl HttpPayloadTraitsWithMediaTypeOutput {
  105    126   
    /// Creates a new builder-style object to manufacture [`HttpPayloadTraitsWithMediaTypeOutput`](crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeOutput).
  106    127   
    pub fn builder() -> crate::operation::http_payload_traits_with_media_type::builders::HttpPayloadTraitsWithMediaTypeOutputBuilder {
  107    128   
        crate::operation::http_payload_traits_with_media_type::builders::HttpPayloadTraitsWithMediaTypeOutputBuilder::default()
  108    129   
    }
  109    130   
}
  110    131   
  111    132   
/// A builder for [`HttpPayloadTraitsWithMediaTypeOutput`](crate::operation::http_payload_traits_with_media_type::HttpPayloadTraitsWithMediaTypeOutput).
  112    133   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  113    134   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_with_structure.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 `HttpPayloadWithStructure`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct HttpPayloadWithStructure;
    6      6   
impl HttpPayloadWithStructure {
    7      7   
    /// Creates a new `HttpPayloadWithStructure`
    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::http_payload_with_structure::HttpPayloadWithStructureInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          16  +
        crate::operation::http_payload_with_structure::HttpPayloadWithStructureOutput::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::http_payload_with_structure::HttpPayloadWithStructureInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::http_payload_with_structure::HttpPayloadWithStructureOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::http_payload_with_structure::HttpPayloadWithStructureError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -110,116 +234,241 @@
  130    136   
                crate::operation::http_payload_with_structure::HttpPayloadWithStructureError,
  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 HttpPayloadWithStructureResponseDeserializer;
  139    145   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for HttpPayloadWithStructureResponseDeserializer {
  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());
  145         -
        let headers = response.headers();
  146         -
        let body = response.body().bytes().expect("body loaded");
  147    152   
        #[allow(unused_mut)]
  148    153   
        let mut force_error = false;
  149    154   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_http_payload_with_structure::de_http_payload_with_structure_http_error(status, headers, body)
         155  +
        if !success && status != 200 || force_error {
         156  +
            let headers = response.headers();
         157  +
            let body = response.body().bytes().expect("body loaded");
         158  +
            #[allow(unused_mut)]
         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  +
            })?;
         162  +
         163  +
            let generic = generic_builder.build();
         164  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         165  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         166  +
                    crate::operation::http_payload_with_structure::HttpPayloadWithStructureError::generic(generic),
         167  +
                ),
         168  +
            ))
  152    169   
        } else {
  153         -
            crate::protocol_serde::shape_http_payload_with_structure::de_http_payload_with_structure_http_response(status, headers, body)
  154         -
        };
  155         -
        crate::protocol_serde::type_erase_result(parse_result)
         170  +
            let protocol = _cfg
         171  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         172  +
                .expect("a SharedClientProtocol is required");
         173  +
            let mut deser = protocol
         174  +
                .deserialize_response(response, HttpPayloadWithStructure::OUTPUT_SCHEMA, _cfg)
         175  +
                .map_err(|e| {
         176  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         177  +
                })?;
         178  +
            let body = response.body().bytes().expect("body loaded");
         179  +
            let output = crate::operation::http_payload_with_structure::HttpPayloadWithStructureOutput::deserialize_with_response(
         180  +
                &mut *deser,
         181  +
                response.headers(),
         182  +
                response.status().into(),
         183  +
                body,
         184  +
            )
         185  +
            .map_err(|e| {
         186  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         187  +
            })?;
         188  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         189  +
        }
  156    190   
    }
  157    191   
}
  158    192   
#[derive(Debug)]
  159    193   
struct HttpPayloadWithStructureRequestSerializer;
  160    194   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for HttpPayloadWithStructureRequestSerializer {
  161    195   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  162    196   
    fn serialize_input(
  163    197   
        &self,
  164    198   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  165    199   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  166    200   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  167    201   
        let input = input
  168    202   
            .downcast::<crate::operation::http_payload_with_structure::HttpPayloadWithStructureInput>()
  169    203   
            .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::http_payload_with_structure::HttpPayloadWithStructureInput,
  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, "/HttpPayloadWithStructure").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::http_payload_with_structure::HttpPayloadWithStructureInput,
  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("PUT").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_http_payload_with_structure_input::ser_nested_http_payload(
  198         -
            &input.nested,
  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())
         204  +
        let protocol = _cfg
         205  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         206  +
            .expect("a SharedClientProtocol is required");
         207  +
        let mut request = protocol
         208  +
            .serialize_request(&input, HttpPayloadWithStructure::INPUT_SCHEMA, "", _cfg)
         209  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         210  +
         211  +
        return ::std::result::Result::Ok(request);
  205    212   
    }
  206    213   
}
  207    214   
#[derive(Debug)]
  208    215   
struct HttpPayloadWithStructureEndpointParamsInterceptor;
  209    216   
  210    217   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for HttpPayloadWithStructureEndpointParamsInterceptor {
  211    218   
    fn name(&self) -> &'static str {
  212    219   
        "HttpPayloadWithStructureEndpointParamsInterceptor"
  213    220   
    }
  214    221   
@@ -297,304 +398,425 @@
  317    324   
            .expect("the config must have a deserializer");
  318    325   
  319    326   
        let parsed = de.deserialize_streaming(&mut http_response);
  320    327   
        let parsed = parsed.unwrap_or_else(|| {
  321    328   
            let http_response = http_response.map(|body| {
  322    329   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  323    330   
                    body.bytes().unwrap(),
  324    331   
                    ::aws_smithy_protocol_test::MediaType::from("application/json"),
  325    332   
                )))
  326    333   
            });
  327         -
            de.deserialize_nonstreaming(&http_response)
         334  +
            // Build a config bag with the protocol for schema-based deserialization
         335  +
            #[allow(unused_mut)]
         336  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         337  +
            {
         338  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         339  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         340  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         341  +
                ));
         342  +
                test_cfg.push_shared_layer(layer.freeze());
         343  +
            }
         344  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  328    345   
        });
  329    346   
        let parsed = parsed
  330    347   
            .expect("should be successful response")
  331    348   
            .downcast::<crate::operation::http_payload_with_structure::HttpPayloadWithStructureOutput>()
  332    349   
            .unwrap();
  333    350   
        ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
  334    351   
    }
  335    352   
  336    353   
    /// Serializes a structure in the payload
  337    354   
    /// Test ID: RestJsonHttpPayloadWithStructureAndEmptyResponseBody
  338    355   
    #[::tokio::test]
  339    356   
    #[::tracing_test::traced_test]
  340    357   
    async fn rest_json_http_payload_with_structure_and_empty_response_body_response() {
  341    358   
        let expected_output = crate::operation::http_payload_with_structure::HttpPayloadWithStructureOutput::builder()
  342    359   
            .set_nested(::std::option::Option::None)
  343    360   
            .build();
  344    361   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  345    362   
            ::http_1x::response::Builder::new()
  346    363   
                .status(200)
  347    364   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  348    365   
                .unwrap(),
  349    366   
        )
  350    367   
        .unwrap();
  351    368   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  352    369   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  353    370   
  354    371   
        let op = crate::operation::http_payload_with_structure::HttpPayloadWithStructure::new();
  355    372   
        let config = op.config().expect("the operation has config");
  356    373   
        let de = config
  357    374   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  358    375   
            .expect("the config must have a deserializer");
  359    376   
  360    377   
        let parsed = de.deserialize_streaming(&mut http_response);
  361    378   
        let parsed = parsed.unwrap_or_else(|| {
  362    379   
            let http_response = http_response.map(|body| {
  363    380   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  364    381   
                    body.bytes().unwrap(),
  365    382   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  366    383   
                )))
  367    384   
            });
  368         -
            de.deserialize_nonstreaming(&http_response)
         385  +
            // Build a config bag with the protocol for schema-based deserialization
         386  +
            #[allow(unused_mut)]
         387  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         388  +
            {
         389  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         390  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         391  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         392  +
                ));
         393  +
                test_cfg.push_shared_layer(layer.freeze());
         394  +
            }
         395  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  369    396   
        });
  370    397   
        let parsed = parsed
  371    398   
            .expect("should be successful response")
  372    399   
            .downcast::<crate::operation::http_payload_with_structure::HttpPayloadWithStructureOutput>()
  373    400   
            .unwrap();
  374    401   
        ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
  375    402   
    }
  376    403   
}
  377    404   
  378    405   
/// Error type for the `HttpPayloadWithStructureError` operation.

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/http_payload_with_structure/_http_payload_with_structure_input.rs

@@ -5,5 +109,130 @@
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::Structure,
   27     27   
    "nested",
   28     28   
    0,
   29     29   
)
   30     30   
.with_http_payload();
   31     31   
static HTTPPAYLOADWITHSTRUCTUREINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   32     32   
    HTTPPAYLOADWITHSTRUCTUREINPUT_SCHEMA_ID,
   33     33   
    ::aws_smithy_schema::ShapeType::Structure,
   34     34   
    &[&HTTPPAYLOADWITHSTRUCTUREINPUT_MEMBER_NESTED],
   35         -
);
          35  +
)
          36  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("PUT", "/HttpPayloadWithStructure", None));
   36     37   
impl HttpPayloadWithStructureInput {
   37     38   
    /// The schema for this shape.
   38     39   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &HTTPPAYLOADWITHSTRUCTUREINPUT_SCHEMA;
   39     40   
}
   40     41   
impl ::aws_smithy_schema::serde::SerializableStruct for HttpPayloadWithStructureInput {
   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.nested {
   47     48   
            ser.write_struct(&HTTPPAYLOADWITHSTRUCTUREINPUT_MEMBER_NESTED, val)?;
   48     49   
        }
   49     50   
        Ok(())
   50     51   
    }
   51     52   
}
   52     53   
impl HttpPayloadWithStructureInput {
   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(&HTTPPAYLOADWITHSTRUCTUREINPUT_SCHEMA, (), |_, member, deser| {
          67  +
        deserializer.read_struct(&HTTPPAYLOADWITHSTRUCTUREINPUT_SCHEMA, &mut |member, deser| {
   67     68   
            match member.member_index() {
   68     69   
                Some(0) => {
   69     70   
                    builder.nested = Some(crate::types::NestedPayload::deserialize(deser)?);
   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 HttpPayloadWithStructureInput {
          82  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
          83  +
    /// Header-bound members are read directly from headers, avoiding runtime
          84  +
    /// member iteration overhead. Body members are read via the deserializer.
          85  +
    pub fn deserialize_with_response(
          86  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          87  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          88  +
        _status: u16,
          89  +
        body: &[u8],
          90  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          91  +
        #[allow(unused_variables, unused_mut)]
          92  +
        let mut builder = Self::builder();
          93  +
        if !body.is_empty() {
          94  +
            builder.nested = Some(crate::types::NestedPayload::deserialize(deserializer)?);
          95  +
        }
          96  +
        builder
          97  +
            .build()
          98  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
          99  +
    }
         100  +
}
   80    101   
impl HttpPayloadWithStructureInput {
   81    102   
    /// Creates a new builder-style object to manufacture [`HttpPayloadWithStructureInput`](crate::operation::http_payload_with_structure::HttpPayloadWithStructureInput).
   82    103   
    pub fn builder() -> crate::operation::http_payload_with_structure::builders::HttpPayloadWithStructureInputBuilder {
   83    104   
        crate::operation::http_payload_with_structure::builders::HttpPayloadWithStructureInputBuilder::default()
   84    105   
    }
   85    106   
}
   86    107   
   87    108   
/// A builder for [`HttpPayloadWithStructureInput`](crate::operation::http_payload_with_structure::HttpPayloadWithStructureInput).
   88    109   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   89    110   
#[non_exhaustive]