Client Test

Client Test

rev. ec7b2441254af868911fccffe8d8dca83aff0045 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/document_type_as_map_value/_document_type_as_map_value_output.rs

@@ -1,1 +125,133 @@
   17     17   
    "aws.protocoltests.restjson.synthetic",
   18     18   
    "DocumentTypeAsMapValueOutput",
   19     19   
);
   20     20   
static DOCUMENTTYPEASMAPVALUEOUTPUT_MEMBER_DOC_VALUED_MAP: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   21     21   
    ::aws_smithy_schema::ShapeId::from_static(
   22     22   
        "aws.protocoltests.restjson.synthetic#DocumentTypeAsMapValueOutput$docValuedMap",
   23     23   
        "aws.protocoltests.restjson.synthetic",
   24     24   
        "DocumentTypeAsMapValueOutput",
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::Map,
   27         -
    "doc_valued_map",
          27  +
    "docValuedMap",
   28     28   
    0,
   29     29   
);
   30     30   
static DOCUMENTTYPEASMAPVALUEOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   31     31   
    DOCUMENTTYPEASMAPVALUEOUTPUT_SCHEMA_ID,
   32     32   
    ::aws_smithy_schema::ShapeType::Structure,
   33     33   
    &[&DOCUMENTTYPEASMAPVALUEOUTPUT_MEMBER_DOC_VALUED_MAP],
   34     34   
);
   35     35   
impl DocumentTypeAsMapValueOutput {
   36     36   
    /// The schema for this shape.
   37     37   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DOCUMENTTYPEASMAPVALUEOUTPUT_SCHEMA;
   38     38   
}
   39     39   
impl ::aws_smithy_schema::serde::SerializableStruct for DocumentTypeAsMapValueOutput {
   40     40   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   41     41   
    fn serialize_members(
   42     42   
        &self,
   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.doc_valued_map {
   46     46   
            ser.write_map(
   47     47   
                &DOCUMENTTYPEASMAPVALUEOUTPUT_MEMBER_DOC_VALUED_MAP,
   48     48   
                &|ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer| {
   49     49   
                    for (key, value) in val {
   50     50   
                        ser.write_string(&::aws_smithy_schema::prelude::STRING, key)?;
   51         -
                        todo!("schema: unsupported map value type");
          51  +
                        ser.write_document(&::aws_smithy_schema::prelude::DOCUMENT, value)?;
   52     52   
                    }
   53     53   
                    Ok(())
   54     54   
                },
   55     55   
            )?;
   56     56   
        }
   57     57   
        Ok(())
   58     58   
    }
   59     59   
}
   60     60   
impl DocumentTypeAsMapValueOutput {
   61     61   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   62         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   63         -
        deserializer: &mut D,
          62  +
    pub fn deserialize(
          63  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   64     64   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   65     65   
        #[allow(unused_variables, unused_mut)]
   66     66   
        let mut builder = Self::builder();
   67     67   
        #[allow(
   68     68   
            unused_variables,
   69     69   
            unreachable_code,
   70     70   
            clippy::single_match,
   71     71   
            clippy::match_single_binding,
   72     72   
            clippy::diverging_sub_expression
   73     73   
        )]
   74         -
        deserializer.read_struct(&DOCUMENTTYPEASMAPVALUEOUTPUT_SCHEMA, (), |_, member, deser| {
          74  +
        deserializer.read_struct(&DOCUMENTTYPEASMAPVALUEOUTPUT_SCHEMA, &mut |member, deser| {
   75     75   
            match member.member_index() {
   76     76   
                Some(0) => {
   77     77   
                    builder.doc_valued_map = Some({
   78         -
                        let container = if let Some(cap) = deser.container_size() {
   79         -
                            std::collections::HashMap::with_capacity(cap)
   80         -
                        } else {
   81         -
                            std::collections::HashMap::new()
   82         -
                        };
   83         -
                        deser.read_map(member, container, |mut map, key, deser| {
   84         -
                            map.insert(key, deser.read_document(member)?);
   85         -
                            Ok(map)
   86         -
                        })?
          78  +
                        let mut container = std::collections::HashMap::new();
          79  +
                        deser.read_map(member, &mut |key, deser| {
          80  +
                            container.insert(key, deser.read_document(member)?);
          81  +
                            Ok(())
          82  +
                        })?;
          83  +
                        container
   87     84   
                    });
   88     85   
                }
   89     86   
                _ => {}
   90     87   
            }
   91     88   
            Ok(())
   92     89   
        })?;
   93     90   
        Ok(builder.build())
   94     91   
    }
   95     92   
}
          93  +
impl DocumentTypeAsMapValueOutput {
          94  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          95  +
    pub fn deserialize_with_response(
          96  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          97  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          98  +
        _status: u16,
          99  +
        _body: &[u8],
         100  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         101  +
        Self::deserialize(deserializer)
         102  +
    }
         103  +
}
   96    104   
impl DocumentTypeAsMapValueOutput {
   97    105   
    /// Creates a new builder-style object to manufacture [`DocumentTypeAsMapValueOutput`](crate::operation::document_type_as_map_value::DocumentTypeAsMapValueOutput).
   98    106   
    pub fn builder() -> crate::operation::document_type_as_map_value::builders::DocumentTypeAsMapValueOutputBuilder {
   99    107   
        crate::operation::document_type_as_map_value::builders::DocumentTypeAsMapValueOutputBuilder::default()
  100    108   
    }
  101    109   
}
  102    110   
  103    111   
/// A builder for [`DocumentTypeAsMapValueOutput`](crate::operation::document_type_as_map_value::DocumentTypeAsMapValueOutput).
  104    112   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
  105    113   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/document_type_as_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 `DocumentTypeAsPayload`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct DocumentTypeAsPayload;
    6      6   
impl DocumentTypeAsPayload {
    7      7   
    /// Creates a new `DocumentTypeAsPayload`
    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::document_type_as_payload::DocumentTypeAsPayloadInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput::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::document_type_as_payload::DocumentTypeAsPayloadInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::document_type_as_payload::DocumentTypeAsPayloadError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -110,114 +234,250 @@
  130    134   
                crate::operation::document_type_as_payload::DocumentTypeAsPayloadError,
  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 DocumentTypeAsPayloadResponseDeserializer;
  139    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for DocumentTypeAsPayloadResponseDeserializer {
  140         -
    fn deserialize_nonstreaming(
         144  +
    fn deserialize_nonstreaming_with_config(
  141    145   
        &self,
  142    146   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
         147  +
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  143    148   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  144    149   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
         150  +
        #[allow(unused_mut)]
         151  +
        let mut force_error = false;
         152  +
         153  +
        if !success && status != 200 || force_error {
  145    154   
            let headers = response.headers();
  146    155   
            let body = response.body().bytes().expect("body loaded");
  147    156   
            #[allow(unused_mut)]
  148         -
        let mut force_error = false;
         157  +
            let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
         158  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         159  +
            })?;
  149    160   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_document_type_as_payload::de_document_type_as_payload_http_error(status, headers, body)
         161  +
            let generic = generic_builder.build();
         162  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         163  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         164  +
                    crate::operation::document_type_as_payload::DocumentTypeAsPayloadError::generic(generic),
         165  +
                ),
         166  +
            ))
  152    167   
        } else {
  153         -
            crate::protocol_serde::shape_document_type_as_payload::de_document_type_as_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, DocumentTypeAsPayload::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::document_type_as_payload::DocumentTypeAsPayloadOutput::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 DocumentTypeAsPayloadRequestSerializer;
  160    192   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DocumentTypeAsPayloadRequestSerializer {
  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::document_type_as_payload::DocumentTypeAsPayloadInput>()
  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::document_type_as_payload::DocumentTypeAsPayloadInput,
  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, "/DocumentTypeAsPayload").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::document_type_as_payload::DocumentTypeAsPayloadInput,
  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(
  198         -
            crate::protocol_serde::shape_document_type_as_payload_input::ser_document_value_http_payload(&input.document_value)?,
  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())
         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.document_value.take();
         207  +
        let mut request = protocol
         208  +
            .serialize_request(&input, DocumentTypeAsPayload::INPUT_SCHEMA, "", _cfg)
         209  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         210  +
        if let ::std::option::Option::Some(payload) = payload {
         211  +
            let mut json = String::new();
         212  +
            ::aws_smithy_json::serialize::JsonValueWriter::new(&mut json).document(&payload);
         213  +
            *request.body_mut() = ::aws_smithy_types::body::SdkBody::from(json.into_bytes());
         214  +
            request.headers_mut().insert("Content-Type", "application/json");
         215  +
            if let ::std::option::Option::Some(content_length) = request.body().content_length() {
         216  +
                request.headers_mut().insert("Content-Length", content_length.to_string());
         217  +
            }
         218  +
        }
         219  +
         220  +
        return ::std::result::Result::Ok(request);
  205    221   
    }
  206    222   
}
  207    223   
#[derive(Debug)]
  208    224   
