Server Test

Server Test

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +273,392 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_range_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedRangeInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_range_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_malformed_range::de_malformed_range(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()?
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_malformed_range_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedRangeOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* RustType.kt:516 */
   66     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     98   
pub fn ser_malformed_range_http_error(
   68     99   
    error: &crate::error::MalformedRangeError,
   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::MalformedRangeError::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))?
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   98    141   
        }
   99         -
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    145   
}
  102    146   
         147  +
/* JsonParserGenerator.kt:148 */
  103    148   
pub(crate) fn de_malformed_range(
  104    149   
    value: &[u8],
  105    150   
    mut builder: crate::input::malformed_range_input::Builder,
  106    151   
) -> ::std::result::Result<
  107    152   
    crate::input::malformed_range_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   
                    "byte" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
  121    173   
                        builder = builder.set_byte(
         174  +
                            /* JsonParserGenerator.kt:365 */
  122    175   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  123    176   
                                tokens.next(),
  124    177   
                            )?
  125    178   
                            .map(i8::try_from)
  126         -
                            .transpose()?,
         179  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  127    180   
                        );
         181  +
                        /* JsonParserGenerator.kt:262 */
  128    182   
                    }
         183  +
                    /* JsonParserGenerator.kt:262 */
  129    184   
                    "float" => {
         185  +
                        /* JsonParserGenerator.kt:272 */
  130    186   
                        builder = builder.set_float(
         187  +
                            /* JsonParserGenerator.kt:361 */
  131    188   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  132    189   
                                tokens.next(),
  133    190   
                            )?
  134         -
                            .map(|v| v.to_f32_lossy()),
         191  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  135    192   
                        );
         193  +
                        /* JsonParserGenerator.kt:262 */
  136    194   
                    }
         195  +
                    /* JsonParserGenerator.kt:262 */
  137    196   
                    "integer" => {
         197  +
                        /* JsonParserGenerator.kt:272 */
  138    198   
                        builder = builder.set_integer(
         199  +
                            /* JsonParserGenerator.kt:365 */
  139    200   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  140    201   
                                tokens.next(),
  141    202   
                            )?
  142    203   
                            .map(i32::try_from)
  143         -
                            .transpose()?,
         204  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  144    205   
                        );
         206  +
                        /* JsonParserGenerator.kt:262 */
  145    207   
                    }
         208  +
                    /* JsonParserGenerator.kt:262 */
  146    209   
                    "long" => {
         210  +
                        /* JsonParserGenerator.kt:272 */
  147    211   
                        builder = builder.set_long(
         212  +
                            /* JsonParserGenerator.kt:365 */
  148    213   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  149    214   
                                tokens.next(),
  150    215   
                            )?
  151    216   
                            .map(i64::try_from)
  152         -
                            .transpose()?,
         217  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  153    218   
                        );
         219  +
                        /* JsonParserGenerator.kt:262 */
  154    220   
                    }
         221  +
                    /* JsonParserGenerator.kt:262 */
  155    222   
                    "maxByte" => {
         223  +
                        /* JsonParserGenerator.kt:272 */
  156    224   
                        builder = builder.set_max_byte(
         225  +
                            /* JsonParserGenerator.kt:365 */
  157    226   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  158    227   
                                tokens.next(),
  159    228   
                            )?
  160    229   
                            .map(i8::try_from)
  161         -
                            .transpose()?,
         230  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  162    231   
                        );
         232  +
                        /* JsonParserGenerator.kt:262 */
  163    233   
                    }
         234  +
                    /* JsonParserGenerator.kt:262 */
  164    235   
                    "maxFloat" => {
         236  +
                        /* JsonParserGenerator.kt:272 */
  165    237   
                        builder = builder.set_max_float(
         238  +
                            /* JsonParserGenerator.kt:361 */
  166    239   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  167    240   
                                tokens.next(),
  168    241   
                            )?
  169         -
                            .map(|v| v.to_f32_lossy()),
         242  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  170    243   
                        );
         244  +
                        /* JsonParserGenerator.kt:262 */
  171    245   
                    }
         246  +
                    /* JsonParserGenerator.kt:262 */
  172    247   
                    "maxInteger" => {
         248  +
                        /* JsonParserGenerator.kt:272 */
  173    249   
                        builder = builder.set_max_integer(
         250  +
                            /* JsonParserGenerator.kt:365 */
  174    251   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  175    252   
                                tokens.next(),
  176    253   
                            )?
  177    254   
                            .map(i32::try_from)
  178         -
                            .transpose()?,
         255  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  179    256   
                        );
         257  +
                        /* JsonParserGenerator.kt:262 */
  180    258   
                    }
         259  +
                    /* JsonParserGenerator.kt:262 */
  181    260   
                    "maxLong" => {
         261  +
                        /* JsonParserGenerator.kt:272 */
  182    262   
                        builder = builder.set_max_long(
         263  +
                            /* JsonParserGenerator.kt:365 */
  183    264   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  184    265   
                                tokens.next(),
  185    266   
                            )?
  186    267   
                            .map(i64::try_from)
  187         -
                            .transpose()?,
         268  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  188    269   
                        );
         270  +
                        /* JsonParserGenerator.kt:262 */
  189    271   
                    }
         272  +
                    /* JsonParserGenerator.kt:262 */
  190    273   
                    "maxShort" => {
         274  +
                        /* JsonParserGenerator.kt:272 */
  191    275   
                        builder = builder.set_max_short(
         276  +
                            /* JsonParserGenerator.kt:365 */
  192    277   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  193    278   
                                tokens.next(),
  194    279   
                            )?
  195    280   
                            .map(i16::try_from)
  196         -
                            .transpose()?,
         281  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  197    282   
                        );
         283  +
                        /* JsonParserGenerator.kt:262 */
  198    284   
                    }
         285  +
                    /* JsonParserGenerator.kt:262 */
  199    286   
                    "minByte" => {
         287  +
                        /* JsonParserGenerator.kt:272 */
  200    288   
                        builder = builder.set_min_byte(
         289  +
                            /* JsonParserGenerator.kt:365 */
  201    290   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  202    291   
                                tokens.next(),
  203    292   
                            )?
  204    293   
                            .map(i8::try_from)
  205         -
                            .transpose()?,
         294  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  206    295   
                        );
         296  +
                        /* JsonParserGenerator.kt:262 */
  207    297   
                    }
         298  +
                    /* JsonParserGenerator.kt:262 */
  208    299   
                    "minFloat" => {
         300  +
                        /* JsonParserGenerator.kt:272 */
  209    301   
                        builder = builder.set_min_float(
         302  +
                            /* JsonParserGenerator.kt:361 */
  210    303   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  211    304   
                                tokens.next(),
  212    305   
                            )?
  213         -
                            .map(|v| v.to_f32_lossy()),
         306  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  214    307   
                        );
         308  +
                        /* JsonParserGenerator.kt:262 */
  215    309   
                    }
         310  +
                    /* JsonParserGenerator.kt:262 */
  216    311   
                    "minInteger" => {
         312  +
                        /* JsonParserGenerator.kt:272 */
  217    313   
                        builder = builder.set_min_integer(
         314  +
                            /* JsonParserGenerator.kt:365 */
  218    315   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  219    316   
                                tokens.next(),
  220    317   
                            )?
  221    318   
                            .map(i32::try_from)
  222         -
                            .transpose()?,
         319  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  223    320   
                        );
         321  +
                        /* JsonParserGenerator.kt:262 */
  224    322   
                    }
         323  +
                    /* JsonParserGenerator.kt:262 */
  225    324   
                    "minLong" => {
         325  +
                        /* JsonParserGenerator.kt:272 */
  226    326   
                        builder = builder.set_min_long(
         327  +
                            /* JsonParserGenerator.kt:365 */
  227    328   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  228    329   
                                tokens.next(),
  229    330   
                            )?
  230    331   
                            .map(i64::try_from)
  231         -
                            .transpose()?,
         332  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  232    333   
                        );
         334  +
                        /* JsonParserGenerator.kt:262 */
  233    335   
                    }
         336  +
                    /* JsonParserGenerator.kt:262 */
  234    337   
                    "minShort" => {
         338  +
                        /* JsonParserGenerator.kt:272 */
  235    339   
                        builder = builder.set_min_short(
         340  +
                            /* JsonParserGenerator.kt:365 */
  236    341   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  237    342   
                                tokens.next(),
  238    343   
                            )?
  239    344   
                            .map(i16::try_from)
  240         -
                            .transpose()?,
         345  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  241    346   
                        );
         347  +
                        /* JsonParserGenerator.kt:262 */
  242    348   
                    }
         349  +
                    /* JsonParserGenerator.kt:262 */
  243    350   
                    "short" => {
         351  +
                        /* JsonParserGenerator.kt:272 */
  244    352   
                        builder = builder.set_short(
         353  +
                            /* JsonParserGenerator.kt:365 */
  245    354   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  246    355   
                                tokens.next(),
  247    356   
                            )?
  248    357   
                            .map(i16::try_from)
  249         -
                            .transpose()?,
         358  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  250    359   
                        );
         360  +
                        /* JsonParserGenerator.kt:262 */
  251    361   
                    }
  252         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         362  +
                    /* JsonParserGenerator.kt:290 */
         363  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  253    364   
                }
         365  +
                /* JsonParserGenerator.kt:686 */
  254    366   
            }
         367  +
            /* JsonParserGenerator.kt:695 */
  255    368   
            other => {
  256    369   
                return Err(
  257    370   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  258    371   
                        "expected object key or end object, found: {:?}",
  259    372   
                        other
  260    373   
                    )),
  261    374   
                )
         375  +
            } /* JsonParserGenerator.kt:685 */
  262    376   
        }
         377  +
        /* JsonParserGenerator.kt:684 */
  263    378   
    }
  264         -
    }
         379  +
    /* JsonParserGenerator.kt:250 */
  265    380   
    if tokens.next().is_some() {
         381  +
        /* JsonParserGenerator.kt:251 */
  266    382   
        return Err(
  267    383   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  268    384   
                "found more JSON tokens after completing parsing",
  269    385   
            ),
  270    386   
        );
         387  +
        /* JsonParserGenerator.kt:250 */
  271    388   
    }
         389  +
    /* JsonParserGenerator.kt:163 */
  272    390   
    Ok(builder)
         391  +
    /* JsonParserGenerator.kt:148 */
  273    392   
}

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

