Client Test

Client Test

rev. 97ba95e6039d206ffea5b866ddc214d34f7f88c3 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-client-test/Cargo.lock

@@ -4436,4436 +4498,4498 @@
 4456   4456   
checksum = "0c6f73aeb92d671e0cc4dca167e59b2deb6387c375391bc99ee743f326994a2b"
 4457   4457   
 4458   4458   
[[package]]
 4459   4459   
name = "slab"
 4460   4460   
version = "0.4.12"
 4461   4461   
source = "registry+https://github.com/rust-lang/crates.io-index"
 4462   4462   
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
 4463   4463   
 4464   4464   
[[package]]
 4465   4465   
name = "smallvec"
 4466         -
version = "1.16.0"
        4466  +
version = "1.16.1"
 4467   4467   
source = "registry+https://github.com/rust-lang/crates.io-index"
 4468         -
checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f"
        4468  +
checksum = "ba467056f1b547ed52077911161fc86985becbc60e8e1857c8a144dab0def891"
 4469   4469   
 4470   4470   
[[package]]
 4471   4471   
name = "socket2"
 4472   4472   
version = "0.5.10"
 4473   4473   
source = "registry+https://github.com/rust-lang/crates.io-index"
 4474   4474   
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
 4475   4475   
dependencies = [
 4476   4476   
 "libc",
 4477   4477   
 "windows-sys 0.52.0",
 4478   4478   
]
@@ -4852,4852 +4914,4914 @@
 4872   4872   
 "bytes",
 4873   4873   
 "futures-core",
 4874   4874   
 "futures-sink",
 4875   4875   
 "libc",
 4876   4876   
 "pin-project-lite",
 4877   4877   
 "tokio",
 4878   4878   
]
 4879   4879   
 4880   4880   
[[package]]
 4881   4881   
name = "toml"
 4882         -
version = "1.1.5+spec-1.1.0"
        4882  +
version = "1.1.6+spec-1.1.0"
 4883   4883   
source = "registry+https://github.com/rust-lang/crates.io-index"
 4884         -
checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785"
        4884  +
checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a"
 4885   4885   
dependencies = [
 4886   4886   
 "indexmap 2.14.2",
 4887   4887   
 "serde_core",
 4888   4888   
 "serde_spanned",
 4889   4889   
 "toml_datetime",
 4890   4890   
 "toml_parser",
 4891   4891   
 "toml_writer",
 4892   4892   
 "winnow",
 4893   4893   
]
 4894   4894   

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/Cargo.toml

@@ -1,1 +74,72 @@
    6      6   
description = "test"
    7      7   
edition = "2021"
    8      8   
    9      9   
[package.metadata.smithy]
   10     10   
codegen-version = "ci"
   11     11   
protocol = "aws.protocols#awsJson1_0"
   12     12   
[dependencies.aws-smithy-async]
   13     13   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-async"
   14     14   
[dependencies.aws-smithy-compression]
   15     15   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-compression"
   16         -
[dependencies.aws-smithy-http]
   17         -
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http"
   18     16   
[dependencies.aws-smithy-json]
   19     17   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-json"
   20     18   
[dependencies.aws-smithy-runtime]
   21     19   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime"
   22     20   
features = ["client"]
   23     21   
[dependencies.aws-smithy-runtime-api]
   24     22   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime-api"
   25     23   
features = ["client", "http-1x"]
   26     24   
[dependencies.aws-smithy-schema]
   27     25   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-schema"
   28     26   
[dependencies.aws-smithy-types]
   29     27   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
   30     28   
features = ["http-body-1-x", "http-body-0-4-x"]
   31         -
[dependencies.bytes]
   32         -
version = "1.4.0"
   33     29   
[dependencies.fastrand]
   34     30   
version = "2.0.0"
   35     31   
[dependencies.flate2]
   36     32   
version = "1.0.30"
   37     33   
[dependencies.http]
   38     34   
version = "0.2.9"
   39     35   
[dependencies.http-1x]
   40     36   
version = "1"
   41     37   
package = "http"
   42     38   
[dependencies.http-body-1x]
   43     39   
version = "1"
   44     40   
package = "http-body"
   45     41   
[dependencies.http-body-util]
   46     42   
version = "0.1.3"
   47     43   
[dependencies.tracing]
   48     44   
version = "0.1"
   49     45   
[dev-dependencies.aws-smithy-http-client]
   50     46   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http-client"
   51     47   
features = ["test-util"]
   52     48   
[dev-dependencies.aws-smithy-protocol-test]
   53     49   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-protocol-test"
   54     50   
[dev-dependencies.aws-smithy-types]
   55     51   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
   56     52   
features = ["http-body-1-x"]
          53  +
[dev-dependencies.bytes]
          54  +
version = "1.4.0"
   57     55   
[dev-dependencies.pretty_assertions]
   58     56   
version = "1.3.0"
   59     57   
[dev-dependencies.tokio]
   60     58   
version = "1.23.1"
   61     59   
features = ["macros", "test-util", "rt-multi-thread"]
   62     60   
[dev-dependencies.tracing-test]
   63     61   
version = "0.2.5"
   64     62   
features = ["no-env-filter"]
   65     63   
[features]
   66     64   
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/client.rs

@@ -77,77 +136,177 @@
   97     97   
    fn validate_config(handle: &Handle) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
   98     98   
        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
   99     99   
        handle
  100    100   
            .runtime_plugins
  101    101   
            .apply_client_configuration(&mut cfg)?
  102    102   
            .validate_base_client_config(&cfg)?;
  103    103   
        Ok(())
  104    104   
    }
  105    105   
}
  106    106   
         107  +
impl Client {
         108  +
    /// Returns the type registry for this service.
         109  +
    ///
         110  +
    /// The registry contains an entry for every structure shape in the service
         111  +
    /// closure (excluding only synthetic operation input/output shapes),
         112  +
    /// keyed by [`ShapeId`](::aws_smithy_schema::ShapeId). It is primarily useful for deserializing
         113  +
    /// a [`Document`](::aws_smithy_types::Document) into a typed shape:
         114  +
    ///
         115  +
    /// ```ignore
         116  +
    /// let registry = MyClient::registry();
         117  +
    /// let typed = registry.deserialize_document(&doc)?;
         118  +
    /// // Downcast to the concrete type you expected.
         119  +
    /// ```
         120  +
    pub fn registry() -> &'static ::aws_smithy_schema::registry::TypeRegistry {
         121  +
        &crate::type_registry::REGISTRY
         122  +
    }
         123  +
}
         124  +
         125  +
impl Client {
         126  +
    /// Returns the service-wide error registry.
         127  +
    ///
         128  +
    /// The registry contains an entry for every `@error`-trait structure shape
         129  +
    /// in the service closure, keyed by [`ShapeId`](::aws_smithy_schema::ShapeId). Use it to reify a
         130  +
    /// discriminated [`Document`](::aws_smithy_types::Document) into a typed error variant via
         131  +
    /// [`TypeRegistry::deserialize_document`](::aws_smithy_schema::registry::TypeRegistry::deserialize_document).
         132  +
    ///
         133  +
    /// This registry is provided for third-party `Document`-based error handling.
         134  +
    /// Internally it also serves as the widening fallback when the schema-serde
         135  +
    /// error path reifies an error code that an operation does not model directly
         136  +
    /// (the operation's own error registry is consulted first).
         137  +
    ///
         138  +
    /// ```ignore
         139  +
    /// let registry = MyClient::error_registry();
         140  +
    /// let typed = registry.deserialize_document(&doc)?;
         141  +
    /// // Downcast to the concrete error variant you expected.
         142  +
    /// ```
         143  +
    pub fn error_registry() -> &'static ::aws_smithy_schema::registry::TypeRegistry {
         144  +
        &crate::error_type_registry::REGISTRY
         145  +
    }
         146  +
}
         147  +
  107    148   
mod content_type_parameters;
  108    149   
  109    150   
/// Operation customization and supporting types.
  110    151   
///
  111    152   
/// The underlying HTTP requests made during an operation can be customized
  112    153   