struct DocumentTypeAsPayloadEndpointParamsInterceptor;
  209    225   
  210    226   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DocumentTypeAsPayloadEndpointParamsInterceptor {
  211    227   
    fn name(&self) -> &'static str {
  212    228   
        "DocumentTypeAsPayloadEndpointParamsInterceptor"
  213    229   
    }
  214    230   
@@ -333,349 +443,479 @@
  353    369   
            .expect("the config must have a deserializer");
  354    370   
  355    371   
        let parsed = de.deserialize_streaming(&mut http_response);
  356    372   
        let parsed = parsed.unwrap_or_else(|| {
  357    373   
            let http_response = http_response.map(|body| {
  358    374   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  359    375   
                    body.bytes().unwrap(),
  360    376   
                    ::aws_smithy_protocol_test::MediaType::from("application/json"),
  361    377   
                )))
  362    378   
            });
  363         -
            de.deserialize_nonstreaming(&http_response)
         379  +
            // Build a config bag with the protocol for schema-based deserialization
         380  +
            #[allow(unused_mut)]
         381  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         382  +
            {
         383  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         384  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         385  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         386  +
                ));
         387  +
                test_cfg.push_shared_layer(layer.freeze());
         388  +
            }
         389  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  364    390   
        });
  365    391   
        let parsed = parsed
  366    392   
            .expect("should be successful response")
  367    393   
            .downcast::<crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput>()
  368    394   
            .unwrap();
  369    395   
        ::pretty_assertions::assert_eq!(
  370    396   
            parsed.document_value,
  371    397   
            expected_output.document_value,
  372    398   
            "Unexpected value for `document_value`"
  373    399   
        );
  374    400   
    }
  375    401   
  376    402   
    /// Serializes a document as a payload string.
  377    403   
    /// Test ID: DocumentTypeAsPayloadOutputString
  378    404   
    #[::tokio::test]
  379    405   
    #[::tracing_test::traced_test]
  380    406   
    async fn document_type_as_payload_output_string_response() {
  381    407   
        let expected_output = crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput::builder()
  382    408   
            .set_document_value(::std::option::Option::Some({
  383    409   
                let json_bytes = br#""hello""#;
  384    410   
                let mut tokens = ::aws_smithy_json::deserialize::json_token_iter(json_bytes).peekable();
  385    411   
                ::aws_smithy_json::deserialize::token::expect_document(&mut tokens).expect("well formed json")
  386    412   
            }))
  387    413   
            .build();
  388    414   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  389    415   
            ::http_1x::response::Builder::new()
  390    416   
                .header("Content-Type", "application/json")
  391    417   
                .status(200)
  392    418   
                .body(::aws_smithy_types::body::SdkBody::from("\"hello\""))
  393    419   
                .unwrap(),
  394    420   
        )
  395    421   
        .unwrap();
  396    422   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  397    423   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  398    424   
  399    425   
        let op = crate::operation::document_type_as_payload::DocumentTypeAsPayload::new();
  400    426   
        let config = op.config().expect("the operation has config");
  401    427   
        let de = config
  402    428   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  403    429   
            .expect("the config must have a deserializer");
  404    430   
  405    431   
        let parsed = de.deserialize_streaming(&mut http_response);
  406    432   
        let parsed = parsed.unwrap_or_else(|| {
  407    433   
            let http_response = http_response.map(|body| {
  408    434   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  409    435   
                    body.bytes().unwrap(),
  410    436   
                    ::aws_smithy_protocol_test::MediaType::from("application/json"),
  411    437   
                )))
  412    438   
            });
  413         -
            de.deserialize_nonstreaming(&http_response)
         439  +
            // Build a config bag with the protocol for schema-based deserialization
         440  +
            #[allow(unused_mut)]
         441  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         442  +
            {
         443  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         444  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         445  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         446  +
                ));
         447  +
                test_cfg.push_shared_layer(layer.freeze());
         448  +
            }
         449  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  414    450   
        });
  415    451   
        let parsed = parsed
  416    452   
            .expect("should be successful response")
  417    453   
            .downcast::<crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput>()
  418    454   
            .unwrap();
  419    455   
        ::pretty_assertions::assert_eq!(
  420    456   
            parsed.document_value,
  421    457   
            expected_output.document_value,
  422    458   
            "Unexpected value for `document_value`"
  423    459   
        );

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/document_type_as_payload/_document_type_as_payload_input.rs

@@ -1,1 +109,130 @@
   17     17   
    "aws.protocoltests.restjson.synthetic",
   18     18   
    "DocumentTypeAsPayloadInput",
   19     19   
);
   20     20   
static DOCUMENTTYPEASPAYLOADINPUT_MEMBER_DOCUMENT_VALUE: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   21     21   
    ::aws_smithy_schema::ShapeId::from_static(
   22     22   
        "aws.protocoltests.restjson.synthetic#DocumentTypeAsPayloadInput$documentValue",
   23     23   
        "aws.protocoltests.restjson.synthetic",
   24     24   
        "DocumentTypeAsPayloadInput",
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::Document,
   27         -
    "document_value",
          27  +
    "documentValue",
   28     28   
    0,
   29     29   
)
   30     30   
.with_http_payload();
   31     31   
static DOCUMENTTYPEASPAYLOADINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   32     32   
    DOCUMENTTYPEASPAYLOADINPUT_SCHEMA_ID,
   33     33   
    ::aws_smithy_schema::ShapeType::Structure,
   34     34   
    &[&DOCUMENTTYPEASPAYLOADINPUT_MEMBER_DOCUMENT_VALUE],
   35         -
);
          35  +
)
          36  +
.with_http(aws_smithy_schema::traits::HttpTrait::new("PUT", "/DocumentTypeAsPayload", None));
   36     37   
impl DocumentTypeAsPayloadInput {
   37     38   
    /// The schema for this shape.
   38     39   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DOCUMENTTYPEASPAYLOADINPUT_SCHEMA;
   39     40   
}
   40     41   
impl ::aws_smithy_schema::serde::SerializableStruct for DocumentTypeAsPayloadInput {
   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.document_value {
   47     48   
            ser.write_document(&DOCUMENTTYPEASPAYLOADINPUT_MEMBER_DOCUMENT_VALUE, val)?;
   48     49   
        }
   49     50   
        Ok(())
   50     51   
    }
   51     52   
}
   52     53   
