Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +93,132 @@
    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_no_input_and_output_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NoInputAndOutputInput,
    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::no_input_and_output_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:811 */
   22     30   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   23     32   
        input.build()
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   24     34   
    })
          35  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   25     36   
}
   26     37   
          38  +
/* RustType.kt:516 */
   27     39   
#[allow(clippy::unnecessary_wraps)]
          40  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   28     41   
pub fn ser_no_input_and_output_http_response(
   29     42   
    #[allow(unused_variables)] output: crate::output::NoInputAndOutputOutput,
   30     43   
) -> std::result::Result<
   31     44   
    ::aws_smithy_http_server::response::Response,
   32     45   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   33     46   
> {
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   34     48   
    Ok({
          49  +
        /* RustType.kt:516 */
   35     50   
        #[allow(unused_mut)]
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   36     52   
        let mut builder = ::http::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   37     54   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   38     55   
            builder,
   39     56   
            ::http::header::CONTENT_TYPE,
   40     57   
            "application/json",
   41     58   
        );
          59  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   42     60   
        let http_status: u16 = 200;
   43     61   
        builder = builder.status(http_status);
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   44     63   
        let payload =
   45         -
            crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
   46         -
        ;
          64  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   47     67   
        let content_length = payload.len();
   48     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     69   
            builder,
   50     70   
            ::http::header::CONTENT_LENGTH,
   51     71   
            content_length,
   52     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   53     74   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   54     76   
        builder.body(body)?
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   55     78   
    })
          79  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   56     80   
}
   57     81   
          82  +
/* RustType.kt:516 */
   58     83   
#[allow(clippy::unnecessary_wraps)]
          84  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   59     85   
pub fn ser_no_input_and_output_http_error(
   60     86   
    error: &crate::error::NoInputAndOutputError,
   61     87   
) -> std::result::Result<
   62     88   
    ::aws_smithy_http_server::response::Response,
   63     89   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   64     90   
> {
          91  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   65     92   
    Ok({
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   66     94   
        match error {
          95  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   67     96   
            crate::error::NoInputAndOutputError::InternalServerError(output) => {
          97  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   68     98   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
          99  +
                /* RustType.kt:516 */
   69    100   
                #[allow(unused_mut)]
         101  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   70    102   
                let mut builder = ::http::Response::builder();
         103  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   71    104   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   72    105   
                    builder,
   73    106   
                    ::http::header::CONTENT_TYPE,
   74    107   
                    "application/json",
   75    108   
                );
         109  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   76    110   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    111   
                    builder,
   78    112   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   79    113   
                    "InternalServerError",
   80    114   
                );
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   81    116   
                let content_length = payload.len();
   82    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    118   
                    builder,
   84    119   
                    ::http::header::CONTENT_LENGTH,
   85    120   
                    content_length,
   86    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   87    123   
                builder
   88    124   
                    .status(500)
   89    125   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         127  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   90    128   
        }
   91         -
        }
         129  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   92    130   
    })
         131  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
   93    132   
}

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

@@ -1,1 +20,28 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_no_input_and_output_output_output_output(
    3      4   
    value: &crate::output::NoInputAndOutputOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_no_input_and_output_output_output(
   16     22   
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    #[allow(unused_variables)] input: &crate::output::NoInputAndOutputOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:372 */
   19     26   
    Ok(())
          27  +
    /* JsonSerializerGenerator.kt:358 */
   20     28   
}

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

@@ -1,1 +167,232 @@
    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_null_and_empty_headers_client_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NullAndEmptyHeadersClientInput,
    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::null_and_empty_headers_client_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   
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_a_header(&headers)?
   25     33   
        {
   26     34   
            input = input.set_a(Some(value))
   27     35   
        }
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   28     37   
        if let Some(value) =
   29     38   
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_b_header(&headers)?
   30     39   
        {
   31     40   
            input = input.set_b(Some(value))
   32     41   
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     43   
        if let Some(value) =
   34     44   
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_c_header(&headers)?
   35     45   
        {
   36     46   
            input = input.set_c(Some(value))
   37     47   
        }
          48  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   38     49   
        input.build()
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   39     51   
    })
          52  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   40     53   
}
   41     54   
          55  +
/* RustType.kt:516 */
   42     56   
#[allow(clippy::unnecessary_wraps)]
          57  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   43     58   
pub fn ser_null_and_empty_headers_client_http_response(
   44     59   
    #[allow(unused_variables)] output: crate::output::NullAndEmptyHeadersClientOutput,
   45     60   
) -> std::result::Result<
   46     61   
    ::aws_smithy_http_server::response::Response,
   47     62   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   48     63   
> {
          64  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   49     65   
    Ok({
          66  +
        /* RustType.kt:516 */
   50     67   
        #[allow(unused_mut)]
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   51     69   
        let mut builder = ::http::Response::builder();
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:629 */
   52     71   
        builder = crate::protocol_serde::shape_null_and_empty_headers_client::ser_null_and_empty_headers_client_headers(&output, builder)?;
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   53     73   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   54     74   
            builder,
   55     75   
            ::http::header::CONTENT_TYPE,
   56     76   
            "application/json",
   57     77   
        );
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   58     79   
        let http_status: u16 = 200;
   59     80   
        builder = builder.status(http_status);
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   60     82   
        let payload =
   61         -
            crate::protocol_serde::shape_null_and_empty_headers_client_output::ser_null_and_empty_headers_client_output_output_output(&output)?
   62         -
        ;
          83  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_null_and_empty_headers_client_output::ser_null_and_empty_headers_client_output_output_output(&output)?
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   63     86   
        let content_length = payload.len();
   64     87   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   65     88   
            builder,
   66     89   
            ::http::header::CONTENT_LENGTH,
   67     90   
            content_length,
   68     91   
        );
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   69     93   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   70     95   
        builder.body(body)?
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   71     97   
    })
          98  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   72     99   
}
   73    100   
         101  +
/* RustType.kt:516 */
   74    102   
#[allow(clippy::unnecessary_wraps)]
         103  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   75    104   
pub fn ser_null_and_empty_headers_client_http_error(
   76    105   
    error: &crate::error::NullAndEmptyHeadersClientError,
   77    106   
) -> std::result::Result<
   78    107   
    ::aws_smithy_http_server::response::Response,
   79    108   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    109   
> {
         110  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   81    111   
    Ok({
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   82    113   
        match error {
         114  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   83    115   
            crate::error::NullAndEmptyHeadersClientError::InternalServerError(output) => {
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   84    117   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         118  +
                /* RustType.kt:516 */
   85    119   
                #[allow(unused_mut)]
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   86    121   
                let mut builder = ::http::Response::builder();
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   87    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    124   
                    builder,
   89    125   
                    ::http::header::CONTENT_TYPE,
   90    126   
                    "application/json",
   91    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   92    129   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   93    130   
                    builder,
   94    131   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   95    132   
                    "InternalServerError",
   96    133   
                );
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   97    135   
                let content_length = payload.len();
   98    136   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   99    137   
                    builder,
  100    138   
                    ::http::header::CONTENT_LENGTH,
  101    139   
                    content_length,
  102    140   
                );
         141  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  103    142   
                builder
  104    143   
                    .status(500)
  105    144   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         145  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         146  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  106    147   
        }
  107         -
        }
         148  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  108    149   
    })
         150  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  109    151   
}
  110    152   
         153  +
/* HttpBindingGenerator.kt:542 */
  111    154   
pub fn ser_null_and_empty_headers_client_headers(
  112    155   
    input: &crate::output::NullAndEmptyHeadersClientOutput,
  113    156   
    mut builder: ::http::response::Builder,
  114    157   
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
  115    158   
{
         159  +
    /* HttpBindingGenerator.kt:592 */
  116    160   
    if let ::std::option::Option::Some(inner_1) = &input.a {
         161  +
        /* HttpBindingGenerator.kt:704 */
  117    162   
        let formatted_2 = inner_1.as_str();
         163  +
        /* HttpBindingGenerator.kt:705 */
  118    164   
        if !formatted_2.is_empty() {
         165  +
            /* HttpBindingGenerator.kt:706 */
  119    166   
            let header_value = formatted_2;
  120    167   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  121    168   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  122    169   
                    "a",
  123    170   
                    format!(
  124    171   
                        "`{}` cannot be used as a header value: {}",
  125    172   
                        &header_value, err
  126    173   
                    ),
  127    174   
                )
  128    175   
            })?;
  129    176   
            builder = builder.header("X-A", header_value);
         177  +
            /* HttpBindingGenerator.kt:705 */
  130    178   
        }
         179  +
        /* HttpBindingGenerator.kt:592 */
  131    180   
    }
         181  +
    /* HttpBindingGenerator.kt:592 */
  132    182   
    if let ::std::option::Option::Some(inner_3) = &input.b {
         183  +
        /* HttpBindingGenerator.kt:704 */
  133    184   
        let formatted_4 = inner_3.as_str();
         185  +
        /* HttpBindingGenerator.kt:705 */
  134    186   
        if !formatted_4.is_empty() {
         187  +
            /* HttpBindingGenerator.kt:706 */
  135    188   
            let header_value = formatted_4;
  136    189   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  137    190   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  138    191   
                    "b",
  139    192   
                    format!(
  140    193   
                        "`{}` cannot be used as a header value: {}",
  141    194   
                        &header_value, err
  142    195   
                    ),
  143    196   
                )
  144    197   
            })?;
  145    198   
            builder = builder.header("X-B", header_value);
         199  +
            /* HttpBindingGenerator.kt:705 */
  146    200   
        }
         201  +
        /* HttpBindingGenerator.kt:592 */
  147    202   
    }
         203  +
    /* HttpBindingGenerator.kt:592 */
  148    204   
    if let ::std::option::Option::Some(inner_5) = &input.c {
         205  +
        /* HttpBindingGenerator.kt:646 */
  149    206   
        for inner_6 in inner_5 {
         207  +
            /* HttpBindingGenerator.kt:704 */
  150    208   
            let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
         209  +
            /* HttpBindingGenerator.kt:705 */
  151    210   
            if !formatted_7.is_empty() {
         211  +
                /* HttpBindingGenerator.kt:706 */
  152    212   
                let header_value = formatted_7;
  153    213   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  154    214   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  155    215   
                        "c",
  156    216   
                        format!(
  157    217   
                            "`{}` cannot be used as a header value: {}",
  158    218   
                            &header_value, err
  159    219   
                        ),
  160    220   
                    )
  161    221   
                })?;
  162    222   
                builder = builder.header("X-C", header_value);
         223  +
                /* HttpBindingGenerator.kt:705 */
  163    224   
            }
         225  +
            /* HttpBindingGenerator.kt:646 */
  164    226   
        }
         227  +
        /* HttpBindingGenerator.kt:592 */
  165    228   
    }
         229  +
    /* HttpBindingGenerator.kt:555 */
  166    230   
    Ok(builder)
         231  +
    /* HttpBindingGenerator.kt:542 */
  167    232   
}

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