@@ -1,1 +274,393 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_range_override_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedRangeOverrideInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_range_override_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input =
   29     39   
                crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override(
   30     40   
                    bytes.as_ref(),
   31     41   
                    input,
   32     42   
                )?;
          43  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   33     44   
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   34     46   
        input.build()?
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   35     48   
    })
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   36     50   
}
   37     51   
          52  +
/* RustType.kt:516 */
   38     53   
#[allow(clippy::unnecessary_wraps)]
          54  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   39     55   
pub fn ser_malformed_range_override_http_response(
   40     56   
    #[allow(unused_variables)] output: crate::output::MalformedRangeOverrideOutput,
   41     57   
) -> std::result::Result<
   42     58   
    ::aws_smithy_http_server::response::Response,
   43     59   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   44     60   
> {
          61  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   45     62   
    Ok({
          63  +
        /* RustType.kt:516 */
   46     64   
        #[allow(unused_mut)]
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   47     66   
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   48     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     69   
            builder,
   50     70   
            ::http::header::CONTENT_TYPE,
   51     71   
            "application/json",
   52     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   53     74   
        let http_status: u16 = 200;
   54     75   
        builder = builder.status(http_status);
   55         -
        let payload = "";
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          77  +
        let payload =
          78  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   56     81   
        let content_length = payload.len();
   57     82   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   58     83   
            builder,
   59     84   
            ::http::header::CONTENT_LENGTH,
   60     85   
            content_length,
   61     86   
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   62     88   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   63     90   
        builder.body(body)?
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   64     92   
    })
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   65     94   
}
   66     95   
          96  +
/* RustType.kt:516 */
   67     97   
#[allow(clippy::unnecessary_wraps)]
          98  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   68     99   
pub fn ser_malformed_range_override_http_error(
   69    100   
    error: &crate::error::MalformedRangeOverrideError,
   70    101   
) -> std::result::Result<
   71    102   
    ::aws_smithy_http_server::response::Response,
   72    103   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   73    104   
> {
         105  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   74    106   
    Ok({
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   75    108   
        match error {
         109  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   76    110   
            crate::error::MalformedRangeOverrideError::ValidationException(output) => {
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   77    112   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         113  +
                /* RustType.kt:516 */
   78    114   
                #[allow(unused_mut)]
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   79    116   
                let mut builder = ::http::Response::builder();
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   80    118   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   81    119   
                    builder,
   82    120   
                    ::http::header::CONTENT_TYPE,
   83    121   
                    "application/json",
   84    122   
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   85    124   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   86    125   
                    builder,
   87    126   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   88    127   
                    "ValidationException",
   89    128   
                );
         129  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   90    130   
                let content_length = payload.len();
   91    131   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   92    132   
                    builder,
   93    133   
                    ::http::header::CONTENT_LENGTH,
   94    134   
                    content_length,
   95    135   
                );
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   96    137   
                builder
   97    138   
                    .status(400)
   98    139   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         141  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   99    142   
        }
  100         -
        }
         143  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  101    144   
    })
         145  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  102    146   
}
  103    147   
         148  +
/* JsonParserGenerator.kt:148 */
  104    149   
