Server Test

Server Test

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943

Files changed:

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_pattern_union_override.rs

@@ -1,1 +80,112 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
    2      3   
pub(crate) fn de_pattern_union_override<'a, I>(tokens: &mut ::std::iter::Peekable<I>) -> ::std::result::Result<Option<crate::unconstrained::pattern_union_override_unconstrained::PatternUnionOverrideUnconstrained>, ::aws_smithy_json::deserialize::error::DeserializeError>
    3      4   
where I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>{
           5  +
    /* JsonParserGenerator.kt:565 */
    4      6   
    let mut variant = None;
           7  +
    /* JsonParserGenerator.kt:567 */
    5      8   
    match tokens.next().transpose()? {
           9  +
        /* JsonParserGenerator.kt:568 */
    6     10   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
    7         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
    8         -
            match tokens.next().transpose()? {
    9         -
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   10         -
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   11         -
                    if let ::std::option::Option::Some(::std::result::Result::Ok(
   12         -
                        ::aws_smithy_json::deserialize::Token::ValueNull { .. },
   13         -
                    )) = tokens.peek()
   14         -
                    {
   15         -
                        let _ = tokens.next().expect("peek returned a token")?;
   16         -
                        continue;
   17         -
                    }
   18         -
                    let key = key.to_unescaped()?;
   19         -
                    if key == "__type" {
   20         -
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   21         -
                        continue;
   22         -
                    }
   23         -
                    if variant.is_some() {
   24         -
                        return Err(
   25         -
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   26         -
                                "encountered mixed variants in union",
   27         -
                            ),
   28         -
                        );
   29         -
                    }
   30         -
                    variant = match key.as_ref() {
          11  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          12  +
            /* JsonParserGenerator.kt:684 */
          13  +
            loop {
          14  +
                /* JsonParserGenerator.kt:685 */
          15  +
                match tokens.next().transpose()? {
          16  +
                    /* JsonParserGenerator.kt:686 */
          17  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          18  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          19  +
                        /* JsonParserGenerator.kt:576 */
          20  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          21  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          22  +
                        )) = tokens.peek()
          23  +
                        {
          24  +
                            let _ = tokens.next().expect("peek returned a token")?;
          25  +
                            continue;
          26  +
                        }
          27  +
                        /* JsonParserGenerator.kt:585 */
          28  +
                        let key = key.to_unescaped()?;
          29  +
                        if key == "__type" {
          30  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          31  +
                            continue;
          32  +
                        }
          33  +
                        if variant.is_some() {
          34  +
                            return Err(
          35  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          36  +
                                    "encountered mixed variants in union",
          37  +
                                ),
          38  +
                            );
          39  +
                        }
          40  +
                        /* JsonParserGenerator.kt:598 */
          41  +
                        variant = match key.as_ref() {
          42  +
                            /* JsonParserGenerator.kt:601 */
   31     43   
                            "first" => {
          44  +
                                /* JsonParserGenerator.kt:611 */
   32     45   
                                Some(crate::unconstrained::pattern_union_override_unconstrained::PatternUnionOverrideUnconstrained::First(
   33         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   34         -
                                        s.to_unescaped().map(|u|
   35         -
                                            u.into_owned()
   36         -
                                        )
   37         -
                                    ).transpose()?
   38         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'first' cannot be null"))?
   39         -
                                ))
          46  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          47  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          48  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          49  +
                                        /* JsonParserGenerator.kt:339 */)
          50  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          51  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'first' cannot be null"))?
          52  +
                                /* JsonParserGenerator.kt:611 */))
          53  +
                                /* JsonParserGenerator.kt:601 */
   40     54   
                            }
          55  +
                            /* JsonParserGenerator.kt:601 */
   41     56   
                            "second" => {
          57  +
                                /* JsonParserGenerator.kt:611 */
   42     58   
                                Some(crate::unconstrained::pattern_union_override_unconstrained::PatternUnionOverrideUnconstrained::Second(
   43         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   44         -
                                        s.to_unescaped().map(|u|
   45         -
                                            u.into_owned()
   46         -
                                        )
   47         -
                                    ).transpose()?
   48         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'second' cannot be null"))?
   49         -
                                ))
          59  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          60  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          61  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          62  +
                                        /* JsonParserGenerator.kt:339 */)
          63  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          64  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'second' cannot be null"))?
          65  +
                                /* JsonParserGenerator.kt:611 */))
          66  +
                                /* JsonParserGenerator.kt:601 */
   50     67   
                            }
   51         -
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {}", variant)))
          68  +
                            /* JsonParserGenerator.kt:634 */
          69  +
                            variant => {
          70  +
                                return Err(
          71  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          72  +
                                        format!("unexpected union variant: {}", variant),
          73  +
                                    ),
          74  +
                                )
          75  +
                            } /* JsonParserGenerator.kt:598 */
   52     76   
                        };
          77  +
                        /* JsonParserGenerator.kt:686 */
          78  +
                    }
          79  +
                    /* JsonParserGenerator.kt:695 */
          80  +
                    other => {
          81  +
                        return Err(
          82  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          83  +
                                format!("expected object key or end object, found: {:?}", other),
          84  +
                            ),
          85  +
                        )
          86  +
                    } /* JsonParserGenerator.kt:685 */
   53     87   
                }
   54         -
                other => {
   55         -
                    return Err(
   56         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   57         -
                            "expected object key or end object, found: {:?}",
   58         -
                            other
   59         -
                        )),
   60         -
                    )
   61         -
                }
          88  +
                /* JsonParserGenerator.kt:684 */
   62     89   
            }
   63         -
        },
          90  +
            /* JsonParserGenerator.kt:568 */
          91  +
        }
          92  +
        /* JsonParserGenerator.kt:642 */
   64     93   
        _ => {
   65     94   
            return Err(
   66     95   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   67     96   
                    "expected start object or null",
   68     97   
                ),
   69     98   
            )
   70         -
        }
          99  +
        } /* JsonParserGenerator.kt:567 */
   71    100   
    }
         101  +
    /* JsonParserGenerator.kt:649 */
   72    102   
    if variant.is_none() {
   73    103   
        return Err(
   74    104   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   75    105   
                "Union did not contain a valid variant.",
   76    106   
            ),
   77    107   
        );
   78    108   
    }
         109  +
    /* JsonParserGenerator.kt:657 */
   79    110   
    Ok(variant)
         111  +
    /* JsonParserGenerator.kt:551 */
   80    112   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_recursive_structures.rs

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

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_recursive_union_one.rs