@@ -1,1 +31,44 @@
    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_a_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:160 */
    8     10   
    let headers = header_map.get_all("X-A");
          11  +
    /* HttpBindingGenerator.kt:375 */
    9     12   
    ::aws_smithy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:153 */
   10     14   
}
   11     15   
          16  +
/* HttpBindingGenerator.kt:153 */
   12     17   
pub(crate) fn de_b_header(
   13     18   
    header_map: &::aws_smithy_runtime_api::http::Headers,
   14     19   
) -> ::std::result::Result<
   15     20   
    ::std::option::Option<::std::string::String>,
   16     21   
    ::aws_smithy_http::header::ParseError,
   17     22   
> {
          23  +
    /* HttpBindingGenerator.kt:160 */
   18     24   
    let headers = header_map.get_all("X-B");
          25  +
    /* HttpBindingGenerator.kt:375 */
   19     26   
    ::aws_smithy_http::header::one_or_none(headers)
          27  +
    /* HttpBindingGenerator.kt:153 */
   20     28   
}
   21     29   
          30  +
/* HttpBindingGenerator.kt:153 */
   22     31   
pub(crate) fn de_c_header(
   23     32   
    header_map: &::aws_smithy_runtime_api::http::Headers,
   24     33   
) -> ::std::result::Result<
   25     34   
    ::std::option::Option<::std::vec::Vec<::std::string::String>>,
   26     35   
    ::aws_smithy_http::header::ParseError,
   27     36   
> {
          37  +
    /* HttpBindingGenerator.kt:160 */
   28     38   
    let headers = header_map.get_all("X-C");
          39  +
    /* HttpBindingGenerator.kt:409 */
   29     40   
    let var_1: Vec<::std::string::String> = ::aws_smithy_http::header::read_many_from_str(headers)?;
          41  +
    /* HttpBindingGenerator.kt:430 */
   30     42   
    Ok(if !var_1.is_empty() { Some(var_1) } else { None })
          43  +
    /* HttpBindingGenerator.kt:153 */
   31     44   
}

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

@@ -1,1 +17,25 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_null_and_empty_headers_client_output_output_output(
    3      4   
    value: &crate::output::NullAndEmptyHeadersClientOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_null_and_empty_headers_client_output::ser_null_and_empty_headers_client_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_null_and_empty_headers_client_output_output(
   13     19   
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    #[allow(unused_variables)] input: &crate::output::NullAndEmptyHeadersClientOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:372 */
   16     23   
    Ok(())
          24  +
    /* JsonSerializerGenerator.kt:358 */
   17     25   
}

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

@@ -1,1 +167,232 @@
    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_null_and_empty_headers_server_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NullAndEmptyHeadersServerInput,
    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::null_and_empty_headers_server_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   
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_a_header(&headers)?
   25     33   
        {
   26     34   
            input = input.set_a(Some(value))
   27     35   
        }
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   28     37   
        if let Some(value) =
   29     38   
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_b_header(&headers)?
   30     39   
        {
   31     40   
            input = input.set_b(Some(value))
   32     41   
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     43   
        if let Some(value) =
   34     44   
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_c_header(&headers)?
   35     45   
        {
   36     46   
            input = input.set_c(Some(value))
   37     47   
        }
          48  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   38     49   
        input.build()
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   39     51   
    })
          52  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   40     53   
}
   41     54   
          55  +
/* RustType.kt:516 */
   42     56   
#[allow(clippy::unnecessary_wraps)]
          57  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   43     58   
pub fn ser_null_and_empty_headers_server_http_response(
   44     59   
    #[allow(unused_variables)] output: crate::output::NullAndEmptyHeadersServerOutput,
   45     60   
) -> std::result::Result<
   46     61   
    ::aws_smithy_http_server::response::Response,
   47     62   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   48     63   
> {
          64  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   49     65   
    Ok({
          66  +
        /* RustType.kt:516 */
   50     67   
        #[allow(unused_mut)]
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   51     69   
        let mut builder = ::http::Response::builder();
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:629 */
   52     71   
        builder = crate::protocol_serde::shape_null_and_empty_headers_server::ser_null_and_empty_headers_server_headers(&output, builder)?;
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   53     73   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   54     74   
            builder,
   55     75   
            ::http::header::CONTENT_TYPE,
   56     76   
            "application/json",
   57     77   
        );
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   58     79   
        let http_status: u16 = 200;
   59     80   
        builder = builder.status(http_status);
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   60     82   
        let payload =
   61         -
            crate::protocol_serde::shape_null_and_empty_headers_server_output::ser_null_and_empty_headers_server_output_output_output(&output)?
   62         -
        ;
          83  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_null_and_empty_headers_server_output::ser_null_and_empty_headers_server_output_output_output(&output)?
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   63     86   
        let content_length = payload.len();
   64     87   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   65     88   
            builder,
   66     89   
            ::http::header::CONTENT_LENGTH,
   67     90   
            content_length,
   68     91   
        );
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   69     93   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   70     95   
        builder.body(body)?
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   71     97   
    })
          98  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   72     99   
}
   73    100   
         101  +
/* RustType.kt:516 */
   74    102   
#[allow(clippy::unnecessary_wraps)]
         103  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   75    104   
pub fn ser_null_and_empty_headers_server_http_error(
   76    105   
    error: &crate::error::NullAndEmptyHeadersServerError,
   77    106   
) -> std::result::Result<
   78    107   
    ::aws_smithy_http_server::response::Response,
   79    108   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    109   
> {
         110  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   81    111   
    Ok({
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   82    113   
        match error {
         114  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   83    115   
            crate::error::NullAndEmptyHeadersServerError::InternalServerError(output) => {
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   84    117   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         118  +
                /* RustType.kt:516 */
   85    119   
                #[allow(unused_mut)]
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   86    121   
                let mut builder = ::http::Response::builder();
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   87    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    124   
                    builder,
   89    125   
                    ::http::header::CONTENT_TYPE,
   90    126   
                    "application/json",
   91    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   92    129   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   93    130   
                    builder,
   94    131   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   95    132   
                    "InternalServerError",
   96    133   
                );
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   97    135   
                let content_length = payload.len();
   98    136   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   99    137   
                    builder,
  100    138   
                    ::http::header::CONTENT_LENGTH,
  101    139   
                    content_length,
  102    140   
                );
         141  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  103    142   
                builder
  104    143   
                    .status(500)
  105    144   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         145  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         146  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  106    147   
        }
  107         -
        }
         148  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  108    149   
    })
         150  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  109    151   
}
  110    152   
         153  +
/* HttpBindingGenerator.kt:542 */
  111    154   
pub fn ser_null_and_empty_headers_server_headers(
  112    155   
    input: &crate::output::NullAndEmptyHeadersServerOutput,
  113    156   
    mut builder: ::http::response::Builder,
  114    157   
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
  115    158   
{
         159  +
    /* HttpBindingGenerator.kt:592 */
  116    160   
    if let ::std::option::Option::Some(inner_1) = &input.a {
         161  +
        /* HttpBindingGenerator.kt:704 */
  117    162   
        let formatted_2 = inner_1.as_str();
         163  +
        /* HttpBindingGenerator.kt:705 */
  118    164   
        if !formatted_2.is_empty() {
         165  +
            /* HttpBindingGenerator.kt:706 */
  119    166   
            let header_value = formatted_2;
  120    167   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  121    168   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  122    169   
                    "a",
  123    170   
                    format!(
  124    171   
                        "`{}` cannot be used as a header value: {}",
  125    172   
                        &header_value, err
  126    173   
                    ),
  127    174   
                )
  128    175   
            })?;
  129    176   
            builder = builder.header("X-A", header_value);
         177  +
            /* HttpBindingGenerator.kt:705 */
  130    178   
        }
         179  +
        /* HttpBindingGenerator.kt:592 */
  131    180   
    }
         181  +
    /* HttpBindingGenerator.kt:592 */
  132    182   
    if let ::std::option::Option::Some(inner_3) = &input.b {
         183  +
        /* HttpBindingGenerator.kt:704 */
  133    184   
        let formatted_4 = inner_3.as_str();
         185  +
        /* HttpBindingGenerator.kt:705 */
  134    186   
        if !formatted_4.is_empty() {
         187  +
            /* HttpBindingGenerator.kt:706 */
  135    188   
            let header_value = formatted_4;
  136    189   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  137    190   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  138    191   
                    "b",
  139    192   
                    format!(
  140    193   
                        "`{}` cannot be used as a header value: {}",
  141    194   
                        &header_value, err
  142    195   
                    ),
  143    196   
                )
  144    197   
            })?;
  145    198   
            builder = builder.header("X-B", header_value);
         199  +
            /* HttpBindingGenerator.kt:705 */
  146    200   
        }
         201  +
        /* HttpBindingGenerator.kt:592 */
  147    202   
    }
         203  +
    /* HttpBindingGenerator.kt:592 */
  148    204   
    if let ::std::option::Option::Some(inner_5) = &input.c {
         205  +
        /* HttpBindingGenerator.kt:646 */
  149    206   
        for inner_6 in inner_5 {
         207  +
            /* HttpBindingGenerator.kt:704 */
  150    208   
            let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
         209  +
            /* HttpBindingGenerator.kt:705 */
  151    210   
            if !formatted_7.is_empty() {
         211  +
                /* HttpBindingGenerator.kt:706 */
  152    212   
                let header_value = formatted_7;
  153    213   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  154    214   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  155    215   
                        "c",
  156    216   
                        format!(
  157    217   
                            "`{}` cannot be used as a header value: {}",
  158    218   
                            &header_value, err
  159    219   
                        ),
  160    220   
                    )
  161    221   
                })?;
  162    222   
                builder = builder.header("X-C", header_value);
         223  +
                /* HttpBindingGenerator.kt:705 */
  163    224   
            }
         225  +
            /* HttpBindingGenerator.kt:646 */
  164    226   
        }
         227  +
        /* HttpBindingGenerator.kt:592 */
  165    228   
    }
         229  +
    /* HttpBindingGenerator.kt:555 */
  166    230   
    Ok(builder)
         231  +
    /* HttpBindingGenerator.kt:542 */
  167    232   
}

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

