Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405

Files changed:

tmp-codegen-diff/codegen-server-test/unique_items-http0x/rust-server-codegen/src/types.rs

@@ -0,1 +0,5 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub use ::aws_smithy_types::date_time::Format as DateTimeFormat;
           3  +
pub use ::aws_smithy_types::error::display::DisplayErrorContext;
           4  +
pub use ::aws_smithy_types::Blob;
           5  +
pub use ::aws_smithy_types::DateTime;

tmp-codegen-diff/codegen-server-test/unique_items-http0x/rust-server-codegen/src/unconstrained.rs

@@ -0,1 +0,44 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
           3  +
pub(crate) mod complex_set_unconstrained {
           4  +
           5  +
    #[derive(Debug, Clone)]
           6  +
    pub(crate) struct ComplexSetUnconstrained(
           7  +
        pub(crate) std::vec::Vec<crate::model::ComplexSetStruct>,
           8  +
    );
           9  +
          10  +
    impl From<ComplexSetUnconstrained>
          11  +
        for crate::constrained::MaybeConstrained<crate::model::ComplexSet>
          12  +
    {
          13  +
        fn from(value: ComplexSetUnconstrained) -> Self {
          14  +
            Self::Unconstrained(value)
          15  +
        }
          16  +
    }
          17  +
    impl std::convert::TryFrom<ComplexSetUnconstrained> for crate::model::ComplexSet {
          18  +
        type Error = crate::model::complex_set::ConstraintViolation;
          19  +
        fn try_from(value: ComplexSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          20  +
            let inner = value.0;
          21  +
            Self::try_from(inner)
          22  +
        }
          23  +
    }
          24  +
}
          25  +
pub(crate) mod simple_set_unconstrained {
          26  +
          27  +
    #[derive(Debug, Clone)]
          28  +
    pub(crate) struct SimpleSetUnconstrained(pub(crate) std::vec::Vec<::std::string::String>);
          29  +
          30  +
    impl From<SimpleSetUnconstrained>
          31  +
        for crate::constrained::MaybeConstrained<crate::model::SimpleSet>
          32  +
    {
          33  +
        fn from(value: SimpleSetUnconstrained) -> Self {
          34  +
            Self::Unconstrained(value)
          35  +
        }
          36  +
    }
          37  +
    impl std::convert::TryFrom<SimpleSetUnconstrained> for crate::model::SimpleSet {
          38  +
        type Error = crate::model::simple_set::ConstraintViolation;
          39  +
        fn try_from(value: SimpleSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          40  +
            let inner = value.0;
          41  +
            Self::try_from(inner)
          42  +
        }
          43  +
    }
          44  +
}

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/Cargo.toml

@@ -1,1 +56,60 @@
   10     10   
codegen-version = "ci"
   11     11   
protocol = "aws.protocols#restJson1"
   12     12   
[dependencies.aws-smithy-http]
   13     13   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http"
   14     14   
[dependencies.aws-smithy-http-server]
   15     15   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http-server"
   16     16   
[dependencies.aws-smithy-json]
   17     17   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-json"
   18     18   
[dependencies.aws-smithy-runtime-api]
   19     19   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime-api"
          20  +
features = ["http-1x"]
   20     21   
[dependencies.aws-smithy-types]
   21     22   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
          23  +
features = ["http-body-1-x"]
   22     24   
[dependencies.futures-util]
   23     25   
version = "0.3"
   24         -
[dependencies.http]
   25         -
version = "0.2.9"
   26         -
[dependencies.hyper]
   27         -
version = "0.14.26"
          26  +
[dependencies.http-1x]
          27  +
version = "1"
          28  +
package = "http"
          29  +
[dependencies.http-body-util]
          30  +
version = "0.1.3"
   28     31   
[dependencies.mime]
   29     32   
version = "0.3"
   30     33   
[dependencies.pin-project-lite]
   31     34   
version = "0.2"
   32     35   
[dependencies.tower]
   33     36   
version = "0.4"
   34     37   
[dependencies.tracing]
   35     38   
version = "0.1"
   36     39   
[dev-dependencies.aws-smithy-protocol-test]
   37     40   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-protocol-test"
          41  +
features = ["http-1x"]
   38     42   
[dev-dependencies.bytes]
   39     43   
version = "1.4.0"
   40     44   
[dev-dependencies.hyper]
   41         -
version = "0.14.12"
          45  +