/// by calling the `customize()` method on the builder returned from a client
  113    154   
/// operation call. For example, this can be used to add an additional HTTP header:
  114    155   
///
  115    156   
/// ```ignore
  116    157   
/// # async fn wrapper() -> ::std::result::Result<(), json_rpc10::Error> {

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/config.rs

@@ -10,10 +69,73 @@
   30     30   
            config: self.cloneable.clone(),
   31     31   
            runtime_components: self.runtime_components.clone(),
   32     32   
            runtime_plugins: self.runtime_plugins.clone(),
   33     33   
            behavior_version: self.behavior_version,
   34     34   
        }
   35     35   
    }
   36     36   
    /// Return a reference to the stalled stream protection configuration contained in this config, if any.
   37     37   
    pub fn stalled_stream_protection(&self) -> ::std::option::Option<&crate::config::StalledStreamProtectionConfig> {
   38     38   
        self.config.load::<crate::config::StalledStreamProtectionConfig>()
   39     39   
    }
          40  +
    /// Returns the client protocol used for serialization and deserialization.
          41  +
    pub fn protocol(&self) -> ::std::option::Option<&::aws_smithy_schema::protocol::SharedClientProtocol> {
          42  +
        self.config.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
          43  +
    }
   40     44   
    /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
   41     45   
    pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
   42     46   
        self.runtime_components.http_client()
   43     47   
    }
   44     48   
    /// Return the auth schemes configured on this service config
   45     49   
    pub fn auth_schemes(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::auth::SharedAuthScheme> + '_ {
   46     50   
        self.runtime_components.auth_schemes()
   47     51   
    }
   48     52   
   49     53   
    /// Return the auth scheme resolver configured on this service config
@@ -105,109 +164,171 @@
  125    129   
    ///
  126    130   
    pub fn new() -> Self {
  127    131   
        Self::default()
  128    132   
    }
  129    133   
    /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
  130    134   
    /// but not those in runtime components.
  131    135   
    #[allow(unused)]
  132    136   
    pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
  133    137   
        let mut builder = Self::new();
  134    138   
        builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
         139  +
        if let ::std::option::Option::Some(protocol) = config_bag.load::<::aws_smithy_schema::protocol::SharedClientProtocol>().cloned() {
         140  +
            builder.set_protocol(::std::option::Option::Some(protocol));
         141  +
        }
  135    142   
        builder.set_auth_scheme_preference(config_bag.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>().cloned());
  136    143   
        builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
  137    144   
        builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
  138    145   
        builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
  139    146   
        builder
  140    147   
    }
  141    148   
    /// Names operation-input members whose values are captured *and* emitted as
  142    149   
    /// attributes on the client's built-in metrics (e.g. `["Bucket"]`).
  143    150   
    ///
  144    151   
    /// Emitting implies capture, so an emitted member is also readable in-process
@@ -169,176 +228,261 @@
  189    196   
    }
  190    197   
    /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
  191    198   
    /// to configure protection for stalled streams.
  192    199   
    pub fn set_stalled_stream_protection(
  193    200   
        &mut self,
  194    201   
        stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
  195    202   
    ) -> &mut Self {
  196    203   
        self.config.store_or_unset(stalled_stream_protection_config);
  197    204   
        self
  198    205   
    }
         206  +
    /// Sets the client protocol to use for serialization and deserialization.
         207  +
    ///
         208  +
    /// This overrides the default protocol determined by the service model,
         209  +
    /// enabling runtime protocol selection.
         210  +
    ///
         211  +
    /// # Transport
         212  +
    ///
         213  +
    /// This setter is HTTP-specific. The config bag stores
         214  +
    /// `SharedClientProtocol` (which elides to its HTTP specialization) and
         215  +
    /// only `SharedClientProtocol<http::Request, http::Response>` has a
         216  +
    /// `Storable` impl. The `impl ClientProtocol + 'static` bound here elides
         217  +
    /// to `impl ClientProtocol<http::Request, http::Response>` to match —
         218  +
    /// a `ClientProtocol<Other, Other>` impl wouldn't round-trip through
         219  +
    /// config-bag storage even though the trait itself is transport-generic.
         220  +
    pub fn protocol(mut self, protocol: impl ::aws_smithy_schema::protocol::ClientProtocol + 'static) -> Self {
         221  +
        self.set_protocol(::std::option::Option::Some(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         222  +
            protocol,
         223  +
        )));
         224  +
        self
         225  +
    }
         226  +
         227  +
    /// Sets the client protocol to use for serialization and deserialization.
         228  +
    pub fn set_protocol(&mut self, protocol: ::std::option::Option<::aws_smithy_schema::protocol::SharedClientProtocol>) -> &mut Self {
         229  +
        self.config.store_or_unset(protocol);
         230  +
        self
         231  +
    }
  199    232   
    /// Sets the HTTP client to use when making requests.
  200    233   
    ///
  201    234   
    /// # Examples
  202    235   
    /// ```no_run
  203    236   
    /// # #[cfg(test)]
  204    237   
    /// # mod tests {
  205    238   
    /// # #[test]
  206    239   
    /// # fn example() {
  207    240   
    /// use std::time::Duration;
  208    241   
    /// use json_rpc10::config::Config;
@@ -1183,1216 +1242,1283 @@
 1203   1236   
#[derive(::std::fmt::Debug)]
 1204   1237   
pub(crate) struct ServiceRuntimePlugin {
 1205   1238   
    config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
 1206   1239   
    runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
 1207   1240   
}
 1208   1241   
 1209   1242   
impl ServiceRuntimePlugin {
 1210   1243   
    pub fn new(_service_config: crate::config::Config) -> Self {
 1211   1244   
        let config = {
 1212   1245   
            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("JsonRpc10");
        1246  +
            cfg.store_put(::aws_smithy_schema::protocol::ServiceShapeName::new("JsonRpc10"));
        1247  +
            cfg.store_put(::aws_smithy_schema::protocol::ServiceShapeNamespace::new("aws.protocoltests.json10"));
        1248  +
            cfg.store_put(::aws_smithy_schema::protocol::ServiceVersion::new("2020-07-14"));
        1249  +
            if _service_config.protocol().is_none() {
        1250  +
                cfg.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
        1251  +
                    ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_0().with_default_namespace("aws.protocoltests.json10"),
        1252  +
                ));
        1253  +
            }
 1213   1254   
            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
 1214   1255   
            ::std::option::Option::Some(cfg.freeze())
 1215   1256   
        };
 1216   1257   
        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
 1217   1258   
        runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
 1218   1259   
            use crate::config::auth::ResolveAuthScheme;
 1219   1260   
            crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
 1220   1261   
        }));
 1221   1262   
        runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
 1222   1263   
            ::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new(),

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/error_type_registry.rs

@@ -0,1 +0,32 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) static REGISTRY: ::std::sync::LazyLock<::aws_smithy_schema::registry::TypeRegistry> = ::std::sync::LazyLock::new(|| {
           3  +
    ::aws_smithy_schema::registry::TypeRegistry::builder()
           4  +
                        .insert_error_shape(
           5  +
                        crate::types::error::ComplexError::SCHEMA,
           6  +
                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
           7  +
                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::ComplexError::deserialize(d)?))
           8  +
                        },
           9  +
                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
          10  +
                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::ComplexError::deserialize(d)?))
          11  +
                        },
          12  +
                    )
          13  +
.insert_error_shape(
          14  +
                        crate::types::error::FooError::SCHEMA,
          15  +
                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
          16  +
                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::FooError::deserialize(d)?))
          17  +
                        },
          18  +
                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
          19  +
                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::FooError::deserialize(d)?))
          20  +
                        },
          21  +
                    )
          22  +