@@ -1,1 +31,44 @@
    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_a_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:160 */
    8     10   
    let headers = header_map.get_all("X-A");
          11  +
    /* HttpBindingGenerator.kt:375 */
    9     12   
    ::aws_smithy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:153 */
   10     14   
}
   11     15   
          16  +
/* HttpBindingGenerator.kt:153 */
   12     17   
pub(crate) fn de_b_header(
   13     18   
    header_map: &::aws_smithy_runtime_api::http::Headers,
   14     19   
) -> ::std::result::Result<
   15     20   
    ::std::option::Option<::std::string::String>,
   16     21   
    ::aws_smithy_http::header::ParseError,
   17     22   
> {
          23  +
    /* HttpBindingGenerator.kt:160 */
   18     24   
    let headers = header_map.get_all("X-B");
          25  +
    /* HttpBindingGenerator.kt:375 */
   19     26   
    ::aws_smithy_http::header::one_or_none(headers)
          27  +
    /* HttpBindingGenerator.kt:153 */
   20     28   
}
   21     29   
          30  +
/* HttpBindingGenerator.kt:153 */
   22     31   
pub(crate) fn de_c_header(
   23     32   
    header_map: &::aws_smithy_runtime_api::http::Headers,
   24     33   
) -> ::std::result::Result<
   25     34   
    ::std::option::Option<::std::vec::Vec<::std::string::String>>,
   26     35   
    ::aws_smithy_http::header::ParseError,
   27     36   
> {
          37  +
    /* HttpBindingGenerator.kt:160 */
   28     38   
    let headers = header_map.get_all("X-C");
          39  +
    /* HttpBindingGenerator.kt:409 */
   29     40   
    let var_1: Vec<::std::string::String> = ::aws_smithy_http::header::read_many_from_str(headers)?;
          41  +
    /* HttpBindingGenerator.kt:430 */
   30     42   
    Ok(if !var_1.is_empty() { Some(var_1) } else { None })
          43  +
    /* HttpBindingGenerator.kt:153 */
   31     44   
}

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

@@ -1,1 +17,25 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_null_and_empty_headers_server_output_output_output(
    3      4   
    value: &crate::output::NullAndEmptyHeadersServerOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_null_and_empty_headers_server_output::ser_null_and_empty_headers_server_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_null_and_empty_headers_server_output_output(
   13     19   
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    #[allow(unused_variables)] input: &crate::output::NullAndEmptyHeadersServerOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:372 */
   16     23   
    Ok(())
          24  +
    /* JsonSerializerGenerator.kt:358 */
   17     25   
}

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

@@ -1,1 +109,156 @@
    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_omits_null_serializes_empty_string_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OmitsNullSerializesEmptyStringInput,
    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::omits_null_serializes_empty_string_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:1073 */
   23     31   
        let query_string = uri.query().unwrap_or("");
   24     32   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   25     34   
        let mut empty_string_seen = false;
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   26     36   
        let mut null_value_seen = false;
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   27     38   
        for (k, v) in pairs {
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   28     40   
            if !empty_string_seen && k == "Empty" {
   29     41   
                input = input.set_empty_string(
   30     42   
                    crate::protocol_serde::shape_omits_null_serializes_empty_string_input::de_empty_string(&v)?
   31     43   
                );
   32     44   
                empty_string_seen = true;
   33     45   
            }
          46  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   34     47   
            if !null_value_seen && k == "Null" {
   35     48   
                input = input.set_null_value(
   36     49   
                    crate::protocol_serde::shape_omits_null_serializes_empty_string_input::de_null_value(&v)?
   37     50   
                );
   38     51   
                null_value_seen = true;
   39     52   
            }
          53  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   40     54   
        }
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   41     56   
        input.build()
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   42     58   
    })
          59  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   43     60   
}
   44     61   
          62  +
/* RustType.kt:516 */
   45     63   
#[allow(clippy::unnecessary_wraps)]
          64  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   46     65   
pub fn ser_omits_null_serializes_empty_string_http_response(
   47     66   
    #[allow(unused_variables)] output: crate::output::OmitsNullSerializesEmptyStringOutput,
   48     67   
) -> std::result::Result<
   49     68   
    ::aws_smithy_http_server::response::Response,
   50     69   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   51     70   
> {
          71  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   52     72   
    Ok({
          73  +
        /* RustType.kt:516 */
   53     74   
        #[allow(unused_mut)]
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   54     76   
        let mut builder = ::http::Response::builder();
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   55     78   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   56     79   
            builder,
   57     80   
            ::http::header::CONTENT_TYPE,
   58     81   
            "application/json",
   59     82   
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   60     84   
        let http_status: u16 = 200;
   61     85   
        builder = builder.status(http_status);
   62         -
        let payload = "";
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          87  +
        let payload =
          88  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   63     91   
        let content_length = payload.len();
   64     92   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   65     93   
            builder,
   66     94   
            ::http::header::CONTENT_LENGTH,
   67     95   
            content_length,
   68     96   
        );
          97  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   69     98   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          99  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   70    100   
        builder.body(body)?
         101  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   71    102   
    })
         103  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   72    104   
}
   73    105   
         106  +
/* RustType.kt:516 */
   74    107   
#[allow(clippy::unnecessary_wraps)]
         108  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   75    109   
pub fn ser_omits_null_serializes_empty_string_http_error(
   76    110   
    error: &crate::error::OmitsNullSerializesEmptyStringError,
   77    111   
) -> std::result::Result<
   78    112   
    ::aws_smithy_http_server::response::Response,
   79    113   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    114   
> {
         115  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   81    116   
    Ok({
         117  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   82    118   
        match error {
         119  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   83    120   
            crate::error::OmitsNullSerializesEmptyStringError::InternalServerError(output) => {
         121  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   84    122   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         123  +
                /* RustType.kt:516 */
   85    124   
                #[allow(unused_mut)]
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   86    126   
                let mut builder = ::http::Response::builder();
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   87    128   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    129   
                    builder,
   89    130   
                    ::http::header::CONTENT_TYPE,
   90    131   
                    "application/json",
   91    132   
                );
         133  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   92    134   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   93    135   
                    builder,
   94    136   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   95    137   
                    "InternalServerError",
   96    138   
                );
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   97    140   
                let content_length = payload.len();
   98    141   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   99    142   
                    builder,
  100    143   
                    ::http::header::CONTENT_LENGTH,
  101    144   
                    content_length,
  102    145   
                );
         146  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  103    147   
                builder
  104    148   
                    .status(500)
  105    149   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         150  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         151  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  106    152   
        }
  107         -
        }
         153  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  108    154   
    })
         155  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  109    156   
}

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

@@ -1,1 +20,28 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
    2      3   
pub fn de_empty_string(
    3      4   
    value: &str,
    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  +
    /* ServerHttpBoundProtocolGenerator.kt:1309 */
    8     10   
    let value = value.to_owned();
          11  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
    9     12   
    Ok(Some(value))
          13  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   10     14   
}
   11     15   
          16  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   12     17   
pub fn de_null_value(
   13     18   
    value: &str,
   14     19   
) -> std::result::Result<
   15     20   
    ::std::option::Option<::std::string::String>,
   16     21   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   17     22   
> {
          23  +
    /* ServerHttpBoundProtocolGenerator.kt:1309 */
   18     24   
    let value = value.to_owned();
          25  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   19     26   
    Ok(Some(value))
          27  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   20     28   
}

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