version = "1"
   42     46   
[dev-dependencies.pretty_assertions]
   43     47   
version = "1.3.0"
   44     48   
[dev-dependencies.tokio]
   45     49   
version = "1.23.1"
   46     50   
features = ["macros", "test-util", "rt-multi-thread"]
   47     51   
[dev-dependencies.tracing-test]
   48     52   
version = "0.2.5"
   49     53   
features = ["no-env-filter"]
   50     54   
[features]
   51     55   
rt-tokio = ["aws-smithy-types/rt-tokio"]

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/src/lib.rs

@@ -19,19 +128,131 @@
   39     39   
)]
   40     40   
//! The [`crate::input`], [`crate::output`], and [`crate::error`]
   41     41   
//! modules provide the types used in each operation.
   42     42   
//!
   43     43   
//! ### Running on Hyper
   44     44   
//!
   45     45   
//! ```rust,no_run
   46     46   
//! # use std::net::SocketAddr;
   47     47   
//! # async fn dummy() {
   48     48   
//! use unique_items::{UniqueItemsService, UniqueItemsServiceConfig};
          49  +
//! use unique_items::serve;
          50  +
//! use ::tokio::net::TcpListener;
   49     51   
//!
   50     52   
//! # let app = UniqueItemsService::builder(
   51     53   
//! #     UniqueItemsServiceConfig::builder()
   52     54   
//! #         .build()
   53     55   
//! # ).build_unchecked();
   54         -
//! let server = app.into_make_service();
   55     56   
//! let bind: SocketAddr = "127.0.0.1:6969".parse()
   56     57   
//!     .expect("unable to parse the server bind address and port");
   57         -
//! ::hyper::Server::bind(&bind).serve(server).await.unwrap();
          58  +
//! let listener = TcpListener::bind(bind).await
          59  +
//!     .expect("failed to bind TCP listener");
          60  +
//! serve(listener, app.into_make_service()).await.unwrap();
   58     61   
//! # }
   59     62   
//! ```
   60     63   
//!
   61     64   
//! ### Running on Lambda
   62     65   
//!
   63     66   
//! ```rust,ignore
   64     67   
//! use unique_items::server::routing::LambdaHandler;
   65     68   
//! use unique_items::UniqueItemsService;
   66     69   
//!
   67     70   
//! # async fn dummy() {
   68     71   
//! # let app = UniqueItemsService::builder(
   69     72   
//! #     UniqueItemsServiceConfig::builder()
   70     73   
//! #         .build()
   71     74   
//! # ).build_unchecked();
   72     75   
//! let handler = LambdaHandler::new(app);
   73     76   
//! lambda_http::run(handler).await.unwrap();
   74     77   
//! # }
   75     78   
//! ```
   76     79   
//!
   77     80   
//! # Building the UniqueItemsService
   78     81   
//!
   79     82   
//! To construct [`UniqueItemsService`] we use [`UniqueItemsServiceBuilder`] returned by [`UniqueItemsService::builder`].
   80     83   
//!
   81     84   
//! ## Plugins
   82     85   
//!
   83     86   
//! The [`UniqueItemsService::builder`] method, returning [`UniqueItemsServiceBuilder`],
   84     87   
//! accepts a config object on which plugins can be registered.
   85     88   
//! Plugins allow you to build middleware which is aware of the operation it is being applied to.
   86     89   
//!
   87     90   
//! ```rust,no_run
   88     91   
//! # use unique_items::server::plugin::IdentityPlugin as LoggingPlugin;
   89     92   
//! # use unique_items::server::plugin::IdentityPlugin as MetricsPlugin;
   90         -
//! # use ::hyper::Body;
          93  +
//! # use ::hyper::body::Incoming;
   91     94   
//! use unique_items::server::plugin::HttpPlugins;
   92     95   
//! use unique_items::{UniqueItemsService, UniqueItemsServiceConfig, UniqueItemsServiceBuilder};
   93     96   
//!
   94     97   
//! let http_plugins = HttpPlugins::new()
   95     98   
//!         .push(LoggingPlugin)
   96     99   
//!         .push(MetricsPlugin);
   97    100   
//! let config = UniqueItemsServiceConfig::builder().build();
   98         -
//! let builder: UniqueItemsServiceBuilder<Body, _, _, _> = UniqueItemsService::builder(config);
         101  +