impl DocumentTypeAsPayloadInput {
   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(&DOCUMENTTYPEASPAYLOADINPUT_SCHEMA, (), |_, member, deser| {
          67  +
        deserializer.read_struct(&DOCUMENTTYPEASPAYLOADINPUT_SCHEMA, &mut |member, deser| {
   67     68   
            match member.member_index() {
   68     69   
                Some(0) => {
   69     70   
                    builder.document_value = Some(deser.read_document(member)?);
   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 DocumentTypeAsPayloadInput {
          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.document_value = Some(deserializer.read_document(&DOCUMENTTYPEASPAYLOADINPUT_MEMBER_DOCUMENT_VALUE)?);
          95  +
        }
          96  +
        builder
          97  +
            .build()
          98  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
          99  +
    }
         100  +
}
   80    101   
impl DocumentTypeAsPayloadInput {
   81    102   
    /// Creates a new builder-style object to manufacture [`DocumentTypeAsPayloadInput`](crate::operation::document_type_as_payload::DocumentTypeAsPayloadInput).
   82    103   
    pub fn builder() -> crate::operation::document_type_as_payload::builders::DocumentTypeAsPayloadInputBuilder {
   83    104   
        crate::operation::document_type_as_payload::builders::DocumentTypeAsPayloadInputBuilder::default()
   84    105   
    }
   85    106   
}
   86    107   
   87    108   
/// A builder for [`DocumentTypeAsPayloadInput`](crate::operation::document_type_as_payload::DocumentTypeAsPayloadInput).
   88    109   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   89    110   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/document_type_as_payload/_document_type_as_payload_output.rs

@@ -1,1 +107,125 @@
   17     17   
    "aws.protocoltests.restjson.synthetic",
   18     18   
    "DocumentTypeAsPayloadOutput",
   19     19   
);
   20     20   
static DOCUMENTTYPEASPAYLOADOUTPUT_MEMBER_DOCUMENT_VALUE: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   21     21   
    ::aws_smithy_schema::ShapeId::from_static(
   22     22   
        "aws.protocoltests.restjson.synthetic#DocumentTypeAsPayloadOutput$documentValue",
   23     23   
        "aws.protocoltests.restjson.synthetic",
   24     24   
        "DocumentTypeAsPayloadOutput",
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::Document,
   27         -
    "document_value",
          27  +
    "documentValue",
   28     28   
    0,
   29     29   
)
   30     30   
.with_http_payload();
   31     31   
static DOCUMENTTYPEASPAYLOADOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   32     32   
    DOCUMENTTYPEASPAYLOADOUTPUT_SCHEMA_ID,
   33     33   
    ::aws_smithy_schema::ShapeType::Structure,
   34     34   
    &[&DOCUMENTTYPEASPAYLOADOUTPUT_MEMBER_DOCUMENT_VALUE],
   35     35   
);
   36     36   
impl DocumentTypeAsPayloadOutput {
   37     37   
    /// The schema for this shape.
   38     38   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DOCUMENTTYPEASPAYLOADOUTPUT_SCHEMA;
   39     39   
}
   40     40   
impl ::aws_smithy_schema::serde::SerializableStruct for DocumentTypeAsPayloadOutput {
   41     41   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   42     42   
    fn serialize_members(
   43     43   
        &self,
   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.document_value {
   47     47   
            ser.write_document(&DOCUMENTTYPEASPAYLOADOUTPUT_MEMBER_DOCUMENT_VALUE, val)?;
   48     48   
        }
   49     49   
        Ok(())
   50     50   
    }
   51     51   
}
   52     52   
impl DocumentTypeAsPayloadOutput {
   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(&DOCUMENTTYPEASPAYLOADOUTPUT_SCHEMA, (), |_, member, deser| {
          66  +
        deserializer.read_struct(&DOCUMENTTYPEASPAYLOADOUTPUT_SCHEMA, &mut |member, deser| {
   67     67   
            match member.member_index() {
   68     68   
                Some(0) => {
   69     69   
                    builder.document_value = Some(deser.read_document(member)?);
   70     70   
                }
   71     71   
                _ => {}
   72     72   
            }
   73     73   
            Ok(())
   74     74   
        })?;
   75     75   
        Ok(builder.build())
   76     76   
    }
   77     77   
}
          78  +
impl DocumentTypeAsPayloadOutput {
          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  +
            builder.document_value = Some(deserializer.read_document(&DOCUMENTTYPEASPAYLOADOUTPUT_MEMBER_DOCUMENT_VALUE)?);
          92  +
        }
          93  +
        Ok(builder.build())
          94  +
    }
          95  +
}
   78     96   
impl DocumentTypeAsPayloadOutput {
   79     97   
    /// Creates a new builder-style object to manufacture [`DocumentTypeAsPayloadOutput`](crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput).
   80     98   
    pub fn builder() -> crate::operation::document_type_as_payload::builders::DocumentTypeAsPayloadOutputBuilder {
   81     99   
        crate::operation::document_type_as_payload::builders::DocumentTypeAsPayloadOutputBuilder::default()
   82    100   
    }
   83    101   
}
   84    102   
   85    103   
/// A builder for [`DocumentTypeAsPayloadOutput`](crate::operation::document_type_as_payload::DocumentTypeAsPayloadOutput).
   86    104   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   87    105   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream.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 `DuplexStream`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct DuplexStream;
    6      6   
impl DuplexStream {
    7      7   
    /// Creates a new `DuplexStream`
    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::duplex_stream::DuplexStreamInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::duplex_stream::DuplexStreamOutput::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::duplex_stream::DuplexStreamInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::duplex_stream::DuplexStreamOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::duplex_stream::DuplexStreamError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -119,123 +247,271 @@
  139    143   
  140    144   
        // If this is an error, defer to the non-streaming parser
  141    145   
        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
  142    146   
            return ::std::option::Option::None;
  143    147   
        }
  144    148   
        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
  145    149   
            crate::protocol_serde::shape_duplex_stream::de_duplex_stream_http_response(response),
  146    150   
        ))
  147    151   
    }
  148    152   
  149         -
    fn deserialize_nonstreaming(
         153  +
    fn deserialize_nonstreaming_with_config(
  150    154   
        &self,
  151    155   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
         156  +
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  152    157   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  153    158   
        // For streaming operations, we only hit this case if its an error
  154    159   
        let body = response.body().bytes().expect("body loaded");
  155         -
        crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_duplex_stream::de_duplex_stream_http_error(
  156         -
            response.status().as_u16(),
  157         -
            response.headers(),
  158         -
            body,
         160  +
        let status = response.status().as_u16();
         161  +
        let headers = response.headers();
         162  +
        #[allow(unused_mut)]
         163  +
        let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
         164  +
            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         165  +
        })?;
         166  +
         167  +
        let generic = generic_builder.build();
         168  +
        let error_code = match generic.code() {
         169  +
            ::std::option::Option::Some(code) => code,
         170  +
            ::std::option::Option::None => {
         171  +
                return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         172  +
                    ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::duplex_stream::DuplexStreamError::unhandled(generic)),
         173  +
                ))
         174  +
            }
         175  +
        };
         176  +
        let _error_message = generic.message().map(|msg| msg.to_owned());
         177  +
        let protocol = _cfg
         178  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         179  +
            .expect("a SharedClientProtocol is required");
         180  +
        let err = match error_code {
         181  +
            "ErrorEvent" => crate::operation::duplex_stream::DuplexStreamError::ErrorEvent({
         182  +
                let mut tmp = match protocol
         183  +
                    .deserialize_response(response, crate::types::error::ErrorEvent::SCHEMA, _cfg)
         184  +
                    .and_then(|mut deser| {
         185  +
                        crate::types::error::ErrorEvent::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body)
         186  +
                    }) {
         187  +
                    ::std::result::Result::Ok(val) => val,
         188  +
                    ::std::result::Result::Err(e) => {
         189  +
                        return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         190  +
                            ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         191  +
                        ))
         192  +
                    }
         193  +
                };
         194  +
                tmp.meta = generic;
         195  +
                if tmp.message.is_none() {
         196  +
                    tmp.message = _error_message;
         197  +
                }
         198  +
                tmp
         199  +
            }),
         200  +
            _ => crate::operation::duplex_stream::DuplexStreamError::generic(generic),
         201  +
        };
         202  +
        ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         203  +
            ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
  159    204   
        ))
  160    205   
    }
  161    206   
}
  162    207   
#[derive(Debug)]
  163    208   
struct DuplexStreamRequestSerializer;
  164    209   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DuplexStreamRequestSerializer {
  165    210   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  166    211   
    fn serialize_input(
  167    212   
        &self,
  168    213   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  169    214   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  170    215   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  171    216   
        let input = input
  172    217   
            .downcast::<crate::operation::duplex_stream::DuplexStreamInput>()
  173    218   
            .expect("correct type");
  174         -
        let _header_serialization_settings = _cfg
  175         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  176         -
            .cloned()
  177         -
            .unwrap_or_default();
  178         -
        let mut request_builder = {
  179         -
            #[allow(clippy::uninlined_format_args)]
  180         -
            fn uri_base(
  181         -
                _input: &crate::operation::duplex_stream::DuplexStreamInput,
  182         -
                output: &mut ::std::string::String,
  183         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  184         -
                use ::std::fmt::Write as _;
  185         -
                ::std::write!(output, "/DuplexStream").expect("formatting should succeed");
  186         -
                ::std::result::Result::Ok(())
  187         -
            }
  188         -
            #[allow(clippy::unnecessary_wraps)]
  189         -
            fn update_http_builder(
  190         -
                input: &crate::operation::duplex_stream::DuplexStreamInput,
  191         -
                builder: ::http_1x::request::Builder,
  192         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  193         -
                let mut uri = ::std::string::String::new();
  194         -
                uri_base(input, &mut uri)?;
  195         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  196         -
            }
  197         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  198         -
            builder =
  199         -
                _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
  200         -
            builder
  201         -
        };
  202         -
        let body = ::aws_smithy_types::body::SdkBody::from({
         219  +
        let protocol = _cfg
         220  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         221  +
            .expect("a SharedClientProtocol is required");
         222  +
        let mut request = protocol
         223  +
            .serialize_request(&input, DuplexStream::INPUT_SCHEMA, "", _cfg)
         224  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         225  +
        *request.body_mut() = ::aws_smithy_types::body::SdkBody::from({
  203    226   
            let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
  204    227   
            let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
  205    228   
            let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
  206    229   
            _cfg.interceptor_state().store_put(signer_sender);
  207    230   
            ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.stream.into_body_stream(
  208    231   
                marshaller,
  209    232   
                error_marshaller,
  210    233   
                signer,
  211    234   
            )))
  212    235   
        });
  213         -
        if let Some(content_length) = body.content_length() {
  214         -
            let content_length = content_length.to_string();
  215         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
  216         -
        }
  217         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         236  +
        // The protocol may have set Content-Length based on the initial empty body.
         237  +
        // Remove it since the event stream body has unknown length.
         238  +
        request.headers_mut().remove("Content-Length");
         239  +
        request.headers_mut().insert("Content-Type", "application/vnd.amazon.eventstream");
         240  +
         241  +
        return ::std::result::Result::Ok(request);
  218    242   
    }
  219    243   
}
  220    244   
#[derive(Debug)]
  221    245   
struct DuplexStreamEndpointParamsInterceptor;
  222    246   
  223    247   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DuplexStreamEndpointParamsInterceptor {
  224    248   
    fn name(&self) -> &'static str {
  225    249   
        "DuplexStreamEndpointParamsInterceptor"
  226    250   
    }
  227    251   

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream/_duplex_stream_input.rs

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

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream/_duplex_stream_output.rs

@@ -16,16 +113,120 @@
   36     36   
impl DuplexStreamOutput {
   37     37   
    /// The schema for this shape.
   38     38   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DUPLEXSTREAMOUTPUT_SCHEMA;
   39     39   
}
   40     40   