@@ -1,1 +177,330 @@
    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_omits_serializing_empty_lists_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OmitsSerializingEmptyListsInput,
    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::omits_serializing_empty_lists_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:1073 */
   23     31   
        let query_string = uri.query().unwrap_or("");
   24     32   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   25     34   
        let mut query_boolean_list = Vec::new();
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   26     36   
        let mut query_double_list = Vec::new();
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   27     38   
        let mut query_enum_list = Vec::new();
          39  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   28     40   
        let mut query_integer_enum_list = Vec::new();
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   29     42   
        let mut query_integer_list = Vec::new();
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   30     44   
        let mut query_string_list = Vec::new();
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:1102 */
   31     46   
        let mut query_timestamp_list = Vec::new();
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   32     48   
        for (k, v) in pairs {
          49  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
   33     50   
            if k == "BooleanList" {
          51  +
                /* ServerHttpBoundProtocolGenerator.kt:1159 */
   34     52   
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          53  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   35     54   
                query_boolean_list.push(v);
   36         -
            } else if k == "DoubleList" {
          55  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          56  +
            }
          57  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          58  +
            else if k == "DoubleList" {
          59  +
                /* ServerHttpBoundProtocolGenerator.kt:1159 */
   37     60   
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          61  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   38     62   
                query_double_list.push(v);
   39         -
            } else if k == "EnumList" {
          63  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          64  +
            }
          65  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          66  +
            else if k == "EnumList" {
          67  +
                /* ServerHttpBoundProtocolGenerator.kt:1134 */
   40     68   
                let v = v.into_owned();
          69  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   41     70   
                query_enum_list.push(v);
   42         -
            } else if k == "IntegerEnumList" {
          71  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          72  +
            }
          73  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          74  +
            else if k == "IntegerEnumList" {
          75  +
                /* ServerHttpBoundProtocolGenerator.kt:1159 */
   43     76   
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          77  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   44     78   
                query_integer_enum_list.push(v);
   45         -
            } else if k == "IntegerList" {
          79  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          80  +
            }
          81  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          82  +
            else if k == "IntegerList" {
          83  +
                /* ServerHttpBoundProtocolGenerator.kt:1159 */
   46     84   
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          85  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   47     86   
                query_integer_list.push(v);
   48         -
            } else if k == "StringList" {
          87  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          88  +
            }
          89  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          90  +
            else if k == "StringList" {
          91  +
                /* ServerHttpBoundProtocolGenerator.kt:1134 */
   49     92   
                let v = v.into_owned();
          93  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   50     94   
                query_string_list.push(v);
   51         -
            } else if k == "TimestampList" {
   52         -
                let v = ::aws_smithy_types::DateTime::from_str(
   53         -
                    &v,
   54         -
                    ::aws_smithy_types::date_time::Format::DateTime,
   55         -
                )?
   56         -
                .into();
          95  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          96  +
            }
          97  +
            /* ServerHttpBoundProtocolGenerator.kt:1122 */
          98  +
            else if k == "TimestampList" {
          99  +
                /* ServerHttpBoundProtocolGenerator.kt:1146 */
         100  +
                let v = ::aws_smithy_types::DateTime::from_str(&v, ::aws_smithy_types::date_time::Format::DateTime)?
         101  +
                /* PythonServerProtocolLoader.kt:68 */.into()
         102  +
                /* ServerHttpBoundProtocolGenerator.kt:1156 */;
         103  +
                /* ServerHttpBoundProtocolGenerator.kt:1168 */
   57    104   
                query_timestamp_list.push(v);
         105  +
                /* ServerHttpBoundProtocolGenerator.kt:1122 */
   58    106   
            }
         107  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   59    108   
        }
         109  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   60    110   
        if !query_boolean_list.is_empty() {
   61         -
            input = input.set_query_boolean_list(Some(query_boolean_list));
         111  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         112  +
            input = input.set_query_boolean_list(
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         114  +
                Some(
         115  +
                    /* ServerHttpBoundProtocolGenerator.kt:1244 */
         116  +
                    query_boolean_list, /* ServerHttpBoundProtocolGenerator.kt:1235 */
         117  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         118  +
            );
         119  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   62    120   
        }
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   63    122   
        if !query_double_list.is_empty() {
   64         -
            input = input.set_query_double_list(Some(query_double_list));
         123  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         124  +
            input = input.set_query_double_list(
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         126  +
                Some(
         127  +
                    /* ServerHttpBoundProtocolGenerator.kt:1244 */
         128  +
                    query_double_list, /* ServerHttpBoundProtocolGenerator.kt:1235 */
         129  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         130  +
            );
         131  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   65    132   
        }
         133  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   66    134   
        if !query_enum_list.is_empty() {
   67         -
            input = input.set_query_enum_list(Some(
         135  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         136  +
            input = input.set_query_enum_list(
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         138  +
                Some(
         139  +
                    /* ServerHttpBoundProtocolGenerator.kt:1236 */
   68    140   
                    crate::unconstrained::foo_enum_list_unconstrained::FooEnumListUnconstrained(
   69         -
                    query_enum_list,
   70         -
                ),
   71         -
            ));
         141  +
                        /* ServerHttpBoundProtocolGenerator.kt:1244 */
         142  +
                        query_enum_list, /* ServerHttpBoundProtocolGenerator.kt:1236 */
         143  +
                    ), /* ServerHttpBoundProtocolGenerator.kt:1235 */
         144  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         145  +
            );
         146  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   72    147   
        }
         148  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   73    149   
        if !query_integer_enum_list.is_empty() {
   74         -
            input = input.set_query_integer_enum_list(Some(query_integer_enum_list));
         150  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         151  +
            input = input.set_query_integer_enum_list(
         152  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         153  +
                Some(
         154  +
                    /* ServerHttpBoundProtocolGenerator.kt:1244 */
         155  +
                    query_integer_enum_list, /* ServerHttpBoundProtocolGenerator.kt:1235 */
         156  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         157  +
            );
         158  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   75    159   
        }
         160  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   76    161   
        if !query_integer_list.is_empty() {
   77         -
            input = input.set_query_integer_list(Some(query_integer_list));
         162  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         163  +
            input = input.set_query_integer_list(
         164  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         165  +
                Some(
         166  +
                    /* ServerHttpBoundProtocolGenerator.kt:1244 */
         167  +
                    query_integer_list, /* ServerHttpBoundProtocolGenerator.kt:1235 */
         168  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         169  +
            );
         170  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   78    171   
        }
         172  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   79    173   
        if !query_string_list.is_empty() {
   80         -
            input = input.set_query_string_list(Some(query_string_list));
         174  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         175  +
            input = input.set_query_string_list(
         176  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         177  +
                Some(
         178  +
                    /* ServerHttpBoundProtocolGenerator.kt:1244 */
         179  +
                    query_string_list, /* ServerHttpBoundProtocolGenerator.kt:1235 */
         180  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         181  +
            );
         182  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   81    183   
        }
         184  +
        /* ServerHttpBoundProtocolGenerator.kt:1228 */
   82    185   
        if !query_timestamp_list.is_empty() {
   83         -
            input = input.set_query_timestamp_list(Some(query_timestamp_list));
         186  +
            /* ServerHttpBoundProtocolGenerator.kt:1229 */
         187  +
            input = input.set_query_timestamp_list(
         188  +
                /* ServerHttpBoundProtocolGenerator.kt:1235 */
         189  +
                Some(
         190  +
                    /* ServerHttpBoundProtocolGenerator.kt:1244 */
         191  +
                    query_timestamp_list, /* ServerHttpBoundProtocolGenerator.kt:1235 */
         192  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1229 */
         193  +
            );
         194  +
            /* ServerHttpBoundProtocolGenerator.kt:1228 */
   84    195   
        }
         196  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   85    197   
        input.build()?
         198  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   86    199   
    })
         200  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   87    201   
}
   88    202   
         203  +
/* RustType.kt:516 */
   89    204   
#[allow(clippy::unnecessary_wraps)]
         205  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   90    206   
pub fn ser_omits_serializing_empty_lists_http_response(
   91    207   
    #[allow(unused_variables)] output: crate::output::OmitsSerializingEmptyListsOutput,
   92    208   
) -> std::result::Result<
   93    209   
    ::aws_smithy_http_server::response::Response,
   94    210   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   95    211   
> {
         212  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   96    213   
    Ok({
         214  +
        /* RustType.kt:516 */
   97    215   
        #[allow(unused_mut)]
         216  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   98    217   
        let mut builder = ::http::Response::builder();
         218  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   99    219   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
  100    220   
            builder,
  101    221   
            ::http::header::CONTENT_TYPE,
  102    222   
            "application/json",
  103    223   
        );
         224  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
  104    225   
        let http_status: u16 = 200;
  105    226   
        builder = builder.status(http_status);
  106         -
        let payload = "";
         227  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         228  +
        let payload =
         229  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         230  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         231  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
  107    232   
        let content_length = payload.len();
  108    233   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
  109    234   
            builder,
  110    235   
            ::http::header::CONTENT_LENGTH,
  111    236   
            content_length,
  112    237   
        );
         238  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
  113    239   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         240  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
  114    241   
        builder.body(body)?
         242  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  115    243   
    })
         244  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  116    245   
}
  117    246   
         247  +
/* RustType.kt:516 */
  118    248   
#[allow(clippy::unnecessary_wraps)]
         249  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  119    250   
pub fn ser_omits_serializing_empty_lists_http_error(
  120    251   
    error: &crate::error::OmitsSerializingEmptyListsError,
  121    252   
) -> std::result::Result<
  122    253   
    ::aws_smithy_http_server::response::Response,
  123    254   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  124    255   
> {
         256  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  125    257   
    Ok({
         258  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  126    259   
        match error {
         260  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  127    261   
            crate::error::OmitsSerializingEmptyListsError::ValidationException(output) => {
         262  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  128    263   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         264  +
                /* RustType.kt:516 */
  129    265   
                #[allow(unused_mut)]
         266  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  130    267   
                let mut builder = ::http::Response::builder();
         268  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  131    269   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  132    270   
                    builder,
  133    271   
                    ::http::header::CONTENT_TYPE,
  134    272   
                    "application/json",
  135    273   
                );
         274  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  136    275   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  137    276   
                    builder,
  138    277   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  139    278   
                    "ValidationException",
  140    279   
                );
         280  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  141    281   
                let content_length = payload.len();
  142    282   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  143    283   
                    builder,
  144    284   
                    ::http::header::CONTENT_LENGTH,
  145    285   
                    content_length,
  146    286   
                );
         287  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  147    288   
                builder
  148    289   
                    .status(400)
  149    290   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         291  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  150    292   
            }
         293  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  151    294   
            crate::error::OmitsSerializingEmptyListsError::InternalServerError(output) => {
         295  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  152    296   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         297  +
                /* RustType.kt:516 */
  153    298   
                #[allow(unused_mut)]
         299  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  154    300   
                let mut builder = ::http::Response::builder();
         301  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  155    302   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  156    303   
                    builder,
  157    304   
                    ::http::header::CONTENT_TYPE,
  158    305   
                    "application/json",
  159    306   
                );
         307  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  160    308   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  161    309   
                    builder,
  162    310   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  163    311   
                    "InternalServerError",
  164    312   
                );
         313  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  165    314   
                let content_length = payload.len();
  166    315   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  167    316   
                    builder,
  168    317   
                    ::http::header::CONTENT_LENGTH,
  169    318   
                    content_length,
  170    319   
                );
         320  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  171    321   
                builder
  172    322   
                    .status(500)
  173    323   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         324  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         325  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  174    326   
        }
  175         -
        }
         327  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  176    328   
    })
         329  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  177    330   
}

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