//! let builder: UniqueItemsServiceBuilder<::hyper::body::Incoming, _, _, _> = UniqueItemsService::builder(config);
   99    102   
//! ```
  100    103   
//!
  101    104   
//! Check out [`crate::server::plugin`] to learn more about plugins.
  102    105   
//!
  103    106   
//! ## Handlers
  104    107   
//!
  105    108   
//! [`UniqueItemsServiceBuilder`] provides a setter method for each operation in your Smithy model. The setter methods expect an async function as input, matching the signature for the corresponding operation in your Smithy model.
  106    109   
//! We call these async functions **handlers**. This is where your application business logic lives.
  107    110   
//!
  108    111   
//! Every handler must take an `Input`, and optional [`extractor arguments`](crate::server::request), while returning:
@@ -135,138 +228,235 @@
  155    158   
//! [`UniqueItemsServiceBuilder::build`] requires you to provide a handler for every single operation in your Smithy model. It will return an error if that is not the case.
  156    159   
//!
  157    160   
//! [`UniqueItemsServiceBuilder::build_unchecked`], instead, does not require exhaustiveness. The server will automatically return 500 Internal Server Error to all requests for operations that do not have a registered handler.
  158    161   
//! [`UniqueItemsServiceBuilder::build_unchecked`] is particularly useful if you are deploying your Smithy service as a collection of Lambda functions, where each Lambda is only responsible for a subset of the operations in the Smithy service (or even a single one!).
  159    162   
//!
  160    163   
//! # Example
  161    164   
//!
  162    165   
//! ```rust,no_run
  163    166   
//! # use std::net::SocketAddr;
  164    167   
//! use unique_items::{UniqueItemsService, UniqueItemsServiceConfig};
         168  +
//! use unique_items::serve;
         169  +
//! use ::tokio::net::TcpListener;
  165    170   
//!
  166    171   
//! #[::tokio::main]
  167    172   
//! pub async fn main() {
  168    173   
//!    let config = UniqueItemsServiceConfig::builder().build();
  169    174   
//!    let app = UniqueItemsService::builder(config)
  170    175   
//!        .malformed_unique_items(malformed_unique_items)
  171    176   
//!        .build()
  172    177   
//!        .expect("failed to build an instance of UniqueItemsService");
  173    178   
//!
  174    179   
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
  175    180   
//!        .expect("unable to parse the server bind address and port");
  176         -
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
         181  +
//!    let listener = TcpListener::bind(bind).await
         182  +
//!        .expect("failed to bind TCP listener");
  177    183   
//!    # let server = async { Ok::<_, ()>(()) };
  178    184   
//!
  179    185   
//!    // Run your service!
  180         -
//!    if let Err(err) = server.await {
         186  +
//!    if let Err(err) = serve(listener, app.into_make_service()).await {
  181    187   
//!        eprintln!("server error: {:?}", err);
  182    188   
//!    }
  183    189   
//! }
  184    190   
//!
  185    191   
//! use unique_items::{input, output, error};
  186    192   
//!
  187    193   
//! async fn malformed_unique_items(input: input::MalformedUniqueItemsInput) -> Result<output::MalformedUniqueItemsOutput, error::MalformedUniqueItemsError> {
  188    194   
//!     todo!()
  189    195   
//! }
  190    196   
//!
  191    197   
//! ```
  192    198   
//!
  193         -
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
         199  +
//! [`serve`]: crate::serve
         200  +
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  194    201   
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
  195    202   
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
  196    203   
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
  197         -
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  198    204   
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         205  +
pub use crate::server::serve::serve;
  199    206   
pub use crate::service::{
  200    207   
    MissingOperationsError, UniqueItemsService, UniqueItemsServiceBuilder,
  201    208   
    UniqueItemsServiceConfig, UniqueItemsServiceConfigBuilder,
  202    209   
};
  203    210   
  204    211   
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
  205    212   
pub mod server {
  206    213   
    // Re-export all types from the `aws-smithy-http-server` crate.
  207    214   
    pub use ::aws_smithy_http_server::*;
  208    215   
}

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/src/operation.rs

