Server Test

Server Test

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +25,36 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_blobs_output_output_output(
    3      4   
    value: &crate::output::JsonBlobsOutput,
    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_json_blobs_output::ser_json_blobs_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_json_blobs_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonBlobsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.data {
          27  +
        /* JsonSerializerGenerator.kt:439 */
   20     28   
        object
   21     29   
            .key("data")
   22     30   
            .string_unchecked(&::aws_smithy_types::base64::encode(var_1));
          31  +
        /* JsonSerializerGenerator.kt:382 */
   23     32   
    }
          33  +
    /* JsonSerializerGenerator.kt:372 */
   24     34   
    Ok(())
          35  +
    /* JsonSerializerGenerator.kt:358 */
   25     36   
}

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

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

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

@@ -1,1 +57,102 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_enums_output_output_output(
    3      4   
    value: &crate::output::JsonEnumsOutput,
    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_json_enums_output::ser_json_enums_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_json_enums_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonEnumsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.foo_enum1 {
          27  +
        /* JsonSerializerGenerator.kt:423 */
   20     28   
        object.key("fooEnum1").string(var_1.as_str());
          29  +
        /* JsonSerializerGenerator.kt:382 */
   21     30   
    }
          31  +
    /* JsonSerializerGenerator.kt:382 */
   22     32   
    if let Some(var_2) = &input.foo_enum2 {
          33  +
        /* JsonSerializerGenerator.kt:423 */
   23     34   
        object.key("fooEnum2").string(var_2.as_str());
          35  +
        /* JsonSerializerGenerator.kt:382 */
   24     36   
    }
          37  +
    /* JsonSerializerGenerator.kt:382 */
   25     38   
    if let Some(var_3) = &input.foo_enum3 {
          39  +
        /* JsonSerializerGenerator.kt:423 */
   26     40   
        object.key("fooEnum3").string(var_3.as_str());
          41  +
        /* JsonSerializerGenerator.kt:382 */
   27     42   
    }
          43  +
    /* JsonSerializerGenerator.kt:382 */
   28     44   
    if let Some(var_4) = &input.foo_enum_list {
          45  +
        /* JsonSerializerGenerator.kt:484 */
   29     46   
        let mut array_5 = object.key("fooEnumList").start_array();
          47  +
        /* JsonSerializerGenerator.kt:524 */
   30     48   
        for item_6 in var_4 {
          49  +
            /* SerializerUtil.kt:42 */
   31     50   
            {
          51  +
                /* JsonSerializerGenerator.kt:423 */
   32     52   
                array_5.value().string(item_6.as_str());
          53  +
                /* SerializerUtil.kt:42 */
   33     54   
            }
          55  +
            /* JsonSerializerGenerator.kt:524 */
   34     56   
        }
          57  +
        /* JsonSerializerGenerator.kt:486 */
   35     58   
        array_5.finish();
          59  +
        /* JsonSerializerGenerator.kt:382 */
   36     60   
    }
          61  +
    /* JsonSerializerGenerator.kt:382 */
   37     62   
    if let Some(var_7) = &input.foo_enum_map {
          63  +
        /* JsonSerializerGenerator.kt:495 */
   38     64   
        #[allow(unused_mut)]
          65  +
        /* JsonSerializerGenerator.kt:496 */
   39     66   
        let mut object_8 = object.key("fooEnumMap").start_object();
          67  +
        /* JsonSerializerGenerator.kt:537 */
   40     68   
        for (key_9, value_10) in var_7 {
          69  +
            /* SerializerUtil.kt:42 */
   41     70   
            {
          71  +
                /* JsonSerializerGenerator.kt:423 */
   42     72   
                object_8.key(key_9.as_str()).string(value_10.as_str());
          73  +
                /* SerializerUtil.kt:42 */
   43     74   
            }
          75  +
            /* JsonSerializerGenerator.kt:537 */
   44     76   
        }
          77  +
        /* JsonSerializerGenerator.kt:515 */
   45     78   
        object_8.finish();
          79  +
        /* JsonSerializerGenerator.kt:382 */
   46     80   
    }
          81  +
    /* JsonSerializerGenerator.kt:382 */
   47     82   
    if let Some(var_11) = &input.foo_enum_set {
          83  +
        /* JsonSerializerGenerator.kt:484 */
   48     84   
        let mut array_12 = object.key("fooEnumSet").start_array();
          85  +
        /* JsonSerializerGenerator.kt:524 */
   49     86   
        for item_13 in &var_11.0 {
          87  +
            /* SerializerUtil.kt:42 */
   50     88   
            {
          89  +
                /* JsonSerializerGenerator.kt:423 */
   51     90   
                array_12.value().string(item_13.as_str());
          91  +
                /* SerializerUtil.kt:42 */
   52     92   
            }
          93  +
            /* JsonSerializerGenerator.kt:524 */
   53     94   
        }
          95  +
        /* JsonSerializerGenerator.kt:486 */
   54     96   
        array_12.finish();
          97  +
        /* JsonSerializerGenerator.kt:382 */
   55     98   
    }
          99  +
    /* JsonSerializerGenerator.kt:372 */
   56    100   
    Ok(())
         101  +
    /* JsonSerializerGenerator.kt:358 */
   57    102   
}

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

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

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