@@ -1,1 +200,285 @@
    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_operation_with_defaults_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OperationWithDefaultsInput,
    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::operation_with_defaults_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 =
   29     39   
                crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults(
   30     40   
                    bytes.as_ref(),
   31     41   
                    input,
   32     42   
                )?;
          43  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   33     44   
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   34     46   
        input.build()?
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   35     48   
    })
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   36     50   
}
   37     51   
          52  +
/* RustType.kt:516 */
   38     53   
#[allow(clippy::unnecessary_wraps)]
          54  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   39     55   
pub fn ser_operation_with_defaults_http_response(
   40     56   
    #[allow(unused_variables)] output: crate::output::OperationWithDefaultsOutput,
   41     57   
) -> std::result::Result<
   42     58   
    ::aws_smithy_http_server::response::Response,
   43     59   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   44     60   
> {
          61  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   45     62   
    Ok({
          63  +
        /* RustType.kt:516 */
   46     64   
        #[allow(unused_mut)]
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   47     66   
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   48     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     69   
            builder,
   50     70   
            ::http::header::CONTENT_TYPE,
   51     71   
            "application/json",
   52     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   53     74   
        let http_status: u16 = 200;
   54     75   
        builder = builder.status(http_status);
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   55     77   
        let payload =
   56         -
            crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output_output(&output)?
   57         -
        ;
          78  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output_output(&output)?
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   58     81   
        let content_length = payload.len();
   59     82   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   60     83   
            builder,
   61     84   
            ::http::header::CONTENT_LENGTH,
   62     85   
            content_length,
   63     86   
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   64     88   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   65     90   
        builder.body(body)?
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   66     92   
    })
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   67     94   
}
   68     95   
          96  +
/* RustType.kt:516 */
   69     97   
#[allow(clippy::unnecessary_wraps)]
          98  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   70     99   
pub fn ser_operation_with_defaults_http_error(
   71    100   
    error: &crate::error::OperationWithDefaultsError,
   72    101   
) -> std::result::Result<
   73    102   
    ::aws_smithy_http_server::response::Response,
   74    103   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   75    104   
> {
         105  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   76    106   
    Ok({
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   77    108   
        match error {
         109  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   78    110   
            crate::error::OperationWithDefaultsError::ValidationException(output) => {
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   79    112   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         113  +
                /* RustType.kt:516 */
   80    114   
                #[allow(unused_mut)]
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   81    116   
                let mut builder = ::http::Response::builder();
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   82    118   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    119   
                    builder,
   84    120   
                    ::http::header::CONTENT_TYPE,
   85    121   
                    "application/json",
   86    122   
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   87    124   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    125   
                    builder,
   89    126   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   90    127   
                    "ValidationException",
   91    128   
                );
         129  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   92    130   
                let content_length = payload.len();
   93    131   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    132   
                    builder,
   95    133   
                    ::http::header::CONTENT_LENGTH,
   96    134   
                    content_length,
   97    135   
                );
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   98    137   
                builder
   99    138   
                    .status(400)
  100    139   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  101    141   
            }
         142  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  102    143   
            crate::error::OperationWithDefaultsError::InternalServerError(output) => {
         144  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  103    145   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         146  +
                /* RustType.kt:516 */
  104    147   
                #[allow(unused_mut)]
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  105    149   
                let mut builder = ::http::Response::builder();
         150  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  106    151   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  107    152   
                    builder,
  108    153   
                    ::http::header::CONTENT_TYPE,
  109    154   
                    "application/json",
  110    155   
                );
         156  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  111    157   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  112    158   
                    builder,
  113    159   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  114    160   
                    "InternalServerError",
  115    161   
                );
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  116    163   
                let content_length = payload.len();
  117    164   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  118    165   
                    builder,
  119    166   
                    ::http::header::CONTENT_LENGTH,
  120    167   
                    content_length,
  121    168   
                );
         169  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  122    170   
                builder
  123    171   
                    .status(500)
  124    172   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         173  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         174  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  125    175   
        }
  126         -
        }
         176  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  127    177   
    })
         178  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  128    179   
}
  129    180   
         181  +
/* JsonParserGenerator.kt:148 */
  130    182   
pub(crate) fn de_operation_with_defaults(
  131    183   
    value: &[u8],
  132    184   
    mut builder: crate::input::operation_with_defaults_input_internal::Builder,
  133    185   
) -> ::std::result::Result<
  134    186   
    crate::input::operation_with_defaults_input_internal::Builder,
  135    187   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  136    188   
> {
         189  +
    /* JsonParserGenerator.kt:153 */
  137    190   
    let mut tokens_owned =
  138    191   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  139    192   
            .peekable();
  140    193   
    let tokens = &mut tokens_owned;
  141    194   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         195  +
    /* JsonParserGenerator.kt:684 */
  142    196   
    loop {
         197  +
        /* JsonParserGenerator.kt:685 */
  143    198   
        match tokens.next().transpose()? {
         199  +
            /* JsonParserGenerator.kt:686 */
  144    200   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  145    201   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         202  +
                /* JsonParserGenerator.kt:260 */
  146    203   
                match key.to_unescaped()?.as_ref() {
         204  +
                    /* JsonParserGenerator.kt:262 */
  147    205   
                    "clientOptionalDefaults" => {
         206  +
                        /* JsonParserGenerator.kt:272 */
  148    207   
                        builder = builder.set_client_optional_defaults(
  149         -
                            crate::protocol_serde::shape_client_optional_defaults::de_client_optional_defaults(tokens)?
  150         -
                        );
         208  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_client_optional_defaults::de_client_optional_defaults(tokens)?
         209  +
                        /* JsonParserGenerator.kt:272 */);
         210  +
                        /* JsonParserGenerator.kt:262 */
  151    211   
                    }
         212  +
                    /* JsonParserGenerator.kt:262 */
  152    213   
                    "defaults" => {
         214  +
                        /* JsonParserGenerator.kt:272 */
  153    215   
                        builder = builder.set_defaults(
  154         -
                            crate::protocol_serde::shape_defaults::de_defaults(tokens)?,
  155         -
                        );
         216  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_defaults::de_defaults(tokens)?
         217  +
                        /* JsonParserGenerator.kt:272 */);
         218  +
                        /* JsonParserGenerator.kt:262 */
  156    219   
                    }
         220  +
                    /* JsonParserGenerator.kt:262 */
  157    221   
                    "otherTopLevelDefault" => {
         222  +
                        /* JsonParserGenerator.kt:276 */
  158    223   
                        if let Some(v) =
         224  +
                            /* JsonParserGenerator.kt:365 */
  159    225   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  160    226   
                                    tokens.next(),
  161    227   
                                )?
  162    228   
                                .map(i32::try_from)
  163    229   
                                .transpose()?
         230  +
                        /* JsonParserGenerator.kt:278 */
  164    231   
                        {
  165    232   
                            builder = builder.set_other_top_level_default(v);
  166    233   
                        }
         234  +
                        /* JsonParserGenerator.kt:262 */
  167    235   
                    }
         236  +
                    /* JsonParserGenerator.kt:262 */
  168    237   
                    "topLevelDefault" => {
         238  +
                        /* JsonParserGenerator.kt:276 */
  169    239   
                        if let Some(v) =
         240  +
                            /* JsonParserGenerator.kt:354 */
  170    241   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  171    242   
                                    tokens.next(),
  172    243   
                                )?
  173         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         244  +
                                .map(|s|
         245  +
                            /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         246  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
         247  +
                            /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
  174    248   
                                .transpose()?
         249  +
                        /* JsonParserGenerator.kt:278 */
  175    250   
                        {
  176    251   
                            builder = builder.set_top_level_default(v);
  177    252   
                        }
         253  +
                        /* JsonParserGenerator.kt:262 */
  178    254   
                    }
  179         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         255  +
                    /* JsonParserGenerator.kt:290 */
         256  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  180    257   
                }
         258  +
                /* JsonParserGenerator.kt:686 */
  181    259   
            }
         260  +
            /* JsonParserGenerator.kt:695 */
  182    261   
            other => {
  183    262   
                return Err(
  184    263   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  185    264   
                        "expected object key or end object, found: {:?}",
  186    265   
                        other
  187    266   
                    )),
  188    267   
                )
         268  +
            } /* JsonParserGenerator.kt:685 */
  189    269   
        }
         270  +
        /* JsonParserGenerator.kt:684 */
  190    271   
    }
  191         -
    }
         272  +
    /* JsonParserGenerator.kt:250 */
  192    273   
    if tokens.next().is_some() {
         274  +
        /* JsonParserGenerator.kt:251 */
  193    275   
        return Err(
  194    276   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  195    277   
                "found more JSON tokens after completing parsing",
  196    278   
            ),
  197    279   
        );
         280  +
        /* JsonParserGenerator.kt:250 */
  198    281   
    }
         282  +
    /* JsonParserGenerator.kt:163 */
  199    283   
    Ok(builder)
         284  +
    /* JsonParserGenerator.kt:148 */
  200    285   
}

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