@@ -11,11 +71,71 @@
   31     31   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   32     32   
    B: 'static,
   33     33   
   34     34   
    B::Data: Send,
   35     35   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   36     36   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   37     37   
{
   38     38   
    type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
   39     39   
    type Future = MalformedUniqueItemsInputFuture;
   40     40   
   41         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
          41  +
    fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
   42     42   
        let fut = async move {
   43     43   
            if !::aws_smithy_http_server::protocol::accept_header_classifier(
   44     44   
                request.headers(),
   45     45   
                &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
   46     46   
            ) {
   47     47   
                return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
   48     48   
            }
   49     49   
            crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
   50     50   
                            .await
   51     51   
        };
@@ -82,82 +207,217 @@
  102    102   
mod malformed_unique_items_test {
  103    103   
  104    104   
    /// When the list has duplicated items, the response should be a 400
  105    105   
    /// ValidationException.
  106    106   
    /// Test ID: RestJsonMalformedUniqueItemsDuplicateItems
  107    107   
    #[::tokio::test]
  108    108   
    #[::tracing_test::traced_test]
  109    109   
    async fn rest_json_malformed_unique_items_duplicate_items_malformed_request() {
  110    110   
        {
  111    111   
            #[allow(unused_mut)]
  112         -
            let mut http_request = http::Request::builder()
         112  +
            let mut http_request = ::http_1x::Request::builder()
  113    113   
                .uri("/MalformedUniqueItems")
  114    114   
                .method("POST")
  115    115   
                .header("content-type", "application/json")
  116         -
                .body(::aws_smithy_http_server::body::Body::from(
  117         -
                    ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
  118         -
                        "{ \"set\" : [\"a\", \"a\", \"b\", \"c\"] }".as_bytes(),
  119         -
                        ::aws_smithy_protocol_test::MediaType::from("unknown"),
         116  +
                .body(::aws_smithy_http_server::body::boxed(
         117  +
                    ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
         118  +
                        &::aws_smithy_protocol_test::decode_body_data(
         119  +
                            "{ \"set\" : [\"a\", \"a\", \"b\", \"c\"] }".as_bytes(),
         120  +
                            ::aws_smithy_protocol_test::MediaType::from("unknown"),
         121  +
                        ),
  120    122   
                    )),
  121    123   
                ))
  122    124   
                .unwrap();
  123    125   
            #[allow(unused_mut)]
  124    126   
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  125    127   
            let config = crate::service::UniqueItemsServiceConfig::builder().build();
  126         -
            let service = crate::service::UniqueItemsService::builder::<::hyper::body::Body, _, _, _>(config)
         128  +
            let service = crate::service::UniqueItemsService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
  127    129   
                            .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
  128    130   
                                let sender = sender.clone();
  129    131   
                                async move {
  130    132   
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
  131    133   
                                    sender.send(()).await.expect("receiver dropped early");
  132    134   
                                    result
  133    135   
                                }
  134    136   
                            })
  135    137   
                            .build_unchecked();
  136    138   
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  137    139   
                .await
  138    140   
                .expect("unable to make an HTTP request");
  139    141   
            ::pretty_assertions::assert_eq!(
  140         -
                http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
         142  +
                ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
  141    143   
                http_response.status()
  142    144   
            );
  143    145   
            let expected_headers = [("x-amzn-errortype", "ValidationException")];
  144    146   
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  145    147   
                http_response.headers(),
  146    148   
                expected_headers,
  147    149   
            ));
  148         -
            let body = ::hyper::body::to_bytes(http_response.into_body())
         150  +
            use ::http_body_util::BodyExt;
         151  +
            let body = http_response
         152  +
                .into_body()
         153  +
                .collect()
  149    154   
                .await
  150         -
                .expect("unable to extract body to bytes");
         155  +
                .expect("unable to collect body")
         156  +
                .to_bytes();
  151    157   
            ::aws_smithy_protocol_test::assert_ok(
  152    158   
            ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 1] at '/set' failed to satisfy constraint: Member must have unique values\",\n  \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 1] at '/set' failed to satisfy constraint: Member must have unique values\", \"path\": \"/set\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
  153    159   
            );
  154    160   
        }
  155    161   
    }
  156    162   
  157    163   
    /// When the list has duplicated blobs, the response should be a 400
  158    164   
    /// ValidationException.
  159    165   
    /// Test ID: RestJsonMalformedUniqueItemsDuplicateBlobs
  160    166   
    #[::tokio::test]
  161    167   
    #[::tracing_test::traced_test]
  162    168   
    async fn rest_json_malformed_unique_items_duplicate_blobs_malformed_request() {
  163    169   
        {
  164    170   
            #[allow(unused_mut)]
  165         -
                        let mut http_request = http::Request::builder()
         171  +
                        let mut http_request = ::http_1x::Request::builder()
  166    172   
                            .uri("/MalformedUniqueItems")
  167    173   
                            .method("POST")
  168    174   
            .header("content-type", "application/json")
  169         -
            .body(::aws_smithy_http_server::body::Body::from(
  170         -
                                    ::bytes::Bytes::copy_from_slice(
  171         -
                                        &::aws_smithy_protocol_test::decode_body_data("{ \"complexSet\" : [{\"foo\": true, \"blob\": \"YmxvYg==\"}, {\"foo\": true, \"blob\": \"b3RoZXJibG9i\"}, {\"foo\": true, \"blob\": \"YmxvYg==\"}] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
  172         -
                                    )
  173         -
                                    )).unwrap();
         175  +
            .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
         176  +
                            ::bytes::Bytes::copy_from_slice(
         177  +
                                &::aws_smithy_protocol_test::decode_body_data("{ \"complexSet\" : [{\"foo\": true, \"blob\": \"YmxvYg==\"}, {\"foo\": true, \"blob\": \"b3RoZXJibG9i\"}, {\"foo\": true, \"blob\": \"YmxvYg==\"}] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
         178  +
                            )
         179  +
                            ))).unwrap();
  174    180   
            #[allow(unused_mut)]
  175    181   
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
  176    182   
            let config = crate::service::UniqueItemsServiceConfig::builder().build();
  177         -
            let service = crate::service::UniqueItemsService::builder::<::hyper::body::Body, _, _, _>(config)
         183  +
            let service = crate::service::UniqueItemsService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
  178    184   
                            .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
  179    185   
                                let sender = sender.clone();
  180    186   
                                async move {
  181    187   
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
  182    188   
                                    sender.send(()).await.expect("receiver dropped early");
  183    189   
                                    result
  184    190   
                                }
  185    191   
                            })
  186    192   
                            .build_unchecked();
  187    193   
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  188    194   
                .await
  189    195   
                .expect("unable to make an HTTP request");
  190    196   
            ::pretty_assertions::assert_eq!(
  191         -
                http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
         197  +
                ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
  192    198   
                http_response.status()
  193    199   
            );
  194    200   
            let expected_headers = [("x-amzn-errortype", "ValidationException")];
  195    201   
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
  196    202   
                http_response.headers(),
  197    203   
                expected_headers,
  198    204   
            ));
  199         -
            let body = ::hyper::body::to_bytes(http_response.into_body())
         205  +
            use ::http_body_util::BodyExt;
         206  +
            let body = http_response
         207  +
                .into_body()
         208  +
                .collect()
  200    209   
                .await
  201         -
                .expect("unable to extract body to bytes");
         210  +
                .expect("unable to collect body")
         211  +
                .to_bytes();
  202    212   
            ::aws_smithy_protocol_test::assert_ok(
  203    213   
            ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\",\n  \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\", \"path\": \"/complexSet\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
  204    214   
            );
  205    215   
        }
  206    216   
    }
  207    217   
}

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/src/protocol_serde/shape_malformed_unique_items.rs