impl ::aws_smithy_schema::serde::SerializableStruct for DuplexStreamOutput {
   41     41   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   42     42   
    fn serialize_members(
   43     43   
        &self,
   44     44   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   45     45   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   46         -
        {
   47         -
            let val = &self.stream;
   48         -
            ser.write_null(&DUPLEXSTREAMOUTPUT_MEMBER_STREAM)?;
   49         -
        }
   50     46   
        Ok(())
   51     47   
    }
   52     48   
}
   53     49   
impl DuplexStreamOutput {
   54     50   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   55         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   56         -
        deserializer: &mut D,
          51  +
    pub fn deserialize(
          52  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   57     53   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   58     54   
        #[allow(unused_variables, unused_mut)]
   59     55   
        let mut builder = Self::builder();
   60     56   
        #[allow(
   61     57   
            unused_variables,
   62     58   
            unreachable_code,
   63     59   
            clippy::single_match,
   64     60   
            clippy::match_single_binding,
   65     61   
            clippy::diverging_sub_expression
   66     62   
        )]
   67         -
        deserializer.read_struct(&DUPLEXSTREAMOUTPUT_SCHEMA, (), |_, member, deser| {
          63  +
        deserializer.read_struct(&DUPLEXSTREAMOUTPUT_SCHEMA, &mut |member, deser| {
   68     64   
            match member.member_index() {
   69     65   
                Some(0) => {
   70     66   
                    builder.stream = Some({
   71     67   
                        let _ = member;
   72         -
                        todo!("deserialize aggregate")
          68  +
                        todo!("deserialize streaming union")
   73     69   
                    });
   74     70   
                }
   75     71   
                _ => {}
   76     72   
            }
   77     73   
            Ok(())
   78     74   
        })?;
   79     75   
        builder
   80     76   
            .build()
   81     77   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   82     78   
    }
   83     79   
}
          80  +
impl DuplexStreamOutput {
          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  +
}
   84     91   
impl DuplexStreamOutput {
   85     92   
    /// Creates a new builder-style object to manufacture [`DuplexStreamOutput`](crate::operation::duplex_stream::DuplexStreamOutput).
   86     93   
    pub fn builder() -> crate::operation::duplex_stream::builders::DuplexStreamOutputBuilder {
   87     94   
        crate::operation::duplex_stream::builders::DuplexStreamOutputBuilder::default()
   88     95   
    }
   89     96   
}
   90     97   
   91     98   
/// A builder for [`DuplexStreamOutput`](crate::operation::duplex_stream::DuplexStreamOutput).
   92     99   
#[derive(::std::default::Default, ::std::fmt::Debug)]
   93    100   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream_with_distinct_streams.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 `DuplexStreamWithDistinctStreams`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct DuplexStreamWithDistinctStreams;
    6      6   
impl DuplexStreamWithDistinctStreams {
    7      7   
    /// Creates a new `DuplexStreamWithDistinctStreams`
    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::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          16  +
        crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsOutput::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::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -109,115 +244,294 @@
  129    135   
                crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError,
  130    136   
            >::new());
  131    137   
  132    138   
        ::std::borrow::Cow::Owned(rcb)
  133    139   
    }
  134    140   
}
  135    141   
  136    142   
#[derive(Debug)]
  137    143   
struct DuplexStreamWithDistinctStreamsResponseDeserializer;
  138    144   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for DuplexStreamWithDistinctStreamsResponseDeserializer {
  139         -
    fn deserialize_nonstreaming(
         145  +
    fn deserialize_nonstreaming_with_config(
  140    146   
        &self,
  141    147   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
         148  +
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  142    149   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  143    150   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
         151  +
        #[allow(unused_mut)]
         152  +
        let mut force_error = false;
         153  +
         154  +
        if !success && status != 200 || force_error {
  144    155   
            let headers = response.headers();
  145    156   
            let body = response.body().bytes().expect("body loaded");
  146    157   
            #[allow(unused_mut)]
  147         -
        let mut force_error = false;
         158  +
            let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
         159  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         160  +
            })?;
  148    161   
  149         -
        let parse_result = if !success && status != 200 || force_error {
  150         -
            crate::protocol_serde::shape_duplex_stream_with_distinct_streams::de_duplex_stream_with_distinct_streams_http_error(status, headers, body)
  151         -
        } else {
  152         -
            crate::protocol_serde::shape_duplex_stream_with_distinct_streams::de_duplex_stream_with_distinct_streams_http_response(
  153         -
                status, headers, body,
         162  +
            let generic = generic_builder.build();
         163  +
            let error_code = match generic.code() {
         164  +
                ::std::option::Option::Some(code) => code,
         165  +
                ::std::option::Option::None => {
         166  +
                    return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         167  +
                        ::aws_smithy_runtime_api::box_error::BoxError::from(
         168  +
                            crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError::unhandled(generic),
         169  +
                        ),
         170  +
                    ))
         171  +
                }
         172  +
            };
         173  +
            let _error_message = generic.message().map(|msg| msg.to_owned());
         174  +
            let protocol = _cfg
         175  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         176  +
                .expect("a SharedClientProtocol is required");
         177  +
            let err = match error_code {
         178  +
                "ErrorEvent" => crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError::ErrorEvent({
         179  +
                    let mut tmp = match protocol
         180  +
                        .deserialize_response(response, crate::types::error::ErrorEvent::SCHEMA, _cfg)
         181  +
                        .and_then(|mut deser| {
         182  +
                            crate::types::error::ErrorEvent::deserialize_with_response(
         183  +
                                &mut *deser,
         184  +
                                response.headers(),
         185  +
                                response.status().into(),
         186  +
                                body,
  154    187   
                            )
         188  +
                        }) {
         189  +
                        ::std::result::Result::Ok(val) => val,
         190  +
                        ::std::result::Result::Err(e) => {
         191  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         192  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         193  +
                            ))
         194  +
                        }
  155    195   
                    };
  156         -
        crate::protocol_serde::type_erase_result(parse_result)
         196  +
                    tmp.meta = generic;
         197  +
                    if tmp.message.is_none() {
         198  +
                        tmp.message = _error_message;
         199  +
                    }
         200  +
                    tmp
         201  +
                }),
         202  +
                _ => crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsError::generic(generic),
         203  +
            };
         204  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         205  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         206  +
            ))
         207  +
        } else {
         208  +
            let protocol = _cfg
         209  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         210  +
                .expect("a SharedClientProtocol is required");
         211  +
            let mut deser = protocol
         212  +
                .deserialize_response(response, DuplexStreamWithDistinctStreams::OUTPUT_SCHEMA, _cfg)
         213  +
                .map_err(|e| {
         214  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         215  +
                })?;
         216  +
            let body = response.body().bytes().expect("body loaded");
         217  +
            let output = crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsOutput::deserialize_with_response(
         218  +
                &mut *deser,
         219  +
                response.headers(),
         220  +
                response.status().into(),
         221  +
                body,
         222  +
            )
         223  +
            .map_err(|e| {
         224  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         225  +
            })?;
         226  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         227  +
        }
  157    228   
    }
  158    229   
}
  159    230   
#[derive(Debug)]
  160    231   
struct DuplexStreamWithDistinctStreamsRequestSerializer;
  161    232   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DuplexStreamWithDistinctStreamsRequestSerializer {
  162    233   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  163    234   
    fn serialize_input(
  164    235   
        &self,
  165    236   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  166    237   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  167    238   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  168    239   
        let input = input
  169    240   
            .downcast::<crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput>()
  170    241   
            .expect("correct type");
  171         -
        let _header_serialization_settings = _cfg
  172         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  173         -
            .cloned()
  174         -
            .unwrap_or_default();
  175         -
        let mut request_builder = {
  176         -
            #[allow(clippy::uninlined_format_args)]
  177         -
            fn uri_base(
  178         -
                _input: &crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput,
  179         -
                output: &mut ::std::string::String,
  180         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  181         -
                use ::std::fmt::Write as _;
  182         -
                ::std::write!(output, "/DuplexStreamWithDistinctStreams").expect("formatting should succeed");
  183         -
                ::std::result::Result::Ok(())
  184         -
            }
  185         -
            #[allow(clippy::unnecessary_wraps)]
  186         -
            fn update_http_builder(
  187         -
                input: &crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput,
  188         -
                builder: ::http_1x::request::Builder,
  189         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  190         -
                let mut uri = ::std::string::String::new();
  191         -
                uri_base(input, &mut uri)?;
  192         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  193         -
            }
  194         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  195         -
            builder =
  196         -
                _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
  197         -
            builder
  198         -
        };
  199         -
        let body = ::aws_smithy_types::body::SdkBody::from({
         242  +
        let protocol = _cfg
         243  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         244  +
            .expect("a SharedClientProtocol is required");
         245  +
        let mut request = protocol
         246  +
            .serialize_request(&input, DuplexStreamWithDistinctStreams::INPUT_SCHEMA, "", _cfg)
         247  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         248  +
        *request.body_mut() = ::aws_smithy_types::body::SdkBody::from({
  200    249   
            let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
  201    250   
            let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
  202    251   
            let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
  203    252   
            _cfg.interceptor_state().store_put(signer_sender);
  204    253   
            ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.stream.into_body_stream(
  205    254   
                marshaller,
  206    255   
                error_marshaller,
  207    256   
                signer,
  208    257   
            )))
  209    258   
        });
  210         -
        if let Some(content_length) = body.content_length() {
  211         -
            let content_length = content_length.to_string();
  212         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
  213         -
        }
  214         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         259  +
        // The protocol may have set Content-Length based on the initial empty body.
         260  +
        // Remove it since the event stream body has unknown length.
         261  +
        request.headers_mut().remove("Content-Length");
         262  +
        request.headers_mut().insert("Content-Type", "application/vnd.amazon.eventstream");
         263  +
         264  +
        return ::std::result::Result::Ok(request);
  215    265   
    }
  216    266   
}
  217    267   