.insert_error_shape(
          23  +
                        crate::types::error::InvalidGreeting::SCHEMA,
          24  +
                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::aws_smithy_types::type_erasure::TypeErasedBox, ::aws_smithy_schema::serde::SerdeError> {
          25  +
                            ::std::result::Result::Ok(::aws_smithy_types::type_erasure::TypeErasedBox::new(crate::types::error::InvalidGreeting::deserialize(d)?))
          26  +
                        },
          27  +
                        |d: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer| -> ::std::result::Result<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync>, ::aws_smithy_schema::serde::SerdeError> {
          28  +
                            ::std::result::Result::Ok(::std::boxed::Box::new(crate::types::error::InvalidGreeting::deserialize(d)?))
          29  +
                        },
          30  +
                    )
          31  +
                        .build()
          32  +
});

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/json_errors.rs

@@ -1,0 +180,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
/*
    3         -
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
    4         -
 * SPDX-License-Identifier: Apache-2.0
    5         -
 */
    6         -
    7         -
use aws_smithy_json::deserialize::token::skip_value;
    8         -
use aws_smithy_json::deserialize::{error::DeserializeError, json_token_iter, Token};
    9         -
use aws_smithy_runtime_api::http::Headers;
   10         -
use aws_smithy_types::error::metadata::{Builder as ErrorMetadataBuilder, ErrorMetadata};
   11         -
use std::borrow::Cow;
   12         -
   13         -
// currently only used by AwsJson
   14         -
#[allow(unused)]
   15         -
pub fn is_error<B>(response: &http_1x::Response<B>) -> bool {
   16         -
    !response.status().is_success()
   17         -
}
   18         -
   19         -
fn sanitize_error_code(error_code: &str) -> &str {
   20         -
    // Trim a trailing URL from the error code, which is done by removing the longest suffix
   21         -
    // beginning with a `:`
   22         -
    let error_code = match error_code.find(':') {
   23         -
        Some(idx) => &error_code[..idx],
   24         -
        None => error_code,
   25         -
    };
   26         -
   27         -
    // Trim a prefixing namespace from the error code, beginning with a `#`
   28         -
    match error_code.find('#') {
   29         -
        Some(idx) => &error_code[idx + 1..],
   30         -
        None => error_code,
   31         -
    }
   32         -
}
   33         -
   34         -
struct ErrorBody<'a> {
   35         -
    code: Option<Cow<'a, str>>,
   36         -
    message: Option<Cow<'a, str>>,
   37         -
}
   38         -
   39         -
fn parse_error_body(bytes: &[u8]) -> Result<ErrorBody<'_>, DeserializeError> {
   40         -
    let mut tokens = json_token_iter(bytes).peekable();
   41         -
    let (mut typ, mut code, mut message) = (None, None, None);
   42         -
    if let Some(Token::StartObject { .. }) = tokens.next().transpose()? {
   43         -
        loop {
   44         -
            match tokens.next().transpose()? {
   45         -
                Some(Token::EndObject { .. }) => break,
   46         -
                Some(Token::ObjectKey { key, .. }) => {
   47         -
                    if let Some(Ok(Token::ValueString { value, .. })) = tokens.peek() {
   48         -
                        match key.as_escaped_str() {
   49         -
                            "code" => code = Some(value.to_unescaped()?),
   50         -
                            "__type" => typ = Some(value.to_unescaped()?),
   51         -
                            "message" | "Message" | "errorMessage" => message = Some(value.to_unescaped()?),
   52         -
                            _ => {}
   53         -
                        }
   54         -
                    }
   55         -
                    skip_value(&mut tokens)?;
   56         -
                }
   57         -
                _ => return Err(DeserializeError::custom("expected object key or end object")),
   58         -
            }
   59         -
        }
   60         -
        if tokens.next().is_some() {
   61         -
            return Err(DeserializeError::custom("found more JSON tokens after completing parsing"));
   62         -
        }
   63         -
    }
   64         -
    Ok(ErrorBody { code: code.or(typ), message })
   65         -
}
   66         -
   67         -
pub fn parse_error_metadata(payload: &[u8], headers: &Headers) -> Result<ErrorMetadataBuilder, DeserializeError> {
   68         -
    let ErrorBody { code, message } = parse_error_body(payload)?;
   69         -
   70         -
    let mut err_builder = ErrorMetadata::builder();
   71         -
    if let Some(code) = headers.get("x-amzn-errortype").or(code.as_deref()).map(sanitize_error_code) {
   72         -
        err_builder = err_builder.code(code);
   73         -
    }
   74         -
    if let Some(message) = message {
   75         -
        err_builder = err_builder.message(message);
   76         -
    }
   77         -
    Ok(err_builder)
   78         -
}
   79         -
   80         -
#[cfg(test)]
   81         -