@@ -1,1 +75,120 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_int_enums_output_output_output(
    3      4   
    value: &crate::output::JsonIntEnumsOutput,
    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_json_int_enums_output::ser_json_int_enums_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_json_int_enums_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonIntEnumsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.integer_enum1 {
          27  +
        /* JsonSerializerGenerator.kt:432 */
   20     28   
        object.key("integerEnum1").number(
   21     29   
            #[allow(clippy::useless_conversion)]
   22     30   
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
   23     31   
        );
          32  +
        /* JsonSerializerGenerator.kt:382 */
   24     33   
    }
          34  +
    /* JsonSerializerGenerator.kt:382 */
   25     35   
    if let Some(var_2) = &input.integer_enum2 {
          36  +
        /* JsonSerializerGenerator.kt:432 */
   26     37   
        object.key("integerEnum2").number(
   27     38   
            #[allow(clippy::useless_conversion)]
   28     39   
            ::aws_smithy_types::Number::NegInt((*var_2).into()),
   29     40   
        );
          41  +
        /* JsonSerializerGenerator.kt:382 */
   30     42   
    }
          43  +
    /* JsonSerializerGenerator.kt:382 */
   31     44   
    if let Some(var_3) = &input.integer_enum3 {
          45  +
        /* JsonSerializerGenerator.kt:432 */
   32     46   
        object.key("integerEnum3").number(
   33     47   
            #[allow(clippy::useless_conversion)]
   34     48   
            ::aws_smithy_types::Number::NegInt((*var_3).into()),
   35     49   
        );
          50  +
        /* JsonSerializerGenerator.kt:382 */
   36     51   
    }
          52  +
    /* JsonSerializerGenerator.kt:382 */
   37     53   
    if let Some(var_4) = &input.integer_enum_list {
          54  +
        /* JsonSerializerGenerator.kt:484 */
   38     55   
        let mut array_5 = object.key("integerEnumList").start_array();
          56  +
        /* JsonSerializerGenerator.kt:524 */
   39     57   
        for item_6 in var_4 {
          58  +
            /* SerializerUtil.kt:42 */
   40     59   
            {
          60  +
                /* JsonSerializerGenerator.kt:432 */
   41     61   
                array_5.value().number(
   42     62   
                    #[allow(clippy::useless_conversion)]
   43     63   
                    ::aws_smithy_types::Number::NegInt((*item_6).into()),
   44     64   
                );
          65  +
                /* SerializerUtil.kt:42 */
   45     66   
            }
          67  +
            /* JsonSerializerGenerator.kt:524 */
   46     68   
        }
          69  +
        /* JsonSerializerGenerator.kt:486 */
   47     70   
        array_5.finish();
          71  +
        /* JsonSerializerGenerator.kt:382 */
   48     72   
    }
          73  +
    /* JsonSerializerGenerator.kt:382 */
   49     74   
    if let Some(var_7) = &input.integer_enum_map {
          75  +
        /* JsonSerializerGenerator.kt:495 */
   50     76   
        #[allow(unused_mut)]
          77  +
        /* JsonSerializerGenerator.kt:496 */
   51     78   
        let mut object_8 = object.key("integerEnumMap").start_object();
          79  +
        /* JsonSerializerGenerator.kt:537 */
   52     80   
        for (key_9, value_10) in var_7 {
          81  +
            /* SerializerUtil.kt:42 */
   53     82   
            {
          83  +
                /* JsonSerializerGenerator.kt:432 */
   54     84   
                object_8.key(key_9.as_str()).number(
   55     85   
                    #[allow(clippy::useless_conversion)]
   56     86   
                    ::aws_smithy_types::Number::NegInt((*value_10).into()),
   57     87   
                );
          88  +
                /* SerializerUtil.kt:42 */
   58     89   
            }
          90  +
            /* JsonSerializerGenerator.kt:537 */
   59     91   
        }
          92  +
        /* JsonSerializerGenerator.kt:515 */
   60     93   
        object_8.finish();
          94  +
        /* JsonSerializerGenerator.kt:382 */
   61     95   
    }
          96  +
    /* JsonSerializerGenerator.kt:382 */
   62     97   
    if let Some(var_11) = &input.integer_enum_set {
          98  +
        /* JsonSerializerGenerator.kt:484 */
   63     99   
        let mut array_12 = object.key("integerEnumSet").start_array();
         100  +
        /* JsonSerializerGenerator.kt:524 */
   64    101   
        for item_13 in &var_11.0 {
         102  +
            /* SerializerUtil.kt:42 */
   65    103   
            {
         104  +
                /* JsonSerializerGenerator.kt:432 */
   66    105   
                array_12.value().number(
   67    106   
                    #[allow(clippy::useless_conversion)]
   68    107   
                    ::aws_smithy_types::Number::NegInt((*item_13).into()),
   69    108   
                );
         109  +
                /* SerializerUtil.kt:42 */
   70    110   
            }
         111  +
            /* JsonSerializerGenerator.kt:524 */
   71    112   
        }
         113  +
        /* JsonSerializerGenerator.kt:486 */
   72    114   
        array_12.finish();
         115  +
        /* JsonSerializerGenerator.kt:382 */
   73    116   
    }
         117  +
    /* JsonSerializerGenerator.kt:372 */
   74    118   
    Ok(())
         119  +
    /* JsonSerializerGenerator.kt:358 */
   75    120   
}

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

@@ -1,1 +190,287 @@
    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_json_lists_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::JsonListsInput,
    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::json_lists_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_json_lists::de_json_lists(bytes.as_ref(), input)?;
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   29     40   
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   30     42   
        input.build()?
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   31     44   
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   32     46   
}
   33     47   
          48  +
/* RustType.kt:516 */
   34     49   
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   35     51   
pub fn ser_json_lists_http_response(
   36     52   
    #[allow(unused_variables)] output: crate::output::JsonListsOutput,
   37     53   
) -> std::result::Result<
   38     54   
    ::aws_smithy_http_server::response::Response,
   39     55   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   40     56   