pub(crate) fn de_malformed_range_override(
  105    150   
    value: &[u8],
  106    151   
    mut builder: crate::input::malformed_range_override_input::Builder,
  107    152   
) -> ::std::result::Result<
  108    153   
    crate::input::malformed_range_override_input::Builder,
  109    154   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  110    155   
> {
         156  +
    /* JsonParserGenerator.kt:153 */
  111    157   
    let mut tokens_owned =
  112    158   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  113    159   
            .peekable();
  114    160   
    let tokens = &mut tokens_owned;
  115    161   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         162  +
    /* JsonParserGenerator.kt:684 */
  116    163   
    loop {
         164  +
        /* JsonParserGenerator.kt:685 */
  117    165   
        match tokens.next().transpose()? {
         166  +
            /* JsonParserGenerator.kt:686 */
  118    167   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  119    168   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         169  +
                /* JsonParserGenerator.kt:260 */
  120    170   
                match key.to_unescaped()?.as_ref() {
         171  +
                    /* JsonParserGenerator.kt:262 */
  121    172   
                    "byte" => {
         173  +
                        /* JsonParserGenerator.kt:272 */
  122    174   
                        builder = builder.set_byte(
         175  +
                            /* JsonParserGenerator.kt:365 */
  123    176   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  124    177   
                                tokens.next(),
  125    178   
                            )?
  126    179   
                            .map(i8::try_from)
  127         -
                            .transpose()?,
         180  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  128    181   
                        );
         182  +
                        /* JsonParserGenerator.kt:262 */
  129    183   
                    }
         184  +
                    /* JsonParserGenerator.kt:262 */
  130    185   
                    "float" => {
         186  +
                        /* JsonParserGenerator.kt:272 */
  131    187   
                        builder = builder.set_float(
         188  +
                            /* JsonParserGenerator.kt:361 */
  132    189   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  133    190   
                                tokens.next(),
  134    191   
                            )?
  135         -
                            .map(|v| v.to_f32_lossy()),
         192  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  136    193   
                        );
         194  +
                        /* JsonParserGenerator.kt:262 */
  137    195   
                    }
         196  +
                    /* JsonParserGenerator.kt:262 */
  138    197   
                    "integer" => {
         198  +
                        /* JsonParserGenerator.kt:272 */
  139    199   
                        builder = builder.set_integer(
         200  +
                            /* JsonParserGenerator.kt:365 */
  140    201   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  141    202   
                                tokens.next(),
  142    203   
                            )?
  143    204   
                            .map(i32::try_from)
  144         -
                            .transpose()?,
         205  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  145    206   
                        );
         207  +
                        /* JsonParserGenerator.kt:262 */
  146    208   
                    }
         209  +
                    /* JsonParserGenerator.kt:262 */
  147    210   
                    "long" => {
         211  +
                        /* JsonParserGenerator.kt:272 */
  148    212   
                        builder = builder.set_long(
         213  +
                            /* JsonParserGenerator.kt:365 */
  149    214   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  150    215   
                                tokens.next(),
  151    216   
                            )?
  152    217   
                            .map(i64::try_from)
  153         -
                            .transpose()?,
         218  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  154    219   
                        );
         220  +
                        /* JsonParserGenerator.kt:262 */
  155    221   
                    }
         222  +
                    /* JsonParserGenerator.kt:262 */
  156    223   
                    "maxByte" => {
         224  +
                        /* JsonParserGenerator.kt:272 */
  157    225   
                        builder = builder.set_max_byte(
         226  +
                            /* JsonParserGenerator.kt:365 */
  158    227   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  159    228   
                                tokens.next(),
  160    229   
                            )?
  161    230   
                            .map(i8::try_from)
  162         -
                            .transpose()?,
         231  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  163    232   
                        );
         233  +
                        /* JsonParserGenerator.kt:262 */
  164    234   
                    }
         235  +
                    /* JsonParserGenerator.kt:262 */
  165    236   
                    "maxFloat" => {
         237  +
                        /* JsonParserGenerator.kt:272 */
  166    238   
                        builder = builder.set_max_float(
         239  +
                            /* JsonParserGenerator.kt:361 */
  167    240   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  168    241   
                                tokens.next(),
  169    242   
                            )?
  170         -
                            .map(|v| v.to_f32_lossy()),
         243  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  171    244   
                        );
         245  +
                        /* JsonParserGenerator.kt:262 */
  172    246   
                    }
         247  +
                    /* JsonParserGenerator.kt:262 */
  173    248   
                    "maxInteger" => {
         249  +
                        /* JsonParserGenerator.kt:272 */
  174    250   
                        builder = builder.set_max_integer(
         251  +
                            /* JsonParserGenerator.kt:365 */
  175    252   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  176    253   
                                tokens.next(),
  177    254   
                            )?
  178    255   
                            .map(i32::try_from)
  179         -
                            .transpose()?,
         256  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  180    257   
                        );
         258  +
                        /* JsonParserGenerator.kt:262 */
  181    259   
                    }
         260  +
                    /* JsonParserGenerator.kt:262 */
  182    261   
                    "maxLong" => {
         262  +
                        /* JsonParserGenerator.kt:272 */
  183    263   
                        builder = builder.set_max_long(
         264  +
                            /* JsonParserGenerator.kt:365 */
  184    265   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  185    266   
                                tokens.next(),
  186    267   
                            )?
  187    268   
                            .map(i64::try_from)
  188         -
                            .transpose()?,
         269  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  189    270   
                        );
         271  +
                        /* JsonParserGenerator.kt:262 */
  190    272   
                    }
         273  +
                    /* JsonParserGenerator.kt:262 */
  191    274   
                    "maxShort" => {
         275  +
                        /* JsonParserGenerator.kt:272 */
  192    276   
                        builder = builder.set_max_short(
         277  +
                            /* JsonParserGenerator.kt:365 */
  193    278   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  194    279   
                                tokens.next(),
  195    280   
                            )?
  196    281   
                            .map(i16::try_from)
  197         -
                            .transpose()?,
         282  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  198    283   
                        );
         284  +
                        /* JsonParserGenerator.kt:262 */
  199    285   
                    }
         286  +
                    /* JsonParserGenerator.kt:262 */
  200    287   
                    "minByte" => {
         288  +
                        /* JsonParserGenerator.kt:272 */
  201    289   
                        builder = builder.set_min_byte(
         290  +
                            /* JsonParserGenerator.kt:365 */
  202    291   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  203    292   
                                tokens.next(),
  204    293   
                            )?
  205    294   
                            .map(i8::try_from)
  206         -
                            .transpose()?,
         295  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  207    296   
                        );
         297  +
                        /* JsonParserGenerator.kt:262 */
  208    298   
                    }
         299  +
                    /* JsonParserGenerator.kt:262 */
  209    300   
                    "minFloat" => {
         301  +
                        /* JsonParserGenerator.kt:272 */
  210    302   
                        builder = builder.set_min_float(
         303  +
                            /* JsonParserGenerator.kt:361 */
  211    304   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  212    305   
                                tokens.next(),
  213    306   
                            )?
  214         -
                            .map(|v| v.to_f32_lossy()),
         307  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  215    308   
                        );
         309  +
                        /* JsonParserGenerator.kt:262 */
  216    310   
                    }
         311  +
                    /* JsonParserGenerator.kt:262 */
  217    312   
                    "minInteger" => {
         313  +
                        /* JsonParserGenerator.kt:272 */
  218    314   
                        builder = builder.set_min_integer(
         315  +
                            /* JsonParserGenerator.kt:365 */
  219    316   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  220    317   
                                tokens.next(),
  221    318   
                            )?
  222    319   
                            .map(i32::try_from)
  223         -
                            .transpose()?,
         320  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  224    321   
                        );
         322  +
                        /* JsonParserGenerator.kt:262 */
  225    323   
                    }
         324  +
                    /* JsonParserGenerator.kt:262 */
  226    325   
                    "minLong" => {
         326  +
                        /* JsonParserGenerator.kt:272 */
  227    327   
                        builder = builder.set_min_long(
         328  +
                            /* JsonParserGenerator.kt:365 */
  228    329   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  229    330   
                                tokens.next(),
  230    331   
                            )?
  231    332   
                            .map(i64::try_from)
  232         -
                            .transpose()?,
         333  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  233    334   
                        );
         335  +
                        /* JsonParserGenerator.kt:262 */
  234    336   
                    }
         337  +
                    /* JsonParserGenerator.kt:262 */
  235    338   
                    "minShort" => {
         339  +
                        /* JsonParserGenerator.kt:272 */
  236    340   
                        builder = builder.set_min_short(
         341  +
                            /* JsonParserGenerator.kt:365 */
  237    342   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  238    343   
                                tokens.next(),
  239    344   
                            )?
  240    345   
                            .map(i16::try_from)
  241         -
                            .transpose()?,
         346  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  242    347   
                        );
         348  +
                        /* JsonParserGenerator.kt:262 */
  243    349   
                    }
         350  +
                    /* JsonParserGenerator.kt:262 */
  244    351   
                    "short" => {
         352  +
                        /* JsonParserGenerator.kt:272 */
  245    353   
                        builder = builder.set_short(
         354  +
                            /* JsonParserGenerator.kt:365 */
  246    355   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  247    356   
                                tokens.next(),
  248    357   
                            )?
  249    358   
                            .map(i16::try_from)
  250         -
                            .transpose()?,
         359  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  251    360   
                        );
         361  +
                        /* JsonParserGenerator.kt:262 */
  252    362   
                    }
  253         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         363  +
                    /* JsonParserGenerator.kt:290 */
         364  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  254    365   
                }
         366  +
                /* JsonParserGenerator.kt:686 */
  255    367   
            }
         368  +
            /* JsonParserGenerator.kt:695 */
  256    369   
            other => {
  257    370   
                return Err(
  258    371   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  259    372   
                        "expected object key or end object, found: {:?}",
  260    373   
                        other
  261    374   
                    )),
  262    375   
                )
         376  +
            } /* JsonParserGenerator.kt:685 */
  263    377   
        }
         378  +
        /* JsonParserGenerator.kt:684 */
  264    379   
    }
  265         -
    }
         380  +
    /* JsonParserGenerator.kt:250 */
  266    381   
    if tokens.next().is_some() {
         382  +
        /* JsonParserGenerator.kt:251 */
  267    383   
        return Err(
  268    384   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  269    385   
                "found more JSON tokens after completing parsing",
  270    386   
            ),
  271    387   
        );
         388  +
        /* JsonParserGenerator.kt:250 */
  272    389   
    }
         390  +
    /* JsonParserGenerator.kt:163 */
  273    391   
    Ok(builder)
         392  +
    /* JsonParserGenerator.kt:148 */
  274    393   
}

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