mod test {
   82         -
    use crate::json_errors::{parse_error_body, parse_error_metadata, sanitize_error_code};
   83         -
    use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
   84         -
    use aws_smithy_types::{body::SdkBody, error::ErrorMetadata};
   85         -
    use std::borrow::Cow;
   86         -
   87         -
    #[test]
   88         -
    fn error_metadata() {
   89         -
        let response = HttpResponse::try_from(
   90         -
            http_1x::Response::builder()
   91         -
                .body(SdkBody::from(r#"{ "__type": "FooError", "message": "Go to foo" }"#))
   92         -
                .unwrap(),
   93         -
        )
   94         -
        .unwrap();
   95         -
        assert_eq!(
   96         -
            parse_error_metadata(response.body().bytes().unwrap(), response.headers())
   97         -
                .unwrap()
   98         -
                .build(),
   99         -
            ErrorMetadata::builder().code("FooError").message("Go to foo").build()
  100         -
        )
  101         -
    }
  102         -
  103         -
    #[test]
  104         -
    fn error_type() {
  105         -
        assert_eq!(
  106         -
            Some(Cow::Borrowed("FooError")),
  107         -
            parse_error_body(br#"{ "__type": "FooError" }"#).unwrap().code
  108         -
        );
  109         -
    }
  110         -
  111         -
    #[test]
  112         -
    fn code_takes_priority() {
  113         -
        assert_eq!(
  114         -
            Some(Cow::Borrowed("BarError")),
  115         -
            parse_error_body(br#"{ "code": "BarError", "__type": "FooError" }"#).unwrap().code
  116         -
        );
  117         -
    }
  118         -
  119         -
    #[test]
  120         -
    fn ignore_unrecognized_fields() {
  121         -
        assert_eq!(
  122         -
            Some(Cow::Borrowed("FooError")),
  123         -
            parse_error_body(br#"{ "__type": "FooError", "asdf": 5, "fdsa": {}, "foo": "1" }"#)
  124         -
                .unwrap()
  125         -
                .code
  126         -
        );
  127         -
    }
  128         -
  129         -
    #[test]
  130         -
    fn sanitize_namespace_and_url() {
  131         -
        assert_eq!(
  132         -
            sanitize_error_code("aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/"),
  133         -
            "FooError"
  134         -
        );
  135         -
    }
  136         -
  137         -
    #[test]
  138         -
    fn sanitize_noop() {
  139         -
        assert_eq!(sanitize_error_code("FooError"), "FooError");
  140         -
    }
  141         -
  142         -
    #[test]
  143         -
    fn sanitize_url() {
  144         -
        assert_eq!(
  145         -
            sanitize_error_code("FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/"),
  146         -
            "FooError"
  147         -
        );
  148         -
    }
  149         -
  150         -
    #[test]
  151         -
    fn sanitize_namespace() {
  152         -
        assert_eq!(sanitize_error_code("aws.protocoltests.restjson#FooError"), "FooError");
  153         -
    }
  154         -
  155         -
    // services like lambda use an alternate `Message` instead of `message`
  156         -
    #[test]
  157         -
    fn alternative_error_message_names() {
  158         -
        let response = HttpResponse::try_from(
  159         -
            http_1x::Response::builder()
  160         -
                .header("x-amzn-errortype", "ResourceNotFoundException")
  161         -
                .body(SdkBody::from(
  162         -
                    r#"{
  163         -
                    "Type": "User",
  164         -
                    "Message": "Functions from 'us-west-2' are not reachable from us-east-1"
  165         -
                }"#,
  166         -
                ))
  167         -
                .unwrap(),
  168         -
        )
  169         -
        .unwrap();
  170         -
        assert_eq!(
  171         -
            parse_error_metadata(response.body().bytes().unwrap(), response.headers())
  172         -
                .unwrap()
  173         -
                .build(),
  174         -
            ErrorMetadata::builder()
  175         -
                .code("ResourceNotFoundException")
  176         -
                .message("Functions from 'us-west-2' are not reachable from us-east-1")
  177         -
                .build()
  178         -
        );
  179         -
    }
  180         -
}

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/lib.rs

@@ -81,81 +135,131 @@
  101    101   
pub mod client;
  102    102   
  103    103   
/// Configuration for Sample Json 1.0 Protocol Service.
  104    104   
pub mod config;
  105    105   
  106    106   
/// Common errors and error handling utilities.
  107    107   
pub mod error;
  108    108   
  109    109   
mod error_meta;
  110    110   
         111  +
mod error_type_registry;
         112  +
  111    113   
/// Information about this crate.
  112    114   
pub mod meta;
  113    115   
  114    116   
/// Primitives such as `Blob` or `DateTime` used by other types.
  115    117   
pub mod primitives;
  116    118   
         119  +
mod type_registry;
         120  +
  117    121   
/// Data structures used by operation inputs/outputs.
  118    122   
pub mod types;
  119    123   
  120    124   
mod client_request_compression;
  121    125   
  122    126   
/// All operations that this crate can perform.
  123    127   
pub mod operation;
  124    128   
  125         -
pub(crate) mod protocol_serde;
  126         -
  127    129   
mod sdk_feature_tracker;
  128    130   
  129         -
mod serialization_settings;
  130         -
  131         -
mod serde_util;
  132         -
  133         -
mod json_errors;
  134         -
  135    131   
pub use client::Client;

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/operation/content_type_parameters.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 `ContentTypeParameters`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct ContentTypeParameters;
    6      6   
impl ContentTypeParameters {
    7      7   
    /// Creates a new `ContentTypeParameters`
    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<'static> =
          13  +
        crate::operation::content_type_parameters::ContentTypeParametersInput::SCHEMA;
          14  +
    /// The schema for this operation's output shape.
          15  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> =
          16  +
        crate::operation::content_type_parameters::ContentTypeParametersOutput::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::content_type_parameters::ContentTypeParametersInput,
   14     20   
    ) -> ::std::result::Result<
   15     21   
        crate::operation::content_type_parameters::ContentTypeParametersOutput,
   16     22   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     23   
            crate::operation::content_type_parameters::ContentTypeParametersError,
   18     24   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     25   
        >,
   20     26   
    > {
@@ -114,120 +238,252 @@
  134    140   
  135    141   
#[derive(Debug)]
  136    142   
struct ContentTypeParametersResponseDeserializer;
  137    143   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for ContentTypeParametersResponseDeserializer {
  138    144   
    fn deserialize_nonstreaming_with_config(
  139    145   
        &self,
  140    146   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
  141    147   
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  142    148   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  143    149   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
  144         -
        let headers = response.headers();
         150  +
        // Load body and headers BEFORE BeforeParseResponse so customizations
         151  +
        // (e.g., S3's `body_is_error` check that detects errors returned with
         152  +
        // HTTP 200) can inspect them. The legacy non-streaming path also
         153  +
        // loads `body` before firing this hook.
  145    154   
        let body = response.body().bytes().expect("body loaded");
         155  +
        let headers = response.headers();
  146    156   
        #[allow(unused_mut)]
  147    157   
        let mut force_error = false;
  148    158   
  149         -
        let parse_result = if !success && status != 200 || force_error {
  150         -
            crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters_http_error(status, headers, body)
         159  +
        if !success && status != 200 || force_error {
         160  +
            let protocol = _cfg
         161  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         162  +
                .expect("a SharedClientProtocol is required");
         163  +
            #[allow(unused_mut)]
         164  +
            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
         165  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         166  +
            })?;
         167  +
         168  +
            let generic = generic_builder.build();
         169  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         170  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         171  +
                    crate::operation::content_type_parameters::ContentTypeParametersError::generic(generic),
         172  +
                ),
         173  +
            ))
  151    174   
        } else {
  152         -
            crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters_http_response(status, headers, body)
  153         -
        };
  154         -
        crate::protocol_serde::type_erase_result(parse_result)
         175  +
            let protocol = _cfg
         176  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         177  +
                .expect("a SharedClientProtocol is required");
         178  +
            let mut deser = protocol
         179  +
                .deserialize_response(response, ContentTypeParameters::OUTPUT_SCHEMA, _cfg)
         180  +
                .map_err(|e| {
         181  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         182  +
                })?;
         183  +
            // body and headers are already in scope from the top of the function;
         184  +
            // alias `headers` as `_response_headers` so MutateOutput
         185  +
            // customizations have a stable name to read from.
         186  +
            let _response_headers = headers;
         187  +
            #[allow(unused_mut)]
         188  +
            let mut output = crate::operation::content_type_parameters::ContentTypeParametersOutput::deserialize_with_response(
         189  +
                &mut *deser,
         190  +
                _response_headers,
         191  +
                response.status().into(),
         192  +
                body,
         193  +
            )
         194  +
            .map_err(|e| {
         195  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         196  +
            })?;
         197  +
         198  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         199  +
        }
  155    200   
    }
  156    201   
}
  157    202   
#[derive(Debug)]
  158    203   
struct ContentTypeParametersRequestSerializer;
  159    204   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for ContentTypeParametersRequestSerializer {
  160    205   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  161    206   
    fn serialize_input(
  162    207   
        &self,
  163    208   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  164    209   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  165    210   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  166    211   
        let input = input
  167    212   
            .downcast::<crate::operation::content_type_parameters::ContentTypeParametersInput>()
  168    213   
            .expect("correct type");
  169         -
        let _header_serialization_settings = _cfg
  170         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  171         -
            .cloned()
  172         -
            .unwrap_or_default();
  173         -
        let mut request_builder = {
  174         -
            #[allow(clippy::uninlined_format_args)]
  175         -
            fn uri_base(
  176         -
                _input: &crate::operation::content_type_parameters::ContentTypeParametersInput,
  177         -
                output: &mut ::std::string::String,
  178         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  179         -
                use ::std::fmt::Write as _;
  180         -
                ::std::write!(output, "/").expect("formatting should succeed");
  181         -
                ::std::result::Result::Ok(())
  182         -
            }
  183         -
            #[allow(clippy::unnecessary_wraps)]
  184         -
            fn update_http_builder(
  185         -
                input: &crate::operation::content_type_parameters::ContentTypeParametersInput,
  186         -
                builder: ::http_1x::request::Builder,
  187         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  188         -
                let mut uri = ::std::string::String::new();
  189         -
                uri_base(input, &mut uri)?;
  190         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  191         -
            }
  192         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  193         -
            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.0");
  194         -
            builder = _header_serialization_settings.set_default_header(
  195         -
                builder,
  196         -
                ::http_1x::header::HeaderName::from_static("x-amz-target"),
  197         -
                "JsonRpc10.ContentTypeParameters",
  198         -
            );
  199         -
            builder
  200         -
        };
  201         -
        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_content_type_parameters::ser_content_type_parameters_input(
  202         -
            &input,
  203         -
        )?);
  204         -
        if let Some(content_length) = body.content_length() {
  205         -
            let content_length = content_length.to_string();
  206         -
            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
  207         -
        }
  208         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         214  +
         215  +
        let protocol = _cfg
         216  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         217  +
            .expect("a SharedClientProtocol is required");
         218  +
        let mut request = protocol
         219  +
            .serialize_request(&input, ContentTypeParameters::INPUT_SCHEMA, "/", _cfg)
         220  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         221  +
         222  +
        return ::std::result::Result::Ok(request);
  209    223   
    }
  210    224   
}
  211    225   
#[derive(Debug)]
  212    226   
struct ContentTypeParametersEndpointParamsInterceptor;
  213    227   
  214    228   
#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
  215    229   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for ContentTypeParametersEndpointParamsInterceptor {
  216    230   
    fn name(&self) -> &'static str {
  217    231   
        "ContentTypeParametersEndpointParamsInterceptor"
  218    232   
    }

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/operation/content_type_parameters/_content_type_parameters_input.rs