> {
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   41     58   
    Ok({
          59  +
        /* RustType.kt:516 */
   42     60   
        #[allow(unused_mut)]
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   43     62   
        let mut builder = ::http::Response::builder();
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   44     64   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     65   
            builder,
   46     66   
            ::http::header::CONTENT_TYPE,
   47     67   
            "application/json",
   48     68   
        );
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   49     70   
        let http_status: u16 = 200;
   50     71   
        builder = builder.status(http_status);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   51     73   
        let payload =
   52         -
            crate::protocol_serde::shape_json_lists_output::ser_json_lists_output_output_output(
   53         -
                &output,
   54         -
            )?;
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_json_lists_output::ser_json_lists_output_output_output(&output)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     77   
        let content_length = payload.len();
   56     78   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     79   
            builder,
   58     80   
            ::http::header::CONTENT_LENGTH,
   59     81   
            content_length,
   60     82   
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     84   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     86   
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     88   
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     90   
}
   65     91   
          92  +
/* RustType.kt:516 */
   66     93   
#[allow(clippy::unnecessary_wraps)]
          94  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     95   
pub fn ser_json_lists_http_error(
   68     96   
    error: &crate::error::JsonListsError,
   69     97   
) -> std::result::Result<
   70     98   
    ::aws_smithy_http_server::response::Response,
   71     99   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    100   
> {
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    102   
    Ok({
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    104   
        match error {
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    106   
            crate::error::JsonListsError::ValidationException(output) => {
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    108   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         109  +
                /* RustType.kt:516 */
   77    110   
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    112   
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    114   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    115   
                    builder,
   81    116   
                    ::http::header::CONTENT_TYPE,
   82    117   
                    "application/json",
   83    118   
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    120   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    121   
                    builder,
   86    122   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    123   
                    "ValidationException",
   88    124   
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    126   
                let content_length = payload.len();
   90    127   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    128   
                    builder,
   92    129   
                    ::http::header::CONTENT_LENGTH,
   93    130   
                    content_length,
   94    131   
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    133   
                builder
   96    134   
                    .status(400)
   97    135   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         137  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   98    138   
        }
   99         -
        }
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    140   
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    142   
}
  102    143   
         144  +
/* JsonParserGenerator.kt:148 */
  103    145   
pub(crate) fn de_json_lists(
  104    146   
    value: &[u8],
  105    147   
    mut builder: crate::input::json_lists_input::Builder,
  106    148   
) -> ::std::result::Result<
  107    149   
    crate::input::json_lists_input::Builder,
  108    150   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  109    151   
> {
         152  +
    /* JsonParserGenerator.kt:153 */
  110    153   
    let mut tokens_owned =
  111    154   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  112    155   
            .peekable();
  113    156   
    let tokens = &mut tokens_owned;
  114    157   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         158  +
    /* JsonParserGenerator.kt:684 */
  115    159   
    loop {
         160  +
        /* JsonParserGenerator.kt:685 */
  116    161   
        match tokens.next().transpose()? {
         162  +
            /* JsonParserGenerator.kt:686 */
  117    163   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  118    164   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         165  +
                /* JsonParserGenerator.kt:260 */
  119    166   
                match key.to_unescaped()?.as_ref() {
         167  +
                    /* JsonParserGenerator.kt:262 */
  120    168   
                    "booleanList" => {
         169  +
                        /* JsonParserGenerator.kt:272 */
  121    170   
                        builder = builder.set_boolean_list(
  122         -
                            crate::protocol_serde::shape_boolean_list::de_boolean_list(tokens)?,
  123         -
                        );
         171  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_boolean_list::de_boolean_list(tokens)?
         172  +
                        /* JsonParserGenerator.kt:272 */);
         173  +
                        /* JsonParserGenerator.kt:262 */
  124    174   
                    }
         175  +
                    /* JsonParserGenerator.kt:262 */
  125    176   
                    "enumList" => {
  126         -
                        builder = builder.set_enum_list(
  127         -
                            crate::protocol_serde::shape_foo_enum_list::de_foo_enum_list(tokens)?,
         177  +
                        /* JsonParserGenerator.kt:272 */
         178  +
                        builder =
         179  +
                            builder.set_enum_list(
         180  +
                                /* JsonParserGenerator.kt:451 */
         181  +
                                crate::protocol_serde::shape_foo_enum_list::de_foo_enum_list(
         182  +
                                    tokens,
         183  +
                                )?, /* JsonParserGenerator.kt:272 */
  128    184   
                            );
         185  +
                        /* JsonParserGenerator.kt:262 */
  129    186   
                    }
         187  +
                    /* JsonParserGenerator.kt:262 */
  130    188   
                    "intEnumList" => {
         189  +
                        /* JsonParserGenerator.kt:272 */
  131    190   
                        builder = builder.set_int_enum_list(
         191  +
                            /* JsonParserGenerator.kt:451 */
  132    192   
                            crate::protocol_serde::shape_integer_enum_list::de_integer_enum_list(
  133    193   
                                tokens,
  134         -
                            )?,
         194  +
                            )?, /* JsonParserGenerator.kt:272 */
  135    195   
                        );
         196  +
                        /* JsonParserGenerator.kt:262 */
  136    197   
                    }
         198  +
                    /* JsonParserGenerator.kt:262 */
  137    199   
                    "integerList" => {
         200  +
                        /* JsonParserGenerator.kt:272 */
  138    201   
                        builder = builder.set_integer_list(
  139         -
                            crate::protocol_serde::shape_integer_list::de_integer_list(tokens)?,
  140         -
                        );
         202  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_integer_list::de_integer_list(tokens)?
         203  +
                        /* JsonParserGenerator.kt:272 */);
         204  +
                        /* JsonParserGenerator.kt:262 */
  141    205   
                    }
         206  +
                    /* JsonParserGenerator.kt:262 */
  142    207   
                    "nestedStringList" => {
         208  +
                        /* JsonParserGenerator.kt:272 */
  143    209   
                        builder = builder.set_nested_string_list(
         210  +
                            /* JsonParserGenerator.kt:451 */
  144    211   
                            crate::protocol_serde::shape_nested_string_list::de_nested_string_list(
  145    212   
                                tokens,
  146         -
                            )?,
         213  +
                            )?, /* JsonParserGenerator.kt:272 */
  147    214   
                        );
         215  +
                        /* JsonParserGenerator.kt:262 */
  148    216   
                    }
         217  +
                    /* JsonParserGenerator.kt:262 */
  149    218   
                    "stringList" => {
         219  +
                        /* JsonParserGenerator.kt:272 */
  150    220   
                        builder = builder.set_string_list(
  151         -
                            crate::protocol_serde::shape_string_list::de_string_list(tokens)?,
  152         -
                        );
         221  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_string_list::de_string_list(tokens)?
         222  +
                        /* JsonParserGenerator.kt:272 */);
         223  +
                        /* JsonParserGenerator.kt:262 */
  153    224   
                    }
         225  +
                    /* JsonParserGenerator.kt:262 */
  154    226   
                    "stringSet" => {
         227  +
                        /* JsonParserGenerator.kt:272 */
  155    228   
                        builder = builder.set_string_set(
  156         -
                            crate::protocol_serde::shape_string_set::de_string_set(tokens)?,
  157         -
                        );
         229  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_string_set::de_string_set(tokens)?
         230  +
                        /* JsonParserGenerator.kt:272 */);
         231  +
                        /* JsonParserGenerator.kt:262 */
  158    232   
                    }
         233  +
                    /* JsonParserGenerator.kt:262 */
  159    234   
                    "myStructureList" => {
  160         -
                        builder = builder.set_structure_list(
  161         -
                            crate::protocol_serde::shape_structure_list::de_structure_list(tokens)?,
         235  +
                        /* JsonParserGenerator.kt:272 */
         236  +
                        builder =
         237  +
                            builder.set_structure_list(
         238  +
                                /* JsonParserGenerator.kt:451 */
         239  +
                                crate::protocol_serde::shape_structure_list::de_structure_list(
         240  +
                                    tokens,
         241  +
                                )?, /* JsonParserGenerator.kt:272 */
  162    242   
                            );
         243  +
                        /* JsonParserGenerator.kt:262 */
  163    244   
                    }
         245  +
                    /* JsonParserGenerator.kt:262 */
  164    246   
                    "timestampList" => {
  165         -
                        builder = builder.set_timestamp_list(
  166         -
                            crate::protocol_serde::shape_timestamp_list::de_timestamp_list(tokens)?,
         247  +
                        /* JsonParserGenerator.kt:272 */
         248  +
                        builder =
         249  +
                            builder.set_timestamp_list(
         250  +
                                /* JsonParserGenerator.kt:451 */
         251  +
                                crate::protocol_serde::shape_timestamp_list::de_timestamp_list(
         252  +
                                    tokens,
         253  +
                                )?, /* JsonParserGenerator.kt:272 */
  167    254   
                            );
         255  +
                        /* JsonParserGenerator.kt:262 */
  168    256   
                    }
  169         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         257  +
                    /* JsonParserGenerator.kt:290 */
         258  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  170    259   
                }
         260  +
                /* JsonParserGenerator.kt:686 */
  171    261   
            }
         262  +
            /* JsonParserGenerator.kt:695 */
  172    263   
            other => {
  173    264   
                return Err(
  174    265   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  175    266   
                        "expected object key or end object, found: {:?}",
  176    267   
                        other
  177    268   
                    )),
  178    269   
                )
         270  +
            } /* JsonParserGenerator.kt:685 */
  179    271   
        }
         272  +
        /* JsonParserGenerator.kt:684 */
  180    273   
    }
  181         -
    }
         274  +
    /* JsonParserGenerator.kt:250 */
  182    275   
    if tokens.next().is_some() {
         276  +
        /* JsonParserGenerator.kt:251 */
  183    277   
        return Err(
  184    278   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  185    279   
                "found more JSON tokens after completing parsing",
  186    280   
            ),
  187    281   
        );
         282  +
        /* JsonParserGenerator.kt:250 */
  188    283   
    }
         284  +
    /* JsonParserGenerator.kt:163 */
  189    285   
    Ok(builder)
         286  +
    /* JsonParserGenerator.kt:148 */
  190    287   
}

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