#[derive(Debug)]
  218    268   
struct DuplexStreamWithDistinctStreamsEndpointParamsInterceptor;
  219    269   
  220    270   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DuplexStreamWithDistinctStreamsEndpointParamsInterceptor {
  221    271   
    fn name(&self) -> &'static str {
  222    272   
        "DuplexStreamWithDistinctStreamsEndpointParamsInterceptor"
  223    273   
    }
  224    274   

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream_with_distinct_streams/_duplex_stream_with_distinct_streams_input.rs

@@ -5,5 +113,125 @@
   25     25   
    ),
   26     26   
    ::aws_smithy_schema::ShapeType::Union,
   27     27   
    "stream",
   28     28   
    0,
   29     29   
)
   30     30   
.with_http_payload();
   31     31   
static DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   32     32   
    DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_SCHEMA_ID,
   33     33   
    ::aws_smithy_schema::ShapeType::Structure,
   34     34   
    &[&DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_MEMBER_STREAM],
   35         -
);
          35  +
)
          36  +
.with_http(aws_smithy_schema::traits::HttpTrait::new(
          37  +
    "POST",
          38  +
    "/DuplexStreamWithDistinctStreams",
          39  +
    None,
          40  +
));
   36     41   
impl DuplexStreamWithDistinctStreamsInput {
   37     42   
    /// The schema for this shape.
   38     43   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_SCHEMA;
   39     44   
}
   40     45   
impl ::aws_smithy_schema::serde::SerializableStruct for DuplexStreamWithDistinctStreamsInput {
   41     46   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   42     47   
    fn serialize_members(
   43     48   
        &self,
   44     49   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   45     50   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   46         -
        {
   47         -
            let val = &self.stream;
   48         -
            ser.write_null(&DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_MEMBER_STREAM)?;
   49         -
        }
   50     51   
        Ok(())
   51     52   
    }
   52     53   
}
   53     54   
impl DuplexStreamWithDistinctStreamsInput {
   54     55   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   55         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   56         -
        deserializer: &mut D,
          56  +
    pub fn deserialize(
          57  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   57     58   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   58     59   
        #[allow(unused_variables, unused_mut)]
   59     60   
        let mut builder = Self::builder();
   60     61   
        #[allow(
   61     62   
            unused_variables,
   62     63   
            unreachable_code,
   63     64   
            clippy::single_match,
   64     65   
            clippy::match_single_binding,
   65     66   
            clippy::diverging_sub_expression
   66     67   
        )]
   67         -
        deserializer.read_struct(&DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_SCHEMA, (), |_, member, deser| {
          68  +
        deserializer.read_struct(&DUPLEXSTREAMWITHDISTINCTSTREAMSINPUT_SCHEMA, &mut |member, deser| {
   68     69   
            match member.member_index() {
   69     70   
                Some(0) => {
   70     71   
                    builder.stream = Some({
   71     72   
                        let _ = member;
   72         -
                        todo!("deserialize aggregate")
          73  +
                        todo!("deserialize streaming union")
   73     74   
                    });
   74     75   
                }
   75     76   
                _ => {}
   76     77   
            }
   77     78   
            Ok(())
   78     79   
        })?;
   79     80   
        builder
   80     81   
            .build()
   81     82   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
   82     83   
    }
   83     84   
}
          85  +
impl DuplexStreamWithDistinctStreamsInput {
          86  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          87  +
    pub fn deserialize_with_response(
          88  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          89  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          90  +
        _status: u16,
          91  +
        _body: &[u8],
          92  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          93  +
        Self::deserialize(deserializer)
          94  +
    }
          95  +
}
   84     96   
impl DuplexStreamWithDistinctStreamsInput {
   85     97   
    /// Creates a new builder-style object to manufacture [`DuplexStreamWithDistinctStreamsInput`](crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput).
   86     98   
    pub fn builder() -> crate::operation::duplex_stream_with_distinct_streams::builders::DuplexStreamWithDistinctStreamsInputBuilder {
   87     99   
        crate::operation::duplex_stream_with_distinct_streams::builders::DuplexStreamWithDistinctStreamsInputBuilder::default()
   88    100   
    }
   89    101   
}
   90    102   
   91    103   
/// A builder for [`DuplexStreamWithDistinctStreamsInput`](crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsInput).
   92    104   
#[derive(::std::default::Default, ::std::fmt::Debug)]
   93    105   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream_with_distinct_streams/_duplex_stream_with_distinct_streams_output.rs

@@ -17,17 +110,125 @@
   37     37   
    /// The schema for this shape.
   38     38   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DUPLEXSTREAMWITHDISTINCTSTREAMSOUTPUT_SCHEMA;
   39     39   
}
   40     40   
impl ::aws_smithy_schema::serde::SerializableStruct for DuplexStreamWithDistinctStreamsOutput {
   41     41   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   42     42   
    fn serialize_members(
   43     43   
        &self,
   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.stream {
   47         -
            ser.write_null(&DUPLEXSTREAMWITHDISTINCTSTREAMSOUTPUT_MEMBER_STREAM)?;
          47  +
            ser.write_struct(&DUPLEXSTREAMWITHDISTINCTSTREAMSOUTPUT_MEMBER_STREAM, val)?;
   48     48   
        }
   49     49   
        Ok(())
   50     50   
    }
   51     51   
}
   52     52   
impl DuplexStreamWithDistinctStreamsOutput {
   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(&DUPLEXSTREAMWITHDISTINCTSTREAMSOUTPUT_SCHEMA, (), |_, member, deser| {
          66  +
        deserializer.read_struct(&DUPLEXSTREAMWITHDISTINCTSTREAMSOUTPUT_SCHEMA, &mut |member, deser| {
   67     67   
            match member.member_index() {
   68     68   
                Some(0) => {
   69         -
                    builder.stream = Some({
   70         -
                        let _ = member;
   71         -
                        todo!("deserialize aggregate")
   72         -
                    });
          69  +
                    builder.stream = Some(crate::types::SingletonEventStream::deserialize(deser)?);
   73     70   
                }
   74     71   
                _ => {}
   75     72   
            }
   76     73   
            Ok(())
   77     74   
        })?;
   78     75   
        Ok(builder.build())
   79     76   
    }
   80     77   
}
          78  +
impl DuplexStreamWithDistinctStreamsOutput {
          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  +
            builder.stream = Some(crate::types::SingletonEventStream::deserialize(deserializer)?);
          92  +
        }
          93  +
        Ok(builder.build())
          94  +
    }
          95  +
}
   81     96   
impl DuplexStreamWithDistinctStreamsOutput {
   82     97   
    /// Creates a new builder-style object to manufacture [`DuplexStreamWithDistinctStreamsOutput`](crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsOutput).
   83     98   
    pub fn builder() -> crate::operation::duplex_stream_with_distinct_streams::builders::DuplexStreamWithDistinctStreamsOutputBuilder {
   84     99   
        crate::operation::duplex_stream_with_distinct_streams::builders::DuplexStreamWithDistinctStreamsOutputBuilder::default()
   85    100   
    }
   86    101   
}
   87    102   
   88    103   
/// A builder for [`DuplexStreamWithDistinctStreamsOutput`](crate::operation::duplex_stream_with_distinct_streams::DuplexStreamWithDistinctStreamsOutput).
   89    104   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   90    105   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream_with_initial_messages.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 `DuplexStreamWithInitialMessages`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct DuplexStreamWithInitialMessages;
    6      6   
