Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943

Files changed:

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_content_type_with_generic_string_input.rs

@@ -1,1 +14,20 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:248 */
    2      3   
pub(crate) fn de_payload_payload(
    3      4   
    body: &[u8],
    4      5   
) -> std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:319 */
    8     10   
    (!body.is_empty())
    9     11   
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:332 */
   10     13   
            let body_str = std::str::from_utf8(body)?;
          14  +
            /* HttpBindingGenerator.kt:344 */
   11     15   
            Ok(body_str.to_string())
          16  +
            /* HttpBindingGenerator.kt:319 */
   12     17   
        })
   13     18   
        .transpose()
          19  +
    /* HttpBindingGenerator.kt:248 */
   14     20   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_content_type_with_payload.rs

@@ -1,1 +103,144 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_content_type_with_payload_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedContentTypeWithPayloadInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input =
   18     23   
            crate::input::malformed_content_type_with_payload_input_internal::Builder::default();
          24  +
        /* RustType.kt:516 */
   19     25   
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   20     27   
        let ::aws_smithy_runtime_api::http::RequestParts {
   21     28   
            uri, headers, body, ..
   22     29   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   23     31   
        if let Some(value) = {
   24     32   
            let bytes = ::hyper::body::to_bytes(body).await?;
   25     33   
            if !bytes.is_empty() {
   26     34   
                ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   27     35   
                    &headers,
   28     36   
                    Some("image/jpeg"),
   29     37   
                )?;
   30     38   
            }
   31     39   
            crate::protocol_serde::shape_malformed_content_type_with_payload_input::de_payload_payload(&bytes)?
   32     40   
        } {
   33     41   
            input = input.set_payload(Some(value))
   34     42   
        }
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   35     44   
        input.build()
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   36     46   
    })
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   37     48   
}
   38     49   
          50  +
/* RustType.kt:516 */
   39     51   
#[allow(clippy::unnecessary_wraps)]
          52  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   40     53   
pub fn ser_malformed_content_type_with_payload_http_response(
   41     54   
    #[allow(unused_variables)] output: crate::output::MalformedContentTypeWithPayloadOutput,
   42     55   
) -> std::result::Result<
   43     56   
    ::aws_smithy_http_server::response::Response,
   44     57   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   45     58   
> {
          59  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   46     60   
    Ok({
          61  +
        /* RustType.kt:516 */
   47     62   
        #[allow(unused_mut)]
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   48     64   
        let mut builder = ::http::Response::builder();
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   49     66   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   50     67   
            builder,
   51     68   
            ::http::header::CONTENT_TYPE,
   52     69   
            "application/json",
   53     70   
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   54     72   
        let http_status: u16 = 200;
   55     73   
        builder = builder.status(http_status);
   56         -
        let payload = "";
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          75  +
        let payload =
          76  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   57     79   
        let content_length = payload.len();
   58     80   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   59     81   
            builder,
   60     82   
            ::http::header::CONTENT_LENGTH,
   61     83   
            content_length,
   62     84   
        );
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   63     86   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   64     88   
        builder.body(body)?
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   65     90   
    })
          91  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   66     92   
}
   67     93   
          94  +
/* RustType.kt:516 */
   68     95   
#[allow(clippy::unnecessary_wraps)]
          96  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   69     97   
pub fn ser_malformed_content_type_with_payload_http_error(
   70     98   
    error: &crate::error::MalformedContentTypeWithPayloadError,
   71     99   
) -> std::result::Result<
   72    100   
    ::aws_smithy_http_server::response::Response,
   73    101   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   74    102   
> {
         103  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   75    104   
    Ok({
         105  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   76    106   
        match error {
         107  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   77    108   
            crate::error::MalformedContentTypeWithPayloadError::InternalServerError(output) => {
         109  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   78    110   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         111  +
                /* RustType.kt:516 */
   79    112   
                #[allow(unused_mut)]
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   80    114   
                let mut builder = ::http::Response::builder();
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   81    116   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82    117   
                    builder,
   83    118   
                    ::http::header::CONTENT_TYPE,
   84    119   
                    "application/json",
   85    120   
                );
         121  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   86    122   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    123   
                    builder,
   88    124   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   89    125   
                    "InternalServerError",
   90    126   
                );
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   91    128   
                let content_length = payload.len();
   92    129   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   93    130   
                    builder,
   94    131   
                    ::http::header::CONTENT_LENGTH,
   95    132   
                    content_length,
   96    133   
                );
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   97    135   
                builder
   98    136   
                    .status(500)
   99    137   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  100         -
            }
         138  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         139  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  101    140   
        }
         141  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  102    142   
    })
         143  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  103    144   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_content_type_with_payload_input.rs

@@ -1,1 +11,18 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:248 */
    2      3   
pub(crate) fn de_payload_payload(
    3      4   
    body: &[u8],
    4      5   
) -> std::result::Result<
    5      6   
    ::std::option::Option<::aws_smithy_http_server_python::types::Blob>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:319 */
    8     10   
    (!body.is_empty())
    9         -
        .then(|| Ok(::aws_smithy_http_server_python::types::Blob::new(body)))
          11  +
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:349 */
          13  +
            Ok(::aws_smithy_http_server_python::types::Blob::new(body))
          14  +
            /* HttpBindingGenerator.kt:319 */
          15  +
        })
   10     16   
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:248 */
   11     18   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_content_type_without_body.rs

@@ -1,1 +92,133 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_content_type_without_body_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedContentTypeWithoutBodyInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input =
   18     23   
            crate::input::malformed_content_type_without_body_input_internal::Builder::default();
          24  +
        /* RustType.kt:516 */
   19     25   
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   20     27   
        let ::aws_smithy_runtime_api::http::RequestParts {
   21     28   
            uri, headers, body, ..
   22     29   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:811 */
   23     31   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   24     33   
        input.build()
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   25     35   
    })
          36  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   26     37   
}
   27     38   
          39  +
/* RustType.kt:516 */
   28     40   
#[allow(clippy::unnecessary_wraps)]
          41  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   29     42   
pub fn ser_malformed_content_type_without_body_http_response(
   30     43   
    #[allow(unused_variables)] output: crate::output::MalformedContentTypeWithoutBodyOutput,
   31     44   
) -> std::result::Result<
   32     45   
    ::aws_smithy_http_server::response::Response,
   33     46   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   34     47   
> {
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   35     49   
    Ok({
          50  +
        /* RustType.kt:516 */
   36     51   
        #[allow(unused_mut)]
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   37     53   
        let mut builder = ::http::Response::builder();
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   38     55   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   39     56   
            builder,
   40     57   
            ::http::header::CONTENT_TYPE,
   41     58   
            "application/json",
   42     59   
        );
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   43     61   
        let http_status: u16 = 200;
   44     62   
        builder = builder.status(http_status);
   45         -
        let payload = "";
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          64  +
        let payload =
          65  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   46     68   
        let content_length = payload.len();
   47     69   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     70   
            builder,
   49     71   
            ::http::header::CONTENT_LENGTH,
   50     72   
            content_length,
   51     73   
        );
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   52     75   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   53     77   
        builder.body(body)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   54     79   
    })
          80  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   55     81   
}
   56     82   
          83  +
/* RustType.kt:516 */
   57     84   
#[allow(clippy::unnecessary_wraps)]
          85  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   58     86   
pub fn ser_malformed_content_type_without_body_http_error(
   59     87   
    error: &crate::error::MalformedContentTypeWithoutBodyError,
   60     88   
) -> std::result::Result<
   61     89   
    ::aws_smithy_http_server::response::Response,
   62     90   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   63     91   