@@ -1,1 +170,243 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_required_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedRequiredInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_required_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_malformed_required::de_malformed_required(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_required_input::de_string_in_header_header(
   35     47   
                &headers,
   36     48   
            )?
   37     49   
        {
   38     50   
            input = input.set_string_in_header(value)
   39     51   
        }
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   40     53   
        let query_string = uri.query().unwrap_or("");
   41     54   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   42     56   
        let mut string_in_query_seen = false;
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   43     58   
        for (k, v) in pairs {
          59  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   44     60   
            if !string_in_query_seen && k == "stringInQuery" {
   45     61   
                input = input.set_string_in_query(
   46     62   
                    crate::protocol_serde::shape_malformed_required_input::de_string_in_query(&v)?,
   47     63   
                );
   48     64   
                string_in_query_seen = true;
   49     65   
            }
          66  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   50     67   
        }
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   51     69   
        input.build()?
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   52     71   
    })
          72  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   53     73   
}
   54     74   
          75  +
/* RustType.kt:516 */
   55     76   
#[allow(clippy::unnecessary_wraps)]
          77  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   56     78   
pub fn ser_malformed_required_http_response(
   57     79   
    #[allow(unused_variables)] output: crate::output::MalformedRequiredOutput,
   58     80   
) -> std::result::Result<
   59     81   
    ::aws_smithy_http_server::response::Response,
   60     82   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   61     83   
> {
          84  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   62     85   
    Ok({
          86  +
        /* RustType.kt:516 */
   63     87   
        #[allow(unused_mut)]
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   64     89   
        let mut builder = ::http::Response::builder();
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   65     91   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   66     92   
            builder,
   67     93   
            ::http::header::CONTENT_TYPE,
   68     94   
            "application/json",
   69     95   
        );
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   70     97   
        let http_status: u16 = 200;
   71     98   
        builder = builder.status(http_status);
   72         -
        let payload = "";
          99  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         100  +
        let payload =
         101  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         102  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   73    104   
        let content_length = payload.len();
   74    105   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   75    106   
            builder,
   76    107   
            ::http::header::CONTENT_LENGTH,
   77    108   
            content_length,
   78    109   
        );
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   79    111   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   80    113   
        builder.body(body)?
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   81    115   
    })
         116  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   82    117   
}
   83    118   
         119  +
/* RustType.kt:516 */
   84    120   
#[allow(clippy::unnecessary_wraps)]
         121  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   85    122   
pub fn ser_malformed_required_http_error(
   86    123   
    error: &crate::error::MalformedRequiredError,
   87    124   
) -> std::result::Result<
   88    125   
    ::aws_smithy_http_server::response::Response,
   89    126   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   90    127   