@@ -1,1 +89,121 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
    2      3   
pub(crate) fn de_recursive_union_one<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::recursive_union_one_unconstrained::RecursiveUnionOneUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:565 */
   16     18   
    let mut variant = None;
          19  +
    /* JsonParserGenerator.kt:567 */
   17     20   
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:568 */
   18     22   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
   19         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
   20         -
            match tokens.next().transpose()? {
   21         -
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   22         -
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   23         -
                    if let ::std::option::Option::Some(::std::result::Result::Ok(
   24         -
                        ::aws_smithy_json::deserialize::Token::ValueNull { .. },
   25         -
                    )) = tokens.peek()
   26         -
                    {
   27         -
                        let _ = tokens.next().expect("peek returned a token")?;
   28         -
                        continue;
   29         -
                    }
   30         -
                    let key = key.to_unescaped()?;
   31         -
                    if key == "__type" {
   32         -
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   33         -
                        continue;
   34         -
                    }
   35         -
                    if variant.is_some() {
   36         -
                        return Err(
   37         -
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   38         -
                                "encountered mixed variants in union",
   39         -
                            ),
   40         -
                        );
   41         -
                    }
   42         -
                    variant = match key.as_ref() {
          23  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:576 */
          32  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          33  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          34  +
                        )) = tokens.peek()
          35  +
                        {
          36  +
                            let _ = tokens.next().expect("peek returned a token")?;
          37  +
                            continue;
          38  +
                        }
          39  +
                        /* JsonParserGenerator.kt:585 */
          40  +
                        let key = key.to_unescaped()?;
          41  +
                        if key == "__type" {
          42  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          43  +
                            continue;
          44  +
                        }
          45  +
                        if variant.is_some() {
          46  +
                            return Err(
          47  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          48  +
                                    "encountered mixed variants in union",
          49  +
                                ),
          50  +
                            );
          51  +
                        }
          52  +
                        /* JsonParserGenerator.kt:598 */
          53  +
                        variant = match key.as_ref() {
          54  +
                            /* JsonParserGenerator.kt:601 */
   43     55   
                            "string" => {
          56  +
                                /* JsonParserGenerator.kt:611 */
   44     57   
                                Some(crate::unconstrained::recursive_union_one_unconstrained::RecursiveUnionOneUnconstrained::String(
   45         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   46         -
                                        s.to_unescaped().map(|u|
   47         -
                                            u.into_owned()
   48         -
                                        )
   49         -
                                    ).transpose()?
   50         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'string' cannot be null"))?
   51         -
                                ))
          58  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          59  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          60  +
                                            /* JsonParserGenerator.kt:343 */u.into_owned()
          61  +
                                        /* JsonParserGenerator.kt:339 */)
          62  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          63  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'string' cannot be null"))?
          64  +
                                /* JsonParserGenerator.kt:611 */))
          65  +
                                /* JsonParserGenerator.kt:601 */
   52     66   
                            }
          67  +
                            /* JsonParserGenerator.kt:601 */
   53     68   
                            "union" => {
          69  +
                                /* JsonParserGenerator.kt:611 */
   54     70   
                                Some(crate::unconstrained::recursive_union_one_unconstrained::RecursiveUnionOneUnconstrained::Union(
   55         -
                                    crate::protocol_serde::shape_recursive_union_two::de_recursive_union_two(tokens)?
   56         -
                                    .map(Box::new)
   57         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'union' cannot be null"))?
   58         -
                                ))
          71  +
                                    /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_recursive_union_two::de_recursive_union_two(tokens)?
          72  +
                                    /* JsonParserGenerator.kt:314 */.map(Box::new)
          73  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'union' cannot be null"))?
          74  +
                                /* JsonParserGenerator.kt:611 */))
          75  +
                                /* JsonParserGenerator.kt:601 */
   59     76   
                            }
   60         -
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {}", variant)))
          77  +
                            /* JsonParserGenerator.kt:634 */
          78  +
                            variant => {
          79  +
                                return Err(
          80  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          81  +
                                        format!("unexpected union variant: {}", variant),
          82  +
                                    ),
          83  +
                                )
          84  +
                            } /* JsonParserGenerator.kt:598 */
   61     85   
                        };
          86  +
                        /* JsonParserGenerator.kt:686 */
          87  +
                    }
          88  +
                    /* JsonParserGenerator.kt:695 */
          89  +
                    other => {
          90  +
                        return Err(
          91  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          92  +
                                format!("expected object key or end object, found: {:?}", other),
          93  +
                            ),
          94  +
                        )
          95  +
                    } /* JsonParserGenerator.kt:685 */
   62     96   
                }
   63         -
                other => {
   64         -
                    return Err(
   65         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   66         -
                            "expected object key or end object, found: {:?}",
   67         -
                            other
   68         -
                        )),
   69         -
                    )
   70         -
                }
          97  +
                /* JsonParserGenerator.kt:684 */
   71     98   
            }
   72         -
        },
          99  +
            /* JsonParserGenerator.kt:568 */
         100  +
        }
         101  +
        /* JsonParserGenerator.kt:642 */
   73    102   
        _ => {
   74    103   
            return Err(
   75    104   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   76    105   
                    "expected start object or null",
   77    106   
                ),
   78    107   
            )
   79         -
        }
         108  +
        } /* JsonParserGenerator.kt:567 */
   80    109   
    }
         110  +
    /* JsonParserGenerator.kt:649 */
   81    111   
    if variant.is_none() {
   82    112   
        return Err(
   83    113   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   84    114   
                "Union did not contain a valid variant.",
   85    115   
            ),
   86    116   
        );
   87    117   
    }
         118  +
    /* JsonParserGenerator.kt:657 */
   88    119   
    Ok(variant)
         120  +
    /* JsonParserGenerator.kt:551 */
   89    121   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_recursive_union_two.rs