> {
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   64     93   
    Ok({
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   65     95   
        match error {
          96  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   66     97   
            crate::error::MalformedContentTypeWithoutBodyError::InternalServerError(output) => {
          98  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   67     99   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         100  +
                /* RustType.kt:516 */
   68    101   
                #[allow(unused_mut)]
         102  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   69    103   
                let mut builder = ::http::Response::builder();
         104  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   70    105   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   71    106   
                    builder,
   72    107   
                    ::http::header::CONTENT_TYPE,
   73    108   
                    "application/json",
   74    109   
                );
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   75    111   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   76    112   
                    builder,
   77    113   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   78    114   
                    "InternalServerError",
   79    115   
                );
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   80    117   
                let content_length = payload.len();
   81    118   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82    119   
                    builder,
   83    120   
                    ::http::header::CONTENT_LENGTH,
   84    121   
                    content_length,
   85    122   
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   86    124   
                builder
   87    125   
                    .status(500)
   88    126   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   89         -
            }
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         128  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   90    129   
        }
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   91    131   
    })
         132  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
   92    133   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_double.rs

@@ -1,1 +212,293 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_double_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedDoubleInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_double_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_double::de_malformed_double(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_double_input::de_double_in_header_header(
   35     47   
                &headers,
   36     48   
            )?
   37     49   
        {
   38     50   
            input = input.set_double_in_header(Some(value))
   39     51   
        }
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   40     53   
        let input_string = uri.path();
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   41     55   
        let (input_string, (_, m1)) =
   42     56   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   43     57   
                ::nom::sequence::preceded(
   44     58   
                    ::nom::bytes::complete::tag("/"),
   45     59   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   46     60   
                        "MalformedDouble",
   47     61   
                    ),
   48     62   
                ),
   49     63   
                ::nom::sequence::preceded(
   50     64   
                    ::nom::bytes::complete::tag("/"),
   51     65   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   52     66   
                        ::nom::bytes::complete::take_until("/"),
   53     67   
                        ::nom::combinator::rest,
   54     68   
                    )),
   55     69   
                ),
   56     70   
            ))(input_string)?;
   57     71   
        debug_assert_eq!("", input_string);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   58     73   
        input = input.set_double_in_path(
   59     74   
            crate::protocol_serde::shape_malformed_double_input::de_double_in_path(m1)?,
   60     75   
        );
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   61     77   
        let query_string = uri.query().unwrap_or("");
   62     78   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   63     80   
        let mut double_in_query_seen = false;
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   64     82   
        for (k, v) in pairs {
          83  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   65     84   
            if !double_in_query_seen && k == "doubleInQuery" {
   66     85   
                input = input.set_double_in_query(
   67     86   
                    crate::protocol_serde::shape_malformed_double_input::de_double_in_query(&v)?,
   68     87   
                );
   69     88   
                double_in_query_seen = true;
   70     89   
            }
          90  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   71     91   
        }
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   72     93   
        input.build()?
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   73     95   
    })
          96  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   74     97   
}
   75     98   
          99  +
/* RustType.kt:516 */
   76    100   
#[allow(clippy::unnecessary_wraps)]
         101  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   77    102   
pub fn ser_malformed_double_http_response(
   78    103   
    #[allow(unused_variables)] output: crate::output::MalformedDoubleOutput,
   79    104   
) -> std::result::Result<
   80    105   
    ::aws_smithy_http_server::response::Response,
   81    106   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   82    107   
> {
         108  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   83    109   
    Ok({
         110  +
        /* RustType.kt:516 */
   84    111   
        #[allow(unused_mut)]
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   85    113   
        let mut builder = ::http::Response::builder();
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   86    115   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    116   
            builder,
   88    117   
            ::http::header::CONTENT_TYPE,
   89    118   
            "application/json",
   90    119   
        );
         120  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   91    121   
        let http_status: u16 = 200;
   92    122   
        builder = builder.status(http_status);
   93         -
        let payload = "";
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         124  +
        let payload =
         125  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         127  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   94    128   
        let content_length = payload.len();
   95    129   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96    130   
            builder,
   97    131   
            ::http::header::CONTENT_LENGTH,
   98    132   
            content_length,
   99    133   
        );
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
  100    135   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         136  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
  101    137   
        builder.body(body)?
         138  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  102    139   
    })
         140  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  103    141   
}
  104    142   
         143  +
/* RustType.kt:516 */
  105    144   
#[allow(clippy::unnecessary_wraps)]
         145  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  106    146   
pub fn ser_malformed_double_http_error(
  107    147   
    error: &crate::error::MalformedDoubleError,
  108    148   
) -> std::result::Result<
  109    149   
    ::aws_smithy_http_server::response::Response,
  110    150   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  111    151   
> {
         152  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  112    153   
    Ok({
         154  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  113    155   
        match error {
         156  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  114    157   
            crate::error::MalformedDoubleError::ValidationException(output) => {
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  115    159   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         160  +
                /* RustType.kt:516 */
  116    161   
                #[allow(unused_mut)]
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  117    163   
                let mut builder = ::http::Response::builder();
         164  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  118    165   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  119    166   
                    builder,
  120    167   
                    ::http::header::CONTENT_TYPE,
  121    168   
                    "application/json",
  122    169   
                );
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  123    171   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  124    172   
                    builder,
  125    173   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  126    174   
                    "ValidationException",
  127    175   
                );
         176  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  128    177   
                let content_length = payload.len();
  129    178   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    179   
                    builder,
  131    180   
                    ::http::header::CONTENT_LENGTH,
  132    181   
                    content_length,
  133    182   
                );
         183  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  134    184   
                builder
  135    185   
                    .status(400)
  136    186   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         187  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  137    188   
            }
         189  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  138    190   
            crate::error::MalformedDoubleError::InternalServerError(output) => {
         191  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  139    192   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         193  +
                /* RustType.kt:516 */
  140    194   
                #[allow(unused_mut)]
         195  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  141    196   
                let mut builder = ::http::Response::builder();
         197  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  142    198   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  143    199   
                    builder,
  144    200   
                    ::http::header::CONTENT_TYPE,
  145    201   
                    "application/json",
  146    202   
                );
         203  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  147    204   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  148    205   
                    builder,
  149    206   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  150    207   
                    "InternalServerError",
  151    208   
                );
         209  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  152    210   
                let content_length = payload.len();
  153    211   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  154    212   
                    builder,
  155    213   
                    ::http::header::CONTENT_LENGTH,
  156    214   
                    content_length,
  157    215   
                );
         216  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  158    217   
                builder
  159    218   
                    .status(500)
  160    219   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  161         -
            }
         220  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         221  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  162    222   
        }
         223  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  163    224   
    })
         225  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  164    226   
}
  165    227   
         228  +
/* JsonParserGenerator.kt:148 */
  166    229   
pub(crate) fn de_malformed_double(
  167    230   
    value: &[u8],
  168    231   
    mut builder: crate::input::malformed_double_input_internal::Builder,
  169    232   
) -> ::std::result::Result<
  170    233   
    crate::input::malformed_double_input_internal::Builder,
  171    234   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  172    235   