> {
         128  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   91    129   
    Ok({
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   92    131   
        match error {
         132  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   93    133   
            crate::error::MalformedRequiredError::ValidationException(output) => {
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   94    135   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         136  +
                /* RustType.kt:516 */
   95    137   
                #[allow(unused_mut)]
         138  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   96    139   
                let mut builder = ::http::Response::builder();
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   97    141   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   98    142   
                    builder,
   99    143   
                    ::http::header::CONTENT_TYPE,
  100    144   
                    "application/json",
  101    145   
                );
         146  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  102    147   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  103    148   
                    builder,
  104    149   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  105    150   
                    "ValidationException",
  106    151   
                );
         152  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  107    153   
                let content_length = payload.len();
  108    154   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  109    155   
                    builder,
  110    156   
                    ::http::header::CONTENT_LENGTH,
  111    157   
                    content_length,
  112    158   
                );
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  113    160   
                builder
  114    161   
                    .status(400)
  115    162   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         163  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         164  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  116    165   
        }
  117         -
        }
         166  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  118    167   
    })
         168  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  119    169   
}
  120    170   
         171  +
/* JsonParserGenerator.kt:148 */
  121    172   
pub(crate) fn de_malformed_required(
  122    173   
    value: &[u8],
  123    174   
    mut builder: crate::input::malformed_required_input::Builder,
  124    175   
) -> ::std::result::Result<
  125    176   
    crate::input::malformed_required_input::Builder,
  126    177   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  127    178   
> {
         179  +
    /* JsonParserGenerator.kt:153 */
  128    180   
    let mut tokens_owned =
  129    181   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  130    182   
            .peekable();
  131    183   
    let tokens = &mut tokens_owned;
  132    184   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         185  +
    /* JsonParserGenerator.kt:684 */
  133    186   
    loop {
         187  +
        /* JsonParserGenerator.kt:685 */
  134    188   
        match tokens.next().transpose()? {
         189  +
            /* JsonParserGenerator.kt:686 */
  135    190   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  136    191   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         192  +
                /* JsonParserGenerator.kt:260 */
  137    193   
                match key.to_unescaped()?.as_ref() {
         194  +
                    /* JsonParserGenerator.kt:262 */
  138    195   
                    "string" => {
         196  +
                        /* JsonParserGenerator.kt:276 */
  139    197   
                        if let Some(v) =
         198  +
                            /* JsonParserGenerator.kt:354 */
  140    199   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  141    200   
                                    tokens.next(),
  142    201   
                                )?
  143         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         202  +
                                .map(|s|
         203  +
                            /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         204  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
         205  +
                            /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
  144    206   
                                .transpose()?
         207  +
                        /* JsonParserGenerator.kt:278 */
  145    208   
                        {
  146    209   
                            builder = builder.set_string(v);
  147    210   
                        }
         211  +
                        /* JsonParserGenerator.kt:262 */
  148    212   
                    }
  149         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         213  +
                    /* JsonParserGenerator.kt:290 */
         214  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  150    215   
                }
         216  +
                /* JsonParserGenerator.kt:686 */
  151    217   
            }
         218  +
            /* JsonParserGenerator.kt:695 */
  152    219   
            other => {
  153    220   
                return Err(
  154    221   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  155    222   
                        "expected object key or end object, found: {:?}",
  156    223   
                        other
  157    224   
                    )),
  158    225   
                )
         226  +
            } /* JsonParserGenerator.kt:685 */
  159    227   
        }
         228  +
        /* JsonParserGenerator.kt:684 */
  160    229   
    }
  161         -
    }
         230  +
    /* JsonParserGenerator.kt:250 */
  162    231   
    if tokens.next().is_some() {
         232  +
        /* JsonParserGenerator.kt:251 */
  163    233   
        return Err(
  164    234   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  165    235   
                "found more JSON tokens after completing parsing",
  166    236   
            ),
  167    237   
        );
         238  +
        /* JsonParserGenerator.kt:250 */
  168    239   
    }
         240  +
    /* JsonParserGenerator.kt:163 */
  169    241   
    Ok(builder)
         242  +
    /* JsonParserGenerator.kt:148 */
  170    243   
}

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

@@ -1,1 +20,28 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_string_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:160 */
    8     10   
    let headers = header_map.get_all("string-in-headers");
          11  +
    /* HttpBindingGenerator.kt:375 */
    9     12   
    ::aws_smithy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:153 */
   10     14   
}
   11     15   
          16  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   12     17   
pub fn de_string_in_query(
   13     18   
    value: &str,
   14     19   
) -> std::result::Result<
   15     20   
    ::std::string::String,
   16     21   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   17     22   
> {
          23  +
    /* ServerHttpBoundProtocolGenerator.kt:1309 */
   18     24   
    let value = value.to_owned();
          25  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   19     26   
    Ok(value)
          27  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   20     28   
}

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

@@ -1,1 +223,347 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_unique_items_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedUniqueItemsInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_unique_items_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_malformed_unique_items::de_malformed_unique_items(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()?
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_malformed_unique_items_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedUniqueItemsOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* RustType.kt:516 */
   66     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     98   
pub fn ser_malformed_unique_items_http_error(
   68     99   
    error: &crate::error::MalformedUniqueItemsError,
   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::MalformedUniqueItemsError::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))?
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   98    141   
        }
   99         -
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    145   
}
  102    146   
         147  +
/* JsonParserGenerator.kt:148 */
  103    148   