@@ -1,1 +88,120 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
    2      3   
pub(crate) fn de_recursive_union_two<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::recursive_union_two_unconstrained::RecursiveUnionTwoUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:565 */
   16     18   
    let mut variant = None;
          19  +
    /* JsonParserGenerator.kt:567 */
   17     20   
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:568 */
   18     22   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
   19         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
   20         -
            match tokens.next().transpose()? {
   21         -
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   22         -
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   23         -
                    if let ::std::option::Option::Some(::std::result::Result::Ok(
   24         -
                        ::aws_smithy_json::deserialize::Token::ValueNull { .. },
   25         -
                    )) = tokens.peek()
   26         -
                    {
   27         -
                        let _ = tokens.next().expect("peek returned a token")?;
   28         -
                        continue;
   29         -
                    }
   30         -
                    let key = key.to_unescaped()?;
   31         -
                    if key == "__type" {
   32         -
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   33         -
                        continue;
   34         -
                    }
   35         -
                    if variant.is_some() {
   36         -
                        return Err(
   37         -
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   38         -
                                "encountered mixed variants in union",
   39         -
                            ),
   40         -
                        );
   41         -
                    }
   42         -
                    variant = match key.as_ref() {
          23  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:576 */
          32  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          33  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          34  +
                        )) = tokens.peek()
          35  +
                        {
          36  +
                            let _ = tokens.next().expect("peek returned a token")?;
          37  +
                            continue;
          38  +
                        }
          39  +
                        /* JsonParserGenerator.kt:585 */
          40  +
                        let key = key.to_unescaped()?;
          41  +
                        if key == "__type" {
          42  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          43  +
                            continue;
          44  +
                        }
          45  +
                        if variant.is_some() {
          46  +
                            return Err(
          47  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          48  +
                                    "encountered mixed variants in union",
          49  +
                                ),
          50  +
                            );
          51  +
                        }
          52  +
                        /* JsonParserGenerator.kt:598 */
          53  +
                        variant = match key.as_ref() {
          54  +
                            /* JsonParserGenerator.kt:601 */
   43     55   
                            "string" => {
          56  +
                                /* JsonParserGenerator.kt:611 */
   44     57   
                                Some(crate::unconstrained::recursive_union_two_unconstrained::RecursiveUnionTwoUnconstrained::String(
   45         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   46         -
                                        s.to_unescaped().map(|u|
   47         -
                                            u.into_owned()
   48         -
                                        )
   49         -
                                    ).transpose()?
   50         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'string' cannot be null"))?
   51         -
                                ))
          58  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          59  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          60  +
                                            /* JsonParserGenerator.kt:343 */u.into_owned()
          61  +
                                        /* JsonParserGenerator.kt:339 */)
          62  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          63  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'string' cannot be null"))?
          64  +
                                /* JsonParserGenerator.kt:611 */))
          65  +
                                /* JsonParserGenerator.kt:601 */
   52     66   
                            }
          67  +
                            /* JsonParserGenerator.kt:601 */
   53     68   
                            "union" => {
          69  +
                                /* JsonParserGenerator.kt:611 */
   54     70   
                                Some(crate::unconstrained::recursive_union_two_unconstrained::RecursiveUnionTwoUnconstrained::Union(
   55         -
                                    crate::protocol_serde::shape_recursive_union_one::de_recursive_union_one(tokens)?
   56         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'union' cannot be null"))?
   57         -
                                ))
          71  +
                                    /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_recursive_union_one::de_recursive_union_one(tokens)?
          72  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'union' cannot be null"))?
          73  +
                                /* JsonParserGenerator.kt:611 */))
          74  +
                                /* JsonParserGenerator.kt:601 */
   58     75   
                            }
   59         -
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {}", variant)))
          76  +
                            /* JsonParserGenerator.kt:634 */
          77  +
                            variant => {
          78  +
                                return Err(
          79  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          80  +
                                        format!("unexpected union variant: {}", variant),
          81  +
                                    ),
          82  +
                                )
          83  +
                            } /* JsonParserGenerator.kt:598 */
   60     84   
                        };
          85  +
                        /* JsonParserGenerator.kt:686 */
          86  +
                    }
          87  +
                    /* JsonParserGenerator.kt:695 */
          88  +
                    other => {
          89  +
                        return Err(
          90  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          91  +
                                format!("expected object key or end object, found: {:?}", other),
          92  +
                            ),
          93  +
                        )
          94  +
                    } /* JsonParserGenerator.kt:685 */
   61     95   
                }
   62         -
                other => {
   63         -
                    return Err(
   64         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   65         -
                            "expected object key or end object, found: {:?}",
   66         -
                            other
   67         -
                        )),
   68         -
                    )
   69         -
                }
          96  +
                /* JsonParserGenerator.kt:684 */
   70     97   
            }
   71         -
        },
          98  +
            /* JsonParserGenerator.kt:568 */
          99  +
        }
         100  +
        /* JsonParserGenerator.kt:642 */
   72    101   
        _ => {
   73    102   
            return Err(
   74    103   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   75    104   
                    "expected start object or null",
   76    105   
                ),
   77    106   
            )
   78         -
        }
         107  +
        } /* JsonParserGenerator.kt:567 */
   79    108   
    }
         109  +
    /* JsonParserGenerator.kt:649 */
   80    110   
    if variant.is_none() {
   81    111   
        return Err(
   82    112   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   83    113   
                "Union did not contain a valid variant.",
   84    114   
            ),
   85    115   
        );
   86    116   
    }
         117  +
    /* JsonParserGenerator.kt:657 */
   87    118   
    Ok(variant)
         119  +
    /* JsonParserGenerator.kt:551 */
   88    120   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_sensitive_validation.rs

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

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_short_set.rs