> {
         236  +
    /* JsonParserGenerator.kt:153 */
  173    237   
    let mut tokens_owned =
  174    238   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  175    239   
            .peekable();
  176    240   
    let tokens = &mut tokens_owned;
  177    241   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         242  +
    /* JsonParserGenerator.kt:684 */
  178    243   
    loop {
         244  +
        /* JsonParserGenerator.kt:685 */
  179    245   
        match tokens.next().transpose()? {
         246  +
            /* JsonParserGenerator.kt:686 */
  180    247   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  181    248   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         249  +
                /* JsonParserGenerator.kt:260 */
  182    250   
                match key.to_unescaped()?.as_ref() {
         251  +
                    /* JsonParserGenerator.kt:262 */
  183    252   
                    "doubleInBody" => {
         253  +
                        /* JsonParserGenerator.kt:272 */
  184    254   
                        builder = builder.set_double_in_body(
         255  +
                            /* JsonParserGenerator.kt:363 */
  185    256   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  186    257   
                                tokens.next(),
  187    258   
                            )?
  188         -
                            .map(|v| v.to_f64_lossy()),
         259  +
                            .map(|v| v.to_f64_lossy()), /* JsonParserGenerator.kt:272 */
  189    260   
                        );
         261  +
                        /* JsonParserGenerator.kt:262 */
  190    262   
                    }
  191         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         263  +
                    /* JsonParserGenerator.kt:290 */
         264  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  192    265   
                }
         266  +
                /* JsonParserGenerator.kt:686 */
  193    267   
            }
         268  +
            /* JsonParserGenerator.kt:695 */
  194    269   
            other => {
  195    270   
                return Err(
  196    271   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  197    272   
                        "expected object key or end object, found: {:?}",
  198    273   
                        other
  199    274   
                    )),
  200    275   
                )
  201         -
            }
         276  +
            } /* JsonParserGenerator.kt:685 */
  202    277   
        }
         278  +
        /* JsonParserGenerator.kt:684 */
  203    279   
    }
         280  +
    /* JsonParserGenerator.kt:250 */
  204    281   
    if tokens.next().is_some() {
         282  +
        /* JsonParserGenerator.kt:251 */
  205    283   
        return Err(
  206    284   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  207    285   
                "found more JSON tokens after completing parsing",
  208    286   
            ),
  209    287   
        );
         288  +
        /* JsonParserGenerator.kt:250 */
  210    289   
    }
         290  +
    /* JsonParserGenerator.kt:163 */
  211    291   
    Ok(builder)
         292  +
    /* JsonParserGenerator.kt:148 */
  212    293   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_double_input.rs

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_double_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<f64>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("doubleInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<f64>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_double_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    f64,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_double_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<f64>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_float.rs

@@ -1,1 +210,291 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_float_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedFloatInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_float_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_float::de_malformed_float(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_float_input::de_float_in_header_header(&headers)?
   35     47   
        {
   36     48   
            input = input.set_float_in_header(Some(value))
   37     49   
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   38     51   
        let input_string = uri.path();
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   39     53   
        let (input_string, (_, m1)) =
   40     54   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     55   
                ::nom::sequence::preceded(
   42     56   
                    ::nom::bytes::complete::tag("/"),
   43     57   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   44     58   
                        "MalformedFloat",
   45     59   
                    ),
   46     60   
                ),
   47     61   
                ::nom::sequence::preceded(
   48     62   
                    ::nom::bytes::complete::tag("/"),
   49     63   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   50     64   
                        ::nom::bytes::complete::take_until("/"),
   51     65   
                        ::nom::combinator::rest,
   52     66   
                    )),
   53     67   
                ),
   54     68   
            ))(input_string)?;
   55     69   
        debug_assert_eq!("", input_string);
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   56     71   
        input = input.set_float_in_path(
   57     72   
            crate::protocol_serde::shape_malformed_float_input::de_float_in_path(m1)?,
   58     73   
        );
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   59     75   
        let query_string = uri.query().unwrap_or("");
   60     76   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   61     78   
        let mut float_in_query_seen = false;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   62     80   
        for (k, v) in pairs {
          81  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   63     82   
            if !float_in_query_seen && k == "floatInQuery" {
   64     83   
                input = input.set_float_in_query(
   65     84   
                    crate::protocol_serde::shape_malformed_float_input::de_float_in_query(&v)?,
   66     85   
                );
   67     86   
                float_in_query_seen = true;
   68     87   
            }
          88  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   69     89   
        }
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   70     91   
        input.build()?
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   71     93   
    })
          94  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   72     95   
}
   73     96   
          97  +
/* RustType.kt:516 */
   74     98   
#[allow(clippy::unnecessary_wraps)]
          99  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   75    100   
pub fn ser_malformed_float_http_response(
   76    101   
    #[allow(unused_variables)] output: crate::output::MalformedFloatOutput,
   77    102   
) -> std::result::Result<
   78    103   
    ::aws_smithy_http_server::response::Response,
   79    104   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    105   
> {
         106  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   81    107   
    Ok({
         108  +
        /* RustType.kt:516 */
   82    109   
        #[allow(unused_mut)]
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   83    111   
        let mut builder = ::http::Response::builder();
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    113   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    114   
            builder,
   86    115   
            ::http::header::CONTENT_TYPE,
   87    116   
            "application/json",
   88    117   
        );
         118  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   89    119   
        let http_status: u16 = 200;
   90    120   
        builder = builder.status(http_status);
   91         -
        let payload = "";
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         122  +
        let payload =
         123  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         124  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         125  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   92    126   
        let content_length = payload.len();
   93    127   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    128   
            builder,
   95    129   
            ::http::header::CONTENT_LENGTH,
   96    130   
            content_length,
   97    131   
        );
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   98    133   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   99    135   
        builder.body(body)?
         136  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  100    137   
    })
         138  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  101    139   
}
  102    140   
         141  +
/* RustType.kt:516 */
  103    142   
#[allow(clippy::unnecessary_wraps)]
         143  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  104    144   
pub fn ser_malformed_float_http_error(
  105    145   
    error: &crate::error::MalformedFloatError,
  106    146   
) -> std::result::Result<
  107    147   
    ::aws_smithy_http_server::response::Response,
  108    148   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  109    149   
> {
         150  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  110    151   
    Ok({
         152  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  111    153   
        match error {
         154  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  112    155   
            crate::error::MalformedFloatError::ValidationException(output) => {
         156  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  113    157   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         158  +
                /* RustType.kt:516 */
  114    159   
                #[allow(unused_mut)]
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  115    161   
                let mut builder = ::http::Response::builder();
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  116    163   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    164   
                    builder,
  118    165   
                    ::http::header::CONTENT_TYPE,
  119    166   
                    "application/json",
  120    167   
                );
         168  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  121    169   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  122    170   
                    builder,
  123    171   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  124    172   
                    "ValidationException",
  125    173   
                );
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  126    175   
                let content_length = payload.len();
  127    176   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  128    177   
                    builder,
  129    178   
                    ::http::header::CONTENT_LENGTH,
  130    179   
                    content_length,
  131    180   
                );
         181  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  132    182   
                builder
  133    183   
                    .status(400)
  134    184   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         185  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  135    186   
            }
         187  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  136    188   
            crate::error::MalformedFloatError::InternalServerError(output) => {
         189  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  137    190   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         191  +
                /* RustType.kt:516 */
  138    192   
                #[allow(unused_mut)]
         193  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  139    194   
                let mut builder = ::http::Response::builder();
         195  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  140    196   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  141    197   
                    builder,
  142    198   
                    ::http::header::CONTENT_TYPE,
  143    199   
                    "application/json",
  144    200   
                );
         201  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  145    202   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  146    203   
                    builder,
  147    204   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  148    205   
                    "InternalServerError",
  149    206   
                );
         207  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  150    208   
                let content_length = payload.len();
  151    209   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  152    210   
                    builder,
  153    211   
                    ::http::header::CONTENT_LENGTH,
  154    212   
                    content_length,
  155    213   
                );
         214  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  156    215   
                builder
  157    216   
                    .status(500)
  158    217   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  159         -
            }
         218  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         219  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  160    220   
        }
         221  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  161    222   
    })
         223  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  162    224   
}
  163    225   
         226  +
/* JsonParserGenerator.kt:148 */
  164    227   
pub(crate) fn de_malformed_float(
  165    228   
    value: &[u8],
  166    229   
    mut builder: crate::input::malformed_float_input_internal::Builder,
  167    230   
) -> ::std::result::Result<
  168    231   
    crate::input::malformed_float_input_internal::Builder,
  169    232   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  170    233   