@@ -1,1 +122,125 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
#[allow(clippy::unnecessary_wraps)]
    3      3   
pub async fn de_malformed_unique_items_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           4  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      5   
) -> std::result::Result<
    6      6   
    crate::input::MalformedUniqueItemsInput,
    7      7   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8      8   
>
    9      9   
where
   10     10   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     11   
    B::Data: Send,
   12     12   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     13   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     14   
{
   15     15   
    Ok({
   16     16   
        #[allow(unused_mut)]
   17     17   
        let mut input = crate::input::malformed_unique_items_input::Builder::default();
   18     18   
        #[allow(unused_variables)]
   19     19   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     20   
            uri, headers, body, ..
   21     21   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          22  +
        let bytes = {
          23  +
            use ::http_body_util::BodyExt;
          24  +
            body.collect().await?.to_bytes()
          25  +
        };
   23     26   
        if !bytes.is_empty() {
   24     27   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     28   
                &headers,
   26     29   
                Some("application/json"),
   27     30   
            )?;
   28     31   
            input = crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items(
   29     32   
                bytes.as_ref(),
   30     33   
                input,
   31     34   
            )?;
   32     35   
        }
   33     36   
        input.build()?
   34     37   
    })
   35     38   
}
   36     39   
   37     40   
#[allow(clippy::unnecessary_wraps)]
   38     41   