pub(crate) fn de_malformed_unique_items(
  104    149   
    value: &[u8],
  105    150   
    mut builder: crate::input::malformed_unique_items_input::Builder,
  106    151   
) -> ::std::result::Result<
  107    152   
    crate::input::malformed_unique_items_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   
                    "blobList" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
  121    173   
                        builder = builder.set_blob_list(
  122         -
                            crate::protocol_serde::shape_blob_set::de_blob_set(tokens)?,
  123         -
                        );
         174  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_blob_set::de_blob_set(tokens)?
         175  +
                        /* JsonParserGenerator.kt:272 */);
         176  +
                        /* JsonParserGenerator.kt:262 */
  124    177   
                    }
         178  +
                    /* JsonParserGenerator.kt:262 */
  125    179   
                    "booleanList" => {
         180  +
                        /* JsonParserGenerator.kt:272 */
  126    181   
                        builder = builder.set_boolean_list(
  127         -
                            crate::protocol_serde::shape_boolean_set::de_boolean_set(tokens)?,
  128         -
                        );
         182  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_boolean_set::de_boolean_set(tokens)?
         183  +
                        /* JsonParserGenerator.kt:272 */);
         184  +
                        /* JsonParserGenerator.kt:262 */
  129    185   
                    }
         186  +
                    /* JsonParserGenerator.kt:262 */
  130    187   
                    "byteList" => {
         188  +
                        /* JsonParserGenerator.kt:272 */
  131    189   
                        builder = builder.set_byte_list(
  132         -
                            crate::protocol_serde::shape_byte_set::de_byte_set(tokens)?,
  133         -
                        );
         190  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_byte_set::de_byte_set(tokens)?
         191  +
                        /* JsonParserGenerator.kt:272 */);
         192  +
                        /* JsonParserGenerator.kt:262 */
  134    193   
                    }
         194  +
                    /* JsonParserGenerator.kt:262 */
  135    195   
                    "dateTimeList" => {
  136         -
                        builder = builder.set_date_time_list(
  137         -
                            crate::protocol_serde::shape_date_time_set::de_date_time_set(tokens)?,
         196  +
                        /* JsonParserGenerator.kt:272 */
         197  +
                        builder =
         198  +
                            builder.set_date_time_list(
         199  +
                                /* JsonParserGenerator.kt:451 */
         200  +
                                crate::protocol_serde::shape_date_time_set::de_date_time_set(
         201  +
                                    tokens,
         202  +
                                )?, /* JsonParserGenerator.kt:272 */
  138    203   
                            );
         204  +
                        /* JsonParserGenerator.kt:262 */
  139    205   
                    }
         206  +
                    /* JsonParserGenerator.kt:262 */
  140    207   
                    "enumList" => {
         208  +
                        /* JsonParserGenerator.kt:272 */
  141    209   
                        builder = builder.set_enum_list(
  142         -
                            crate::protocol_serde::shape_foo_enum_set::de_foo_enum_set(tokens)?,
  143         -
                        );
         210  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_foo_enum_set::de_foo_enum_set(tokens)?
         211  +
                        /* JsonParserGenerator.kt:272 */);
         212  +
                        /* JsonParserGenerator.kt:262 */
  144    213   
                    }
         214  +
                    /* JsonParserGenerator.kt:262 */
  145    215   
                    "httpDateList" => {
  146         -
                        builder = builder.set_http_date_list(
  147         -
                            crate::protocol_serde::shape_http_date_set::de_http_date_set(tokens)?,
         216  +
                        /* JsonParserGenerator.kt:272 */
         217  +
                        builder =
         218  +
                            builder.set_http_date_list(
         219  +
                                /* JsonParserGenerator.kt:451 */
         220  +
                                crate::protocol_serde::shape_http_date_set::de_http_date_set(
         221  +
                                    tokens,
         222  +
                                )?, /* JsonParserGenerator.kt:272 */
  148    223   
                            );
         224  +
                        /* JsonParserGenerator.kt:262 */
  149    225   
                    }
         226  +
                    /* JsonParserGenerator.kt:262 */
  150    227   
                    "intEnumList" => {
         228  +
                        /* JsonParserGenerator.kt:272 */
  151    229   
                        builder = builder.set_int_enum_list(
         230  +
                            /* JsonParserGenerator.kt:451 */
  152    231   
                            crate::protocol_serde::shape_integer_enum_set::de_integer_enum_set(
  153    232   
                                tokens,
  154         -
                            )?,
         233  +
                            )?, /* JsonParserGenerator.kt:272 */
  155    234   
                        );
         235  +
                        /* JsonParserGenerator.kt:262 */
  156    236   
                    }
         237  +
                    /* JsonParserGenerator.kt:262 */
  157    238   
                    "integerList" => {
         239  +
                        /* JsonParserGenerator.kt:272 */
  158    240   
                        builder = builder.set_integer_list(
  159         -
                            crate::protocol_serde::shape_integer_set::de_integer_set(tokens)?,
  160         -
                        );
         241  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_integer_set::de_integer_set(tokens)?
         242  +
                        /* JsonParserGenerator.kt:272 */);
         243  +
                        /* JsonParserGenerator.kt:262 */
  161    244   
                    }
         245  +
                    /* JsonParserGenerator.kt:262 */
  162    246   
                    "listList" => {
         247  +
                        /* JsonParserGenerator.kt:272 */
  163    248   
                        builder = builder.set_list_list(
  164         -
                            crate::protocol_serde::shape_list_set::de_list_set(tokens)?,
  165         -
                        );
         249  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_list_set::de_list_set(tokens)?
         250  +
                        /* JsonParserGenerator.kt:272 */);
         251  +
                        /* JsonParserGenerator.kt:262 */
  166    252   
                    }
         253  +
                    /* JsonParserGenerator.kt:262 */
  167    254   
                    "longList" => {
         255  +
                        /* JsonParserGenerator.kt:272 */
  168    256   
                        builder = builder.set_long_list(
  169         -
                            crate::protocol_serde::shape_long_set::de_long_set(tokens)?,
  170         -
                        );
         257  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_long_set::de_long_set(tokens)?
         258  +
                        /* JsonParserGenerator.kt:272 */);
         259  +
                        /* JsonParserGenerator.kt:262 */
  171    260   
                    }
         261  +
                    /* JsonParserGenerator.kt:262 */
  172    262   
                    "shortList" => {
         263  +
                        /* JsonParserGenerator.kt:272 */
  173    264   
                        builder = builder.set_short_list(
  174         -
                            crate::protocol_serde::shape_short_set::de_short_set(tokens)?,
  175         -
                        );
         265  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_short_set::de_short_set(tokens)?
         266  +
                        /* JsonParserGenerator.kt:272 */);
         267  +
                        /* JsonParserGenerator.kt:262 */
  176    268   
                    }
         269  +
                    /* JsonParserGenerator.kt:262 */
  177    270   
                    "stringList" => {
         271  +
                        /* JsonParserGenerator.kt:272 */
  178    272   
                        builder = builder.set_string_list(
  179         -
                            crate::protocol_serde::shape_string_set::de_string_set(tokens)?,
  180         -
                        );
         273  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_string_set::de_string_set(tokens)?
         274  +
                        /* JsonParserGenerator.kt:272 */);
         275  +
                        /* JsonParserGenerator.kt:262 */
  181    276   
                    }
         277  +
                    /* JsonParserGenerator.kt:262 */
  182    278   
                    "structureList" => {
  183         -
                        builder = builder.set_structure_list(
  184         -
                            crate::protocol_serde::shape_structure_set::de_structure_set(tokens)?,
         279  +
                        /* JsonParserGenerator.kt:272 */
         280  +
                        builder =
         281  +
                            builder.set_structure_list(
         282  +
                                /* JsonParserGenerator.kt:451 */
         283  +
                                crate::protocol_serde::shape_structure_set::de_structure_set(
         284  +
                                    tokens,
         285  +
                                )?, /* JsonParserGenerator.kt:272 */
  185    286   
                            );
         287  +
                        /* JsonParserGenerator.kt:262 */
  186    288   
                    }
         289  +
                    /* JsonParserGenerator.kt:262 */
  187    290   
                    "structureListWithNoKey" => {
         291  +
                        /* JsonParserGenerator.kt:272 */
  188    292   
                        builder = builder.set_structure_list_with_no_key(
  189         -
                            crate::protocol_serde::shape_structure_set_with_no_key::de_structure_set_with_no_key(tokens)?
  190         -
                        );
         293  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_structure_set_with_no_key::de_structure_set_with_no_key(tokens)?
         294  +
                        /* JsonParserGenerator.kt:272 */);
         295  +
                        /* JsonParserGenerator.kt:262 */
  191    296   
                    }
         297  +
                    /* JsonParserGenerator.kt:262 */
  192    298   
                    "timestampList" => {
  193         -
                        builder = builder.set_timestamp_list(
  194         -
                            crate::protocol_serde::shape_timestamp_set::de_timestamp_set(tokens)?,
         299  +
                        /* JsonParserGenerator.kt:272 */
         300  +
                        builder =
         301  +
                            builder.set_timestamp_list(
         302  +
                                /* JsonParserGenerator.kt:451 */
         303  +
                                crate::protocol_serde::shape_timestamp_set::de_timestamp_set(
         304  +
                                    tokens,
         305  +
                                )?, /* JsonParserGenerator.kt:272 */
  195    306   
                            );
         307  +
                        /* JsonParserGenerator.kt:262 */
  196    308   
                    }
         309  +
                    /* JsonParserGenerator.kt:262 */
  197    310   
                    "unionList" => {
         311  +
                        /* JsonParserGenerator.kt:272 */
  198    312   
                        builder = builder.set_union_list(
  199         -
                            crate::protocol_serde::shape_union_set::de_union_set(tokens)?,
  200         -
                        );
         313  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_union_set::de_union_set(tokens)?
         314  +
                        /* JsonParserGenerator.kt:272 */);
         315  +
                        /* JsonParserGenerator.kt:262 */
  201    316   
                    }
  202         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         317  +
                    /* JsonParserGenerator.kt:290 */
         318  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  203    319   
                }
         320  +
                /* JsonParserGenerator.kt:686 */
  204    321   
            }
         322  +
            /* JsonParserGenerator.kt:695 */
  205    323   
            other => {
  206    324   
                return Err(
  207    325   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  208    326   
                        "expected object key or end object, found: {:?}",
  209    327   
                        other
  210    328   
                    )),
  211    329   
                )
         330  +
            } /* JsonParserGenerator.kt:685 */
  212    331   
        }
         332  +
        /* JsonParserGenerator.kt:684 */
  213    333   
    }
  214         -
    }
         334  +
    /* JsonParserGenerator.kt:250 */
  215    335   
    if tokens.next().is_some() {
         336  +
        /* JsonParserGenerator.kt:251 */
  216    337   
        return Err(
  217    338   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  218    339   
                "found more JSON tokens after completing parsing",
  219    340   
            ),
  220    341   
        );
         342  +
        /* JsonParserGenerator.kt:250 */
  221    343   
    }
         344  +
    /* JsonParserGenerator.kt:163 */
  222    345   
    Ok(builder)
         346  +
    /* JsonParserGenerator.kt:148 */
  223    347   
}

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