> {
         234  +
    /* JsonParserGenerator.kt:153 */
  171    235   
    let mut tokens_owned =
  172    236   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  173    237   
            .peekable();
  174    238   
    let tokens = &mut tokens_owned;
  175    239   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         240  +
    /* JsonParserGenerator.kt:684 */
  176    241   
    loop {
         242  +
        /* JsonParserGenerator.kt:685 */
  177    243   
        match tokens.next().transpose()? {
         244  +
            /* JsonParserGenerator.kt:686 */
  178    245   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  179    246   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         247  +
                /* JsonParserGenerator.kt:260 */
  180    248   
                match key.to_unescaped()?.as_ref() {
         249  +
                    /* JsonParserGenerator.kt:262 */
  181    250   
                    "floatInBody" => {
         251  +
                        /* JsonParserGenerator.kt:272 */
  182    252   
                        builder = builder.set_float_in_body(
         253  +
                            /* JsonParserGenerator.kt:361 */
  183    254   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  184    255   
                                tokens.next(),
  185    256   
                            )?
  186         -
                            .map(|v| v.to_f32_lossy()),
         257  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  187    258   
                        );
         259  +
                        /* JsonParserGenerator.kt:262 */
  188    260   
                    }
  189         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         261  +
                    /* JsonParserGenerator.kt:290 */
         262  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  190    263   
                }
         264  +
                /* JsonParserGenerator.kt:686 */
  191    265   
            }
         266  +
            /* JsonParserGenerator.kt:695 */
  192    267   
            other => {
  193    268   
                return Err(
  194    269   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  195    270   
                        "expected object key or end object, found: {:?}",
  196    271   
                        other
  197    272   
                    )),
  198    273   
                )
  199         -
            }
         274  +
            } /* JsonParserGenerator.kt:685 */
  200    275   
        }
         276  +
        /* JsonParserGenerator.kt:684 */
  201    277   
    }
         278  +
    /* JsonParserGenerator.kt:250 */
  202    279   
    if tokens.next().is_some() {
         280  +
        /* JsonParserGenerator.kt:251 */
  203    281   
        return Err(
  204    282   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  205    283   
                "found more JSON tokens after completing parsing",
  206    284   
            ),
  207    285   
        );
         286  +
        /* JsonParserGenerator.kt:250 */
  208    287   
    }
         288  +
    /* JsonParserGenerator.kt:163 */
  209    289   
    Ok(builder)
         290  +
    /* JsonParserGenerator.kt:148 */
  210    291   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_float_input.rs

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_float_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<f32>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("floatInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<f32>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_float_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    f32,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_float_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<f32>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_integer.rs

@@ -1,1 +213,294 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_integer_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedIntegerInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_integer_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_integer::de_malformed_integer(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_integer_input::de_integer_in_header_header(
   35     47   
                &headers,
   36     48   
            )?
   37     49   
        {
   38     50   
            input = input.set_integer_in_header(Some(value))
   39     51   
        }
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   40     53   
        let input_string = uri.path();
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   41     55   
        let (input_string, (_, m1)) =
   42     56   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   43     57   
                ::nom::sequence::preceded(
   44     58   
                    ::nom::bytes::complete::tag("/"),
   45     59   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   46     60   
                        "MalformedInteger",
   47     61   
                    ),
   48     62   
                ),
   49     63   
                ::nom::sequence::preceded(
   50     64   
                    ::nom::bytes::complete::tag("/"),
   51     65   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   52     66   
                        ::nom::bytes::complete::take_until("/"),
   53     67   
                        ::nom::combinator::rest,
   54     68   
                    )),
   55     69   
                ),
   56     70   
            ))(input_string)?;
   57     71   
        debug_assert_eq!("", input_string);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   58     73   
        input = input.set_integer_in_path(
   59     74   
            crate::protocol_serde::shape_malformed_integer_input::de_integer_in_path(m1)?,
   60     75   
        );
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   61     77   
        let query_string = uri.query().unwrap_or("");
   62     78   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   63     80   
        let mut integer_in_query_seen = false;
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   64     82   
        for (k, v) in pairs {
          83  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   65     84   
            if !integer_in_query_seen && k == "integerInQuery" {
   66     85   
                input = input.set_integer_in_query(
   67     86   
                    crate::protocol_serde::shape_malformed_integer_input::de_integer_in_query(&v)?,
   68     87   
                );
   69     88   
                integer_in_query_seen = true;
   70     89   
            }
          90  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   71     91   
        }
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   72     93   
        input.build()?
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   73     95   
    })
          96  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   74     97   
}
   75     98   
          99  +
/* RustType.kt:516 */
   76    100   
#[allow(clippy::unnecessary_wraps)]
         101  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   77    102   
pub fn ser_malformed_integer_http_response(
   78    103   
    #[allow(unused_variables)] output: crate::output::MalformedIntegerOutput,
   79    104   
) -> std::result::Result<
   80    105   
    ::aws_smithy_http_server::response::Response,
   81    106   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   82    107   
> {
         108  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   83    109   
    Ok({
         110  +
        /* RustType.kt:516 */
   84    111   
        #[allow(unused_mut)]
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   85    113   
        let mut builder = ::http::Response::builder();
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   86    115   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    116   
            builder,
   88    117   
            ::http::header::CONTENT_TYPE,
   89    118   
            "application/json",
   90    119   
        );
         120  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   91    121   
        let http_status: u16 = 200;
   92    122   
        builder = builder.status(http_status);
   93         -
        let payload = "";
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         124  +
        let payload =
         125  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         127  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   94    128   
        let content_length = payload.len();
   95    129   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96    130   
            builder,
   97    131   
            ::http::header::CONTENT_LENGTH,
   98    132   
            content_length,
   99    133   
        );
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
  100    135   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         136  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
  101    137   
        builder.body(body)?
         138  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  102    139   
    })
         140  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  103    141   
}
  104    142   
         143  +
/* RustType.kt:516 */
  105    144   
#[allow(clippy::unnecessary_wraps)]
         145  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  106    146   
pub fn ser_malformed_integer_http_error(
  107    147   
    error: &crate::error::MalformedIntegerError,
  108    148   
) -> std::result::Result<
  109    149   
    ::aws_smithy_http_server::response::Response,
  110    150   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  111    151   
> {
         152  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  112    153   
    Ok({
         154  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  113    155   
        match error {
         156  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  114    157   
            crate::error::MalformedIntegerError::ValidationException(output) => {
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  115    159   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         160  +
                /* RustType.kt:516 */
  116    161   
                #[allow(unused_mut)]
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  117    163   
                let mut builder = ::http::Response::builder();
         164  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  118    165   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  119    166   
                    builder,
  120    167   
                    ::http::header::CONTENT_TYPE,
  121    168   
                    "application/json",
  122    169   
                );
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  123    171   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  124    172   
                    builder,
  125    173   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  126    174   
                    "ValidationException",
  127    175   
                );
         176  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  128    177   
                let content_length = payload.len();
  129    178   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    179   
                    builder,
  131    180   
                    ::http::header::CONTENT_LENGTH,
  132    181   
                    content_length,
  133    182   
                );
         183  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  134    184   
                builder
  135    185   
                    .status(400)
  136    186   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         187  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  137    188   
            }
         189  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  138    190   
            crate::error::MalformedIntegerError::InternalServerError(output) => {
         191  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  139    192   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         193  +
                /* RustType.kt:516 */
  140    194   
                #[allow(unused_mut)]
         195  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  141    196   
                let mut builder = ::http::Response::builder();
         197  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  142    198   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  143    199   
                    builder,
  144    200   
                    ::http::header::CONTENT_TYPE,
  145    201   
                    "application/json",
  146    202   
                );
         203  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  147    204   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  148    205   
                    builder,
  149    206   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  150    207   
                    "InternalServerError",
  151    208   
                );
         209  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  152    210   
                let content_length = payload.len();
  153    211   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  154    212   
                    builder,
  155    213   
                    ::http::header::CONTENT_LENGTH,
  156    214   
                    content_length,
  157    215   
                );
         216  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  158    217   
                builder
  159    218   
                    .status(500)
  160    219   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  161         -
            }
         220  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         221  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  162    222   
        }
         223  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  163    224   
    })
         225  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  164    226   
}
  165    227   
         228  +