pub fn ser_malformed_unique_items_http_response(
   39     42   
    #[allow(unused_variables)] output: crate::output::MalformedUniqueItemsOutput,
   40     43   
) -> std::result::Result<
   41     44   
    ::aws_smithy_http_server::response::Response,
   42     45   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     46   
> {
   44     47   
    Ok({
   45     48   
        #[allow(unused_mut)]
   46         -
        let mut builder = ::http::Response::builder();
          49  +
        let mut builder = ::http_1x::Response::builder();
   47     50   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     51   
            builder,
   49         -
            ::http::header::CONTENT_TYPE,
          52  +
            ::http_1x::header::CONTENT_TYPE,
   50     53   
            "application/json",
   51     54   
        );
   52     55   
        let http_status: u16 = 200;
   53     56   
        builder = builder.status(http_status);
   54     57   
        let payload = "";
   55     58   
        let content_length = payload.len();
   56     59   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     60   
            builder,
   58         -
            ::http::header::CONTENT_LENGTH,
          61  +
            ::http_1x::header::CONTENT_LENGTH,
   59     62   
            content_length,
   60     63   
        );
   61     64   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
   62     65   
        builder.body(body)?
   63     66   
    })
   64     67   
}
   65     68   
   66     69   
#[allow(clippy::unnecessary_wraps)]
   67     70   
pub fn ser_malformed_unique_items_http_error(
   68     71   
    error: &crate::error::MalformedUniqueItemsError,
   69     72   
) -> std::result::Result<
   70     73   
    ::aws_smithy_http_server::response::Response,
   71     74   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72     75   
> {
   73     76   
    Ok({
   74     77   
        match error {
   75     78   
            crate::error::MalformedUniqueItemsError::ValidationException(output) => {
   76     79   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
   77     80   
                #[allow(unused_mut)]
   78         -
                let mut builder = ::http::Response::builder();
          81  +
                let mut builder = ::http_1x::Response::builder();
   79     82   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80     83   
                    builder,
   81         -
                    ::http::header::CONTENT_TYPE,
          84  +
                    ::http_1x::header::CONTENT_TYPE,
   82     85   
                    "application/json",
   83     86   
                );
   84     87   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85     88   
                    builder,
   86         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          89  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   87     90   
                    "ValidationException",
   88     91   
                );
   89     92   
                let content_length = payload.len();
   90     93   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91     94   
                    builder,
   92         -
                    ::http::header::CONTENT_LENGTH,
          95  +
                    ::http_1x::header::CONTENT_LENGTH,
   93     96   
                    content_length,
   94     97   
                );
   95     98   
                builder
   96     99   
                    .status(400)
   97    100   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   98    101   
            }
   99    102   
        }
  100    103   
    })
  101    104   
}
  102    105   

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/src/service.rs