@@ -1,1 +57,81 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:516 */
    2      3   
pub(crate) fn de_missing_key_structure<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::missing_key_structure::Builder>,
    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::StartObject { .. }) => {
          22  +
            /* RustType.kt:516 */
   19     23   
            #[allow(unused_mut)]
          24  +
            /* JsonParserGenerator.kt:526 */
   20     25   
            let mut builder = crate::model::missing_key_structure::Builder::default();
          26  +
            /* JsonParserGenerator.kt:684 */
   21     27   
            loop {
          28  +
                /* JsonParserGenerator.kt:685 */
   22     29   
                match tokens.next().transpose()? {
          30  +
                    /* JsonParserGenerator.kt:686 */
   23     31   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   24     32   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          33  +
                        /* JsonParserGenerator.kt:260 */
   25     34   
                        match key.to_unescaped()?.as_ref() {
          35  +
                            /* JsonParserGenerator.kt:262 */
   26     36   
                            "hi" => {
          37  +
                                /* JsonParserGenerator.kt:276 */
   27     38   
                                if let Some(v) =
   28         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
   29         -
                                        tokens.next(),
   30         -
                                    )?
   31         -
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   32         -
                                    .transpose()?
   33         -
                                {
          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:278 */{
   34     45   
                                                                            builder = builder.set_hi(v);
   35     46   
                                                                        }
          47  +
                                /* JsonParserGenerator.kt:262 */
   36     48   
                            }
   37         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          49  +
                            /* JsonParserGenerator.kt:290 */
          50  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   38     51   
                        }
          52  +
                        /* JsonParserGenerator.kt:686 */
   39     53   
                    }
          54  +
                    /* JsonParserGenerator.kt:695 */
   40     55   
                    other => {
   41     56   
                        return Err(
   42     57   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   43     58   
                                format!("expected object key or end object, found: {:?}", other),
   44     59   
                            ),
   45     60   
                        )
          61  +
                    } /* JsonParserGenerator.kt:685 */
   46     62   
                }
          63  +
                /* JsonParserGenerator.kt:684 */
   47     64   
            }
   48         -
            }
          65  +
            /* JsonParserGenerator.kt:540 */
   49     66   
            Ok(Some(builder))
          67  +
            /* JsonParserGenerator.kt:713 */
   50     68   
        }
   51         -
        _ => Err(
          69  +
        /* JsonParserGenerator.kt:722 */
          70  +
        _ => {
          71  +
            /* JsonParserGenerator.kt:723 */
          72  +
            Err(
   52     73   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   53     74   
                    "expected start object or null",
   54     75   
                ),
   55         -
        ),
          76  +
            )
          77  +
            /* JsonParserGenerator.kt:722 */
          78  +
        } /* JsonParserGenerator.kt:712 */
   56     79   
    }
          80  +
    /* JsonParserGenerator.kt:516 */
   57     81   
}

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

@@ -1,1 +62,89 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
    2      3   