/* JsonParserGenerator.kt:148 */
  166    229   
pub(crate) fn de_malformed_integer(
  167    230   
    value: &[u8],
  168    231   
    mut builder: crate::input::malformed_integer_input_internal::Builder,
  169    232   
) -> ::std::result::Result<
  170    233   
    crate::input::malformed_integer_input_internal::Builder,
  171    234   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  172    235   
> {
         236  +
    /* JsonParserGenerator.kt:153 */
  173    237   
    let mut tokens_owned =
  174    238   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  175    239   
            .peekable();
  176    240   
    let tokens = &mut tokens_owned;
  177    241   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         242  +
    /* JsonParserGenerator.kt:684 */
  178    243   
    loop {
         244  +
        /* JsonParserGenerator.kt:685 */
  179    245   
        match tokens.next().transpose()? {
         246  +
            /* JsonParserGenerator.kt:686 */
  180    247   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  181    248   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         249  +
                /* JsonParserGenerator.kt:260 */
  182    250   
                match key.to_unescaped()?.as_ref() {
         251  +
                    /* JsonParserGenerator.kt:262 */
  183    252   
                    "integerInBody" => {
         253  +
                        /* JsonParserGenerator.kt:272 */
  184    254   
                        builder = builder.set_integer_in_body(
         255  +
                            /* JsonParserGenerator.kt:365 */
  185    256   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  186    257   
                                tokens.next(),
  187    258   
                            )?
  188    259   
                            .map(i32::try_from)
  189         -
                            .transpose()?,
         260  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  190    261   
                        );
         262  +
                        /* JsonParserGenerator.kt:262 */
  191    263   
                    }
  192         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         264  +
                    /* JsonParserGenerator.kt:290 */
         265  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  193    266   
                }
         267  +
                /* JsonParserGenerator.kt:686 */
  194    268   
            }
         269  +
            /* JsonParserGenerator.kt:695 */
  195    270   
            other => {
  196    271   
                return Err(
  197    272   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  198    273   
                        "expected object key or end object, found: {:?}",
  199    274   
                        other
  200    275   
                    )),
  201    276   
                )
  202         -
            }
         277  +
            } /* JsonParserGenerator.kt:685 */
  203    278   
        }
         279  +
        /* JsonParserGenerator.kt:684 */
  204    280   
    }
         281  +
    /* JsonParserGenerator.kt:250 */
  205    282   
    if tokens.next().is_some() {
         283  +
        /* JsonParserGenerator.kt:251 */
  206    284   
        return Err(
  207    285   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  208    286   
                "found more JSON tokens after completing parsing",
  209    287   
            ),
  210    288   
        );
         289  +
        /* JsonParserGenerator.kt:250 */
  211    290   
    }
         291  +
    /* JsonParserGenerator.kt:163 */
  212    292   
    Ok(builder)
         293  +
    /* JsonParserGenerator.kt:148 */
  213    294   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_integer_input.rs

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_integer_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("integerInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i32>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_integer_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i32,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_integer_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i32>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_list.rs

@@ -1,1 +146,208 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_list_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedListInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_list_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_list::de_malformed_list(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_malformed_list_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedListOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* RustType.kt:516 */
   66     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     98   
pub fn ser_malformed_list_http_error(
   68     99   
    error: &crate::error::MalformedListError,
   69    100   
) -> std::result::Result<
   70    101   
    ::aws_smithy_http_server::response::Response,
   71    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    109   
            crate::error::MalformedListError::InternalServerError(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    111   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         112  +
                /* RustType.kt:516 */
   77    113   
                #[allow(unused_mut)]
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    115   
                let mut builder = ::http::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    118   
                    builder,
   81    119   
                    ::http::header::CONTENT_TYPE,
   82    120   
                    "application/json",
   83    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    124   
                    builder,
   86    125   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    126   
                    "InternalServerError",
   88    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    129   
                let content_length = payload.len();
   90    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    131   
                    builder,
   92    132   
                    ::http::header::CONTENT_LENGTH,
   93    133   
                    content_length,
   94    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    136   
                builder
   96    137   
                    .status(500)
   97    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   98         -
            }
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   99    141   
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    145   
}
  102    146   
         147  +
/* JsonParserGenerator.kt:148 */
  103    148   
pub(crate) fn de_malformed_list(
  104    149   
    value: &[u8],
  105    150   
    mut builder: crate::input::malformed_list_input_internal::Builder,
  106    151   
) -> ::std::result::Result<
  107    152   
    crate::input::malformed_list_input_internal::Builder,
  108    153   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  109    154   
> {
         155  +
    /* JsonParserGenerator.kt:153 */
  110    156   
    let mut tokens_owned =
  111    157   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  112    158   
            .peekable();
  113    159   
    let tokens = &mut tokens_owned;
  114    160   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
  115    162   
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
  116    164   
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
  117    166   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  118    167   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
  119    169   
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
  120    171   
                    "bodyList" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
  121    173   
                        builder = builder.set_body_list(
  122         -
                            crate::protocol_serde::shape_simple_list::de_simple_list(tokens)?,
  123         -
                        );
         174  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_simple_list::de_simple_list(tokens)?
         175  +
                        /* JsonParserGenerator.kt:272 */);
         176  +
                        /* JsonParserGenerator.kt:262 */
  124    177   
                    }
  125         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         178  +
                    /* JsonParserGenerator.kt:290 */
         179  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  126    180   
                }
         181  +
                /* JsonParserGenerator.kt:686 */
  127    182   
            }
         183  +
            /* JsonParserGenerator.kt:695 */
  128    184   
            other => {
  129    185   
                return Err(
  130    186   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  131    187   
                        "expected object key or end object, found: {:?}",
  132    188   
                        other
  133    189   
                    )),
  134    190   
                )
  135         -
            }
         191  +
            } /* JsonParserGenerator.kt:685 */
  136    192   
        }
         193  +
        /* JsonParserGenerator.kt:684 */
  137    194   
    }
         195  +
    /* JsonParserGenerator.kt:250 */
  138    196   
    if tokens.next().is_some() {
         197  +
        /* JsonParserGenerator.kt:251 */
  139    198   
        return Err(
  140    199   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  141    200   
                "found more JSON tokens after completing parsing",
  142    201   
            ),
  143    202   
        );
         203  +
        /* JsonParserGenerator.kt:250 */
  144    204   
    }
         205  +
    /* JsonParserGenerator.kt:163 */
  145    206   
    Ok(builder)
         207  +
    /* JsonParserGenerator.kt:148 */
  146    208   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_long.rs

@@ -1,1 +209,290 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_long_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedLongInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_long_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_long::de_malformed_long(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_long_input::de_long_in_header_header(&headers)?
   35     47   
        {
   36     48   
            input = input.set_long_in_header(Some(value))
   37     49   
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   38     51   
        let input_string = uri.path();
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   39     53   
        let (input_string, (_, m1)) =
   40     54   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     55   
                ::nom::sequence::preceded(
   42     56   
                    ::nom::bytes::complete::tag("/"),
   43     57   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("MalformedLong"),
   44     58   
                ),
   45     59   
                ::nom::sequence::preceded(
   46     60   
                    ::nom::bytes::complete::tag("/"),
   47     61   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   48     62   
                        ::nom::bytes::complete::take_until("/"),
   49     63   
                        ::nom::combinator::rest,
   50     64   
                    )),
   51     65   
                ),
   52     66   
            ))(input_string)?;
   53     67   
        debug_assert_eq!("", input_string);
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   54     69   
        input = input.set_long_in_path(
   55     70   
            crate::protocol_serde::shape_malformed_long_input::de_long_in_path(m1)?,
   56     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   57     73   
        let query_string = uri.query().unwrap_or("");
   58     74   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   59     76   
        let mut long_in_query_seen = false;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   60     78   
        for (k, v) in pairs {
          79  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   61     80   
            if !long_in_query_seen && k == "longInQuery" {
   62     81   
                input = input.set_long_in_query(
   63     82   
                    crate::protocol_serde::shape_malformed_long_input::de_long_in_query(&v)?,
   64     83   
                );
   65     84   
                long_in_query_seen = true;
   66     85   
            }
          86  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   67     87   
        }
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   68     89   
        input.build()?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   69     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   70     93   
}
   71     94   
          95  +