impl DuplexStreamWithInitialMessages {
    7      7   
    /// Creates a new `DuplexStreamWithInitialMessages`
    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::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          16  +
        crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesOutput::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::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -125,131 +258,307 @@
  145    151   
  146    152   
        // If this is an error, defer to the non-streaming parser
  147    153   
        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
  148    154   
            return ::std::option::Option::None;
  149    155   
        }
  150    156   
        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
  151    157   
            crate::protocol_serde::shape_duplex_stream_with_initial_messages::de_duplex_stream_with_initial_messages_http_response(response),
  152    158   
        ))
  153    159   
    }
  154    160   
  155         -
    fn deserialize_nonstreaming(
         161  +
    fn deserialize_nonstreaming_with_config(
  156    162   
        &self,
  157    163   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
         164  +
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  158    165   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  159    166   
        // For streaming operations, we only hit this case if its an error
  160    167   
        let body = response.body().bytes().expect("body loaded");
  161         -
        crate::protocol_serde::type_erase_result(
  162         -
            crate::protocol_serde::shape_duplex_stream_with_initial_messages::de_duplex_stream_with_initial_messages_http_error(
  163         -
                response.status().as_u16(),
         168  +
        let status = response.status().as_u16();
         169  +
        let headers = response.headers();
         170  +
        #[allow(unused_mut)]
         171  +
        let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
         172  +
            ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         173  +
        })?;
         174  +
         175  +
        let generic = generic_builder.build();
         176  +
        let error_code = match generic.code() {
         177  +
            ::std::option::Option::Some(code) => code,
         178  +
            ::std::option::Option::None => {
         179  +
                return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         180  +
                    ::aws_smithy_runtime_api::box_error::BoxError::from(
         181  +
                        crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError::unhandled(generic),
         182  +
                    ),
         183  +
                ))
         184  +
            }
         185  +
        };
         186  +
        let _error_message = generic.message().map(|msg| msg.to_owned());
         187  +
        let protocol = _cfg
         188  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         189  +
            .expect("a SharedClientProtocol is required");
         190  +
        let err = match error_code {
         191  +
            "ServiceUnavailableError" => {
         192  +
                crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError::ServiceUnavailableError({
         193  +
                    let mut tmp = match protocol
         194  +
                        .deserialize_response(response, crate::types::error::ServiceUnavailableError::SCHEMA, _cfg)
         195  +
                        .and_then(|mut deser| {
         196  +
                            crate::types::error::ServiceUnavailableError::deserialize_with_response(
         197  +
                                &mut *deser,
  164    198   
                                response.headers(),
         199  +
                                response.status().into(),
  165    200   
                                body,
  166         -
            ),
  167    201   
                            )
         202  +
                        }) {
         203  +
                        ::std::result::Result::Ok(val) => val,
         204  +
                        ::std::result::Result::Err(e) => {
         205  +
                            return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         206  +
                                ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         207  +
                            ))
         208  +
                        }
         209  +
                    };
         210  +
                    tmp.meta = generic;
         211  +
                    if tmp.message.is_none() {
         212  +
                        tmp.message = _error_message;
         213  +
                    }
         214  +
                    tmp
         215  +
                })
         216  +
            }
         217  +
            "ErrorEvent" => crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError::ErrorEvent({
         218  +
                let mut tmp = match protocol
         219  +
                    .deserialize_response(response, crate::types::error::ErrorEvent::SCHEMA, _cfg)
         220  +
                    .and_then(|mut deser| {
         221  +
                        crate::types::error::ErrorEvent::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body)
         222  +
                    }) {
         223  +
                    ::std::result::Result::Ok(val) => val,
         224  +
                    ::std::result::Result::Err(e) => {
         225  +
                        return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
         226  +
                            ::aws_smithy_runtime_api::box_error::BoxError::from(e),
         227  +
                        ))
         228  +
                    }
         229  +
                };
         230  +
                tmp.meta = generic;
         231  +
                if tmp.message.is_none() {
         232  +
                    tmp.message = _error_message;
         233  +
                }
         234  +
                tmp
         235  +
            }),
         236  +
            _ => crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesError::generic(generic),
         237  +
        };
         238  +
        ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         239  +
            ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
         240  +
        ))
  168    241   
    }
  169    242   
}
  170    243   
#[derive(Debug)]
  171    244   
struct DuplexStreamWithInitialMessagesRequestSerializer;
  172    245   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for DuplexStreamWithInitialMessagesRequestSerializer {
  173    246   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  174    247   
    fn serialize_input(
  175    248   
        &self,
  176    249   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  177    250   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  178    251   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  179    252   
        let input = input
  180    253   
            .downcast::<crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput>()
  181    254   
            .expect("correct type");
  182         -
        let _header_serialization_settings = _cfg
  183         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  184         -
            .cloned()
  185         -
            .unwrap_or_default();
  186         -
        let mut request_builder = {
  187         -
            #[allow(clippy::uninlined_format_args)]
  188         -
            fn uri_base(
  189         -
                _input: &crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
  190         -
                output: &mut ::std::string::String,
  191         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  192         -
                use ::std::fmt::Write as _;
  193         -
                ::std::write!(output, "/DuplexStreamWithInitialMessages").expect("formatting should succeed");
  194         -
                ::std::result::Result::Ok(())
  195         -
            }
  196         -
            #[allow(clippy::unnecessary_wraps)]
  197         -
            fn update_http_builder(
  198         -
                input: &crate::operation::duplex_stream_with_initial_messages::DuplexStreamWithInitialMessagesInput,
  199         -
                builder: ::http_1x::request::Builder,
  200         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  201         -
                let mut uri = ::std::string::String::new();
  202         -
                uri_base(input, &mut uri)?;
  203         -
                let builder = crate::protocol_serde::shape_duplex_stream_with_initial_messages::ser_duplex_stream_with_initial_messages_headers(
  204         -
                    input, builder,
  205         -
                )?;
  206         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  207         -
            }
  208         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  209         -
            builder =
  210         -
                _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/vnd.amazon.eventstream");
  211         -
            builder
  212         -
        };
  213         -
        let body = ::aws_smithy_types::body::SdkBody::from({
         255  +
        let protocol = _cfg
         256  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         257  +
            .expect("a SharedClientProtocol is required");
         258  +
        let mut request = protocol
         259  +
            .serialize_request(&input, DuplexStreamWithInitialMessages::INPUT_SCHEMA, "", _cfg)
         260  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         261  +
        *request.body_mut() = ::aws_smithy_types::body::SdkBody::from({
  214    262   
            let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
  215    263   
            let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
  216    264   
            let (signer, signer_sender) = ::aws_smithy_eventstream::frame::DeferredSigner::new();
  217    265   
            _cfg.interceptor_state().store_put(signer_sender);
  218    266   
            ::aws_smithy_types::body::SdkBody::from_body_1_x(::http_body_util::StreamBody::new(input.stream.into_body_stream(
  219    267   
                marshaller,
  220    268   
                error_marshaller,
  221    269   
                signer,
  222    270   
            )))
  223    271   
        });
  224         -
        if let Some(content_length) = body.content_length() {
  225         -
            let content_length = content_length.to_string();
  226         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
  227         -
        }
  228         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         272  +
        // The protocol may have set Content-Length based on the initial empty body.
         273  +
        // Remove it since the event stream body has unknown length.
         274  +
        request.headers_mut().remove("Content-Length");
         275  +
        request.headers_mut().insert("Content-Type", "application/vnd.amazon.eventstream");
         276  +
         277  +
        return ::std::result::Result::Ok(request);
  229    278   
    }
  230    279   
}
  231    280   
#[derive(Debug)]
  232    281   
struct DuplexStreamWithInitialMessagesEndpointParamsInterceptor;
  233    282   
  234    283   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for DuplexStreamWithInitialMessagesEndpointParamsInterceptor {
  235    284   
    fn name(&self) -> &'static str {
  236    285   
        "DuplexStreamWithInitialMessagesEndpointParamsInterceptor"
  237    286   
    }
  238    287   

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream_with_initial_messages/_duplex_stream_with_initial_messages_input.rs

@@ -3,3 +128,170 @@
   23     23   
    "aws.protocoltests.restjson.synthetic",
   24     24   
    "DuplexStreamWithInitialMessagesInput",
   25     25   
);
   26     26   
static DUPLEXSTREAMWITHINITIALMESSAGESINPUT_MEMBER_INITIAL_REQUEST_MEMBER: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   27     27   
    ::aws_smithy_schema::ShapeId::from_static(
   28     28   
        "aws.protocoltests.restjson.synthetic#DuplexStreamWithInitialMessagesInput$initialRequestMember",
   29     29   
        "aws.protocoltests.restjson.synthetic",
   30     30   
        "DuplexStreamWithInitialMessagesInput",
   31     31   
    ),
   32     32   
    ::aws_smithy_schema::ShapeType::String,
   33         -
    "initial_request_member",
          33  +
    "initialRequestMember",
   34     34   
    0,
   35     35   
)
   36     36   
.with_http_header("initial-request-member");
   37     37   
static DUPLEXSTREAMWITHINITIALMESSAGESINPUT_MEMBER_STREAM: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   38     38   
    ::aws_smithy_schema::ShapeId::from_static(
   39     39   
        "aws.protocoltests.restjson.synthetic#DuplexStreamWithInitialMessagesInput$stream",
   40     40   
        "aws.protocoltests.restjson.synthetic",
   41     41   
        "DuplexStreamWithInitialMessagesInput",
   42     42   
    ),
   43     43   
    ::aws_smithy_schema::ShapeType::Union,
   44     44   
    "stream",
   45     45   
    1,
   46     46   
)
   47     47   
.with_http_payload();
   48     48   
static DUPLEXSTREAMWITHINITIALMESSAGESINPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   49     49   
    DUPLEXSTREAMWITHINITIALMESSAGESINPUT_SCHEMA_ID,
   50     50   
    ::aws_smithy_schema::ShapeType::Structure,
   51     51   
    &[
   52     52   
        &DUPLEXSTREAMWITHINITIALMESSAGESINPUT_MEMBER_INITIAL_REQUEST_MEMBER,
   53     53   
        &DUPLEXSTREAMWITHINITIALMESSAGESINPUT_MEMBER_STREAM,
   54     54   
    ],
   55         -
);
          55  +
)
          56  +