@@ -1,1 +174,279 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_operation_with_defaults_output_output_output(
    3      4   
    value: &crate::output::OperationWithDefaultsOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_operation_with_defaults_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::OperationWithDefaultsOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* SerializerUtil.kt:46 */
   16     23   
    {
          24  +
        /* JsonSerializerGenerator.kt:439 */
   17     25   
        object
   18     26   
            .key("defaultBlob")
   19     27   
            .string_unchecked(&::aws_smithy_types::base64::encode(&input.default_blob));
          28  +
        /* SerializerUtil.kt:46 */
   20     29   
    }
          30  +
    /* SerializerUtil.kt:46 */
   21     31   
    if !input.default_boolean {
          32  +
        /* JsonSerializerGenerator.kt:424 */
   22     33   
        object.key("defaultBoolean").boolean(input.default_boolean);
          34  +
        /* SerializerUtil.kt:46 */
   23     35   
    }
          36  +
    /* SerializerUtil.kt:46 */
   24     37   
    if input.default_byte != 1 {
          38  +
        /* JsonSerializerGenerator.kt:432 */
   25     39   
        object.key("defaultByte").number(
   26     40   
            #[allow(clippy::useless_conversion)]
   27     41   
            ::aws_smithy_types::Number::NegInt((input.default_byte).into()),
   28     42   
        );
          43  +
        /* SerializerUtil.kt:46 */
   29     44   
    }
          45  +
    /* SerializerUtil.kt:46 */
   30     46   
    {
          47  +
        /* JsonSerializerGenerator.kt:474 */
   31     48   
        object
   32     49   
            .key("defaultDocumentBoolean")
   33     50   
            .document(&input.default_document_boolean);
          51  +
        /* SerializerUtil.kt:46 */
   34     52   
    }
          53  +
    /* SerializerUtil.kt:46 */
   35     54   
    {
          55  +
        /* JsonSerializerGenerator.kt:474 */
   36     56   
        object
   37     57   
            .key("defaultDocumentList")
   38     58   
            .document(&input.default_document_list);
          59  +
        /* SerializerUtil.kt:46 */
   39     60   
    }
          61  +
    /* SerializerUtil.kt:46 */
   40     62   
    {
          63  +
        /* JsonSerializerGenerator.kt:474 */
   41     64   
        object
   42     65   
            .key("defaultDocumentMap")
   43     66   
            .document(&input.default_document_map);
          67  +
        /* SerializerUtil.kt:46 */
   44     68   
    }
          69  +
    /* SerializerUtil.kt:46 */
   45     70   
    {
          71  +
        /* JsonSerializerGenerator.kt:474 */
   46     72   
        object
   47     73   
            .key("defaultDocumentString")
   48     74   
            .document(&input.default_document_string);
          75  +
        /* SerializerUtil.kt:46 */
   49     76   
    }
          77  +
    /* SerializerUtil.kt:46 */
   50     78   
    if input.default_double != 1.0 {
          79  +
        /* JsonSerializerGenerator.kt:432 */
   51     80   
        object.key("defaultDouble").number(
   52     81   
            #[allow(clippy::useless_conversion)]
   53     82   
            ::aws_smithy_types::Number::Float((input.default_double).into()),
   54     83   
        );
          84  +
        /* SerializerUtil.kt:46 */
   55     85   
    }
          86  +
    /* SerializerUtil.kt:46 */
   56     87   
    {
          88  +
        /* JsonSerializerGenerator.kt:423 */
   57     89   
        object
   58     90   
            .key("defaultEnum")
   59     91   
            .string(input.default_enum.as_str());
          92  +
        /* SerializerUtil.kt:46 */
   60     93   
    }
          94  +
    /* SerializerUtil.kt:46 */
   61     95   
    if input.default_float != 1.0 {
          96  +
        /* JsonSerializerGenerator.kt:432 */
   62     97   
        object.key("defaultFloat").number(
   63     98   
            #[allow(clippy::useless_conversion)]
   64     99   
            ::aws_smithy_types::Number::Float((input.default_float).into()),
   65    100   
        );
         101  +
        /* SerializerUtil.kt:46 */
   66    102   
    }
         103  +
    /* SerializerUtil.kt:46 */
   67    104   
    if input.default_int_enum != 1 {
         105  +
        /* JsonSerializerGenerator.kt:432 */
   68    106   
        object.key("defaultIntEnum").number(
   69    107   
            #[allow(clippy::useless_conversion)]
   70    108   
            ::aws_smithy_types::Number::NegInt((input.default_int_enum).into()),
   71    109   
        );
         110  +
        /* SerializerUtil.kt:46 */
   72    111   
    }
         112  +
    /* SerializerUtil.kt:46 */
   73    113   
    if input.default_integer != 10 {
         114  +
        /* JsonSerializerGenerator.kt:432 */
   74    115   
        object.key("defaultInteger").number(
   75    116   
            #[allow(clippy::useless_conversion)]
   76    117   
            ::aws_smithy_types::Number::NegInt((input.default_integer).into()),
   77    118   
        );
         119  +
        /* SerializerUtil.kt:46 */
   78    120   
    }
         121  +
    /* SerializerUtil.kt:46 */
   79    122   
    {
         123  +
        /* JsonSerializerGenerator.kt:484 */
   80    124   
        let mut array_1 = object.key("defaultList").start_array();
         125  +
        /* JsonSerializerGenerator.kt:524 */
   81    126   
        for item_2 in &input.default_list {
         127  +
            /* SerializerUtil.kt:42 */
   82    128   
            {
         129  +
                /* JsonSerializerGenerator.kt:423 */
   83    130   
                array_1.value().string(item_2.as_str());
         131  +
                /* SerializerUtil.kt:42 */
   84    132   
            }
         133  +
            /* JsonSerializerGenerator.kt:524 */
   85    134   
        }
         135  +
        /* JsonSerializerGenerator.kt:486 */
   86    136   
        array_1.finish();
         137  +
        /* SerializerUtil.kt:46 */
   87    138   
    }
         139  +
    /* SerializerUtil.kt:46 */
   88    140   
    if input.default_long != 100 {
         141  +
        /* JsonSerializerGenerator.kt:432 */
   89    142   
        object.key("defaultLong").number(
   90    143   
            #[allow(clippy::useless_conversion)]
   91    144   
            ::aws_smithy_types::Number::NegInt((input.default_long).into()),
   92    145   
        );
         146  +
        /* SerializerUtil.kt:46 */
   93    147   
    }
         148  +
    /* SerializerUtil.kt:46 */
   94    149   
    {
         150  +
        /* JsonSerializerGenerator.kt:495 */
   95    151   
        #[allow(unused_mut)]
         152  +
        /* JsonSerializerGenerator.kt:496 */
   96    153   
        let mut object_3 = object.key("defaultMap").start_object();
         154  +
        /* JsonSerializerGenerator.kt:537 */
   97    155   
        for (key_4, value_5) in &input.default_map {
         156  +
            /* SerializerUtil.kt:42 */
   98    157   
            {
         158  +
                /* JsonSerializerGenerator.kt:423 */
   99    159   
                object_3.key(key_4.as_str()).string(value_5.as_str());
         160  +
                /* SerializerUtil.kt:42 */
  100    161   
            }
         162  +
            /* JsonSerializerGenerator.kt:537 */
  101    163   
        }
         164  +
        /* JsonSerializerGenerator.kt:515 */
  102    165   
        object_3.finish();
         166  +
        /* SerializerUtil.kt:46 */
  103    167   
    }
         168  +
    /* JsonSerializerGenerator.kt:382 */
  104    169   
    if let Some(var_6) = &input.default_null_document {
         170  +
        /* JsonSerializerGenerator.kt:474 */
  105    171   
        object.key("defaultNullDocument").document(var_6);
         172  +
        /* JsonSerializerGenerator.kt:382 */
  106    173   
    }
         174  +
    /* SerializerUtil.kt:46 */
  107    175   
    if input.default_short != 1 {
         176  +
        /* JsonSerializerGenerator.kt:432 */
  108    177   
        object.key("defaultShort").number(
  109    178   
            #[allow(clippy::useless_conversion)]
  110    179   
            ::aws_smithy_types::Number::NegInt((input.default_short).into()),
  111    180   
        );
         181  +
        /* SerializerUtil.kt:46 */
  112    182   
    }
         183  +
    /* SerializerUtil.kt:46 */
  113    184   
    {
         185  +
        /* JsonSerializerGenerator.kt:423 */
  114    186   
        object
  115    187   
            .key("defaultString")
  116    188   
            .string(input.default_string.as_str());
         189  +
        /* SerializerUtil.kt:46 */
  117    190   
    }
         191  +
    /* SerializerUtil.kt:46 */
  118    192   
    {
         193  +
        /* JsonSerializerGenerator.kt:448 */
  119    194   
        object.key("defaultTimestamp").date_time(
  120    195   
            &input.default_timestamp,
  121    196   
            ::aws_smithy_types::date_time::Format::EpochSeconds,
  122    197   
        )?;
         198  +
        /* SerializerUtil.kt:46 */
  123    199   
    }
         200  +
    /* SerializerUtil.kt:46 */
  124    201   
    {
         202  +
        /* JsonSerializerGenerator.kt:439 */
  125    203   
        object
  126    204   
            .key("emptyBlob")
  127    205   
            .string_unchecked(&::aws_smithy_types::base64::encode(&input.empty_blob));
         206  +
        /* SerializerUtil.kt:46 */
  128    207   
    }
         208  +
    /* SerializerUtil.kt:46 */
  129    209   
    {
         210  +
        /* JsonSerializerGenerator.kt:423 */
  130    211   
        object
  131    212   
            .key("emptyString")
  132    213   
            .string(input.empty_string.as_str());
         214  +
        /* SerializerUtil.kt:46 */
  133    215   
    }
         216  +
    /* SerializerUtil.kt:46 */
  134    217   
    if input.false_boolean {
         218  +
        /* JsonSerializerGenerator.kt:424 */
  135    219   
        object.key("falseBoolean").boolean(input.false_boolean);
         220  +
        /* SerializerUtil.kt:46 */
  136    221   
    }
         222  +
    /* SerializerUtil.kt:46 */
  137    223   
    if input.zero_byte != 0 {
         224  +
        /* JsonSerializerGenerator.kt:432 */
  138    225   
        object.key("zeroByte").number(
  139    226   
            #[allow(clippy::useless_conversion)]
  140    227   
            ::aws_smithy_types::Number::NegInt((input.zero_byte).into()),
  141    228   
        );
         229  +
        /* SerializerUtil.kt:46 */
  142    230   
    }
         231  +
    /* SerializerUtil.kt:46 */
  143    232   
    if input.zero_double != 0.0 {
         233  +
        /* JsonSerializerGenerator.kt:432 */
  144    234   
        object.key("zeroDouble").number(
  145    235   
            #[allow(clippy::useless_conversion)]
  146    236   
            ::aws_smithy_types::Number::Float((input.zero_double).into()),
  147    237   
        );
         238  +
        /* SerializerUtil.kt:46 */
  148    239   
    }
         240  +
    /* SerializerUtil.kt:46 */
  149    241   
    if input.zero_float != 0.0 {
         242  +
        /* JsonSerializerGenerator.kt:432 */
  150    243   
        object.key("zeroFloat").number(
  151    244   
            #[allow(clippy::useless_conversion)]
  152    245   
            ::aws_smithy_types::Number::Float((input.zero_float).into()),
  153    246   
        );
         247  +
        /* SerializerUtil.kt:46 */
  154    248   
    }
         249  +
    /* SerializerUtil.kt:46 */
  155    250   
    if input.zero_integer != 0 {
         251  +
        /* JsonSerializerGenerator.kt:432 */
  156    252   
        object.key("zeroInteger").number(
  157    253   
            #[allow(clippy::useless_conversion)]
  158    254   
            ::aws_smithy_types::Number::NegInt((input.zero_integer).into()),
  159    255   
        );
         256  +
        /* SerializerUtil.kt:46 */
  160    257   
    }
         258  +
    /* SerializerUtil.kt:46 */
  161    259   
    if input.zero_long != 0 {
         260  +
        /* JsonSerializerGenerator.kt:432 */
  162    261   
        object.key("zeroLong").number(
  163    262   
            #[allow(clippy::useless_conversion)]
  164    263   
            ::aws_smithy_types::Number::NegInt((input.zero_long).into()),
  165    264   
        );
         265  +
        /* SerializerUtil.kt:46 */
  166    266   
    }
         267  +
    /* SerializerUtil.kt:46 */
  167    268   
    if input.zero_short != 0 {
         269  +
        /* JsonSerializerGenerator.kt:432 */
  168    270   
        object.key("zeroShort").number(
  169    271   
            #[allow(clippy::useless_conversion)]
  170    272   
            ::aws_smithy_types::Number::NegInt((input.zero_short).into()),
  171    273   
        );
         274  +
        /* SerializerUtil.kt:46 */
  172    275   
    }
         276  +
    /* JsonSerializerGenerator.kt:372 */
  173    277   
    Ok(())
         278  +
    /* JsonSerializerGenerator.kt:358 */
  174    279   
}

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