/* RustType.kt:516 */
   72     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   73     98   
pub fn ser_malformed_long_http_response(
   74     99   
    #[allow(unused_variables)] output: crate::output::MalformedLongOutput,
   75    100   
) -> std::result::Result<
   76    101   
    ::aws_smithy_http_server::response::Response,
   77    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   78    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   79    105   
    Ok({
         106  +
        /* RustType.kt:516 */
   80    107   
        #[allow(unused_mut)]
         108  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   81    109   
        let mut builder = ::http::Response::builder();
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   82    111   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    112   
            builder,
   84    113   
            ::http::header::CONTENT_TYPE,
   85    114   
            "application/json",
   86    115   
        );
         116  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   87    117   
        let http_status: u16 = 200;
   88    118   
        builder = builder.status(http_status);
   89         -
        let payload = "";
         119  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         120  +
        let payload =
         121  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         122  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   90    124   
        let content_length = payload.len();
   91    125   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   92    126   
            builder,
   93    127   
            ::http::header::CONTENT_LENGTH,
   94    128   
            content_length,
   95    129   
        );
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   96    131   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   97    133   
        builder.body(body)?
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   98    135   
    })
         136  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   99    137   
}
  100    138   
         139  +
/* RustType.kt:516 */
  101    140   
#[allow(clippy::unnecessary_wraps)]
         141  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  102    142   
pub fn ser_malformed_long_http_error(
  103    143   
    error: &crate::error::MalformedLongError,
  104    144   
) -> std::result::Result<
  105    145   
    ::aws_smithy_http_server::response::Response,
  106    146   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  107    147   
> {
         148  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  108    149   
    Ok({
         150  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  109    151   
        match error {
         152  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  110    153   
            crate::error::MalformedLongError::ValidationException(output) => {
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  111    155   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         156  +
                /* RustType.kt:516 */
  112    157   
                #[allow(unused_mut)]
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  113    159   
                let mut builder = ::http::Response::builder();
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  114    161   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  115    162   
                    builder,
  116    163   
                    ::http::header::CONTENT_TYPE,
  117    164   
                    "application/json",
  118    165   
                );
         166  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  119    167   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  120    168   
                    builder,
  121    169   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  122    170   
                    "ValidationException",
  123    171   
                );
         172  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  124    173   
                let content_length = payload.len();
  125    174   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  126    175   
                    builder,
  127    176   
                    ::http::header::CONTENT_LENGTH,
  128    177   
                    content_length,
  129    178   
                );
         179  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  130    180   
                builder
  131    181   
                    .status(400)
  132    182   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         183  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  133    184   
            }
         185  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  134    186   
            crate::error::MalformedLongError::InternalServerError(output) => {
         187  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  135    188   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         189  +
                /* RustType.kt:516 */
  136    190   
                #[allow(unused_mut)]
         191  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  137    192   
                let mut builder = ::http::Response::builder();
         193  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  138    194   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  139    195   
                    builder,
  140    196   
                    ::http::header::CONTENT_TYPE,
  141    197   
                    "application/json",
  142    198   
                );
         199  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  143    200   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  144    201   
                    builder,
  145    202   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  146    203   
                    "InternalServerError",
  147    204   
                );
         205  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  148    206   
                let content_length = payload.len();
  149    207   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  150    208   
                    builder,
  151    209   
                    ::http::header::CONTENT_LENGTH,
  152    210   
                    content_length,
  153    211   
                );
         212  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  154    213   
                builder
  155    214   
                    .status(500)
  156    215   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  157         -
            }
         216  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         217  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  158    218   
        }
         219  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  159    220   
    })
         221  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  160    222   
}
  161    223   
         224  +
/* JsonParserGenerator.kt:148 */
  162    225   
pub(crate) fn de_malformed_long(
  163    226   
    value: &[u8],
  164    227   
    mut builder: crate::input::malformed_long_input_internal::Builder,
  165    228   
) -> ::std::result::Result<
  166    229   
    crate::input::malformed_long_input_internal::Builder,
  167    230   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  168    231   
> {
         232  +
    /* JsonParserGenerator.kt:153 */
  169    233   
    let mut tokens_owned =
  170    234   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  171    235   
            .peekable();
  172    236   
    let tokens = &mut tokens_owned;
  173    237   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         238  +
    /* JsonParserGenerator.kt:684 */
  174    239   
    loop {
         240  +
        /* JsonParserGenerator.kt:685 */
  175    241   
        match tokens.next().transpose()? {
         242  +
            /* JsonParserGenerator.kt:686 */
  176    243   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  177    244   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         245  +
                /* JsonParserGenerator.kt:260 */
  178    246   
                match key.to_unescaped()?.as_ref() {
         247  +
                    /* JsonParserGenerator.kt:262 */
  179    248   
                    "longInBody" => {
         249  +
                        /* JsonParserGenerator.kt:272 */
  180    250   
                        builder = builder.set_long_in_body(
         251  +
                            /* JsonParserGenerator.kt:365 */
  181    252   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  182    253   
                                tokens.next(),
  183    254   
                            )?
  184    255   
                            .map(i64::try_from)
  185         -
                            .transpose()?,
         256  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  186    257   
                        );
         258  +
                        /* JsonParserGenerator.kt:262 */
  187    259   
                    }
  188         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         260  +
                    /* JsonParserGenerator.kt:290 */
         261  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  189    262   
                }
         263  +
                /* JsonParserGenerator.kt:686 */
  190    264   
            }
         265  +
            /* JsonParserGenerator.kt:695 */
  191    266   
            other => {
  192    267   
                return Err(
  193    268   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  194    269   
                        "expected object key or end object, found: {:?}",
  195    270   
                        other
  196    271   
                    )),
  197    272   
                )
  198         -
            }
         273  +
            } /* JsonParserGenerator.kt:685 */
  199    274   
        }
         275  +
        /* JsonParserGenerator.kt:684 */
  200    276   
    }
         277  +
    /* JsonParserGenerator.kt:250 */
  201    278   
    if tokens.next().is_some() {
         279  +
        /* JsonParserGenerator.kt:251 */
  202    280   
        return Err(
  203    281   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  204    282   
                "found more JSON tokens after completing parsing",
  205    283   
            ),
  206    284   
        );
         285  +
        /* JsonParserGenerator.kt:250 */
  207    286   
    }
         287  +
    /* JsonParserGenerator.kt:163 */
  208    288   
    Ok(builder)
         289  +
    /* JsonParserGenerator.kt:148 */
  209    290   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_long_input.rs

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_long_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i64>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("longInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i64>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_long_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i64,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_long_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i64>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_map.rs

@@ -1,1 +146,208 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_map_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedMapInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_map_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_map::de_malformed_map(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_malformed_map_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedMapOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* RustType.kt:516 */
   66     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     98   
pub fn ser_malformed_map_http_error(
   68     99   
    error: &crate::error::MalformedMapError,
   69    100   
) -> std::result::Result<
   70    101   
    ::aws_smithy_http_server::response::Response,
   71    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    109   
            crate::error::MalformedMapError::InternalServerError(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    111   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         112  +
                /* RustType.kt:516 */
   77    113   
                #[allow(unused_mut)]
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    115   
                let mut builder = ::http::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    118   
                    builder,
   81    119   
                    ::http::header::CONTENT_TYPE,
   82    120   
                    "application/json",
   83    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    124   
                    builder,
   86    125   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    126   
                    "InternalServerError",
   88    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    129   
                let content_length = payload.len();
   90    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    131   
                    builder,
   92    132   
                    ::http::header::CONTENT_LENGTH,
   93    133   
                    content_length,
   94    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    136   
                builder
   96    137   
                    .status(500)
   97    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   98         -
            }
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   99    141   
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    145   
}
  102    146   
         147  +
/* JsonParserGenerator.kt:148 */
  103    148   
pub(crate) fn de_malformed_map(
  104    149   
    value: &[u8],
  105    150   
    mut builder: crate::input::malformed_map_input_internal::Builder,
  106    151   
) -> ::std::result::Result<
  107    152   
    crate::input::malformed_map_input_internal::Builder,
  108    153   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  109    154   
> {
         155  +
    /* JsonParserGenerator.kt:153 */
  110    156   
    let mut tokens_owned =
  111    157   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  112    158   
            .peekable();
  113    159   
    let tokens = &mut tokens_owned;
  114    160   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
  115    162   
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
  116    164   
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
  117    166   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  118    167   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
  119    169   
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
  120    171   
                    "bodyMap" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
  121    173   
                        builder = builder.set_body_map(
  122         -
                            crate::protocol_serde::shape_simple_map::de_simple_map(tokens)?,
  123         -
                        );
         174  +
                            /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_simple_map::de_simple_map(tokens)?
         175  +
                        /* JsonParserGenerator.kt:272 */);
         176  +
                        /* JsonParserGenerator.kt:262 */
  124    177   
                    }
  125         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         178  +
                    /* JsonParserGenerator.kt:290 */
         179  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  126    180   
                }
         181  +
                /* JsonParserGenerator.kt:686 */
  127    182   
            }
         183  +
            /* JsonParserGenerator.kt:695 */
  128    184   
            other => {
  129    185   
                return Err(
  130    186   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  131    187   
                        "expected object key or end object, found: {:?}",
  132    188   
                        other
  133    189   
                    )),
  134    190   
                )
  135         -
            }
         191  +
            } /* JsonParserGenerator.kt:685 */
  136    192   
        }
         193  +
        /* JsonParserGenerator.kt:684 */
  137    194   
    }
         195  +
    /* JsonParserGenerator.kt:250 */
  138    196   
    if tokens.next().is_some() {
         197  +
        /* JsonParserGenerator.kt:251 */
  139    198   
        return Err(
  140    199   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  141    200   
                "found more JSON tokens after completing parsing",
  142    201   
            ),
  143    202   
        );
         203  +
        /* JsonParserGenerator.kt:250 */
  144    204   
    }
         205  +
    /* JsonParserGenerator.kt:163 */
  145    206   
    Ok(builder)
         207  +
    /* JsonParserGenerator.kt:148 */
  146    208   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_request_body.rs