@@ -1,1 +44,122 @@
    5      5   
pub struct ContentTypeParametersInput {
    6      6   
    #[allow(missing_docs)] // documentation missing in model
    7      7   
    pub value: ::std::option::Option<i32>,
    8      8   
}
    9      9   
impl ContentTypeParametersInput {
   10     10   
    #[allow(missing_docs)] // documentation missing in model
   11     11   
    pub fn value(&self) -> ::std::option::Option<i32> {
   12     12   
        self.value
   13     13   
    }
   14     14   
}
          15  +
static CONTENTTYPEPARAMETERSINPUT_MEMBER_VALUE: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
          16  +
    ::aws_smithy_schema::ShapeId::from_parts(
          17  +
        "aws.protocoltests.json10.synthetic#ContentTypeParametersInput$value",
          18  +
        "aws.protocoltests.json10.synthetic",
          19  +
        "ContentTypeParametersInput",
          20  +
    ),
          21  +
    ::aws_smithy_schema::ShapeType::Integer,
          22  +
    "value",
          23  +
    0,
          24  +
);
          25  +
static CONTENTTYPEPARAMETERSINPUT_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
          26  +
    ::aws_smithy_schema::ShapeId::from_parts(
          27  +
        "aws.protocoltests.json10.synthetic#ContentTypeParametersInput",
          28  +
        "aws.protocoltests.json10.synthetic",
          29  +
        "ContentTypeParametersInput",
          30  +
    ),
          31  +
    ::aws_smithy_schema::ShapeType::Structure,
          32  +
    &[&CONTENTTYPEPARAMETERSINPUT_MEMBER_VALUE],
          33  +
)
          34  +
.with_payload_hint(::aws_smithy_schema::PayloadHint::NoStructPayload)
          35  +
.with_original_name("ContentTypeParametersInput");
          36  +
impl ContentTypeParametersInput {
          37  +
    /// The schema for this shape.
          38  +
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &CONTENTTYPEPARAMETERSINPUT_SCHEMA;
          39  +
}
          40  +
impl ::aws_smithy_schema::serde::SerializableStruct for ContentTypeParametersInput {
          41  +
    #[allow(unused_variables, clippy::diverging_sub_expression)]
          42  +
    fn serialize_members(
          43  +
        &self,
          44  +
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
          45  +
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
          46  +
        if let Some(ref val) = self.value {
          47  +
            ser.write_integer(&CONTENTTYPEPARAMETERSINPUT_MEMBER_VALUE, *val)?;
          48  +
        }
          49  +
        Ok(())
          50  +
    }
          51  +
}
          52  +
impl ContentTypeParametersInput {
          53  +
    /// Deserializes this structure from a [`ShapeDeserializer`].
          54  +
    pub fn deserialize(
          55  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          56  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          57  +
        #[allow(unused_variables, unused_mut)]
          58  +
        let mut builder = Self::builder();
          59  +
        #[allow(
          60  +
            unused_variables,
          61  +
            unreachable_code,
          62  +
            clippy::single_match,
          63  +
            clippy::match_single_binding,
          64  +
            clippy::diverging_sub_expression
          65  +
        )]
          66  +
        deserializer.read_struct(&CONTENTTYPEPARAMETERSINPUT_SCHEMA, &mut |member, deser| {
          67  +
            match member.member_index() {
          68  +
                Some(0) => {
          69  +
                    if deser.is_null() {
          70  +
                        deser.read_null()?;
          71  +
                    } else {
          72  +
                        builder.value = Some(deser.read_integer(member)?);
          73  +
                    }
          74  +
                }
          75  +
                _ => {}
          76  +
            }
          77  +
            Ok(())
          78  +
        })?;
          79  +
        builder.build().map_err(|e| aws_smithy_schema::serde::SerdeError::custom(e.to_string()))
          80  +
    }
          81  +
}
          82  +
impl ContentTypeParametersInput {
          83  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          84  +
    pub fn deserialize_with_response(
          85  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          86  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          87  +
        _status: u16,
          88  +
        _body: &[u8],
          89  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          90  +
        Self::deserialize(deserializer)
          91  +
    }
          92  +
}
   15     93   
impl ContentTypeParametersInput {
   16     94   
    /// Creates a new builder-style object to manufacture [`ContentTypeParametersInput`](crate::operation::content_type_parameters::ContentTypeParametersInput).
   17     95   
    pub fn builder() -> crate::operation::content_type_parameters::builders::ContentTypeParametersInputBuilder {
   18     96   
        crate::operation::content_type_parameters::builders::ContentTypeParametersInputBuilder::default()
   19     97   
    }
   20     98   
}
   21     99   
   22    100   
/// A builder for [`ContentTypeParametersInput`](crate::operation::content_type_parameters::ContentTypeParametersInput).
   23    101   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   24    102   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/operation/content_type_parameters/_content_type_parameters_output.rs

@@ -1,1 +22,79 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    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 ContentTypeParametersOutput {}
           6  +
static CONTENTTYPEPARAMETERSOUTPUT_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
           7  +
    ::aws_smithy_schema::ShapeId::from_parts(
           8  +
        "aws.protocoltests.json10.synthetic#ContentTypeParametersOutput",
           9  +
        "aws.protocoltests.json10.synthetic",
          10  +
        "ContentTypeParametersOutput",
          11  +
    ),
          12  +
    ::aws_smithy_schema::ShapeType::Structure,
          13  +
    &[],
          14  +
)
          15  +
.with_original_name("ContentTypeParametersOutput");
          16  +
impl ContentTypeParametersOutput {
          17  +
    /// The schema for this shape.
          18  +
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &CONTENTTYPEPARAMETERSOUTPUT_SCHEMA;
          19  +
}
          20  +
impl ::aws_smithy_schema::serde::SerializableStruct for ContentTypeParametersOutput {
          21  +
    #[allow(unused_variables, clippy::diverging_sub_expression)]
          22  +
    fn serialize_members(
          23  +
        &self,
          24  +
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
          25  +
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
          26  +
        Ok(())
          27  +
    }
          28  +
}
          29  +
impl ContentTypeParametersOutput {
          30  +
    /// Deserializes this structure from a [`ShapeDeserializer`].
          31  +
    pub fn deserialize(
          32  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          33  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          34  +
        #[allow(unused_variables, unused_mut)]
          35  +
        let mut builder = Self::builder();
          36  +
        #[allow(
          37  +
            unused_variables,
          38  +
            unreachable_code,
          39  +
            clippy::single_match,
          40  +
            clippy::match_single_binding,
          41  +
            clippy::diverging_sub_expression
          42  +
        )]
          43  +
        deserializer.read_struct(&CONTENTTYPEPARAMETERSOUTPUT_SCHEMA, &mut |member, deser| {
          44  +
            match member.member_index() {
          45  +
                _ => {}
          46  +
            }
          47  +
            Ok(())
          48  +
        })?;
          49  +
        Ok(builder.build())
          50  +
    }
          51  +
}
          52  +
impl ContentTypeParametersOutput {
          53  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          54  +
    pub fn deserialize_with_response(
          55  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          56  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          57  +
        _status: u16,
          58  +
        _body: &[u8],
          59  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          60  +
        Ok(Self::builder().build())
          61  +
    }
          62  +
}
    6     63   
impl ContentTypeParametersOutput {
    7     64   
    /// Creates a new builder-style object to manufacture [`ContentTypeParametersOutput`](crate::operation::content_type_parameters::ContentTypeParametersOutput).
    8     65   
    pub fn builder() -> crate::operation::content_type_parameters::builders::ContentTypeParametersOutputBuilder {
    9     66   
        crate::operation::content_type_parameters::builders::ContentTypeParametersOutputBuilder::default()
   10     67   
    }
   11     68   
}
   12     69   
   13     70   