@@ -1,1 +172,243 @@
    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_operation_with_nested_structure_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OperationWithNestedStructureInput,
    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::operation_with_nested_structure_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:745 */
   23     31   
        let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   24     33   
        if !bytes.is_empty() {
          34  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   25     35   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   26     36   
                &headers,
   27     37   
                Some("application/json"),
   28     38   
            )?;
   29     39   
            input = crate::protocol_serde::shape_operation_with_nested_structure::de_operation_with_nested_structure(bytes.as_ref(), input)?;
          40  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   30     41   
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   31     43   
        input.build()?
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   32     45   
    })
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   33     47   
}
   34     48   
          49  +
/* RustType.kt:516 */
   35     50   
#[allow(clippy::unnecessary_wraps)]
          51  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   36     52   
pub fn ser_operation_with_nested_structure_http_response(
   37     53   
    #[allow(unused_variables)] output: crate::output::OperationWithNestedStructureOutput,
   38     54   
) -> std::result::Result<
   39     55   
    ::aws_smithy_http_server::response::Response,
   40     56   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   41     57   
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   42     59   
    Ok({
          60  +
        /* RustType.kt:516 */
   43     61   
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   44     63   
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   45     65   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   46     66   
            builder,
   47     67   
            ::http::header::CONTENT_TYPE,
   48     68   
            "application/json",
   49     69   
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   50     71   
        let http_status: u16 = 200;
   51     72   
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   52     74   
        let payload =
   53         -
            crate::protocol_serde::shape_operation_with_nested_structure_output::ser_operation_with_nested_structure_output_output_output(&output)?
   54         -
        ;
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_operation_with_nested_structure_output::ser_operation_with_nested_structure_output_output_output(&output)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     78   
        let content_length = payload.len();
   56     79   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     80   
            builder,
   58     81   
            ::http::header::CONTENT_LENGTH,
   59     82   
            content_length,
   60     83   
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     85   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     87   
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     89   
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     91   
}
   65     92   
          93  +
/* RustType.kt:516 */
   66     94   
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     96   
pub fn ser_operation_with_nested_structure_http_error(
   68     97   
    error: &crate::error::OperationWithNestedStructureError,
   69     98   
) -> std::result::Result<
   70     99   
    ::aws_smithy_http_server::response::Response,
   71    100   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    101   
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    103   
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    105   
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    107   
            crate::error::OperationWithNestedStructureError::ValidationException(output) => {
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    109   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                /* RustType.kt:516 */
   77    111   
                #[allow(unused_mut)]
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    113   
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    115   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    116   
                    builder,
   81    117   
                    ::http::header::CONTENT_TYPE,
   82    118   
                    "application/json",
   83    119   
                );
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    121   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    122   
                    builder,
   86    123   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    124   
                    "ValidationException",
   88    125   
                );
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    127   
                let content_length = payload.len();
   90    128   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    129   
                    builder,
   92    130   
                    ::http::header::CONTENT_LENGTH,
   93    131   
                    content_length,
   94    132   
                );
         133  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    134   
                builder
   96    135   
                    .status(400)
   97    136   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   98    138   
            }
         139  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   99    140   
            crate::error::OperationWithNestedStructureError::InternalServerError(output) => {
         141  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  100    142   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         143  +
                /* RustType.kt:516 */
  101    144   
                #[allow(unused_mut)]
         145  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  102    146   
                let mut builder = ::http::Response::builder();
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  103    148   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  104    149   
                    builder,
  105    150   
                    ::http::header::CONTENT_TYPE,
  106    151   
                    "application/json",
  107    152   
                );
         153  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  108    154   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  109    155   
                    builder,
  110    156   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  111    157   
                    "InternalServerError",
  112    158   
                );
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  113    160   
                let content_length = payload.len();
  114    161   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  115    162   
                    builder,
  116    163   
                    ::http::header::CONTENT_LENGTH,
  117    164   
                    content_length,
  118    165   
                );
         166  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  119    167   
                builder
  120    168   
                    .status(500)
  121    169   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         171  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  122    172   
        }
  123         -
        }
         173  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  124    174   
    })
         175  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  125    176   
}
  126    177   
         178  +
/* JsonParserGenerator.kt:148 */
  127    179   
pub(crate) fn de_operation_with_nested_structure(
  128    180   
    value: &[u8],
  129    181   
    mut builder: crate::input::operation_with_nested_structure_input_internal::Builder,
  130    182   
) -> ::std::result::Result<
  131    183   
    crate::input::operation_with_nested_structure_input_internal::Builder,
  132    184   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  133    185   
> {
         186  +
    /* JsonParserGenerator.kt:153 */
  134    187   
    let mut tokens_owned =
  135    188   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  136    189   
            .peekable();
  137    190   
    let tokens = &mut tokens_owned;
  138    191   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         192  +
    /* JsonParserGenerator.kt:684 */
  139    193   
    loop {
         194  +
        /* JsonParserGenerator.kt:685 */
  140    195   
        match tokens.next().transpose()? {
         196  +
            /* JsonParserGenerator.kt:686 */
  141    197   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  142    198   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         199  +
                /* JsonParserGenerator.kt:260 */
  143    200   
                match key.to_unescaped()?.as_ref() {
         201  +
                    /* JsonParserGenerator.kt:262 */
  144    202   
                    "topLevel" => {
         203  +
                        /* JsonParserGenerator.kt:276 */
  145    204   
                        if let Some(v) =
         205  +
                            /* JsonParserGenerator.kt:544 */
  146    206   
                            crate::protocol_serde::shape_top_level::de_top_level(tokens)?
         207  +
                        /* JsonParserGenerator.kt:278 */
  147    208   
                        {
  148    209   
                            builder = builder.set_top_level(v);
  149    210   
                        }
         211  +
                        /* JsonParserGenerator.kt:262 */
  150    212   
                    }
  151         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         213  +
                    /* JsonParserGenerator.kt:290 */
         214  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  152    215   
                }
         216  +
                /* JsonParserGenerator.kt:686 */
  153    217   
            }
         218  +
            /* JsonParserGenerator.kt:695 */
  154    219   
            other => {
  155    220   
                return Err(
  156    221   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  157    222   
                        "expected object key or end object, found: {:?}",
  158    223   
                        other
  159    224   
                    )),
  160    225   
                )
         226  +
            } /* JsonParserGenerator.kt:685 */
  161    227   
        }
         228  +
        /* JsonParserGenerator.kt:684 */
  162    229   
    }
  163         -
    }
         230  +
    /* JsonParserGenerator.kt:250 */
  164    231   
    if tokens.next().is_some() {
         232  +
        /* JsonParserGenerator.kt:251 */
  165    233   
        return Err(
  166    234   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  167    235   
                "found more JSON tokens after completing parsing",
  168    236   
            ),
  169    237   
        );
         238  +
        /* JsonParserGenerator.kt:250 */
  170    239   
    }
         240  +
    /* JsonParserGenerator.kt:163 */
  171    241   
    Ok(builder)
         242  +
    /* JsonParserGenerator.kt:148 */
  172    243   
}

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