.with_http(aws_smithy_schema::traits::HttpTrait::new(
          57  +
    "POST",
          58  +
    "/DuplexStreamWithInitialMessages",
          59  +
    None,
          60  +
));
   56     61   
impl DuplexStreamWithInitialMessagesInput {
   57     62   
    /// The schema for this shape.
   58     63   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DUPLEXSTREAMWITHINITIALMESSAGESINPUT_SCHEMA;
   59     64   
}
   60     65   
impl ::aws_smithy_schema::serde::SerializableStruct for DuplexStreamWithInitialMessagesInput {
   61     66   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   62     67   
    fn serialize_members(
   63     68   
        &self,
   64     69   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   65     70   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   66     71   
        if let Some(ref val) = self.initial_request_member {
   67     72   
            ser.write_string(&DUPLEXSTREAMWITHINITIALMESSAGESINPUT_MEMBER_INITIAL_REQUEST_MEMBER, val)?;
   68     73   
        }
   69         -
        {
   70         -
            let val = &self.stream;
   71         -
            ser.write_null(&DUPLEXSTREAMWITHINITIALMESSAGESINPUT_MEMBER_STREAM)?;
   72         -
        }
   73     74   
        Ok(())
   74     75   
    }
   75     76   
}
   76     77   
impl DuplexStreamWithInitialMessagesInput {
   77     78   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   78         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   79         -
        deserializer: &mut D,
          79  +
    pub fn deserialize(
          80  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   80     81   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   81     82   
        #[allow(unused_variables, unused_mut)]
   82     83   
        let mut builder = Self::builder();
   83     84   
        #[allow(
   84     85   
            unused_variables,
   85     86   
            unreachable_code,
   86     87   
            clippy::single_match,
   87     88   
            clippy::match_single_binding,
   88     89   
            clippy::diverging_sub_expression
   89     90   
        )]
   90         -
        deserializer.read_struct(&DUPLEXSTREAMWITHINITIALMESSAGESINPUT_SCHEMA, (), |_, member, deser| {
          91  +
        deserializer.read_struct(&DUPLEXSTREAMWITHINITIALMESSAGESINPUT_SCHEMA, &mut |member, deser| {
   91     92   
            match member.member_index() {
   92     93   
                Some(0) => {
   93     94   
                    builder.initial_request_member = Some(deser.read_string(member)?);
   94     95   
                }
   95     96   
                Some(1) => {
   96     97   
                    builder.stream = Some({
   97     98   
                        let _ = member;
   98         -
                        todo!("deserialize aggregate")
          99  +
                        todo!("deserialize streaming union")
         100  +
                    });
         101  +
                }
         102  +
                _ => {}
         103  +
            }
         104  +
            Ok(())
         105  +
        })?;
         106  +
        builder.initial_request_member = builder.initial_request_member.or(Some(String::new()));
         107  +
        builder
         108  +
            .build()
         109  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
         110  +
    }
         111  +
}
         112  +
impl DuplexStreamWithInitialMessagesInput {
         113  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         114  +
    /// Header-bound members are read directly from headers, avoiding runtime
         115  +
    /// member iteration overhead. Body members are read via the deserializer.
         116  +
    pub fn deserialize_with_response(
         117  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         118  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         119  +
        _status: u16,
         120  +
        _body: &[u8],
         121  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         122  +
        #[allow(unused_variables, unused_mut)]
         123  +
        let mut builder = Self::builder();
         124  +
        if let Some(val) = headers.get("initial-request-member") {
         125  +
            builder.initial_request_member = Some(val.to_string());
         126  +
        }
         127  +
        #[allow(
         128  +
            unused_variables,
         129  +
            unreachable_code,
         130  +
            clippy::single_match,
         131  +
            clippy::match_single_binding,
         132  +
            clippy::diverging_sub_expression
         133  +
        )]
         134  +
        deserializer.read_struct(&DUPLEXSTREAMWITHINITIALMESSAGESINPUT_SCHEMA, &mut |member, deser| {
         135  +
            match member.member_index() {
         136  +
                Some(0) => { /* read from headers above */ }
         137  +
                Some(1) => {
         138  +
                    builder.stream = Some({
         139  +
                        let _ = member;
         140  +
                        todo!("deserialize streaming union")
   99    141   
                    });
  100    142   
                }
  101    143   
                _ => {}
  102    144   
            }
  103    145   
            Ok(())
  104    146   
        })?;
  105    147   
        builder
  106    148   
            .build()
  107    149   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  108    150   
    }

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/duplex_stream_with_initial_messages/_duplex_stream_with_initial_messages_output.rs

@@ -4,4 +130,167 @@
   24     24   
    "aws.protocoltests.restjson.synthetic",
   25     25   
    "DuplexStreamWithInitialMessagesOutput",
   26     26   
);
   27     27   
static DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_MEMBER_INITIAL_RESPONSE_MEMBER: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   28     28   
    ::aws_smithy_schema::ShapeId::from_static(
   29     29   
        "aws.protocoltests.restjson.synthetic#DuplexStreamWithInitialMessagesOutput$initialResponseMember",
   30     30   
        "aws.protocoltests.restjson.synthetic",
   31     31   
        "DuplexStreamWithInitialMessagesOutput",
   32     32   
    ),
   33     33   
    ::aws_smithy_schema::ShapeType::String,
   34         -
    "initial_response_member",
          34  +
    "initialResponseMember",
   35     35   
    0,
   36     36   
)
   37     37   
.with_http_header("initial-response-member");
   38     38   
static DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_MEMBER_STREAM: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
   39     39   
    ::aws_smithy_schema::ShapeId::from_static(
   40     40   
        "aws.protocoltests.restjson.synthetic#DuplexStreamWithInitialMessagesOutput$stream",
   41     41   
        "aws.protocoltests.restjson.synthetic",
   42     42   
        "DuplexStreamWithInitialMessagesOutput",
   43     43   
    ),
   44     44   
    ::aws_smithy_schema::ShapeType::Union,
   45     45   
    "stream",
   46     46   
    1,
   47     47   
)
   48     48   
.with_http_payload();
   49     49   
static DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
   50     50   
    DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_SCHEMA_ID,
   51     51   
    ::aws_smithy_schema::ShapeType::Structure,
   52     52   
    &[
   53     53   
        &DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_MEMBER_INITIAL_RESPONSE_MEMBER,
   54     54   
        &DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_MEMBER_STREAM,
   55     55   
    ],
   56     56   
);
   57     57   
impl DuplexStreamWithInitialMessagesOutput {
   58     58   
    /// The schema for this shape.
   59     59   
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_SCHEMA;
   60     60   
}
   61     61   
impl ::aws_smithy_schema::serde::SerializableStruct for DuplexStreamWithInitialMessagesOutput {
   62     62   
    #[allow(unused_variables, clippy::diverging_sub_expression)]
   63     63   
    fn serialize_members(
   64     64   
        &self,
   65     65   
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
   66     66   
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
   67     67   
        {
   68     68   
            let val = &self.initial_response_member;
   69     69   
            ser.write_string(&DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_MEMBER_INITIAL_RESPONSE_MEMBER, val)?;
   70     70   
        }
   71         -
        {
   72         -
            let val = &self.stream;
   73         -
            ser.write_null(&DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_MEMBER_STREAM)?;
   74         -
        }
   75     71   
        Ok(())
   76     72   
    }
   77     73   
}
   78     74   