@@ -1,1 +54,78 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_short_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::short_set_unconstrained::ShortSetUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
   27         -
                        let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(
   28         -
                            tokens.next(),
   29         -
                        )?
   30         -
                        .map(i16::try_from)
   31         -
                        .transpose()?;
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          40  +
                                                .map(i16::try_from)
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:419 */;
          43  +
                        /* JsonParserGenerator.kt:422 */
   32     44   
                        if let Some(value) = value {
   33     45   
                            items.push(value);
   34         -
                        } else {
          46  +
                        }
          47  +
                        /* JsonParserGenerator.kt:430 */
          48  +
                        else {
   35     49   
                            return Err(
   36     50   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     51   
                                    "dense list cannot contain null values",
   38     52   
                                ),
   39     53   
                            );
   40     54   
                        }
   41         -
                    }
          55  +
                        /* JsonParserGenerator.kt:413 */
          56  +
                    } /* JsonParserGenerator.kt:409 */
   42     57   
                }
          58  +
                /* JsonParserGenerator.kt:408 */
   43     59   
            }
          60  +
            /* JsonParserGenerator.kt:444 */
   44     61   
            Ok(Some(
   45     62   
                crate::unconstrained::short_set_unconstrained::ShortSetUnconstrained(items),
   46     63   
            ))
          64  +
            /* JsonParserGenerator.kt:713 */
   47     65   
        }
   48         -
        _ => Err(
   49         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   50         -
                "expected start array or null",
   51         -
            ),
   52         -
        ),
          66  +
        /* JsonParserGenerator.kt:722 */
          67  +
        _ => {
          68  +
            /* JsonParserGenerator.kt:723 */
          69  +
            Err(
          70  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          71  +
                    "expected start array or null",
          72  +
                ),
          73  +
            )
          74  +
            /* JsonParserGenerator.kt:722 */
          75  +
        } /* JsonParserGenerator.kt:712 */
   53     76   
    }
          77  +
    /* JsonParserGenerator.kt:398 */
   54     78   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_string_list.rs