@@ -1,1 +48,87 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_operation_with_nested_structure_output_output_output(
    3      4   
    value: &crate::output::OperationWithNestedStructureOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_operation_with_nested_structure_output::ser_operation_with_nested_structure_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_operation_with_nested_structure_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::OperationWithNestedStructureOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* SerializerUtil.kt:42 */
   16     23   
    {
          24  +
        /* JsonSerializerGenerator.kt:495 */
   17     25   
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
   18     27   
        let mut object_1 = object.key("dialog").start_object();
          28  +
        /* JsonSerializerGenerator.kt:375 */
   19     29   
        crate::protocol_serde::shape_dialog::ser_dialog(&mut object_1, &input.dialog)?;
          30  +
        /* JsonSerializerGenerator.kt:515 */
   20     31   
        object_1.finish();
          32  +
        /* SerializerUtil.kt:42 */
   21     33   
    }
          34  +
    /* SerializerUtil.kt:46 */
   22     35   
    {
          36  +
        /* JsonSerializerGenerator.kt:484 */
   23     37   
        let mut array_2 = object.key("dialogList").start_array();
          38  +
        /* JsonSerializerGenerator.kt:524 */
   24     39   
        for item_3 in &input.dialog_list {
          40  +
            /* SerializerUtil.kt:42 */
   25     41   
            {
          42  +
                /* JsonSerializerGenerator.kt:495 */
   26     43   
                #[allow(unused_mut)]
          44  +
                /* JsonSerializerGenerator.kt:496 */
   27     45   
                let mut object_4 = array_2.value().start_object();
          46  +
                /* JsonSerializerGenerator.kt:375 */
   28     47   
                crate::protocol_serde::shape_dialog::ser_dialog(&mut object_4, item_3)?;
          48  +
                /* JsonSerializerGenerator.kt:515 */
   29     49   
                object_4.finish();
          50  +
                /* SerializerUtil.kt:42 */
   30     51   
            }
          52  +
            /* JsonSerializerGenerator.kt:524 */
   31     53   
        }
          54  +
        /* JsonSerializerGenerator.kt:486 */
   32     55   
        array_2.finish();
          56  +
        /* SerializerUtil.kt:46 */
   33     57   
    }
          58  +
    /* SerializerUtil.kt:46 */
   34     59   
    {
          60  +
        /* JsonSerializerGenerator.kt:495 */
   35     61   
        #[allow(unused_mut)]
          62  +
        /* JsonSerializerGenerator.kt:496 */
   36     63   
        let mut object_5 = object.key("dialogMap").start_object();
          64  +
        /* JsonSerializerGenerator.kt:537 */
   37     65   
        for (key_6, value_7) in &input.dialog_map {
          66  +
            /* SerializerUtil.kt:42 */
   38     67   
            {
          68  +
                /* JsonSerializerGenerator.kt:495 */
   39     69   
                #[allow(unused_mut)]
          70  +
                /* JsonSerializerGenerator.kt:496 */
   40     71   
                let mut object_8 = object_5.key(key_6.as_str()).start_object();
          72  +
                /* JsonSerializerGenerator.kt:375 */
   41     73   
                crate::protocol_serde::shape_dialog::ser_dialog(&mut object_8, value_7)?;
          74  +
                /* JsonSerializerGenerator.kt:515 */
   42     75   
                object_8.finish();
          76  +
                /* SerializerUtil.kt:42 */
   43     77   
            }
          78  +
            /* JsonSerializerGenerator.kt:537 */
   44     79   
        }
          80  +
        /* JsonSerializerGenerator.kt:515 */
   45     81   
        object_5.finish();
          82  +
        /* SerializerUtil.kt:46 */
   46     83   
    }
          84  +
    /* JsonSerializerGenerator.kt:372 */
   47     85   
    Ok(())
          86  +
    /* JsonSerializerGenerator.kt:358 */
   48     87   
}

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

@@ -1,1 +94,130 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:175 */
    2      3   
pub(crate) fn de_payload_config_payload(
    3      4   
    input: &[u8],
    4      5   
) -> ::std::result::Result<
    5      6   
    crate::model::PayloadConfig,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
> {
           9  +
    /* JsonParserGenerator.kt:187 */
    8     10   
    let mut tokens_owned =
    9     11   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(input))
   10     12   
            .peekable();
   11     13   
    let tokens = &mut tokens_owned;
   12         -
    let result = crate::protocol_serde::shape_payload_config::de_payload_config(tokens)?
   13         -
        .ok_or_else(|| {
   14         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   15         -
                "expected payload member value",
   16         -
            )
   17         -
        });
          14  +
    /* JsonParserGenerator.kt:194 */
          15  +
    let result =
          16  +
    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_payload_config::de_payload_config(tokens)?
          17  +
    /* JsonParserGenerator.kt:196 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          18  +
    /* JsonParserGenerator.kt:250 */
   18     19   
    if tokens.next().is_some() {
          20  +
        /* JsonParserGenerator.kt:251 */
   19     21   
        return Err(
   20     22   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   21     23   
                "found more JSON tokens after completing parsing",
   22     24   
            ),
   23     25   
        );
          26  +
        /* JsonParserGenerator.kt:250 */
   24     27   
    }
          28  +
    /* JsonParserGenerator.kt:198 */
   25     29   
    result
          30  +
    /* JsonParserGenerator.kt:175 */
   26     31   
}
   27     32   
          33  +
/* JsonParserGenerator.kt:516 */
   28     34   
pub(crate) fn de_payload_config<'a, I>(
   29     35   
    tokens: &mut ::std::iter::Peekable<I>,
   30     36   
) -> ::std::result::Result<
   31     37   
    Option<crate::model::PayloadConfig>,
   32     38   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   33     39   
>
   34     40   
where
   35     41   
    I: Iterator<
   36     42   
        Item = Result<
   37     43   
            ::aws_smithy_json::deserialize::Token<'a>,
   38     44   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   39     45   
        >,
   40     46   
    >,
   41     47   
{
          48  +
    /* JsonParserGenerator.kt:712 */
   42     49   
    match tokens.next().transpose()? {
          50  +
        /* JsonParserGenerator.kt:713 */
   43     51   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   44     52   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          53  +
            /* RustType.kt:516 */
   45     54   
            #[allow(unused_mut)]
          55  +
            /* JsonParserGenerator.kt:526 */
   46     56   
            let mut builder = crate::model::payload_config_internal::Builder::default();
          57  +
            /* JsonParserGenerator.kt:684 */
   47     58   
            loop {
          59  +
                /* JsonParserGenerator.kt:685 */
   48     60   
                match tokens.next().transpose()? {
          61  +
                    /* JsonParserGenerator.kt:686 */
   49     62   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   50     63   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          64  +
                        /* JsonParserGenerator.kt:260 */
   51     65   
                        match key.to_unescaped()?.as_ref() {
          66  +
                            /* JsonParserGenerator.kt:262 */
   52     67   
                            "data" => {
          68  +
                                /* JsonParserGenerator.kt:272 */
   53     69   
                                builder = builder.set_data(
          70  +
                                    /* JsonParserGenerator.kt:365 */
   54     71   
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
   55     72   
                                        tokens.next(),
   56     73   
                                    )?
   57     74   
                                    .map(i32::try_from)
   58         -
                                    .transpose()?,
          75  +
                                    .transpose()?, /* JsonParserGenerator.kt:272 */
   59     76   
                                );
          77  +
                                /* JsonParserGenerator.kt:262 */
   60     78   
                            }
   61         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          79  +
                            /* JsonParserGenerator.kt:290 */
          80  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   62     81   
                        }
          82  +
                        /* JsonParserGenerator.kt:686 */
   63     83   
                    }
          84  +
                    /* JsonParserGenerator.kt:695 */
   64     85   
                    other => {
   65     86   
                        return Err(
   66     87   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   67     88   
                                format!("expected object key or end object, found: {:?}", other),
   68     89   
                            ),
   69     90   
                        )
          91  +
                    } /* JsonParserGenerator.kt:685 */
   70     92   
                }
          93  +
                /* JsonParserGenerator.kt:684 */
   71     94   
            }
   72         -
            }
          95  +
            /* JsonParserGenerator.kt:540 */
   73     96   
            Ok(Some(builder.build()))
          97  +
            /* JsonParserGenerator.kt:713 */
   74     98   
        }
   75         -
        _ => Err(
          99  +
        /* JsonParserGenerator.kt:722 */
         100  +
        _ => {
         101  +
            /* JsonParserGenerator.kt:723 */
         102  +
            Err(
   76    103   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   77    104   
                    "expected start object or null",
   78    105   
                ),
   79         -
        ),
         106  +
            )
         107  +
            /* JsonParserGenerator.kt:722 */
         108  +
        } /* JsonParserGenerator.kt:712 */
   80    109   
    }
         110  +
    /* JsonParserGenerator.kt:516 */
   81    111   
}
   82    112   
         113  +
/* JsonSerializerGenerator.kt:358 */
   83    114   
pub fn ser_payload_config(
   84    115   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   85    116   
    input: &crate::model::PayloadConfig,
   86    117   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         118  +
    /* JsonSerializerGenerator.kt:382 */
   87    119   
    if let Some(var_1) = &input.data {
         120  +
        /* JsonSerializerGenerator.kt:432 */
   88    121   
        object.key("data").number(
   89    122   
            #[allow(clippy::useless_conversion)]
   90    123   
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
   91    124   
        );
         125  +
        /* JsonSerializerGenerator.kt:382 */
   92    126   
    }
         127  +
    /* JsonSerializerGenerator.kt:372 */
   93    128   
    Ok(())
         129  +
    /* JsonSerializerGenerator.kt:358 */
   94    130   
}