/// A builder for [`ContentTypeParametersOutput`](crate::operation::content_type_parameters::ContentTypeParametersOutput).
   14     71   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   15     72   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/json_rpc10/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<'static> =
          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<'static> =
          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   
    > {
@@ -120,126 +241,258 @@
  140    146   
  141    147   
#[derive(Debug)]
  142    148   
struct EmptyInputAndEmptyOutputResponseDeserializer;
  143    149   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EmptyInputAndEmptyOutputResponseDeserializer {
  144    150   
    fn deserialize_nonstreaming_with_config(
  145    151   
        &self,
  146    152   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
  147    153   
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  148    154   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  149    155   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
  150         -
        let headers = response.headers();
         156  +
        // Load body and headers BEFORE BeforeParseResponse so customizations
         157  +
        // (e.g., S3's `body_is_error` check that detects errors returned with
         158  +
        // HTTP 200) can inspect them. The legacy non-streaming path also
         159  +
        // loads `body` before firing this hook.
  151    160   
        let body = response.body().bytes().expect("body loaded");
         161  +
        let headers = response.headers();
  152    162   
        #[allow(unused_mut)]
  153    163   
        let mut force_error = false;
  154    164   
  155         -
        let parse_result = if !success && status != 200 || force_error {
  156         -
            crate::protocol_serde::shape_empty_input_and_empty_output::de_empty_input_and_empty_output_http_error(status, headers, body)
         165  +
        if !success && status != 200 || force_error {
         166  +
            let protocol = _cfg
         167  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         168  +
                .expect("a SharedClientProtocol is required");
         169  +
            #[allow(unused_mut)]
         170  +
            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
         171  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         172  +
            })?;
         173  +
         174  +
            let generic = generic_builder.build();
         175  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         176  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         177  +
                    crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputError::generic(generic),
         178  +
                ),
         179  +
            ))
  157    180   
        } else {
  158         -
            crate::protocol_serde::shape_empty_input_and_empty_output::de_empty_input_and_empty_output_http_response(status, headers, body)
  159         -
        };
  160         -
        crate::protocol_serde::type_erase_result(parse_result)
         181  +
            let protocol = _cfg
         182  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         183  +
                .expect("a SharedClientProtocol is required");
         184  +
            let mut deser = protocol
         185  +
                .deserialize_response(response, EmptyInputAndEmptyOutput::OUTPUT_SCHEMA, _cfg)
         186  +
                .map_err(|e| {
         187  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         188  +
                })?;
         189  +
            // body and headers are already in scope from the top of the function;
         190  +
            // alias `headers` as `_response_headers` so MutateOutput
         191  +
            // customizations have a stable name to read from.
         192  +
            let _response_headers = headers;
         193  +
            #[allow(unused_mut)]
         194  +
            let mut output = crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput::deserialize_with_response(
         195  +
                &mut *deser,
         196  +
                _response_headers,
         197  +
                response.status().into(),
         198  +
                body,
         199  +
            )
         200  +
            .map_err(|e| {
         201  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         202  +
            })?;
         203  +
         204  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         205  +
        }
  161    206   
    }
  162    207   
}
  163    208   
#[derive(Debug)]
  164    209   
struct EmptyInputAndEmptyOutputRequestSerializer;
  165    210   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EmptyInputAndEmptyOutputRequestSerializer {
  166    211   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  167    212   
    fn serialize_input(
  168    213   
        &self,
  169    214   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  170    215   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  171    216   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  172    217   
        let input = input
  173    218   
            .downcast::<crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput>()
  174    219   
            .expect("correct type");
  175         -
        let _header_serialization_settings = _cfg
  176         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  177         -
            .cloned()
  178         -
            .unwrap_or_default();
  179         -
        let mut request_builder = {
  180         -
            #[allow(clippy::uninlined_format_args)]
  181         -
            fn uri_base(
  182         -
                _input: &crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput,
  183         -
                output: &mut ::std::string::String,
  184         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  185         -
                use ::std::fmt::Write as _;
  186         -
                ::std::write!(output, "/").expect("formatting should succeed");
  187         -
                ::std::result::Result::Ok(())
  188         -
            }
  189         -
            #[allow(clippy::unnecessary_wraps)]
  190         -
            fn update_http_builder(
  191         -
                input: &crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput,
  192         -
                builder: ::http_1x::request::Builder,
  193         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  194         -
                let mut uri = ::std::string::String::new();
  195         -
                uri_base(input, &mut uri)?;
  196         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  197         -
            }
  198         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  199         -
            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.0");
  200         -
            builder = _header_serialization_settings.set_default_header(
  201         -
                builder,
  202         -
                ::http_1x::header::HeaderName::from_static("x-amz-target"),
  203         -
                "JsonRpc10.EmptyInputAndEmptyOutput",
  204         -
            );
  205         -
            builder
  206         -
        };
  207         -
        let body = ::aws_smithy_types::body::SdkBody::from(
  208         -
            crate::protocol_serde::shape_empty_input_and_empty_output::ser_empty_input_and_empty_output_input(&input)?,
  209         -
        );
  210    220   
  211         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         221  +
        let protocol = _cfg
         222  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         223  +
            .expect("a SharedClientProtocol is required");
         224  +
        let mut request = protocol
         225  +
            .serialize_request(&input, EmptyInputAndEmptyOutput::INPUT_SCHEMA, "/", _cfg)
         226  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         227  +
         228  +
        return ::std::result::Result::Ok(request);
  212    229   
    }
  213    230   
}
  214    231   
#[derive(Debug)]
  215    232   
struct EmptyInputAndEmptyOutputEndpointParamsInterceptor;
  216    233   
  217    234   
#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
  218    235   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EmptyInputAndEmptyOutputEndpointParamsInterceptor {
  219    236   
    fn name(&self) -> &'static str {
  220    237   
        "EmptyInputAndEmptyOutputEndpointParamsInterceptor"
  221    238   
    }
@@ -283,300 +342,366 @@
  303    320   
  304    321   
        let op = crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutput::new();
  305    322   
        let config = op.config().expect("the operation has config");
  306    323   
        let de = config
  307    324   
            .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
  308    325   
            .expect("the config must have a deserializer");
  309    326   
  310    327   
        // Build a config bag with the protocol for schema-based deserialization
  311    328   
        #[allow(unused_mut)]
  312    329   
        let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
         330  +
        {
         331  +
            let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
         332  +
            layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
         333  +
                ::aws_smithy_json::protocol::aws_json_rpc::AwsJsonRpcProtocol::aws_json_1_0().with_target_prefix("JsonRpc10"),
         334  +
            ));
         335  +
            test_cfg.push_shared_layer(layer.freeze());
         336  +
        }
  313    337   
  314    338   
        let parsed = de.deserialize_streaming(&mut http_response);
  315    339   
        let parsed = parsed.unwrap_or_else(|| {
  316    340   
            let http_response = http_response.map(|body| {
  317    341   
                ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  318    342   
                    body.bytes().unwrap(),
  319    343   
                    ::aws_smithy_protocol_test::MediaType::from("application/json"),
  320    344   
                )))
  321    345   
            });
  322    346   
            de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)

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

@@ -1,1 +27,88 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    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  +
static EMPTYINPUTANDEMPTYOUTPUTINPUT_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
           7  +
    ::aws_smithy_schema::ShapeId::from_parts(
           8  +
        "aws.protocoltests.json10.synthetic#EmptyInputAndEmptyOutputInput",
           9  +
        "aws.protocoltests.json10.synthetic",
          10  +
        "EmptyInputAndEmptyOutputInput",
          11  +
    ),
          12  +
    ::aws_smithy_schema::ShapeType::Structure,
          13  +
    &[],
          14  +
)
          15  +
.with_no_body_members()
          16  +
.with_payload_hint(::aws_smithy_schema::PayloadHint::NoStructPayload)
          17  +
.with_original_name("EmptyInputAndEmptyOutputInput");
          18  +
impl EmptyInputAndEmptyOutputInput {
          19  +
    /// The schema for this shape.
          20  +
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &EMPTYINPUTANDEMPTYOUTPUTINPUT_SCHEMA;
          21  +
}
          22  +
impl ::aws_smithy_schema::serde::SerializableStruct for EmptyInputAndEmptyOutputInput {
          23  +
    #[allow(unused_variables, clippy::diverging_sub_expression)]
          24  +
    fn serialize_members(
          25  +
        &self,
          26  +
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
          27  +
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
          28  +
        Ok(())
          29  +
    }
          30  +
}
          31  +