@@ -1,1 +52,78 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_string_list<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::vec::Vec<::std::string::String>>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
   27         -
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
   28         -
                            tokens.next(),
   29         -
                        )?
   30         -
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   31         -
                        .transpose()?;
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:419 */;
          45  +
                        /* JsonParserGenerator.kt:422 */
   32     46   
                        if let Some(value) = value {
   33     47   
                            items.push(value);
   34         -
                        } else {
          48  +
                        }
          49  +
                        /* JsonParserGenerator.kt:430 */
          50  +
                        else {
   35     51   
                            return Err(
   36     52   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     53   
                                    "dense list cannot contain null values",
   38     54   
                                ),
   39     55   
                            );
   40     56   
                        }
   41         -
                    }
          57  +
                        /* JsonParserGenerator.kt:413 */
          58  +
                    } /* JsonParserGenerator.kt:409 */
   42     59   
                }
          60  +
                /* JsonParserGenerator.kt:408 */
   43     61   
            }
          62  +
            /* JsonParserGenerator.kt:446 */
   44     63   
            Ok(Some(items))
          64  +
            /* JsonParserGenerator.kt:713 */
   45     65   
        }
   46         -
        _ => Err(
   47         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   48         -
                "expected start array or null",
   49         -
            ),
   50         -
        ),
          66  +
        /* JsonParserGenerator.kt:722 */
          67  +
        _ => {
          68  +
            /* JsonParserGenerator.kt:723 */
          69  +
            Err(
          70  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          71  +
                    "expected start array or null",
          72  +
                ),
          73  +
            )
          74  +
            /* JsonParserGenerator.kt:722 */
          75  +
        } /* JsonParserGenerator.kt:712 */
   51     76   
    }
          77  +
    /* JsonParserGenerator.kt:398 */
   52     78   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_string_set.rs

@@ -1,1 +54,80 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_string_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::string_set_unconstrained::StringSetUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
   27         -
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
   28         -
                            tokens.next(),
   29         -
                        )?
   30         -
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   31         -
                        .transpose()?;
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:419 */;
          45  +
                        /* JsonParserGenerator.kt:422 */
   32     46   
                        if let Some(value) = value {
   33     47   
                            items.push(value);
   34         -
                        } else {
          48  +
                        }
          49  +
                        /* JsonParserGenerator.kt:430 */
          50  +
                        else {
   35     51   
                            return Err(
   36     52   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     53   
                                    "dense list cannot contain null values",
   38     54   
                                ),
   39     55   
                            );
   40     56   
                        }
   41         -
                    }
          57  +
                        /* JsonParserGenerator.kt:413 */
          58  +
                    } /* JsonParserGenerator.kt:409 */
   42     59   
                }
          60  +
                /* JsonParserGenerator.kt:408 */
   43     61   
            }
          62  +
            /* JsonParserGenerator.kt:444 */
   44     63   
            Ok(Some(
   45     64   
                crate::unconstrained::string_set_unconstrained::StringSetUnconstrained(items),
   46     65   
            ))
          66  +
            /* JsonParserGenerator.kt:713 */
   47     67   
        }
   48         -
        _ => Err(
   49         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   50         -
                "expected start array or null",
   51         -
            ),
   52         -
        ),
          68  +
        /* JsonParserGenerator.kt:722 */
          69  +
        _ => {
          70  +
            /* JsonParserGenerator.kt:723 */
          71  +
            Err(
          72  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          73  +
                    "expected start array or null",
          74  +
                ),
          75  +
            )
          76  +
            /* JsonParserGenerator.kt:722 */
          77  +
        } /* JsonParserGenerator.kt:712 */
   53     78   
    }
          79  +
    /* JsonParserGenerator.kt:398 */
   54     80   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_structure_set.rs