@@ -1,1 +121,219 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_lists_output_output_output(
    3      4   
    value: &crate::output::JsonListsOutput,
    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_json_lists_output::ser_json_lists_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_json_lists_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonListsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.boolean_list {
          27  +
        /* JsonSerializerGenerator.kt:484 */
   20     28   
        let mut array_2 = object.key("booleanList").start_array();
          29  +
        /* JsonSerializerGenerator.kt:524 */
   21     30   
        for item_3 in var_1 {
          31  +
            /* SerializerUtil.kt:42 */
   22     32   
            {
          33  +
                /* JsonSerializerGenerator.kt:424 */
   23     34   
                array_2.value().boolean(*item_3);
          35  +
                /* SerializerUtil.kt:42 */
   24     36   
            }
          37  +
            /* JsonSerializerGenerator.kt:524 */
   25     38   
        }
          39  +
        /* JsonSerializerGenerator.kt:486 */
   26     40   
        array_2.finish();
          41  +
        /* JsonSerializerGenerator.kt:382 */
   27     42   
    }
          43  +
    /* JsonSerializerGenerator.kt:382 */
   28     44   
    if let Some(var_4) = &input.enum_list {
          45  +
        /* JsonSerializerGenerator.kt:484 */
   29     46   
        let mut array_5 = object.key("enumList").start_array();
          47  +
        /* JsonSerializerGenerator.kt:524 */
   30     48   
        for item_6 in var_4 {
          49  +
            /* SerializerUtil.kt:42 */
   31     50   
            {
          51  +
                /* JsonSerializerGenerator.kt:423 */
   32     52   
                array_5.value().string(item_6.as_str());
          53  +
                /* SerializerUtil.kt:42 */
   33     54   
            }
          55  +
            /* JsonSerializerGenerator.kt:524 */
   34     56   
        }
          57  +
        /* JsonSerializerGenerator.kt:486 */
   35     58   
        array_5.finish();
          59  +
        /* JsonSerializerGenerator.kt:382 */
   36     60   
    }
          61  +
    /* JsonSerializerGenerator.kt:382 */
   37     62   
    if let Some(var_7) = &input.int_enum_list {
          63  +
        /* JsonSerializerGenerator.kt:484 */
   38     64   
        let mut array_8 = object.key("intEnumList").start_array();
          65  +
        /* JsonSerializerGenerator.kt:524 */
   39     66   
        for item_9 in var_7 {
          67  +
            /* SerializerUtil.kt:42 */
   40     68   
            {
          69  +
                /* JsonSerializerGenerator.kt:432 */
   41     70   
                array_8.value().number(
   42     71   
                    #[allow(clippy::useless_conversion)]
   43     72   
                    ::aws_smithy_types::Number::NegInt((*item_9).into()),
   44     73   
                );
          74  +
                /* SerializerUtil.kt:42 */
   45     75   
            }
          76  +
            /* JsonSerializerGenerator.kt:524 */
   46     77   
        }
          78  +
        /* JsonSerializerGenerator.kt:486 */
   47     79   
        array_8.finish();
          80  +
        /* JsonSerializerGenerator.kt:382 */
   48     81   
    }
          82  +
    /* JsonSerializerGenerator.kt:382 */
   49     83   
    if let Some(var_10) = &input.integer_list {
          84  +
        /* JsonSerializerGenerator.kt:484 */
   50     85   
        let mut array_11 = object.key("integerList").start_array();
          86  +
        /* JsonSerializerGenerator.kt:524 */
   51     87   
        for item_12 in var_10 {
          88  +
            /* SerializerUtil.kt:42 */
   52     89   
            {
          90  +
                /* JsonSerializerGenerator.kt:432 */
   53     91   
                array_11.value().number(
   54     92   
                    #[allow(clippy::useless_conversion)]
   55     93   
                    ::aws_smithy_types::Number::NegInt((*item_12).into()),
   56     94   
                );
          95  +
                /* SerializerUtil.kt:42 */
   57     96   
            }
          97  +
            /* JsonSerializerGenerator.kt:524 */
   58     98   
        }
          99  +
        /* JsonSerializerGenerator.kt:486 */
   59    100   
        array_11.finish();
         101  +
        /* JsonSerializerGenerator.kt:382 */
   60    102   
    }
         103  +
    /* JsonSerializerGenerator.kt:382 */
   61    104   
    if let Some(var_13) = &input.nested_string_list {
         105  +
        /* JsonSerializerGenerator.kt:484 */
   62    106   
        let mut array_14 = object.key("nestedStringList").start_array();
         107  +
        /* JsonSerializerGenerator.kt:524 */
   63    108   
        for item_15 in var_13 {
         109  +
            /* SerializerUtil.kt:42 */
   64    110   
            {
         111  +
                /* JsonSerializerGenerator.kt:484 */
   65    112   
                let mut array_16 = array_14.value().start_array();
         113  +
                /* JsonSerializerGenerator.kt:524 */
   66    114   
                for item_17 in item_15 {
         115  +
                    /* SerializerUtil.kt:42 */
   67    116   
                    {
         117  +
                        /* JsonSerializerGenerator.kt:423 */
   68    118   
                        array_16.value().string(item_17.as_str());
         119  +
                        /* SerializerUtil.kt:42 */
   69    120   
                    }
         121  +
                    /* JsonSerializerGenerator.kt:524 */
   70    122   
                }
         123  +
                /* JsonSerializerGenerator.kt:486 */
   71    124   
                array_16.finish();
         125  +
                /* SerializerUtil.kt:42 */
   72    126   
            }
         127  +
            /* JsonSerializerGenerator.kt:524 */
   73    128   
        }
         129  +
        /* JsonSerializerGenerator.kt:486 */
   74    130   
        array_14.finish();
         131  +
        /* JsonSerializerGenerator.kt:382 */
   75    132   
    }
         133  +
    /* JsonSerializerGenerator.kt:382 */
   76    134   
    if let Some(var_18) = &input.string_list {
         135  +
        /* JsonSerializerGenerator.kt:484 */
   77    136   
        let mut array_19 = object.key("stringList").start_array();
         137  +
        /* JsonSerializerGenerator.kt:524 */
   78    138   
        for item_20 in var_18 {
         139  +
            /* SerializerUtil.kt:42 */
   79    140   
            {
         141  +
                /* JsonSerializerGenerator.kt:423 */
   80    142   
                array_19.value().string(item_20.as_str());
         143  +
                /* SerializerUtil.kt:42 */
   81    144   
            }
         145  +
            /* JsonSerializerGenerator.kt:524 */
   82    146   
        }
         147  +
        /* JsonSerializerGenerator.kt:486 */
   83    148   
        array_19.finish();
         149  +
        /* JsonSerializerGenerator.kt:382 */
   84    150   
    }
         151  +
    /* JsonSerializerGenerator.kt:382 */
   85    152   
    if let Some(var_21) = &input.string_set {
         153  +
        /* JsonSerializerGenerator.kt:484 */
   86    154   
        let mut array_22 = object.key("stringSet").start_array();
         155  +
        /* JsonSerializerGenerator.kt:524 */
   87    156   
        for item_23 in &var_21.0 {
         157  +
            /* SerializerUtil.kt:42 */
   88    158   
            {
         159  +
                /* JsonSerializerGenerator.kt:423 */
   89    160   
                array_22.value().string(item_23.as_str());
         161  +
                /* SerializerUtil.kt:42 */
   90    162   
            }
         163  +
            /* JsonSerializerGenerator.kt:524 */
   91    164   
        }
         165  +
        /* JsonSerializerGenerator.kt:486 */
   92    166   
        array_22.finish();
         167  +
        /* JsonSerializerGenerator.kt:382 */
   93    168   
    }
         169  +
    /* JsonSerializerGenerator.kt:382 */
   94    170   
    if let Some(var_24) = &input.structure_list {
         171  +
        /* JsonSerializerGenerator.kt:484 */
   95    172   
        let mut array_25 = object.key("myStructureList").start_array();
         173  +
        /* JsonSerializerGenerator.kt:524 */
   96    174   
        for item_26 in var_24 {
         175  +
            /* SerializerUtil.kt:42 */
   97    176   
            {
         177  +
                /* JsonSerializerGenerator.kt:495 */
   98    178   
                #[allow(unused_mut)]
         179  +
                /* JsonSerializerGenerator.kt:496 */
   99    180   
                let mut object_27 = array_25.value().start_object();
         181  +
                /* JsonSerializerGenerator.kt:375 */
  100    182   
                crate::protocol_serde::shape_structure_list_member::ser_structure_list_member(
  101    183   
                    &mut object_27,
  102    184   
                    item_26,
  103    185   
                )?;
         186  +
                /* JsonSerializerGenerator.kt:515 */
  104    187   
                object_27.finish();
         188  +
                /* SerializerUtil.kt:42 */
  105    189   
            }
         190  +
            /* JsonSerializerGenerator.kt:524 */
  106    191   
        }
         192  +
        /* JsonSerializerGenerator.kt:486 */
  107    193   
        array_25.finish();
         194  +
        /* JsonSerializerGenerator.kt:382 */
  108    195   
    }
         196  +
    /* JsonSerializerGenerator.kt:382 */
  109    197   
    if let Some(var_28) = &input.timestamp_list {
         198  +
        /* JsonSerializerGenerator.kt:484 */
  110    199   
        let mut array_29 = object.key("timestampList").start_array();
         200  +
        /* JsonSerializerGenerator.kt:524 */
  111    201   
        for item_30 in var_28 {
         202  +
            /* SerializerUtil.kt:42 */
  112    203   
            {
         204  +
                /* JsonSerializerGenerator.kt:448 */
  113    205   
                array_29
  114    206   
                    .value()
  115    207   
                    .date_time(item_30, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
         208  +
                /* SerializerUtil.kt:42 */
  116    209   
            }
         210  +
            /* JsonSerializerGenerator.kt:524 */
  117    211   
        }
         212  +
        /* JsonSerializerGenerator.kt:486 */
  118    213   
        array_29.finish();
         214  +
        /* JsonSerializerGenerator.kt:382 */
  119    215   
    }
         216  +
    /* JsonSerializerGenerator.kt:372 */
  120    217   
    Ok(())
         218  +
    /* JsonSerializerGenerator.kt:358 */
  121    219   
}

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

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

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

@@ -1,1 +82,149 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_maps_output_output_output(
    3      4   
    value: &crate::output::JsonMapsOutput,
    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_json_maps_output::ser_json_maps_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_json_maps_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::JsonMapsOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.dense_boolean_map {
          24  +
        /* JsonSerializerGenerator.kt:495 */
   17     25   
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
   18     27   
        let mut object_2 = object.key("denseBooleanMap").start_object();
          28  +
        /* JsonSerializerGenerator.kt:537 */
   19     29   
        for (key_3, value_4) in var_1 {
          30  +
            /* SerializerUtil.kt:42 */
   20     31   
            {
          32  +
                /* JsonSerializerGenerator.kt:424 */
   21     33   
                object_2.key(key_3.as_str()).boolean(*value_4);
          34  +
                /* SerializerUtil.kt:42 */
   22     35   
            }
          36  +
            /* JsonSerializerGenerator.kt:537 */
   23     37   
        }
          38  +
        /* JsonSerializerGenerator.kt:515 */
   24     39   
        object_2.finish();
          40  +
        /* JsonSerializerGenerator.kt:382 */
   25     41   
    }
          42  +
    /* JsonSerializerGenerator.kt:382 */
   26     43   
    if let Some(var_5) = &input.dense_number_map {
          44  +
        /* JsonSerializerGenerator.kt:495 */
   27     45   
        #[allow(unused_mut)]
          46  +
        /* JsonSerializerGenerator.kt:496 */
   28     47   
        let mut object_6 = object.key("denseNumberMap").start_object();
          48  +
        /* JsonSerializerGenerator.kt:537 */
   29     49   
        for (key_7, value_8) in var_5 {
          50  +
            /* SerializerUtil.kt:42 */
   30     51   
            {
          52  +
                /* JsonSerializerGenerator.kt:432 */
   31     53   
                object_6.key(key_7.as_str()).number(
   32     54   
                    #[allow(clippy::useless_conversion)]
   33     55   
                    ::aws_smithy_types::Number::NegInt((*value_8).into()),
   34     56   
                );
          57  +
                /* SerializerUtil.kt:42 */
   35     58   
            }
          59  +
            /* JsonSerializerGenerator.kt:537 */
   36     60   
        }
          61  +
        /* JsonSerializerGenerator.kt:515 */
   37     62   
        object_6.finish();
          63  +
        /* JsonSerializerGenerator.kt:382 */
   38     64   
    }
          65  +
    /* JsonSerializerGenerator.kt:382 */
   39     66   
    if let Some(var_9) = &input.dense_set_map {
          67  +
        /* JsonSerializerGenerator.kt:495 */
   40     68   
        #[allow(unused_mut)]
          69  +
        /* JsonSerializerGenerator.kt:496 */
   41     70   
        let mut object_10 = object.key("denseSetMap").start_object();
          71  +
        /* JsonSerializerGenerator.kt:537 */
   42     72   
        for (key_11, value_12) in var_9 {
          73  +
            /* SerializerUtil.kt:42 */
   43     74   
            {
          75  +
                /* JsonSerializerGenerator.kt:484 */
   44     76   
                let mut array_13 = object_10.key(key_11.as_str()).start_array();
          77  +
                /* JsonSerializerGenerator.kt:524 */
   45     78   
                for item_14 in &value_12.0 {
          79  +
                    /* SerializerUtil.kt:42 */
   46     80   
                    {
          81  +
                        /* JsonSerializerGenerator.kt:423 */
   47     82   
                        array_13.value().string(item_14.as_str());
          83  +
                        /* SerializerUtil.kt:42 */
   48     84   
                    }
          85  +
                    /* JsonSerializerGenerator.kt:524 */
   49     86   
                }
          87  +
                /* JsonSerializerGenerator.kt:486 */
   50     88   
                array_13.finish();
          89  +
                /* SerializerUtil.kt:42 */
   51     90   
            }
          91  +
            /* JsonSerializerGenerator.kt:537 */
   52     92   
        }
          93  +
        /* JsonSerializerGenerator.kt:515 */
   53     94   
        object_10.finish();
          95  +
        /* JsonSerializerGenerator.kt:382 */
   54     96   
    }
          97  +
    /* JsonSerializerGenerator.kt:382 */
   55     98   
    if let Some(var_15) = &input.dense_string_map {
          99  +
        /* JsonSerializerGenerator.kt:495 */
   56    100   
        #[allow(unused_mut)]
         101  +
        /* JsonSerializerGenerator.kt:496 */
   57    102   
        let mut object_16 = object.key("denseStringMap").start_object();
         103  +
        /* JsonSerializerGenerator.kt:537 */
   58    104   
        for (key_17, value_18) in var_15 {
         105  +
            /* SerializerUtil.kt:42 */
   59    106   
            {
         107  +
                /* JsonSerializerGenerator.kt:423 */
   60    108   
                object_16.key(key_17.as_str()).string(value_18.as_str());
         109  +
                /* SerializerUtil.kt:42 */
   61    110   
            }
         111  +
            /* JsonSerializerGenerator.kt:537 */
   62    112   
        }
         113  +
        /* JsonSerializerGenerator.kt:515 */
   63    114   
        object_16.finish();
         115  +
        /* JsonSerializerGenerator.kt:382 */
   64    116   
    }
         117  +
    /* JsonSerializerGenerator.kt:382 */
   65    118   
    if let Some(var_19) = &input.dense_struct_map {
         119  +
        /* JsonSerializerGenerator.kt:495 */
   66    120   
        #[allow(unused_mut)]
         121  +
        /* JsonSerializerGenerator.kt:496 */
   67    122   
        let mut object_20 = object.key("denseStructMap").start_object();
         123  +
        /* JsonSerializerGenerator.kt:537 */
   68    124   
        for (key_21, value_22) in var_19 {
         125  +
            /* SerializerUtil.kt:42 */
   69    126   
            {
         127  +
                /* JsonSerializerGenerator.kt:495 */
   70    128   
                #[allow(unused_mut)]
         129  +
                /* JsonSerializerGenerator.kt:496 */
   71    130   
                let mut object_23 = object_20.key(key_21.as_str()).start_object();
         131  +
                /* JsonSerializerGenerator.kt:375 */
   72    132   
                crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(
   73    133   
                    &mut object_23,
   74    134   
                    value_22,
   75    135   
                )?;
         136  +
                /* JsonSerializerGenerator.kt:515 */
   76    137   
                object_23.finish();
         138  +
                /* SerializerUtil.kt:42 */
   77    139   
            }
         140  +
            /* JsonSerializerGenerator.kt:537 */
   78    141   
        }
         142  +
        /* JsonSerializerGenerator.kt:515 */
   79    143   
        object_20.finish();
         144  +
        /* JsonSerializerGenerator.kt:382 */
   80    145   
    }
         146  +
    /* JsonSerializerGenerator.kt:372 */
   81    147   
    Ok(())
         148  +
    /* JsonSerializerGenerator.kt:358 */
   82    149   
}

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

@@ -1,1 +162,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_json_timestamps_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::JsonTimestampsInput,
    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::json_timestamps_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_json_timestamps::de_json_timestamps(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_json_timestamps_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::JsonTimestampsOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   54     76   
        let payload =
   55         -
            crate::protocol_serde::shape_json_timestamps_output::ser_json_timestamps_output_output_output(&output)?
   56         -
        ;
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_json_timestamps_output::ser_json_timestamps_output_output_output(&output)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   57     80   
        let content_length = payload.len();
   58     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   59     82   
            builder,
   60     83   
            ::http::header::CONTENT_LENGTH,
   61     84   
            content_length,
   62     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   63     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   64     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   65     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   66     93   
}
   67     94   
          95  +
/* JsonParserGenerator.kt:148 */
   68     96   
pub(crate) fn de_json_timestamps(
   69     97   
    value: &[u8],
   70     98   
    mut builder: crate::input::json_timestamps_input::Builder,
   71     99   
) -> ::std::result::Result<
   72    100   
    crate::input::json_timestamps_input::Builder,
   73    101   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   74    102   
> {
         103  +
    /* JsonParserGenerator.kt:153 */
   75    104   
    let mut tokens_owned =
   76    105   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   77    106   
            .peekable();
   78    107   
    let tokens = &mut tokens_owned;
   79    108   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         109  +
    /* JsonParserGenerator.kt:684 */
   80    110   
    loop {
         111  +
        /* JsonParserGenerator.kt:685 */
   81    112   
        match tokens.next().transpose()? {
         113  +
            /* JsonParserGenerator.kt:686 */
   82    114   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   83    115   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                /* JsonParserGenerator.kt:260 */
   84    117   
                match key.to_unescaped()?.as_ref() {
         118  +
                    /* JsonParserGenerator.kt:262 */
   85    119   
                    "dateTime" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
   86    121   
                        builder = builder.set_date_time(
         122  +
                            /* JsonParserGenerator.kt:384 */
   87    123   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
   88    124   
                                tokens.next(),
   89    125   
                                ::aws_smithy_types::date_time::Format::DateTime,
   90         -
                            )?,
         126  +
                            )?, /* JsonParserGenerator.kt:272 */
   91    127   
                        );
         128  +
                        /* JsonParserGenerator.kt:262 */
   92    129   
                    }
         130  +
                    /* JsonParserGenerator.kt:262 */
   93    131   
                    "dateTimeOnTarget" => {
         132  +
                        /* JsonParserGenerator.kt:272 */
   94    133   
                        builder = builder.set_date_time_on_target(
         134  +
                            /* JsonParserGenerator.kt:384 */
   95    135   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
   96    136   
                                tokens.next(),
   97    137   
                                ::aws_smithy_types::date_time::Format::DateTime,
   98         -
                            )?,
         138  +
                            )?, /* JsonParserGenerator.kt:272 */
   99    139   
                        );
         140  +
                        /* JsonParserGenerator.kt:262 */
  100    141   
                    }
         142  +
                    /* JsonParserGenerator.kt:262 */
  101    143   
                    "epochSeconds" => {
         144  +
                        /* JsonParserGenerator.kt:272 */
  102    145   
                        builder = builder.set_epoch_seconds(
         146  +
                            /* JsonParserGenerator.kt:384 */
  103    147   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  104    148   
                                tokens.next(),
  105    149   
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
  106         -
                            )?,
         150  +
                            )?, /* JsonParserGenerator.kt:272 */
  107    151   
                        );
         152  +
                        /* JsonParserGenerator.kt:262 */
  108    153   
                    }
         154  +
                    /* JsonParserGenerator.kt:262 */
  109    155   
                    "epochSecondsOnTarget" => {
         156  +
                        /* JsonParserGenerator.kt:272 */
  110    157   
                        builder = builder.set_epoch_seconds_on_target(
         158  +
                            /* JsonParserGenerator.kt:384 */
  111    159   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  112    160   
                                tokens.next(),
  113    161   
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
  114         -
                            )?,
         162  +
                            )?, /* JsonParserGenerator.kt:272 */
  115    163   
                        );
         164  +
                        /* JsonParserGenerator.kt:262 */
  116    165   
                    }
         166  +
                    /* JsonParserGenerator.kt:262 */
  117    167   
                    "httpDate" => {
         168  +
                        /* JsonParserGenerator.kt:272 */
  118    169   
                        builder = builder.set_http_date(
         170  +
                            /* JsonParserGenerator.kt:384 */
  119    171   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  120    172   
                                tokens.next(),
  121    173   
                                ::aws_smithy_types::date_time::Format::HttpDate,
  122         -
                            )?,
         174  +
                            )?, /* JsonParserGenerator.kt:272 */
  123    175   
                        );
         176  +
                        /* JsonParserGenerator.kt:262 */
  124    177   
                    }
         178  +
                    /* JsonParserGenerator.kt:262 */
  125    179   
                    "httpDateOnTarget" => {
         180  +
                        /* JsonParserGenerator.kt:272 */
  126    181   
                        builder = builder.set_http_date_on_target(
         182  +
                            /* JsonParserGenerator.kt:384 */
  127    183   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  128    184   
                                tokens.next(),
  129    185   
                                ::aws_smithy_types::date_time::Format::HttpDate,
  130         -
                            )?,
         186  +
                            )?, /* JsonParserGenerator.kt:272 */
  131    187   
                        );
         188  +
                        /* JsonParserGenerator.kt:262 */
  132    189   
                    }
         190  +
                    /* JsonParserGenerator.kt:262 */
  133    191   
                    "normal" => {
         192  +
                        /* JsonParserGenerator.kt:272 */
  134    193   
                        builder = builder.set_normal(
         194  +
                            /* JsonParserGenerator.kt:384 */
  135    195   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  136    196   
                                tokens.next(),
  137    197   
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
  138         -
                            )?,
         198  +
                            )?, /* JsonParserGenerator.kt:272 */
  139    199   
                        );
         200  +
                        /* JsonParserGenerator.kt:262 */
  140    201   
                    }
  141         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         202  +
                    /* JsonParserGenerator.kt:290 */
         203  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  142    204   
                }
         205  +
                /* JsonParserGenerator.kt:686 */
  143    206   
            }
         207  +
            /* JsonParserGenerator.kt:695 */
  144    208   
            other => {
  145    209   
                return Err(
  146    210   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  147    211   
                        "expected object key or end object, found: {:?}",
  148    212   
                        other
  149    213   
                    )),
  150    214   
                )
         215  +
            } /* JsonParserGenerator.kt:685 */
  151    216   
        }
         217  +
        /* JsonParserGenerator.kt:684 */
  152    218   
    }
  153         -
    }
         219  +
    /* JsonParserGenerator.kt:250 */
  154    220   
    if tokens.next().is_some() {
         221  +
        /* JsonParserGenerator.kt:251 */
  155    222   
        return Err(
  156    223   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  157    224   
                "found more JSON tokens after completing parsing",
  158    225   
            ),
  159    226   
        );
         227  +
        /* JsonParserGenerator.kt:250 */
  160    228   
    }
         229  +
    /* JsonParserGenerator.kt:163 */
  161    230   
    Ok(builder)
         231  +
    /* JsonParserGenerator.kt:148 */
  162    232   
}

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