@@ -35,35 +96,96 @@
   55     55   
                            <
   56     56   
                                ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
   57     57   
                                as ::aws_smithy_http_server::plugin::Plugin<
   58     58   
                                    UniqueItemsService<L>,
   59     59   
                                    crate::operation_shape::MalformedUniqueItems,
   60     60   
                                    ModelPl::Output
   61     61   
                                >
   62     62   
                            >::Output
   63     63   
                        >,
   64     64   
   65         -
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
   66         -
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
          65  +
                        HttpPl::Output: ::tower::Service<::http_1x::Request<Body>, Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
          66  +
                        <HttpPl::Output as ::tower::Service<::http_1x::Request<Body>>>::Future: Send + 'static,
   67     67   
   68     68   
                    {
   69     69   
        use ::aws_smithy_http_server::operation::OperationShapeExt;
   70     70   
        use ::aws_smithy_http_server::plugin::Plugin;
   71     71   
        let svc = crate::operation_shape::MalformedUniqueItems::from_handler(handler);
   72     72   
        let svc = self.model_plugin.apply(svc);
   73     73   
        let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
   74     74   
            .apply(svc);
   75     75   
        let svc = self.http_plugin.apply(svc);
   76     76   
        self.malformed_unique_items_custom(svc)
@@ -102,102 +182,182 @@
  122    122   
                            <
  123    123   
                                ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
  124    124   
                                as ::aws_smithy_http_server::plugin::Plugin<
  125    125   
                                    UniqueItemsService<L>,
  126    126   
                                    crate::operation_shape::MalformedUniqueItems,
  127    127   
                                    ModelPl::Output
  128    128   
                                >
  129    129   
                            >::Output
  130    130   
                        >,
  131    131   
  132         -
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
  133         -
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
         132  +
                        HttpPl::Output: ::tower::Service<::http_1x::Request<Body>, Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
         133  +
                        <HttpPl::Output as ::tower::Service<::http_1x::Request<Body>>>::Future: Send + 'static,
  134    134   
  135    135   
                    {
  136    136   
        use ::aws_smithy_http_server::operation::OperationShapeExt;
  137    137   
        use ::aws_smithy_http_server::plugin::Plugin;
  138    138   
        let svc = crate::operation_shape::MalformedUniqueItems::from_service(service);
  139    139   
        let svc = self.model_plugin.apply(svc);
  140    140   
        let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
  141    141   
            .apply(svc);
  142    142   
        let svc = self.http_plugin.apply(svc);
  143    143   
        self.malformed_unique_items_custom(svc)
  144    144   
    }
  145    145   
  146    146   
    /// Sets the [`MalformedUniqueItems`](crate::operation_shape::MalformedUniqueItems) to a custom [`Service`](tower::Service).
  147    147   
    /// not constrained by the Smithy contract.
  148    148   
    fn malformed_unique_items_custom<S>(mut self, svc: S) -> Self
  149    149   
    where
  150    150   
        S: ::tower::Service<
  151         -
                ::http::Request<Body>,
  152         -
                Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
         151  +
                ::http_1x::Request<Body>,
         152  +
                Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>,
  153    153   
                Error = ::std::convert::Infallible,
  154    154   
            > + Clone
  155    155   
            + Send
  156    156   
            + 'static,
  157    157   
        S::Future: Send + 'static,
  158    158   
    {
  159    159   
        self.malformed_unique_items = Some(::aws_smithy_http_server::routing::Route::new(svc));
  160    160   
        self
  161    161   
    }
  162    162   
}
@@ -249,249 +309,309 @@
  269    269   
        Ok(())
  270    270   
    }
  271    271   
}
  272    272   
  273    273   
impl std::error::Error for MissingOperationsError {}
  274    274   
  275    275   
mod request_specs {
  276    276   
    pub(super) fn malformed_unique_items(
  277    277   
    ) -> ::aws_smithy_http_server::routing::request_spec::RequestSpec {
  278    278   
        ::aws_smithy_http_server::routing::request_spec::RequestSpec::new(
  279         -
                    ::http::Method::POST,
         279  +
                    ::http_1x::Method::POST,
  280    280   
                    ::aws_smithy_http_server::routing::request_spec::UriSpec::new(
  281    281   
                        ::aws_smithy_http_server::routing::request_spec::PathAndQuerySpec::new(
  282    282   
                            ::aws_smithy_http_server::routing::request_spec::PathSpec::from_vector_unchecked(vec![
  283    283   
    ::aws_smithy_http_server::routing::request_spec::PathSegment::Literal(String::from("MalformedUniqueItems")),
  284    284   
]),
  285    285   
                            ::aws_smithy_http_server::routing::request_spec::QuerySpec::from_vector_unchecked(vec![
  286    286   
])
  287    287   
                        )
  288    288   
                    ),
  289    289   
                )
@@ -406,406 +467,467 @@
  426    426   
    ) -> UniqueItemsService<
  427    427   
        ::aws_smithy_http_server::routing::RoutingService<
  428    428   
            ::aws_smithy_http_server::protocol::rest::router::RestRouter<
  429    429   
                ::aws_smithy_http_server::routing::Route<B>,
  430    430   
            >,
  431    431   
            ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  432    432   
        >,
  433    433   
    >
  434    434   
    where
  435    435   
        S: ::tower::Service<
  436         -
            ::http::Request<B>,
  437         -
            Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
         436  +
            ::http_1x::Request<B>,
         437  +
            Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>,
  438    438   
            Error = std::convert::Infallible,
  439    439   
        >,
  440    440   
        S: Clone + Send + 'static,
  441    441   
        S::Future: Send + 'static,
  442    442   
    {
  443    443   
        self.layer(&::tower::layer::layer_fn(
  444    444   
            ::aws_smithy_http_server::routing::Route::new,
  445    445   
        ))
  446    446   
    }
  447    447   
}