@@ -1,1 +53,76 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_structure_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::structure_set_unconstrained::StructureSetUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
   27     38   
                        let value =
   28         -
                            crate::protocol_serde::shape_greeting_struct::de_greeting_struct(
   29         -
                                tokens,
   30         -
                            )?;
          39  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?
          40  +
                        /* JsonParserGenerator.kt:419 */;
          41  +
                        /* JsonParserGenerator.kt:422 */
   31     42   
                        if let Some(value) = value {
   32     43   
                            items.push(value);
   33         -
                        } else {
          44  +
                        }
          45  +
                        /* JsonParserGenerator.kt:430 */
          46  +
                        else {
   34     47   
                            return Err(
   35     48   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   36     49   
                                    "dense list cannot contain null values",
   37     50   
                                ),
   38     51   
                            );
   39     52   
                        }
   40         -
                    }
          53  +
                        /* JsonParserGenerator.kt:413 */
          54  +
                    } /* JsonParserGenerator.kt:409 */
   41     55   
                }
          56  +
                /* JsonParserGenerator.kt:408 */
   42     57   
            }
          58  +
            /* JsonParserGenerator.kt:444 */
   43     59   
            Ok(Some(
   44     60   
                crate::unconstrained::structure_set_unconstrained::StructureSetUnconstrained(items),
   45     61   
            ))
          62  +
            /* JsonParserGenerator.kt:713 */
   46     63   
        }
   47         -
        _ => Err(
   48         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   49         -
                "expected start array or null",
   50         -
            ),
   51         -
        ),
          64  +
        /* JsonParserGenerator.kt:722 */
          65  +
        _ => {
          66  +
            /* JsonParserGenerator.kt:723 */
          67  +
            Err(
          68  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          69  +
                    "expected start array or null",
          70  +
                ),
          71  +
            )
          72  +
            /* JsonParserGenerator.kt:722 */
          73  +
        } /* JsonParserGenerator.kt:712 */
   52     74   
    }
          75  +
    /* JsonParserGenerator.kt:398 */
   53     76   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_structure_set_with_no_key.rs

@@ -1,1 +38,62 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_structure_set_with_no_key<'a, I>(tokens: &mut ::std::iter::Peekable<I>) -> ::std::result::Result<Option<crate::unconstrained::structure_set_with_no_key_unconstrained::StructureSetWithNoKeyUnconstrained>, ::aws_smithy_json::deserialize::error::DeserializeError>
    3      4   
where I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>{
           5  +
    /* JsonParserGenerator.kt:712 */
    4      6   
    match tokens.next().transpose()? {
           7  +
        /* JsonParserGenerator.kt:713 */
    5      8   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
    6      9   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          10  +
            /* JsonParserGenerator.kt:407 */
    7     11   
            let mut items = Vec::new();
          12  +
            /* JsonParserGenerator.kt:408 */
    8     13   
            loop {
          14  +
                /* JsonParserGenerator.kt:409 */
    9     15   
                match tokens.peek() {
          16  +
                    /* JsonParserGenerator.kt:410 */
   10     17   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          18  +
                        /* JsonParserGenerator.kt:411 */
   11     19   
                        tokens.next().transpose().unwrap();
   12     20   
                        break;
          21  +
                        /* JsonParserGenerator.kt:410 */
   13     22   
                    }
          23  +
                    /* JsonParserGenerator.kt:413 */
   14     24   
                    _ => {
          25  +
                        /* JsonParserGenerator.kt:419 */
   15     26   
                        let value =
   16         -
                            crate::protocol_serde::shape_missing_key_structure::de_missing_key_structure(tokens)?
   17         -
                        ;
          27  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_missing_key_structure::de_missing_key_structure(tokens)?
          28  +
                        /* JsonParserGenerator.kt:419 */;
          29  +
                        /* JsonParserGenerator.kt:422 */
   18     30   
                        if let Some(value) = value {
   19     31   
                            items.push(value);
   20         -
                        } else {
          32  +
                        }
          33  +
                        /* JsonParserGenerator.kt:430 */
          34  +
                        else {
   21     35   
                            return Err(
   22     36   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   23     37   
                                    "dense list cannot contain null values",
   24     38   
                                ),
   25     39   
                            );
   26     40   
                        }
   27         -
                    }
          41  +
                        /* JsonParserGenerator.kt:413 */
          42  +
                    } /* JsonParserGenerator.kt:409 */
   28     43   
                }
          44  +
                /* JsonParserGenerator.kt:408 */
   29     45   
            }
          46  +
            /* JsonParserGenerator.kt:444 */
   30     47   
            Ok(Some(crate::unconstrained::structure_set_with_no_key_unconstrained::StructureSetWithNoKeyUnconstrained(items)))
          48  +
            /* JsonParserGenerator.kt:713 */
   31     49   
        }
   32         -
        _ => Err(
   33         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   34         -
                "expected start array or null",
   35         -
            ),
   36         -
        ),
          50  +
        /* JsonParserGenerator.kt:722 */
          51  +
        _ => {
          52  +
            /* JsonParserGenerator.kt:723 */
          53  +
            Err(
          54  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          55  +
                    "expected start array or null",
          56  +
                ),
          57  +
            )
          58  +
            /* JsonParserGenerator.kt:722 */
          59  +
        } /* JsonParserGenerator.kt:712 */
   37     60   
    }
          61  +
    /* JsonParserGenerator.kt:398 */
   38     62   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_timestamp_set.rs