@@ -1,1 +55,84 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_timestamps_output_output_output(
    3      4   
    value: &crate::output::JsonTimestampsOutput,
    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_json_timestamps_output::ser_json_timestamps_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_json_timestamps_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonTimestampsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.date_time {
          27  +
        /* JsonSerializerGenerator.kt:448 */
   20     28   
        object
   21     29   
            .key("dateTime")
   22     30   
            .date_time(var_1, ::aws_smithy_types::date_time::Format::DateTime)?;
          31  +
        /* JsonSerializerGenerator.kt:382 */
   23     32   
    }
          33  +
    /* JsonSerializerGenerator.kt:382 */
   24     34   
    if let Some(var_2) = &input.date_time_on_target {
          35  +
        /* JsonSerializerGenerator.kt:448 */
   25     36   
        object
   26     37   
            .key("dateTimeOnTarget")
   27     38   
            .date_time(var_2, ::aws_smithy_types::date_time::Format::DateTime)?;
          39  +
        /* JsonSerializerGenerator.kt:382 */
   28     40   
    }
          41  +
    /* JsonSerializerGenerator.kt:382 */
   29     42   
    if let Some(var_3) = &input.epoch_seconds {
          43  +
        /* JsonSerializerGenerator.kt:448 */
   30     44   
        object
   31     45   
            .key("epochSeconds")
   32     46   
            .date_time(var_3, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          47  +
        /* JsonSerializerGenerator.kt:382 */
   33     48   
    }
          49  +
    /* JsonSerializerGenerator.kt:382 */
   34     50   
    if let Some(var_4) = &input.epoch_seconds_on_target {
          51  +
        /* JsonSerializerGenerator.kt:448 */
   35     52   
        object
   36     53   
            .key("epochSecondsOnTarget")
   37     54   
            .date_time(var_4, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          55  +
        /* JsonSerializerGenerator.kt:382 */
   38     56   
    }
          57  +
    /* JsonSerializerGenerator.kt:382 */
   39     58   
    if let Some(var_5) = &input.http_date {
          59  +
        /* JsonSerializerGenerator.kt:448 */
   40     60   
        object
   41     61   
            .key("httpDate")
   42     62   
            .date_time(var_5, ::aws_smithy_types::date_time::Format::HttpDate)?;
          63  +
        /* JsonSerializerGenerator.kt:382 */
   43     64   
    }
          65  +
    /* JsonSerializerGenerator.kt:382 */
   44     66   
    if let Some(var_6) = &input.http_date_on_target {
          67  +
        /* JsonSerializerGenerator.kt:448 */
   45     68   
        object
   46     69   
            .key("httpDateOnTarget")
   47     70   
            .date_time(var_6, ::aws_smithy_types::date_time::Format::HttpDate)?;
          71  +
        /* JsonSerializerGenerator.kt:382 */
   48     72   
    }
          73  +
    /* JsonSerializerGenerator.kt:382 */
   49     74   
    if let Some(var_7) = &input.normal {
          75  +
        /* JsonSerializerGenerator.kt:448 */
   50     76   
        object
   51     77   
            .key("normal")
   52     78   
            .date_time(var_7, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          79  +
        /* JsonSerializerGenerator.kt:382 */
   53     80   
    }
          81  +
    /* JsonSerializerGenerator.kt:372 */
   54     82   
    Ok(())
          83  +
    /* JsonSerializerGenerator.kt:358 */
   55     84   
}

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

@@ -1,1 +147,206 @@
    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_json_unions_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::JsonUnionsInput,
    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::json_unions_input::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_json_unions::de_json_unions(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_json_unions_http_response(
   37     53   
    #[allow(unused_variables)] output: crate::output::JsonUnionsOutput,
   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_json_unions_output::ser_json_unions_output_output_output(
   54         -
                &output,
   55         -
            )?;
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output_output(&output)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   56     78   
        let content_length = payload.len();
   57     79   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   58     80   
            builder,
   59     81   
            ::http::header::CONTENT_LENGTH,
   60     82   
            content_length,
   61     83   
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   62     85   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   63     87   
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   64     89   
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   65     91   
}
   66     92   
          93  +
/* RustType.kt:516 */
   67     94   
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   68     96   
pub fn ser_json_unions_http_error(
   69     97   
    error: &crate::error::JsonUnionsError,
   70     98   
) -> std::result::Result<
   71     99   
    ::aws_smithy_http_server::response::Response,
   72    100   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   73    101   
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   74    103   
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   75    105   
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   76    107   
            crate::error::JsonUnionsError::ValidationException(output) => {
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   77    109   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                /* RustType.kt:516 */
   78    111   
                #[allow(unused_mut)]
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   79    113   
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   80    115   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   81    116   
                    builder,
   82    117   
                    ::http::header::CONTENT_TYPE,
   83    118   
                    "application/json",
   84    119   
                );
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   85    121   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   86    122   
                    builder,
   87    123   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   88    124   
                    "ValidationException",
   89    125   
                );
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   90    127   
                let content_length = payload.len();
   91    128   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   92    129   
                    builder,
   93    130   
                    ::http::header::CONTENT_LENGTH,
   94    131   
                    content_length,
   95    132   
                );
         133  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   96    134   
                builder
   97    135   
                    .status(400)
   98    136   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         138  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   99    139   
        }
  100         -
        }
         140  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  101    141   
    })
         142  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  102    143   
}
  103    144   
         145  +