impl EmptyInputAndEmptyOutputInput {
          32  +
    /// Deserializes this structure from a [`ShapeDeserializer`].
          33  +
    pub fn deserialize(
          34  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          35  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          36  +
        #[allow(unused_variables, unused_mut)]
          37  +
        let mut builder = Self::builder();
          38  +
        #[allow(
          39  +
            unused_variables,
          40  +
            unreachable_code,
          41  +
            clippy::single_match,
          42  +
            clippy::match_single_binding,
          43  +
            clippy::diverging_sub_expression
          44  +
        )]
          45  +
        deserializer.read_struct(&EMPTYINPUTANDEMPTYOUTPUTINPUT_SCHEMA, &mut |member, deser| {
          46  +
            match member.member_index() {
          47  +
                _ => {}
          48  +
            }
          49  +
            Ok(())
          50  +
        })?;
          51  +
        builder.build().map_err(|e| aws_smithy_schema::serde::SerdeError::custom(e.to_string()))
          52  +
    }
          53  +
}
          54  +
impl EmptyInputAndEmptyOutputInput {
          55  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          56  +
    pub fn deserialize_with_response(
          57  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          58  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          59  +
        _status: u16,
          60  +
        _body: &[u8],
          61  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          62  +
        Self::builder()
          63  +
            .build()
          64  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::custom(e.to_string()))
          65  +
    }
          66  +
}
    6     67   
impl EmptyInputAndEmptyOutputInput {
    7     68   
    /// Creates a new builder-style object to manufacture [`EmptyInputAndEmptyOutputInput`](crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput).
    8     69   
    pub fn builder() -> crate::operation::empty_input_and_empty_output::builders::EmptyInputAndEmptyOutputInputBuilder {
    9     70   
        crate::operation::empty_input_and_empty_output::builders::EmptyInputAndEmptyOutputInputBuilder::default()
   10     71   
    }
   11     72   
}
   12     73   
   13     74   
/// A builder for [`EmptyInputAndEmptyOutputInput`](crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputInput).
   14     75   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   15     76   
#[non_exhaustive]

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

@@ -1,1 +22,79 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    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 EmptyInputAndEmptyOutputOutput {}
           6  +
static EMPTYINPUTANDEMPTYOUTPUTOUTPUT_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
           7  +
    ::aws_smithy_schema::ShapeId::from_parts(
           8  +
        "aws.protocoltests.json10.synthetic#EmptyInputAndEmptyOutputOutput",
           9  +
        "aws.protocoltests.json10.synthetic",
          10  +
        "EmptyInputAndEmptyOutputOutput",
          11  +
    ),
          12  +
    ::aws_smithy_schema::ShapeType::Structure,
          13  +
    &[],
          14  +
)
          15  +
.with_original_name("EmptyInputAndEmptyOutputOutput");
          16  +
impl EmptyInputAndEmptyOutputOutput {
          17  +
    /// The schema for this shape.
          18  +
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &EMPTYINPUTANDEMPTYOUTPUTOUTPUT_SCHEMA;
          19  +
}
          20  +
impl ::aws_smithy_schema::serde::SerializableStruct for EmptyInputAndEmptyOutputOutput {
          21  +
    #[allow(unused_variables, clippy::diverging_sub_expression)]
          22  +
    fn serialize_members(
          23  +
        &self,
          24  +
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
          25  +
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
          26  +
        Ok(())
          27  +
    }
          28  +
}
          29  +
impl EmptyInputAndEmptyOutputOutput {
          30  +
    /// Deserializes this structure from a [`ShapeDeserializer`].
          31  +
    pub fn deserialize(
          32  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          33  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          34  +
        #[allow(unused_variables, unused_mut)]
          35  +
        let mut builder = Self::builder();
          36  +
        #[allow(
          37  +
            unused_variables,
          38  +
            unreachable_code,
          39  +
            clippy::single_match,
          40  +
            clippy::match_single_binding,
          41  +
            clippy::diverging_sub_expression
          42  +
        )]
          43  +
        deserializer.read_struct(&EMPTYINPUTANDEMPTYOUTPUTOUTPUT_SCHEMA, &mut |member, deser| {
          44  +
            match member.member_index() {
          45  +
                _ => {}
          46  +
            }
          47  +
            Ok(())
          48  +
        })?;
          49  +
        Ok(builder.build())
          50  +
    }
          51  +
}
          52  +
impl EmptyInputAndEmptyOutputOutput {
          53  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          54  +
    pub fn deserialize_with_response(
          55  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          56  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          57  +
        _status: u16,
          58  +
        _body: &[u8],
          59  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          60  +
        Ok(Self::builder().build())
          61  +
    }
          62  +
}
    6     63   
impl EmptyInputAndEmptyOutputOutput {
    7     64   
    /// Creates a new builder-style object to manufacture [`EmptyInputAndEmptyOutputOutput`](crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput).
    8     65   
    pub fn builder() -> crate::operation::empty_input_and_empty_output::builders::EmptyInputAndEmptyOutputOutputBuilder {
    9     66   
        crate::operation::empty_input_and_empty_output::builders::EmptyInputAndEmptyOutputOutputBuilder::default()
   10     67   
    }
   11     68   
}
   12     69   
   13     70   
/// A builder for [`EmptyInputAndEmptyOutputOutput`](crate::operation::empty_input_and_empty_output::EmptyInputAndEmptyOutputOutput).
   14     71   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   15     72   
#[non_exhaustive]

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/operation/endpoint_operation.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 `EndpointOperation`.
    3      3   
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
    4      4   
#[non_exhaustive]
    5      5   
pub struct EndpointOperation;
    6      6   
impl EndpointOperation {
    7      7   
    /// Creates a new `EndpointOperation`
    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<'static> = crate::operation::endpoint_operation::EndpointOperationInput::SCHEMA;
          13  +
    /// The schema for this operation's output shape.
          14  +
    pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = crate::operation::endpoint_operation::EndpointOperationOutput::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::endpoint_operation::EndpointOperationInput,
   14     18   
    ) -> ::std::result::Result<
   15     19   
        crate::operation::endpoint_operation::EndpointOperationOutput,
   16     20   
        ::aws_smithy_runtime_api::client::result::SdkError<
   17     21   
            crate::operation::endpoint_operation::EndpointOperationError,
   18     22   
            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
   19     23   
        >,
   20     24   
    > {
@@ -114,118 +233,250 @@
  134    138   
  135    139   
#[derive(Debug)]
  136    140   
struct EndpointOperationResponseDeserializer;
  137    141   
impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for EndpointOperationResponseDeserializer {
  138    142   
    fn deserialize_nonstreaming_with_config(
  139    143   
        &self,
  140    144   
        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
  141    145   
        _cfg: &::aws_smithy_types::config_bag::ConfigBag,
  142    146   
    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
  143    147   
        let (success, status) = (response.status().is_success(), response.status().as_u16());
  144         -
        let headers = response.headers();
         148  +
        // Load body and headers BEFORE BeforeParseResponse so customizations
         149  +
        // (e.g., S3's `body_is_error` check that detects errors returned with
         150  +
        // HTTP 200) can inspect them. The legacy non-streaming path also
         151  +
        // loads `body` before firing this hook.
  145    152   
        let body = response.body().bytes().expect("body loaded");
         153  +
        let headers = response.headers();
  146    154   
        #[allow(unused_mut)]
  147    155   
        let mut force_error = false;
  148    156   
  149         -
        let parse_result = if !success && status != 200 || force_error {
  150         -
            crate::protocol_serde::shape_endpoint_operation::de_endpoint_operation_http_error(status, headers, body)
         157  +
        if !success && status != 200 || force_error {
         158  +
            let protocol = _cfg
         159  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         160  +
                .expect("a SharedClientProtocol is required");
         161  +
            #[allow(unused_mut)]
         162  +
            let mut generic_builder = protocol.parse_error_metadata(response, _cfg).map_err(|e| {
         163  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         164  +
            })?;
         165  +
         166  +
            let generic = generic_builder.build();
         167  +
            ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
         168  +
                ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(
         169  +
                    crate::operation::endpoint_operation::EndpointOperationError::generic(generic),
         170  +
                ),
         171  +
            ))
  151    172   
        } else {
  152         -
            crate::protocol_serde::shape_endpoint_operation::de_endpoint_operation_http_response(status, headers, body)
  153         -
        };
  154         -
        crate::protocol_serde::type_erase_result(parse_result)
         173  +
            let protocol = _cfg
         174  +
                .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         175  +
                .expect("a SharedClientProtocol is required");
         176  +
            let mut deser = protocol
         177  +
                .deserialize_response(response, EndpointOperation::OUTPUT_SCHEMA, _cfg)
         178  +
                .map_err(|e| {
         179  +
                    ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         180  +
                })?;
         181  +
            // body and headers are already in scope from the top of the function;
         182  +
            // alias `headers` as `_response_headers` so MutateOutput
         183  +
            // customizations have a stable name to read from.
         184  +
            let _response_headers = headers;
         185  +
            #[allow(unused_mut)]
         186  +
            let mut output = crate::operation::endpoint_operation::EndpointOperationOutput::deserialize_with_response(
         187  +
                &mut *deser,
         188  +
                _response_headers,
         189  +
                response.status().into(),
         190  +
                body,
         191  +
            )
         192  +
            .map_err(|e| {
         193  +
                ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
         194  +
            })?;
         195  +
         196  +
            ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
         197  +
        }
  155    198   
    }
  156    199   
}
  157    200   