@@ -1,1 +54,76 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_timestamp_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::timestamp_set_unconstrained::TimestampSetUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
   27     38   
                        let value =
   28         -
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
   29         -
                                tokens.next(),
   30         -
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
   31         -
                            )?;
          39  +
                            /* JsonParserGenerator.kt:384 */::aws_smithy_json::deserialize::token::expect_timestamp_or_null(tokens.next(), ::aws_smithy_types::date_time::Format::EpochSeconds)?
          40  +
                        /* JsonParserGenerator.kt:419 */;
          41  +
                        /* JsonParserGenerator.kt:422 */
   32     42   
                        if let Some(value) = value {
   33     43   
                            items.push(value);
   34         -
                        } else {
          44  +
                        }
          45  +
                        /* JsonParserGenerator.kt:430 */
          46  +
                        else {
   35     47   
                            return Err(
   36     48   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     49   
                                    "dense list cannot contain null values",
   38     50   
                                ),
   39     51   
                            );
   40     52   
                        }
   41         -
                    }
          53  +
                        /* JsonParserGenerator.kt:413 */
          54  +
                    } /* JsonParserGenerator.kt:409 */
   42     55   
                }
          56  +
                /* JsonParserGenerator.kt:408 */
   43     57   
            }
          58  +
            /* JsonParserGenerator.kt:444 */
   44     59   
            Ok(Some(
   45     60   
                crate::unconstrained::timestamp_set_unconstrained::TimestampSetUnconstrained(items),
   46     61   
            ))
          62  +
            /* JsonParserGenerator.kt:713 */
   47     63   
        }
   48         -
        _ => Err(
   49         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   50         -
                "expected start array or null",
   51         -
            ),
   52         -
        ),
          64  +
        /* JsonParserGenerator.kt:722 */
          65  +
        _ => {
          66  +
            /* JsonParserGenerator.kt:723 */
          67  +
            Err(
          68  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          69  +
                    "expected start array or null",
          70  +
                ),
          71  +
            )
          72  +
            /* JsonParserGenerator.kt:722 */
          73  +
        } /* JsonParserGenerator.kt:712 */
   53     74   
    }
          75  +
    /* JsonParserGenerator.kt:398 */
   54     76   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_union_set.rs

@@ -1,1 +50,76 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_union_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::union_set_unconstrained::UnionSetUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
   27         -
                        let value = crate::protocol_serde::shape_foo_union::de_foo_union(tokens)?;
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_foo_union::de_foo_union(tokens)?
          40  +
                        /* JsonParserGenerator.kt:419 */;
          41  +
                        /* JsonParserGenerator.kt:422 */
   28     42   
                        if let Some(value) = value {
   29     43   
                            items.push(value);
   30         -
                        } else {
          44  +
                        }
          45  +
                        /* JsonParserGenerator.kt:430 */
          46  +
                        else {
   31     47   
                            return Err(
   32     48   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   33     49   
                                    "dense list cannot contain null values",
   34     50   
                                ),
   35     51   
                            );
   36     52   
                        }
   37         -
                    }
          53  +
                        /* JsonParserGenerator.kt:413 */
          54  +
                    } /* JsonParserGenerator.kt:409 */
   38     55   
                }
          56  +
                /* JsonParserGenerator.kt:408 */
   39     57   
            }
          58  +
            /* JsonParserGenerator.kt:444 */
   40     59   
            Ok(Some(
   41     60   
                crate::unconstrained::union_set_unconstrained::UnionSetUnconstrained(items),
   42     61   
            ))
          62  +
            /* JsonParserGenerator.kt:713 */
   43     63   
        }
   44         -
        _ => Err(
   45         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   46         -
                "expected start array or null",
   47         -
            ),
   48         -
        ),
          64  +
        /* JsonParserGenerator.kt:722 */
          65  +
        _ => {
          66  +
            /* JsonParserGenerator.kt:723 */
          67  +
            Err(
          68  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          69  +
                    "expected start array or null",
          70  +
                ),
          71  +
            )
          72  +
            /* JsonParserGenerator.kt:722 */
          73  +
        } /* JsonParserGenerator.kt:712 */
   49     74   
    }
          75  +
    /* JsonParserGenerator.kt:398 */
   50     76   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_validation_exception.rs