/* JsonParserGenerator.kt:148 */
  104    146   
pub(crate) fn de_json_unions(
  105    147   
    value: &[u8],
  106    148   
    mut builder: crate::input::json_unions_input::Builder,
  107    149   
) -> ::std::result::Result<
  108    150   
    crate::input::json_unions_input::Builder,
  109    151   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  110    152   
> {
         153  +
    /* JsonParserGenerator.kt:153 */
  111    154   
    let mut tokens_owned =
  112    155   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  113    156   
            .peekable();
  114    157   
    let tokens = &mut tokens_owned;
  115    158   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         159  +
    /* JsonParserGenerator.kt:684 */
  116    160   
    loop {
         161  +
        /* JsonParserGenerator.kt:685 */
  117    162   
        match tokens.next().transpose()? {
         163  +
            /* JsonParserGenerator.kt:686 */
  118    164   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  119    165   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         166  +
                /* JsonParserGenerator.kt:260 */
  120    167   
                match key.to_unescaped()?.as_ref() {
         168  +
                    /* JsonParserGenerator.kt:262 */
  121    169   
                    "contents" => {
         170  +
                        /* JsonParserGenerator.kt:272 */
  122    171   
                        builder = builder.set_contents(
  123         -
                            crate::protocol_serde::shape_my_union::de_my_union(tokens)?,
  124         -
                        );
         172  +
                            /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_my_union::de_my_union(tokens)?
         173  +
                        /* JsonParserGenerator.kt:272 */);
         174  +
                        /* JsonParserGenerator.kt:262 */
  125    175   
                    }
  126         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         176  +
                    /* JsonParserGenerator.kt:290 */
         177  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  127    178   
                }
         179  +
                /* JsonParserGenerator.kt:686 */
  128    180   
            }
         181  +
            /* JsonParserGenerator.kt:695 */
  129    182   
            other => {
  130    183   
                return Err(
  131    184   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  132    185   
                        "expected object key or end object, found: {:?}",
  133    186   
                        other
  134    187   
                    )),
  135    188   
                )
         189  +
            } /* JsonParserGenerator.kt:685 */
  136    190   
        }
         191  +
        /* JsonParserGenerator.kt:684 */
  137    192   
    }
  138         -
    }
         193  +
    /* JsonParserGenerator.kt:250 */
  139    194   
    if tokens.next().is_some() {
         195  +
        /* JsonParserGenerator.kt:251 */
  140    196   
        return Err(
  141    197   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  142    198   
                "found more JSON tokens after completing parsing",
  143    199   
            ),
  144    200   
        );
         201  +
        /* JsonParserGenerator.kt:250 */
  145    202   
    }
         203  +
    /* JsonParserGenerator.kt:163 */
  146    204   
    Ok(builder)
         205  +
    /* JsonParserGenerator.kt:148 */
  147    206   
}

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