pub(crate) fn de_pattern_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::pattern_map_unconstrained::PatternMapUnconstrained>,
    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::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
   19     23   
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
   21     27   
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
   22     29   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   23     30   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   24         -
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
   25         -
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
   26         -
                            tokens.next(),
   27         -
                        )?
   28         -
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   29         -
                        .transpose()?;
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          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:474 */;
          45  +
                        /* JsonParserGenerator.kt:481 */
   30     46   
                        match value {
   31     47   
                            Some(value) => {
   32     48   
                                map.insert(key, value);
   33     49   
                            }
   34     50   
                            None => {
   35     51   
                                return Err(
   36     52   
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     53   
                                        "dense map cannot contain null values",
   38     54   
                                    ),
   39     55   
                                )
   40     56   
                            }
   41     57   
                        }
          58  +
                        /* JsonParserGenerator.kt:686 */
   42     59   
                    }
          60  +
                    /* JsonParserGenerator.kt:695 */
   43     61   
                    other => {
   44     62   
                        return Err(
   45     63   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   46     64   
                                format!("expected object key or end object, found: {:?}", other),
   47     65   
                            ),
   48     66   
                        )
          67  +
                    } /* JsonParserGenerator.kt:685 */
   49     68   
                }
          69  +
                /* JsonParserGenerator.kt:684 */
   50     70   
            }
   51         -
            }
          71  +
            /* JsonParserGenerator.kt:502 */
   52     72   
            Ok(Some(
   53     73   
                crate::unconstrained::pattern_map_unconstrained::PatternMapUnconstrained(map),
   54     74   
            ))
          75  +
            /* JsonParserGenerator.kt:713 */
   55     76   
        }
   56         -
        _ => Err(
          77  +
        /* JsonParserGenerator.kt:722 */
          78  +
        _ => {
          79  +
            /* JsonParserGenerator.kt:723 */
          80  +
            Err(
   57     81   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   58     82   
                    "expected start object or null",
   59     83   
                ),
   60         -
        ),
          84  +
            )
          85  +
            /* JsonParserGenerator.kt:722 */
          86  +
        } /* JsonParserGenerator.kt:712 */
   61     87   
    }
          88  +
    /* JsonParserGenerator.kt:460 */
   62     89   
}

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

@@ -1,1 +62,89 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
    2      3   
pub(crate) fn de_pattern_map_override<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<
    6      7   
        crate::unconstrained::pattern_map_override_unconstrained::PatternMapOverrideUnconstrained,
    7      8   
    >,
    8      9   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    9     10   
>
   10     11   
where
   11     12   
    I: Iterator<
   12     13   
        Item = Result<
   13     14   
            ::aws_smithy_json::deserialize::Token<'a>,
   14     15   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   15     16   
        >,
   16     17   
    >,
   17     18   
{
          19  +
    /* JsonParserGenerator.kt:712 */
   18     20   
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:713 */
   19     22   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   20     23   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          24  +
            /* JsonParserGenerator.kt:469 */
   21     25   
            let mut map = ::std::collections::HashMap::new();
          26  +
            /* JsonParserGenerator.kt:684 */
   22     27   
            loop {
          28  +
                /* JsonParserGenerator.kt:685 */
   23     29   
                match tokens.next().transpose()? {
          30  +
                    /* JsonParserGenerator.kt:686 */
   24     31   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   25     32   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   26         -
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
   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()?;
          33  +
                        /* JsonParserGenerator.kt:471 */
          34  +
                        let key =
          35  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          36  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          37  +
                            /* JsonParserGenerator.kt:339 */)
          38  +
                        /* JsonParserGenerator.kt:471 */?;
          39  +
                        /* JsonParserGenerator.kt:474 */
          40  +
                        let value =
          41  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          42  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          43  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          44  +
                                /* JsonParserGenerator.kt:339 */)
          45  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          46  +
                        /* JsonParserGenerator.kt:474 */;
          47  +
                        /* JsonParserGenerator.kt:481 */
   32     48   
                        match value {
   33     49   
                            Some(value) => {
   34     50   
                                map.insert(key, value);
   35     51   
                            }
   36     52   
                            None => {
   37     53   
                                return Err(
   38     54   
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   39     55   
                                        "dense map cannot contain null values",
   40     56   
                                    ),
   41     57   
                                )
   42     58   
                            }
   43     59   
                        }
          60  +
                        /* JsonParserGenerator.kt:686 */
   44     61   
                    }
          62  +
                    /* JsonParserGenerator.kt:695 */
   45     63   
                    other => {
   46     64   
                        return Err(
   47     65   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   48     66   
                                format!("expected object key or end object, found: {:?}", other),
   49     67   
                            ),
   50     68   
                        )
          69  +
                    } /* JsonParserGenerator.kt:685 */
   51     70   
                }
          71  +
                /* JsonParserGenerator.kt:684 */
   52     72   
            }
   53         -
            }
          73  +
            /* JsonParserGenerator.kt:502 */
   54     74   
            Ok(Some(crate::unconstrained::pattern_map_override_unconstrained::PatternMapOverrideUnconstrained(map)))
          75  +
            /* JsonParserGenerator.kt:713 */
   55     76   
        }
   56         -
        _ => Err(
          77  +
        /* JsonParserGenerator.kt:722 */
          78  +
        _ => {
          79  +
            /* JsonParserGenerator.kt:723 */
          80  +
            Err(
   57     81   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   58     82   
                    "expected start object or null",
   59     83   
                ),
   60         -
        ),
          84  +
            )
          85  +
            /* JsonParserGenerator.kt:722 */
          86  +
        } /* JsonParserGenerator.kt:712 */
   61     87   
    }
          88  +
    /* JsonParserGenerator.kt:460 */
   62     89   
}

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

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

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 {
          11  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          12  +
            /* JsonParserGenerator.kt:684 */
          13  +
            loop {
          14  +
                /* JsonParserGenerator.kt:685 */
    8     15   
                match tokens.next().transpose()? {
          16  +
                    /* JsonParserGenerator.kt:686 */
    9     17   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   10     18   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          19  +
                        /* JsonParserGenerator.kt:576 */
   11     20   
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
   12     21   
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
   13     22   
                        )) = tokens.peek()
   14     23   
                        {
   15     24   
                            let _ = tokens.next().expect("peek returned a token")?;
   16     25   
                            continue;
   17     26   
                        }
          27  +
                        /* JsonParserGenerator.kt:585 */
   18     28   
                        let key = key.to_unescaped()?;
   19     29   
                        if key == "__type" {
   20     30   
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   21     31   
                            continue;
   22     32   
                        }
   23     33   
                        if variant.is_some() {
   24     34   
                            return Err(
   25     35   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   26     36   
                                    "encountered mixed variants in union",
   27     37   
                                ),
   28     38   
                            );
   29     39   
                        }
          40  +
                        /* JsonParserGenerator.kt:598 */
   30     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 */
   53     78   
                    }
          79  +
                    /* JsonParserGenerator.kt:695 */
   54     80   
                    other => {
   55     81   
                        return Err(
   56         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   57         -
                            "expected object key or end object, found: {:?}",
   58         -
                            other
   59         -
                        )),
          82  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          83  +
                                format!("expected object key or end object, found: {:?}", other),
          84  +
                            ),
   60     85   
                        )
          86  +
                    } /* JsonParserGenerator.kt:685 */
   61     87   
                }
          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   
            )
          99  +
        } /* JsonParserGenerator.kt:567 */
   70    100   
    }
   71         -
    }
         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))?
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   98    141   
        }
   99         -
        }
         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   
                )
         191  +
            } /* JsonParserGenerator.kt:685 */
  135    192   
        }
         193  +
        /* JsonParserGenerator.kt:684 */
  136    194   
    }
  137         -
    }
         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   
}