@@ -1,1 +158,225 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_request_body_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedRequestBodyInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_request_body_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_request_body::de_malformed_request_body(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_malformed_request_body_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedRequestBodyOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* RustType.kt:516 */
   66     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     98   
pub fn ser_malformed_request_body_http_error(
   68     99   
    error: &crate::error::MalformedRequestBodyError,
   69    100   
) -> std::result::Result<
   70    101   
    ::aws_smithy_http_server::response::Response,
   71    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    109   
            crate::error::MalformedRequestBodyError::InternalServerError(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    111   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         112  +
                /* RustType.kt:516 */
   77    113   
                #[allow(unused_mut)]
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    115   
                let mut builder = ::http::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    118   
                    builder,
   81    119   
                    ::http::header::CONTENT_TYPE,
   82    120   
                    "application/json",
   83    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    124   
                    builder,
   86    125   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    126   
                    "InternalServerError",
   88    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    129   
                let content_length = payload.len();
   90    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    131   
                    builder,
   92    132   
                    ::http::header::CONTENT_LENGTH,
   93    133   
                    content_length,
   94    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    136   
                builder
   96    137   
                    .status(500)
   97    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   98         -
            }
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   99    141   
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    145   
}
  102    146   
         147  +
/* JsonParserGenerator.kt:148 */
  103    148   
pub(crate) fn de_malformed_request_body(
  104    149   
    value: &[u8],
  105    150   
    mut builder: crate::input::malformed_request_body_input_internal::Builder,
  106    151   
) -> ::std::result::Result<
  107    152   
    crate::input::malformed_request_body_input_internal::Builder,
  108    153   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  109    154   
> {
         155  +
    /* JsonParserGenerator.kt:153 */
  110    156   
    let mut tokens_owned =
  111    157   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  112    158   
            .peekable();
  113    159   
    let tokens = &mut tokens_owned;
  114    160   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
  115    162   
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
  116    164   
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
  117    166   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  118    167   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
  119    169   
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
  120    171   
                    "float" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
  121    173   
                        builder = builder.set_float(
         174  +
                            /* JsonParserGenerator.kt:361 */
  122    175   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  123    176   
                                tokens.next(),
  124    177   
                            )?
  125         -
                            .map(|v| v.to_f32_lossy()),
         178  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  126    179   
                        );
         180  +
                        /* JsonParserGenerator.kt:262 */
  127    181   
                    }
         182  +
                    /* JsonParserGenerator.kt:262 */
  128    183   
                    "int" => {
         184  +
                        /* JsonParserGenerator.kt:272 */
  129    185   
                        builder = builder.set_int(
         186  +
                            /* JsonParserGenerator.kt:365 */
  130    187   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  131    188   
                                tokens.next(),
  132    189   
                            )?
  133    190   
                            .map(i32::try_from)
  134         -
                            .transpose()?,
         191  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  135    192   
                        );
         193  +
                        /* JsonParserGenerator.kt:262 */
  136    194   
                    }
  137         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         195  +
                    /* JsonParserGenerator.kt:290 */
         196  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  138    197   
                }
         198  +
                /* JsonParserGenerator.kt:686 */
  139    199   
            }
         200  +
            /* JsonParserGenerator.kt:695 */
  140    201   
            other => {
  141    202   
                return Err(
  142    203   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  143    204   
                        "expected object key or end object, found: {:?}",
  144    205   
                        other
  145    206   
                    )),
  146    207   
                )
  147         -
            }
         208  +
            } /* JsonParserGenerator.kt:685 */
  148    209   
        }
         210  +
        /* JsonParserGenerator.kt:684 */
  149    211   
    }
         212  +
    /* JsonParserGenerator.kt:250 */
  150    213   
    if tokens.next().is_some() {
         214  +
        /* JsonParserGenerator.kt:251 */
  151    215   
        return Err(
  152    216   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  153    217   
                "found more JSON tokens after completing parsing",
  154    218   
            ),
  155    219   
        );
         220  +
        /* JsonParserGenerator.kt:250 */
  156    221   
    }
         222  +
    /* JsonParserGenerator.kt:163 */
  157    223   
    Ok(builder)
         224  +
    /* JsonParserGenerator.kt:148 */
  158    225   
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_malformed_short.rs