@@ -1,1 +26,40 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_unions_output_output_output(
    3      4   
    value: &crate::output::JsonUnionsOutput,
    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_json_unions_output::ser_json_unions_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_json_unions_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonUnionsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.contents {
          27  +
        /* JsonSerializerGenerator.kt:495 */
   20     28   
        #[allow(unused_mut)]
          29  +
        /* JsonSerializerGenerator.kt:496 */
   21     30   
        let mut object_2 = object.key("contents").start_object();
          31  +
        /* JsonSerializerGenerator.kt:579 */
   22     32   
        crate::protocol_serde::shape_my_union::ser_my_union(&mut object_2, var_1)?;
          33  +
        /* JsonSerializerGenerator.kt:515 */
   23     34   
        object_2.finish();
          35  +
        /* JsonSerializerGenerator.kt:382 */
   24     36   
    }
          37  +
    /* JsonSerializerGenerator.kt:372 */
   25     38   
    Ok(())
          39  +
    /* JsonSerializerGenerator.kt:358 */
   26     40   
}

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

@@ -1,1 +56,80 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_accept_with_body_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedAcceptWithBodyInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_accept_with_body_input::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_malformed_accept_with_body_http_response(
   29     42   
    #[allow(unused_variables)] output: crate::output::MalformedAcceptWithBodyOutput,
   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_malformed_accept_with_body_output::ser_malformed_accept_with_body_output_output_output(&output)?
   46         -
        ;
          64  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_malformed_accept_with_body_output::ser_malformed_accept_with_body_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   
}

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