impl DuplexStreamWithInitialMessagesOutput {
   79     75   
    /// Deserializes this structure from a [`ShapeDeserializer`].
   80         -
    pub fn deserialize<D: ::aws_smithy_schema::serde::ShapeDeserializer>(
   81         -
        deserializer: &mut D,
          76  +
    pub fn deserialize(
          77  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
   82     78   
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
   83     79   
        #[allow(unused_variables, unused_mut)]
   84     80   
        let mut builder = Self::builder();
   85     81   
        #[allow(
   86     82   
            unused_variables,
   87     83   
            unreachable_code,
   88     84   
            clippy::single_match,
   89     85   
            clippy::match_single_binding,
   90     86   
            clippy::diverging_sub_expression
   91     87   
        )]
   92         -
        deserializer.read_struct(&DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_SCHEMA, (), |_, member, deser| {
          88  +
        deserializer.read_struct(&DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_SCHEMA, &mut |member, deser| {
   93     89   
            match member.member_index() {
   94     90   
                Some(0) => {
   95     91   
                    builder.initial_response_member = Some(deser.read_string(member)?);
   96     92   
                }
   97     93   
                Some(1) => {
   98     94   
                    builder.stream = Some({
   99     95   
                        let _ = member;
  100         -
                        todo!("deserialize aggregate")
          96  +
                        todo!("deserialize streaming union")
          97  +
                    });
          98  +
                }
          99  +
                _ => {}
         100  +
            }
         101  +
            Ok(())
         102  +
        })?;
         103  +
        builder.initial_response_member = builder.initial_response_member.or(Some(String::new()));
         104  +
        builder
         105  +
            .build()
         106  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
         107  +
    }
         108  +
}
         109  +
impl DuplexStreamWithInitialMessagesOutput {
         110  +
    /// Deserializes this structure from a body deserializer and HTTP response headers.
         111  +
    /// Header-bound members are read directly from headers, avoiding runtime
         112  +
    /// member iteration overhead. Body members are read via the deserializer.
         113  +
    pub fn deserialize_with_response(
         114  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
         115  +
        headers: &::aws_smithy_runtime_api::http::Headers,
         116  +
        _status: u16,
         117  +
        _body: &[u8],
         118  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
         119  +
        #[allow(unused_variables, unused_mut)]
         120  +
        let mut builder = Self::builder();
         121  +
        if let Some(val) = headers.get("initial-response-member") {
         122  +
            builder.initial_response_member = Some(val.to_string());
         123  +
        }
         124  +
        #[allow(
         125  +
            unused_variables,
         126  +
            unreachable_code,
         127  +
            clippy::single_match,
         128  +
            clippy::match_single_binding,
         129  +
            clippy::diverging_sub_expression
         130  +
        )]
         131  +
        deserializer.read_struct(&DUPLEXSTREAMWITHINITIALMESSAGESOUTPUT_SCHEMA, &mut |member, deser| {
         132  +
            match member.member_index() {
         133  +
                Some(0) => { /* read from headers above */ }
         134  +
                Some(1) => {
         135  +
                    builder.stream = Some({
         136  +
                        let _ = member;
         137  +
                        todo!("deserialize streaming union")
  101    138   
                    });
  102    139   
                }
  103    140   
                _ => {}
  104    141   
            }
  105    142   
            Ok(())
  106    143   
        })?;
  107    144   
        builder
  108    145   
            .build()
  109    146   
            .map_err(|e| aws_smithy_schema::serde::SerdeError::Custom { message: e.to_string() })
  110    147   
    }

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/empty_input_and_empty_output.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 `EmptyInputAndEmptyOutput`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct EmptyInputAndEmptyOutput;
    6      6   
impl EmptyInputAndEmptyOutput {
    7      7   
    /// Creates a new `EmptyInputAndEmptyOutput`
    8      8   
    pub fn new() -> Self {
    9      9   
        Self
   10     10   
    }
          11  +
    /// The schema for this operation's input shape.
          12  +
    pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          13  +
        crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema =
          16  +
        crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput::SCHEMA;
   11     17   
    pub(crate) async fn orchestrate(
   12     18   
        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
   13     19   
        input: crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -110,116 +228,241 @@
  130    136   
                crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputError,
  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 EmptyInputAndEmptyOutputResponseDeserializer;
  139    145   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EmptyInputAndEmptyOutputResponseDeserializer {
  140         -
    fn deserialize_nonstreaming(
         146  +
    fn deserialize_nonstreaming_with_config(
  141    147   
        &self,
  142    148   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
         149  +
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  143    150   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  144    151   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
         152  +
        #[allow(unused_mut)]
         153  +
        let mut force_error = false;
         154  +
         155  +
        if !success && status != 200 || force_error {
  145    156   
            let headers = response.headers();
  146    157   
            let body = response.body().bytes().expect("body loaded");
  147    158   
            #[allow(unused_mut)]
  148         -
        let mut force_error = false;
         159  +
            let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
         160  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         161  +
            })?;
  149    162   
  150         -
        let parse_result = if !success && status != 200 || force_error {
  151         -
            crate::protocol_serde::shape_empty_input_and_empty_output::de_empty_input_and_empty_output_http_error(status, headers, body)
         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::empty_input_and_empty_output::EmptyInputAndEmptyOutputError::generic(generic),
         167  +
                ),
         168  +
            ))
  152    169   
        } else {
  153         -
            crate::protocol_serde::shape_empty_input_and_empty_output::de_empty_input_and_empty_output_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, EmptyInputAndEmptyOutput::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::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput::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 EmptyInputAndEmptyOutputRequestSerializer;
  160    194   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EmptyInputAndEmptyOutputRequestSerializer {
  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::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput>()
  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::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput,
  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, "/EmptyInputAndEmptyOutput").expect("formatting should succeed");
  182         -
                ::std::result::Result::Ok(())
  183         -
            }
  184         -
            #[allow(clippy::unnecessary_wraps)]
  185         -
            fn update_http_builder(
  186         -
                input: &crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput,
  187         -
                builder: ::http_1x::request::Builder,
  188         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  189         -
                let mut uri = ::std::string::String::new();
  190         -
                uri_base(input, &mut uri)?;
  191         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  192         -
            }
  193         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  194         -
            builder
  195         -
        };
  196         -
        let body = ::aws_smithy_types::body::SdkBody::from("");
         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, EmptyInputAndEmptyOutput::INPUT_SCHEMA, "", _cfg)
         209  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
  197    210   
  198         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         211  +
        return ::std::result::Result::Ok(request);
  199    212   
    }
  200    213   
}
  201    214   
#[derive(Debug)]
  202    215   
struct EmptyInputAndEmptyOutputEndpointParamsInterceptor;
  203    216   
  204    217   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EmptyInputAndEmptyOutputEndpointParamsInterceptor {
  205    218   
    fn name(&self) -> &'static str {
  206    219   
        "EmptyInputAndEmptyOutputEndpointParamsInterceptor"
  207    220   
    }
  208    221   
@@ -270,283 +369,402 @@
  290    303   
            .expect("the config must have a deserializer");
  291    304   
  292    305   
        let parsed = de.deserialize_streaming(&mut http_response);
  293    306   
        let parsed = parsed.unwrap_or_else(|| {
  294    307   
            let http_response = http_response.map(|body| {
  295    308   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  296    309   
                    body.bytes().unwrap(),
  297    310   
                    ::aws_smithy_protocol_test::MediaType::from("application/json"),
  298    311   
                )))
  299    312   
            });
  300         -
            de.deserialize_nonstreaming(&http_response)
         313  +
            // Build a config bag with the protocol for schema-based deserialization
         314  +
            #[allow(unused_mut)]
         315  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         316  +
            {
         317  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         318  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         319  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         320  +
                ));
         321  +
                test_cfg.push_shared_layer(layer.freeze());
         322  +
            }
         323  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  301    324   
        });
  302    325   
        let parsed = parsed
  303    326   
            .expect("should be successful response")
  304    327   
            .downcast::<crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput>()
  305    328   
            .unwrap();
  306    329   
    }
  307    330   
  308    331   
    /// This test ensures that clients can gracefully handle
  309    332   
    /// situations where a service omits a JSON payload entirely.
  310    333   
    /// Test ID: RestJsonEmptyInputAndEmptyOutputJsonObjectOutput
  311    334   
    #[::tokio::test]
  312    335   
    #[::tracing_test::traced_test]
  313    336   
    async fn rest_json_empty_input_and_empty_output_json_object_output_response() {
  314    337   
        let expected_output = crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput::builder().build();
  315    338   
        let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
  316    339   
            ::http_1x::response::Builder::new()
  317    340   
                .status(200)
  318    341   
                .body(::aws_smithy_types::body::SdkBody::from(""))
  319    342   
                .unwrap(),
  320    343   
        )
  321    344   
        .unwrap();
  322    345   
        use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
  323    346   
        use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
  324    347   
  325    348   
        let op = crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutput::new();
  326    349   
        let config = op.config().expect("the operation has config");
  327    350   
        let de = config
  328    351   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  329    352   
            .expect("the config must have a deserializer");
  330    353   
  331    354   
        let parsed = de.deserialize_streaming(&mut http_response);
  332    355   
        let parsed = parsed.unwrap_or_else(|| {
  333    356   
            let http_response = http_response.map(|body| {
  334    357   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  335    358   
                    body.bytes().unwrap(),
  336    359   
                    ::aws_smithy_protocol_test::MediaType::from("unknown"),
  337    360   
                )))
  338    361   
            });
  339         -
            de.deserialize_nonstreaming(&http_response)
         362  +
            // Build a config bag with the protocol for schema-based deserialization
         363  +
            #[allow(unused_mut)]
         364  +
            let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         365  +
            {
         366  +
                let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         367  +
                layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         368  +
                    ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
         369  +
                ));
         370  +
                test_cfg.push_shared_layer(layer.freeze());
         371  +
            }
         372  +
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
  340    373   
        });
  341    374   
        let parsed = parsed
  342    375   
            .expect("should be successful response")
  343    376   
            .downcast::<crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput>()
  344    377   
            .unwrap();
  345    378   
    }
  346    379   
}
  347    380   
  348    381   
/// Error type for the `EmptyInputAndEmptyOutputError` operation.
  349    382   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/empty_input_and_empty_output/_empty_input_and_empty_output_input.rs

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

tmp-codegen-diff/codegen-client-test/rest_json/rust-client-codegen/src/operation/empty_input_and_empty_output/_empty_input_and_empty_output_output.rs

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