@@ -1,1 +35,58 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_validation_exception_error(
    3      4   
    value: &crate::error::ValidationException,
    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_validation_exception::ser_validation_exception(
    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_validation_exception(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::error::ValidationException,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.field_list {
          27  +
        /* JsonSerializerGenerator.kt:484 */
   20     28   
        let mut array_2 = object.key("fieldList").start_array();
          29  +
        /* JsonSerializerGenerator.kt:524 */
   21     30   
        for item_3 in var_1 {
          31  +
            /* SerializerUtil.kt:42 */
   22     32   
            {
          33  +
                /* JsonSerializerGenerator.kt:495 */
   23     34   
                #[allow(unused_mut)]
          35  +
                /* JsonSerializerGenerator.kt:496 */
   24     36   
                let mut object_4 = array_2.value().start_object();
          37  +
                /* JsonSerializerGenerator.kt:375 */
   25     38   
                crate::protocol_serde::shape_validation_exception_field::ser_validation_exception_field(&mut object_4, item_3)?;
          39  +
                /* JsonSerializerGenerator.kt:515 */
   26     40   
                object_4.finish();
          41  +
                /* SerializerUtil.kt:42 */
   27     42   
            }
          43  +
            /* JsonSerializerGenerator.kt:524 */
   28     44   
        }
          45  +
        /* JsonSerializerGenerator.kt:486 */
   29     46   
        array_2.finish();
          47  +
        /* JsonSerializerGenerator.kt:382 */
   30     48   
    }
          49  +
    /* SerializerUtil.kt:42 */
   31     50   
    {
          51  +
        /* JsonSerializerGenerator.kt:423 */
   32     52   
        object.key("message").string(input.message.as_str());
          53  +
        /* SerializerUtil.kt:42 */
   33     54   
    }
          55  +
    /* JsonSerializerGenerator.kt:372 */
   34     56   
    Ok(())
          57  +
    /* JsonSerializerGenerator.kt:358 */
   35     58   
}

tmp-codegen-diff/codegen-server-test/rest_json_validation/rust-server-codegen/src/protocol_serde/shape_validation_exception_field.rs

@@ -1,1 +13,22 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:358 */
    2      3   
pub fn ser_validation_exception_field(
    3      4   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    4      5   
    input: &crate::model::ValidationExceptionField,
    5      6   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           7  +
    /* SerializerUtil.kt:42 */
    6      8   
    {
           9  +
        /* JsonSerializerGenerator.kt:423 */
    7     10   
        object.key("path").string(input.path.as_str());
          11  +
        /* SerializerUtil.kt:42 */
    8     12   
    }
          13  +
    /* SerializerUtil.kt:42 */
    9     14   
    {
          15  +
        /* JsonSerializerGenerator.kt:423 */
   10     16   
        object.key("message").string(input.message.as_str());
          17  +
        /* SerializerUtil.kt:42 */
   11     18   
    }
          19  +
    /* JsonSerializerGenerator.kt:372 */
   12     20   
    Ok(())
          21  +
    /* JsonSerializerGenerator.kt:358 */
   13     22   
}

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

@@ -1,1 +31,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerServiceGenerator.kt:795 */
    2      3   
/// The service builder for [`RestJsonValidation`].
    3      4   
///
    4      5   
/// Constructed via [`RestJsonValidation::builder`].
    5      6   
pub struct RestJsonValidationBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    malformed_enum: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    malformed_length: Option<::aws_smithy_http_server::routing::Route<Body>>,
    8      9   
    malformed_length_override: Option<::aws_smithy_http_server::routing::Route<Body>>,
    9     10   
    malformed_length_query_string: Option<::aws_smithy_http_server::routing::Route<Body>>,
   10     11   
    malformed_pattern: Option<::aws_smithy_http_server::routing::Route<Body>>,
   11     12   
    malformed_pattern_override: Option<::aws_smithy_http_server::routing::Route<Body>>,
@@ -2692,2693 +2751,2753 @@
 2712   2713   
            "aws.protocoltests.restjson.validation",
 2713   2714   
            "RestJsonValidation",
 2714   2715   
        );
 2715   2716   
 2716   2717   
    const VERSION: Option<&'static str> = Some("2021-08-19");
 2717   2718   
 2718   2719   
    type Protocol = ::aws_smithy_http_server::protocol::rest_json_1::RestJson1;
 2719   2720   
 2720   2721   
    type Operations = Operation;
 2721   2722   
}
        2723  +
/* ServiceConfigGenerator.kt:178 */
 2722   2724   
/// Configuration for the [`RestJsonValidation`]. This is the central place where to register and
 2723   2725   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
 2724   2726   
///
 2725   2727   
/// ```rust,no_run
 2726   2728   
/// # use rest_json_validation::RestJsonValidationConfig;
 2727   2729   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
 2728   2730   
/// # use ::tower::layer::util::Identity;
 2729   2731   
/// # let authentication_plugin = IdentityPlugin;
 2730   2732   
/// # let authorization_plugin = IdentityPlugin;
 2731   2733   
/// # let server_request_id_provider_layer = Identity::new();
@@ -2813,2815 +2872,2875 @@
 2833   2835   
 2834   2836   
    /// Build the configuration.
 2835   2837   
    pub fn build(self) -> super::RestJsonValidationConfig<L, H, M> {
 2836   2838   
        super::RestJsonValidationConfig {
 2837   2839   
            layers: self.layers,
 2838   2840   
            http_plugins: self.http_plugins,
 2839   2841   
            model_plugins: self.model_plugins,
 2840   2842   
        }
 2841   2843   
    }
 2842   2844   
}
        2845  +
/* ScopeMacroGenerator.kt:81 */
 2843   2846   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
 2844   2847   
///
 2845   2848   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
 2846   2849   
/// of the service and any operations _not_ specified will be placed in the opposing group.
 2847   2850   
///
 2848   2851   
/// # Example
 2849   2852   
///
 2850   2853   
/// ```rust
 2851   2854   
/// scope! {
 2852   2855   
///     /// Includes [`MalformedEnum`], excluding all other operations.

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

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