@@ -1,1 +211,292 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_short_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedShortInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_short_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_short::de_malformed_short(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_short_input::de_short_in_header_header(&headers)?
   35     47   
        {
   36     48   
            input = input.set_short_in_header(Some(value))
   37     49   
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   38     51   
        let input_string = uri.path();
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   39     53   
        let (input_string, (_, m1)) =
   40     54   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     55   
                ::nom::sequence::preceded(
   42     56   
                    ::nom::bytes::complete::tag("/"),
   43     57   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   44     58   
                        "MalformedShort",
   45     59   
                    ),
   46     60   
                ),
   47     61   
                ::nom::sequence::preceded(
   48     62   
                    ::nom::bytes::complete::tag("/"),
   49     63   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   50     64   
                        ::nom::bytes::complete::take_until("/"),
   51     65   
                        ::nom::combinator::rest,
   52     66   
                    )),
   53     67   
                ),
   54     68   
            ))(input_string)?;
   55     69   
        debug_assert_eq!("", input_string);
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   56     71   
        input = input.set_short_in_path(
   57     72   
            crate::protocol_serde::shape_malformed_short_input::de_short_in_path(m1)?,
   58     73   
        );
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   59     75   
        let query_string = uri.query().unwrap_or("");
   60     76   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   61     78   
        let mut short_in_query_seen = false;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   62     80   
        for (k, v) in pairs {
          81  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   63     82   
            if !short_in_query_seen && k == "shortInQuery" {
   64     83   
                input = input.set_short_in_query(
   65     84   
                    crate::protocol_serde::shape_malformed_short_input::de_short_in_query(&v)?,
   66     85   
                );
   67     86   
                short_in_query_seen = true;
   68     87   
            }
          88  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   69     89   
        }
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   70     91   
        input.build()?
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   71     93   
    })
          94  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   72     95   
}
   73     96   
          97  +
/* RustType.kt:516 */
   74     98   
#[allow(clippy::unnecessary_wraps)]
          99  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   75    100   
pub fn ser_malformed_short_http_response(
   76    101   
    #[allow(unused_variables)] output: crate::output::MalformedShortOutput,
   77    102   
) -> std::result::Result<
   78    103   
    ::aws_smithy_http_server::response::Response,
   79    104   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    105   
> {
         106  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   81    107   
    Ok({
         108  +
        /* RustType.kt:516 */
   82    109   
        #[allow(unused_mut)]
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   83    111   
        let mut builder = ::http::Response::builder();
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    113   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    114   
            builder,
   86    115   
            ::http::header::CONTENT_TYPE,
   87    116   
            "application/json",
   88    117   
        );
         118  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   89    119   
        let http_status: u16 = 200;
   90    120   
        builder = builder.status(http_status);
   91         -
        let payload = "";
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         122  +
        let payload =
         123  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         124  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         125  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   92    126   
        let content_length = payload.len();
   93    127   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    128   
            builder,
   95    129   
            ::http::header::CONTENT_LENGTH,
   96    130   
            content_length,
   97    131   
        );
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   98    133   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   99    135   
        builder.body(body)?
         136  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  100    137   
    })
         138  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  101    139   
}
  102    140   
         141  +
/* RustType.kt:516 */
  103    142   
#[allow(clippy::unnecessary_wraps)]
         143  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  104    144   
pub fn ser_malformed_short_http_error(
  105    145   
    error: &crate::error::MalformedShortError,
  106    146   
) -> std::result::Result<
  107    147   
    ::aws_smithy_http_server::response::Response,
  108    148   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  109    149   
> {
         150  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  110    151   
    Ok({
         152  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  111    153   
        match error {
         154  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  112    155   
            crate::error::MalformedShortError::ValidationException(output) => {
         156  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  113    157   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         158  +
                /* RustType.kt:516 */
  114    159   
                #[allow(unused_mut)]
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  115    161   
                let mut builder = ::http::Response::builder();
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  116    163   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    164   
                    builder,
  118    165   
                    ::http::header::CONTENT_TYPE,
  119    166   
                    "application/json",
  120    167   
                );
         168  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  121    169   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  122    170   
                    builder,
  123    171   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  124    172   
                    "ValidationException",
  125    173   
                );
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  126    175   
                let content_length = payload.len();
  127    176   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  128    177   
                    builder,
  129    178   
                    ::http::header::CONTENT_LENGTH,
  130    179   
                    content_length,
  131    180   
                );
         181  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  132    182   
                builder
  133    183   
                    .status(400)
  134    184   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         185  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  135    186   
            }
         187  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  136    188   
            crate::error::MalformedShortError::InternalServerError(output) => {
         189  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  137    190   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         191  +
                /* RustType.kt:516 */
  138    192   
                #[allow(unused_mut)]
         193  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  139    194   
                let mut builder = ::http::Response::builder();
         195  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  140    196   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  141    197   
                    builder,
  142    198   
                    ::http::header::CONTENT_TYPE,
  143    199   
                    "application/json",
  144    200   
                );
         201  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  145    202   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  146    203   
                    builder,
  147    204   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  148    205   
                    "InternalServerError",
  149    206   
                );
         207  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  150    208   
                let content_length = payload.len();
  151    209   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  152    210   
                    builder,
  153    211   
                    ::http::header::CONTENT_LENGTH,
  154    212   
                    content_length,
  155    213   
                );
         214  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  156    215   
                builder
  157    216   
                    .status(500)
  158    217   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  159         -
            }
         218  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         219  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  160    220   
        }
         221  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  161    222   
    })
         223  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  162    224   
}
  163    225   
         226  +
/* JsonParserGenerator.kt:148 */
  164    227   
pub(crate) fn de_malformed_short(
  165    228   
    value: &[u8],
  166    229   
    mut builder: crate::input::malformed_short_input_internal::Builder,
  167    230   
) -> ::std::result::Result<
  168    231   
    crate::input::malformed_short_input_internal::Builder,
  169    232   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  170    233   
> {
         234  +
    /* JsonParserGenerator.kt:153 */
  171    235   
    let mut tokens_owned =
  172    236   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  173    237   
            .peekable();
  174    238   
    let tokens = &mut tokens_owned;
  175    239   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         240  +
    /* JsonParserGenerator.kt:684 */
  176    241   
    loop {
         242  +
        /* JsonParserGenerator.kt:685 */
  177    243   
        match tokens.next().transpose()? {
         244  +
            /* JsonParserGenerator.kt:686 */
  178    245   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  179    246   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         247  +
                /* JsonParserGenerator.kt:260 */
  180    248   
                match key.to_unescaped()?.as_ref() {
         249  +
                    /* JsonParserGenerator.kt:262 */
  181    250   
                    "shortInBody" => {
         251  +
                        /* JsonParserGenerator.kt:272 */
  182    252   
                        builder = builder.set_short_in_body(
         253  +
                            /* JsonParserGenerator.kt:365 */
  183    254   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  184    255   
                                tokens.next(),
  185    256   
                            )?
  186    257   
                            .map(i16::try_from)
  187         -
                            .transpose()?,
         258  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  188    259   
                        );
         260  +
                        /* JsonParserGenerator.kt:262 */
  189    261   
                    }
  190         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         262  +
                    /* JsonParserGenerator.kt:290 */
         263  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  191    264   
                }
         265  +
                /* JsonParserGenerator.kt:686 */
  192    266   
            }
         267  +
            /* JsonParserGenerator.kt:695 */
  193    268   
            other => {
  194    269   
                return Err(
  195    270   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  196    271   
                        "expected object key or end object, found: {:?}",
  197    272   
                        other
  198    273   
                    )),
  199    274   
                )
  200         -
            }
         275  +
            } /* JsonParserGenerator.kt:685 */
  201    276   
        }
         277  +
        /* JsonParserGenerator.kt:684 */
  202    278   
    }
         279  +
    /* JsonParserGenerator.kt:250 */
  203    280   
    if tokens.next().is_some() {
         281  +
        /* JsonParserGenerator.kt:251 */
  204    282   
        return Err(
  205    283   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  206    284   
                "found more JSON tokens after completing parsing",
  207    285   
            ),
  208    286   
        );
         287  +
        /* JsonParserGenerator.kt:250 */
  209    288   
    }
         289  +
    /* JsonParserGenerator.kt:163 */
  210    290   
    Ok(builder)
         291  +
    /* JsonParserGenerator.kt:148 */
  211    292   
}