#[derive(Debug)]
  158    201   
struct EndpointOperationRequestSerializer;
  159    202   
impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for EndpointOperationRequestSerializer {
  160    203   
    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
  161    204   
    fn serialize_input(
  162    205   
        &self,
  163    206   
        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
  164    207   
        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
  165    208   
    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
  166    209   
        let input = input
  167    210   
            .downcast::<crate::operation::endpoint_operation::EndpointOperationInput>()
  168    211   
            .expect("correct type");
  169         -
        let _header_serialization_settings = _cfg
  170         -
            .load::<crate::serialization_settings::HeaderSerializationSettings>()
  171         -
            .cloned()
  172         -
            .unwrap_or_default();
  173         -
        let mut request_builder = {
  174         -
            #[allow(clippy::uninlined_format_args)]
  175         -
            fn uri_base(
  176         -
                _input: &crate::operation::endpoint_operation::EndpointOperationInput,
  177         -
                output: &mut ::std::string::String,
  178         -
            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
  179         -
                use ::std::fmt::Write as _;
  180         -
                ::std::write!(output, "/").expect("formatting should succeed");
  181         -
                ::std::result::Result::Ok(())
  182         -
            }
  183         -
            #[allow(clippy::unnecessary_wraps)]
  184         -
            fn update_http_builder(
  185         -
                input: &crate::operation::endpoint_operation::EndpointOperationInput,
  186         -
                builder: ::http_1x::request::Builder,
  187         -
            ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
  188         -
                let mut uri = ::std::string::String::new();
  189         -
                uri_base(input, &mut uri)?;
  190         -
                ::std::result::Result::Ok(builder.method("POST").uri(uri))
  191         -
            }
  192         -
            let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
  193         -
            builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.0");
  194         -
            builder = _header_serialization_settings.set_default_header(
  195         -
                builder,
  196         -
                ::http_1x::header::HeaderName::from_static("x-amz-target"),
  197         -
                "JsonRpc10.EndpointOperation",
  198         -
            );
  199         -
            builder
  200         -
        };
  201         -
        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_endpoint_operation::ser_endpoint_operation_input(&input)?);
  202    212   
  203         -
        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
         213  +
        let protocol = _cfg
         214  +
            .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
         215  +
            .expect("a SharedClientProtocol is required");
         216  +
        let mut request = protocol
         217  +
            .serialize_request(&input, EndpointOperation::INPUT_SCHEMA, "/", _cfg)
         218  +
            .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
         219  +
         220  +
        return ::std::result::Result::Ok(request);
  204    221   
    }
  205    222   
}
  206    223   
#[derive(Debug)]
  207    224   
struct EndpointOperationEndpointParamsInterceptor;
  208    225   
  209    226   
#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
  210    227   
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EndpointOperationEndpointParamsInterceptor {
  211    228   
    fn name(&self) -> &'static str {
  212    229   
        "EndpointOperationEndpointParamsInterceptor"
  213    230   
    }

tmp-codegen-diff/codegen-client-test/json_rpc10/rust-client-codegen/src/operation/endpoint_operation/_endpoint_operation_input.rs

@@ -1,1 +24,84 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    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 EndpointOperationInput {}
           6  +
static ENDPOINTOPERATIONINPUT_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
           7  +
    ::aws_smithy_schema::ShapeId::from_parts(
           8  +
        "aws.protocoltests.json10.synthetic#EndpointOperationInput",
           9  +
        "aws.protocoltests.json10.synthetic",
          10  +
        "EndpointOperationInput",
          11  +
    ),
          12  +
    ::aws_smithy_schema::ShapeType::Structure,
          13  +
    &[],
          14  +
)
          15  +
.with_no_body_members()
          16  +
.with_payload_hint(::aws_smithy_schema::PayloadHint::NoStructPayload);
          17  +
impl EndpointOperationInput {
          18  +
    /// The schema for this shape.
          19  +
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &ENDPOINTOPERATIONINPUT_SCHEMA;
          20  +
}
          21  +
impl ::aws_smithy_schema::serde::SerializableStruct for EndpointOperationInput {
          22  +
    #[allow(unused_variables, clippy::diverging_sub_expression)]
          23  +
    fn serialize_members(
          24  +
        &self,
          25  +
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
          26  +
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
          27  +
        Ok(())
          28  +
    }
          29  +
}
          30  +
impl EndpointOperationInput {
          31  +
    /// Deserializes this structure from a [`ShapeDeserializer`].
          32  +
    pub fn deserialize(
          33  +
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          34  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          35  +
        #[allow(unused_variables, unused_mut)]
          36  +
        let mut builder = Self::builder();
          37  +
        #[allow(
          38  +
            unused_variables,
          39  +
            unreachable_code,
          40  +
            clippy::single_match,
          41  +
            clippy::match_single_binding,
          42  +
            clippy::diverging_sub_expression
          43  +
        )]
          44  +
        deserializer.read_struct(&ENDPOINTOPERATIONINPUT_SCHEMA, &mut |member, deser| {
          45  +
            match member.member_index() {
          46  +
                _ => {}
          47  +
            }
          48  +
            Ok(())
          49  +
        })?;
          50  +
        builder.build().map_err(|e| aws_smithy_schema::serde::SerdeError::custom(e.to_string()))
          51  +
    }
          52  +
}
          53  +
impl EndpointOperationInput {
          54  +
    /// Deserializes this structure from a body deserializer and HTTP response.
          55  +
    pub fn deserialize_with_response(
          56  +
        _deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
          57  +
        _headers: &::aws_smithy_runtime_api::http::Headers,
          58  +
        _status: u16,
          59  +
        _body: &[u8],
          60  +
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
          61  +
        Self::builder()
          62  +
            .build()
          63  +
            .map_err(|e| aws_smithy_schema::serde::SerdeError::custom(e.to_string()))
          64  +
    }
          65  +
}
    6     66   
impl EndpointOperationInput {
    7     67   
    /// Creates a new builder-style object to manufacture [`EndpointOperationInput`](crate::operation::endpoint_operation::EndpointOperationInput).
    8     68   
    pub fn builder() -> crate::operation::endpoint_operation::builders::EndpointOperationInputBuilder {
    9     69   
        crate::operation::endpoint_operation::builders::EndpointOperationInputBuilder::default()
   10     70   
    }
   11     71   
}
   12     72   
   13     73   
/// A builder for [`EndpointOperationInput`](crate::operation::endpoint_operation::EndpointOperationInput).
   14     74   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
   15     75   
#[non_exhaustive]