@@ -1,1 +20,31 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_malformed_accept_with_body_output_output_output(
    3      4   
    value: &crate::output::MalformedAcceptWithBodyOutput,
    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_malformed_accept_with_body_output::ser_malformed_accept_with_body_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_malformed_accept_with_body_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::MalformedAcceptWithBodyOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.hi {
          24  +
        /* JsonSerializerGenerator.kt:423 */
   17     25   
        object.key("hi").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:382 */
   18     27   
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
   19     29   
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
   20     31   
}

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

@@ -1,1 +57,81 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_accept_with_generic_string_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedAcceptWithGenericStringInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input =
   18     23   
            crate::input::malformed_accept_with_generic_string_input::Builder::default();
          24  +
        /* RustType.kt:516 */
   19     25   
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   20     27   
        let ::aws_smithy_runtime_api::http::RequestParts {
   21     28   
            uri, headers, body, ..
   22     29   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:811 */
   23     31   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   24     33   
        input.build()
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   25     35   
    })
          36  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   26     37   
}
   27     38   
          39  +
/* RustType.kt:516 */
   28     40   
#[allow(clippy::unnecessary_wraps)]
          41  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   29     42   
pub fn ser_malformed_accept_with_generic_string_http_response(
   30     43   
    #[allow(unused_variables)] output: crate::output::MalformedAcceptWithGenericStringOutput,
   31     44   
) -> std::result::Result<
   32     45   
    ::aws_smithy_http_server::response::Response,
   33     46   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   34     47   
> {
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   35     49   
    Ok({
          50  +
        /* RustType.kt:516 */
   36     51   
        #[allow(unused_mut)]
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   37     53   
        let mut builder = ::http::Response::builder();
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   38     55   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   39     56   
            builder,
   40     57   
            ::http::header::CONTENT_TYPE,
   41     58   
            "text/plain",
   42     59   
        );
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   43     61   
        let http_status: u16 = 200;
   44     62   
        builder = builder.status(http_status);
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   45     64   
        let payload =
   46         -
            crate::protocol_serde::shape_malformed_accept_with_generic_string_output::ser_payload_http_payload( output.payload)?
   47         -
        ;
          65  +
            /* HttpBoundProtocolPayloadGenerator.kt:350 */crate::protocol_serde::shape_malformed_accept_with_generic_string_output::ser_payload_http_payload( output.payload)?
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   48     68   
        let content_length = payload.len();
   49     69   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   50     70   
            builder,
   51     71   
            ::http::header::CONTENT_LENGTH,
   52     72   
            content_length,
   53     73   
        );
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   54     75   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   55     77   
        builder.body(body)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   56     79   
    })
          80  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   57     81   
}