Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +26,40 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_recursive_shapes_output_output_output(
    3      4   
    value: &crate::output::RecursiveShapesOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_recursive_shapes_output::ser_recursive_shapes_output_output(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_recursive_shapes_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::RecursiveShapesOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.nested {
          27  +
        /* JsonSerializerGenerator.kt:495 */
   20     28   
        #[allow(unused_mut)]
          29  +
        /* JsonSerializerGenerator.kt:496 */
   21     30   
        let mut object_2 = object.key("nested").start_object();
          31  +
        /* JsonSerializerGenerator.kt:375 */
   22     32   
        crate::protocol_serde::shape_recursive_shapes_input_output_nested1::ser_recursive_shapes_input_output_nested1(&mut object_2, var_1)?;
          33  +
        /* JsonSerializerGenerator.kt:515 */
   23     34   
        object_2.finish();
          35  +
        /* JsonSerializerGenerator.kt:382 */
   24     36   
    }
          37  +
    /* JsonSerializerGenerator.kt:372 */
   25     38   
    Ok(())
          39  +
    /* JsonSerializerGenerator.kt:358 */
   26     40   
}

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

@@ -1,1 +65,95 @@
    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_renamed_greeting<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::RenamedGreeting>,
    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::renamed_greeting_internal::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   
                            "salutation" => {
          37  +
                                /* JsonParserGenerator.kt:272 */
   27     38   
                                builder = builder.set_salutation(
   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:272 */);
          45  +
                                /* JsonParserGenerator.kt:262 */
   34     46   
                            }
   35         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          47  +
                            /* JsonParserGenerator.kt:290 */
          48  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   36     49   
                        }
          50  +
                        /* JsonParserGenerator.kt:686 */
   37     51   
                    }
          52  +
                    /* JsonParserGenerator.kt:695 */
   38     53   
                    other => {
   39     54   
                        return Err(
   40     55   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   41     56   
                                format!("expected object key or end object, found: {:?}", other),
   42     57   
                            ),
   43     58   
                        )
          59  +
                    } /* JsonParserGenerator.kt:685 */
   44     60   
                }
          61  +
                /* JsonParserGenerator.kt:684 */
   45     62   
            }
   46         -
            }
          63  +
            /* JsonParserGenerator.kt:540 */
   47     64   
            Ok(Some(builder.build()))
          65  +
            /* JsonParserGenerator.kt:713 */
   48     66   
        }
   49         -
        _ => Err(
          67  +
        /* JsonParserGenerator.kt:722 */
          68  +
        _ => {
          69  +
            /* JsonParserGenerator.kt:723 */
          70  +
            Err(
   50     71   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   51     72   
                    "expected start object or null",
   52     73   
                ),
   53         -
        ),
          74  +
            )
          75  +
            /* JsonParserGenerator.kt:722 */
          76  +
        } /* JsonParserGenerator.kt:712 */
   54     77   
    }
          78  +
    /* JsonParserGenerator.kt:516 */
   55     79   
}
   56     80   
          81  +
/* JsonSerializerGenerator.kt:358 */
   57     82   
pub fn ser_renamed_greeting(
   58     83   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   59     84   
    input: &crate::model::RenamedGreeting,
   60     85   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          86  +
    /* JsonSerializerGenerator.kt:382 */
   61     87   
    if let Some(var_1) = &input.salutation {
          88  +
        /* JsonSerializerGenerator.kt:423 */
   62     89   
        object.key("salutation").string(var_1.as_str());
          90  +
        /* JsonSerializerGenerator.kt:382 */
   63     91   
    }
          92  +
    /* JsonSerializerGenerator.kt:372 */
   64     93   
    Ok(())
          94  +
    /* JsonSerializerGenerator.kt:358 */
   65     95   
}

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

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

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

@@ -1,1 +60,87 @@
    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_simple_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::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:504 */
   52     72   
            Ok(Some(map))
          73  +
            /* JsonParserGenerator.kt:713 */
   53     74   
        }
   54         -
        _ => Err(
          75  +
        /* JsonParserGenerator.kt:722 */
          76  +
        _ => {
          77  +
            /* JsonParserGenerator.kt:723 */
          78  +
            Err(
   55     79   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   56     80   
                    "expected start object or null",
   57     81   
                ),
   58         -
        ),
          82  +
            )
          83  +
            /* JsonParserGenerator.kt:722 */
          84  +
        } /* JsonParserGenerator.kt:712 */
   59     85   
    }
          86  +
    /* JsonParserGenerator.kt:460 */
   60     87   
}

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

@@ -1,1 +249,356 @@
    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_simple_scalar_properties_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::SimpleScalarPropertiesInput,
    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::simple_scalar_properties_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input =
   29     39   
                crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties(
   30     40   
                    bytes.as_ref(),
   31     41   
                    input,
   32     42   
                )?;
          43  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   33     44   
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   34     46   
        if let Some(value) =
   35     47   
            crate::protocol_serde::shape_simple_scalar_properties_input::de_foo_header(&headers)?
   36     48   
        {
   37     49   
            input = input.set_foo(Some(value))
   38     50   
        }
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   39     52   
        input.build()
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   40     54   
    })
          55  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   41     56   
}
   42     57   
          58  +
/* RustType.kt:516 */
   43     59   
#[allow(clippy::unnecessary_wraps)]
          60  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   44     61   
pub fn ser_simple_scalar_properties_http_response(
   45     62   
    #[allow(unused_variables)] output: crate::output::SimpleScalarPropertiesOutput,
   46     63   
) -> std::result::Result<
   47     64   
    ::aws_smithy_http_server::response::Response,
   48     65   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   49     66   
> {
          67  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   50     68   
    Ok({
          69  +
        /* RustType.kt:516 */
   51     70   
        #[allow(unused_mut)]
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   52     72   
        let mut builder = ::http::Response::builder();
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:629 */
   53     74   
        builder = crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_headers(&output, builder)?;
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   54     76   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   55     77   
            builder,
   56     78   
            ::http::header::CONTENT_TYPE,
   57     79   
            "application/json",
   58     80   
        );
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   59     82   
        let http_status: u16 = 200;
   60     83   
        builder = builder.status(http_status);
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   61     85   
        let payload =
   62         -
            crate::protocol_serde::shape_simple_scalar_properties_output::ser_simple_scalar_properties_output_output_output(&output)?
   63         -
        ;
          86  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_simple_scalar_properties_output::ser_simple_scalar_properties_output_output_output(&output)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   64     89   
        let content_length = payload.len();
   65     90   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   66     91   
            builder,
   67     92   
            ::http::header::CONTENT_LENGTH,
   68     93   
            content_length,
   69     94   
        );
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   70     96   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          97  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   71     98   
        builder.body(body)?
          99  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   72    100   
    })
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   73    102   
}
   74    103   
         104  +
/* RustType.kt:516 */
   75    105   
#[allow(clippy::unnecessary_wraps)]
         106  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   76    107   
pub fn ser_simple_scalar_properties_http_error(
   77    108   
    error: &crate::error::SimpleScalarPropertiesError,
   78    109   
) -> std::result::Result<
   79    110   
    ::aws_smithy_http_server::response::Response,
   80    111   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   81    112   
> {
         113  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   82    114   
    Ok({
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   83    116   
        match error {
         117  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   84    118   
            crate::error::SimpleScalarPropertiesError::InternalServerError(output) => {
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   85    120   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         121  +
                /* RustType.kt:516 */
   86    122   
                #[allow(unused_mut)]
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   87    124   
                let mut builder = ::http::Response::builder();
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   88    126   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   89    127   
                    builder,
   90    128   
                    ::http::header::CONTENT_TYPE,
   91    129   
                    "application/json",
   92    130   
                );
         131  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   93    132   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    133   
                    builder,
   95    134   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   96    135   
                    "InternalServerError",
   97    136   
                );
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   98    138   
                let content_length = payload.len();
   99    139   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  100    140   
                    builder,
  101    141   
                    ::http::header::CONTENT_LENGTH,
  102    142   
                    content_length,
  103    143   
                );
         144  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  104    145   
                builder
  105    146   
                    .status(500)
  106    147   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         149  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  107    150   
        }
  108         -
        }
         151  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  109    152   
    })
         153  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  110    154   
}
  111    155   
         156  +
/* JsonParserGenerator.kt:148 */
  112    157   
pub(crate) fn de_simple_scalar_properties(
  113    158   
    value: &[u8],
  114    159   
    mut builder: crate::input::simple_scalar_properties_input_internal::Builder,
  115    160   
) -> ::std::result::Result<
  116    161   
    crate::input::simple_scalar_properties_input_internal::Builder,
  117    162   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  118    163   
> {
         164  +
    /* JsonParserGenerator.kt:153 */
  119    165   
    let mut tokens_owned =
  120    166   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  121    167   
            .peekable();
  122    168   
    let tokens = &mut tokens_owned;
  123    169   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         170  +
    /* JsonParserGenerator.kt:684 */
  124    171   
    loop {
         172  +
        /* JsonParserGenerator.kt:685 */
  125    173   
        match tokens.next().transpose()? {
         174  +
            /* JsonParserGenerator.kt:686 */
  126    175   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  127    176   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         177  +
                /* JsonParserGenerator.kt:260 */
  128    178   
                match key.to_unescaped()?.as_ref() {
         179  +
                    /* JsonParserGenerator.kt:262 */
  129    180   
                    "byteValue" => {
         181  +
                        /* JsonParserGenerator.kt:272 */
  130    182   
                        builder = builder.set_byte_value(
         183  +
                            /* JsonParserGenerator.kt:365 */
  131    184   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  132    185   
                                tokens.next(),
  133    186   
                            )?
  134    187   
                            .map(i8::try_from)
  135         -
                            .transpose()?,
         188  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  136    189   
                        );
         190  +
                        /* JsonParserGenerator.kt:262 */
  137    191   
                    }
         192  +
                    /* JsonParserGenerator.kt:262 */
  138    193   
                    "DoubleDribble" => {
         194  +
                        /* JsonParserGenerator.kt:272 */
  139    195   
                        builder = builder.set_double_value(
         196  +
                            /* JsonParserGenerator.kt:363 */
  140    197   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  141    198   
                                tokens.next(),
  142    199   
                            )?
  143         -
                            .map(|v| v.to_f64_lossy()),
         200  +
                            .map(|v| v.to_f64_lossy()), /* JsonParserGenerator.kt:272 */
  144    201   
                        );
         202  +
                        /* JsonParserGenerator.kt:262 */
  145    203   
                    }
         204  +
                    /* JsonParserGenerator.kt:262 */
  146    205   
                    "falseBooleanValue" => {
         206  +
                        /* JsonParserGenerator.kt:272 */
  147    207   
                        builder = builder.set_false_boolean_value(
         208  +
                            /* JsonParserGenerator.kt:298 */
  148    209   
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
  149    210   
                                tokens.next(),
  150         -
                            )?,
         211  +
                            )?, /* JsonParserGenerator.kt:272 */
  151    212   
                        );
         213  +
                        /* JsonParserGenerator.kt:262 */
  152    214   
                    }
         215  +
                    /* JsonParserGenerator.kt:262 */
  153    216   
                    "floatValue" => {
         217  +
                        /* JsonParserGenerator.kt:272 */
  154    218   
                        builder = builder.set_float_value(
         219  +
                            /* JsonParserGenerator.kt:361 */
  155    220   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  156    221   
                                tokens.next(),
  157    222   
                            )?
  158         -
                            .map(|v| v.to_f32_lossy()),
         223  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  159    224   
                        );
         225  +
                        /* JsonParserGenerator.kt:262 */
  160    226   
                    }
         227  +
                    /* JsonParserGenerator.kt:262 */
  161    228   
                    "integerValue" => {
         229  +
                        /* JsonParserGenerator.kt:272 */
  162    230   
                        builder = builder.set_integer_value(
         231  +
                            /* JsonParserGenerator.kt:365 */
  163    232   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  164    233   
                                tokens.next(),
  165    234   
                            )?
  166    235   
                            .map(i32::try_from)
  167         -
                            .transpose()?,
         236  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  168    237   
                        );
         238  +
                        /* JsonParserGenerator.kt:262 */
  169    239   
                    }
         240  +
                    /* JsonParserGenerator.kt:262 */
  170    241   
                    "longValue" => {
         242  +
                        /* JsonParserGenerator.kt:272 */
  171    243   
                        builder = builder.set_long_value(
         244  +
                            /* JsonParserGenerator.kt:365 */
  172    245   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  173    246   
                                tokens.next(),
  174    247   
                            )?
  175    248   
                            .map(i64::try_from)
  176         -
                            .transpose()?,
         249  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  177    250   
                        );
         251  +
                        /* JsonParserGenerator.kt:262 */
  178    252   
                    }
         253  +
                    /* JsonParserGenerator.kt:262 */
  179    254   
                    "shortValue" => {
         255  +
                        /* JsonParserGenerator.kt:272 */
  180    256   
                        builder = builder.set_short_value(
         257  +
                            /* JsonParserGenerator.kt:365 */
  181    258   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  182    259   
                                tokens.next(),
  183    260   
                            )?
  184    261   
                            .map(i16::try_from)
  185         -
                            .transpose()?,
         262  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  186    263   
                        );
         264  +
                        /* JsonParserGenerator.kt:262 */
  187    265   
                    }
         266  +
                    /* JsonParserGenerator.kt:262 */
  188    267   
                    "stringValue" => {
         268  +
                        /* JsonParserGenerator.kt:272 */
  189    269   
                        builder = builder.set_string_value(
         270  +
                            /* JsonParserGenerator.kt:354 */
  190    271   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  191    272   
                                tokens.next(),
  192    273   
                            )?
  193         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  194         -
                            .transpose()?,
         274  +
                            .map(|s|
         275  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         276  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         277  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         278  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  195    279   
                        );
         280  +
                        /* JsonParserGenerator.kt:262 */
  196    281   
                    }
         282  +
                    /* JsonParserGenerator.kt:262 */
  197    283   
                    "trueBooleanValue" => {
         284  +
                        /* JsonParserGenerator.kt:272 */
  198    285   
                        builder = builder.set_true_boolean_value(
         286  +
                            /* JsonParserGenerator.kt:298 */
  199    287   
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
  200    288   
                                tokens.next(),
  201         -
                            )?,
         289  +
                            )?, /* JsonParserGenerator.kt:272 */
  202    290   
                        );
         291  +
                        /* JsonParserGenerator.kt:262 */
  203    292   
                    }
  204         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         293  +
                    /* JsonParserGenerator.kt:290 */
         294  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  205    295   
                }
         296  +
                /* JsonParserGenerator.kt:686 */
  206    297   
            }
         298  +
            /* JsonParserGenerator.kt:695 */
  207    299   
            other => {
  208    300   
                return Err(
  209    301   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  210    302   
                        "expected object key or end object, found: {:?}",
  211    303   
                        other
  212    304   
                    )),
  213    305   
                )
         306  +
            } /* JsonParserGenerator.kt:685 */
  214    307   
        }
         308  +
        /* JsonParserGenerator.kt:684 */
  215    309   
    }
  216         -
    }
         310  +
    /* JsonParserGenerator.kt:250 */
  217    311   
    if tokens.next().is_some() {
         312  +
        /* JsonParserGenerator.kt:251 */
  218    313   
        return Err(
  219    314   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  220    315   
                "found more JSON tokens after completing parsing",
  221    316   
            ),
  222    317   
        );
         318  +
        /* JsonParserGenerator.kt:250 */
  223    319   
    }
         320  +
    /* JsonParserGenerator.kt:163 */
  224    321   
    Ok(builder)
         322  +
    /* JsonParserGenerator.kt:148 */
  225    323   
}
  226    324   
         325  +
/* HttpBindingGenerator.kt:542 */
  227    326   
pub fn ser_simple_scalar_properties_headers(
  228    327   
    input: &crate::output::SimpleScalarPropertiesOutput,
  229    328   
    mut builder: ::http::response::Builder,
  230    329   
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
  231    330   
{
         331  +
    /* HttpBindingGenerator.kt:592 */
  232    332   
    if let ::std::option::Option::Some(inner_1) = &input.foo {
         333  +
        /* HttpBindingGenerator.kt:704 */
  233    334   
        let formatted_2 = inner_1.as_str();
         335  +
        /* HttpBindingGenerator.kt:705 */
  234    336   
        if !formatted_2.is_empty() {
         337  +
            /* HttpBindingGenerator.kt:706 */
  235    338   
            let header_value = formatted_2;
  236    339   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  237    340   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  238    341   
                    "foo",
  239    342   
                    format!(
  240    343   
                        "`{}` cannot be used as a header value: {}",
  241    344   
                        &header_value, err
  242    345   
                    ),
  243    346   
                )
  244    347   
            })?;
  245    348   
            builder = builder.header("X-Foo", header_value);
         349  +
            /* HttpBindingGenerator.kt:705 */
  246    350   
        }
         351  +
        /* HttpBindingGenerator.kt:592 */
  247    352   
    }
         353  +
    /* HttpBindingGenerator.kt:555 */
  248    354   
    Ok(builder)
         355  +
    /* HttpBindingGenerator.kt:542 */
  249    356   
}

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

@@ -1,1 +10,14 @@
    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_foo_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:160 */
    8     10   
    let headers = header_map.get_all("X-Foo");
          11  +
    /* HttpBindingGenerator.kt:375 */
    9     12   
    ::aws_smithy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:153 */
   10     14   
}

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

@@ -1,1 +62,97 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_simple_scalar_properties_output_output_output(
    3      4   
    value: &crate::output::SimpleScalarPropertiesOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_simple_scalar_properties_output::ser_simple_scalar_properties_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_simple_scalar_properties_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::SimpleScalarPropertiesOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.byte_value {
          24  +
        /* JsonSerializerGenerator.kt:432 */
   17     25   
        object.key("byteValue").number(
   18     26   
            #[allow(clippy::useless_conversion)]
   19     27   
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
   20     28   
        );
          29  +
        /* JsonSerializerGenerator.kt:382 */
   21     30   
    }
          31  +
    /* JsonSerializerGenerator.kt:382 */
   22     32   
    if let Some(var_2) = &input.double_value {
          33  +
        /* JsonSerializerGenerator.kt:432 */
   23     34   
        object.key("DoubleDribble").number(
   24     35   
            #[allow(clippy::useless_conversion)]
   25     36   
            ::aws_smithy_types::Number::Float((*var_2).into()),
   26     37   
        );
          38  +
        /* JsonSerializerGenerator.kt:382 */
   27     39   
    }
          40  +
    /* JsonSerializerGenerator.kt:382 */
   28     41   
    if let Some(var_3) = &input.false_boolean_value {
          42  +
        /* JsonSerializerGenerator.kt:424 */
   29     43   
        object.key("falseBooleanValue").boolean(*var_3);
          44  +
        /* JsonSerializerGenerator.kt:382 */
   30     45   
    }
          46  +
    /* JsonSerializerGenerator.kt:382 */
   31     47   
    if let Some(var_4) = &input.float_value {
          48  +
        /* JsonSerializerGenerator.kt:432 */
   32     49   
        object.key("floatValue").number(
   33     50   
            #[allow(clippy::useless_conversion)]
   34     51   
            ::aws_smithy_types::Number::Float((*var_4).into()),
   35     52   
        );
          53  +
        /* JsonSerializerGenerator.kt:382 */
   36     54   
    }
          55  +
    /* JsonSerializerGenerator.kt:382 */
   37     56   
    if let Some(var_5) = &input.integer_value {
          57  +
        /* JsonSerializerGenerator.kt:432 */
   38     58   
        object.key("integerValue").number(
   39     59   
            #[allow(clippy::useless_conversion)]
   40     60   
            ::aws_smithy_types::Number::NegInt((*var_5).into()),
   41     61   
        );
          62  +
        /* JsonSerializerGenerator.kt:382 */
   42     63   
    }
          64  +
    /* JsonSerializerGenerator.kt:382 */
   43     65   
    if let Some(var_6) = &input.long_value {
          66  +
        /* JsonSerializerGenerator.kt:432 */
   44     67   
        object.key("longValue").number(
   45     68   
            #[allow(clippy::useless_conversion)]
   46     69   
            ::aws_smithy_types::Number::NegInt((*var_6).into()),
   47     70   
        );
          71  +
        /* JsonSerializerGenerator.kt:382 */
   48     72   
    }
          73  +
    /* JsonSerializerGenerator.kt:382 */
   49     74   
    if let Some(var_7) = &input.short_value {
          75  +
        /* JsonSerializerGenerator.kt:432 */
   50     76   
        object.key("shortValue").number(
   51     77   
            #[allow(clippy::useless_conversion)]
   52     78   
            ::aws_smithy_types::Number::NegInt((*var_7).into()),
   53     79   
        );
          80  +
        /* JsonSerializerGenerator.kt:382 */
   54     81   
    }
          82  +
    /* JsonSerializerGenerator.kt:382 */
   55     83   
    if let Some(var_8) = &input.string_value {
          84  +
        /* JsonSerializerGenerator.kt:423 */
   56     85   
        object.key("stringValue").string(var_8.as_str());
          86  +
        /* JsonSerializerGenerator.kt:382 */
   57     87   
    }
          88  +
    /* JsonSerializerGenerator.kt:382 */
   58     89   
    if let Some(var_9) = &input.true_boolean_value {
          90  +
        /* JsonSerializerGenerator.kt:424 */
   59     91   
        object.key("trueBooleanValue").boolean(*var_9);
          92  +
        /* JsonSerializerGenerator.kt:382 */
   60     93   
    }
          94  +
    /* JsonSerializerGenerator.kt:372 */
   61     95   
    Ok(())
          96  +
    /* JsonSerializerGenerator.kt:358 */
   62     97   
}

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

@@ -1,1 +102,122 @@
    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_simple_union<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::SimpleUnion>,
    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() {
   43         -
                        "int" => Some(crate::model::SimpleUnion::Int(
   44         -
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
   45         -
                                tokens.next(),
   46         -
                            )?
          54  +
                            /* JsonParserGenerator.kt:601 */
          55  +
                            "int" => {
          56  +
                                /* JsonParserGenerator.kt:611 */
          57  +
                                Some(crate::model::SimpleUnion::Int(
          58  +
                                    /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
   47     59   
                                                        .map(i32::try_from)
   48     60   
                                                        .transpose()?
   49         -
                            .ok_or_else(|| {
   50         -
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   51         -
                                    "value for 'int' cannot be null",
   52         -
                                )
   53         -
                            })?,
   54         -
                        )),
   55         -
                        "string" => Some(crate::model::SimpleUnion::String(
   56         -
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
   57         -
                                tokens.next(),
   58         -
                            )?
   59         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   60         -
                            .transpose()?
   61         -
                            .ok_or_else(|| {
   62         -
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   63         -
                                    "value for 'string' cannot be null",
   64         -
                                )
   65         -
                            })?,
   66         -
                        )),
          61  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'int' cannot be null"))?
          62  +
                                /* JsonParserGenerator.kt:611 */))
          63  +
                                /* JsonParserGenerator.kt:601 */
          64  +
                            }
          65  +
                            /* JsonParserGenerator.kt:601 */
          66  +
                            "string" => {
          67  +
                                /* JsonParserGenerator.kt:611 */
          68  +
                                Some(crate::model::SimpleUnion::String(
          69  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          70  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          71  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          72  +
                                        /* JsonParserGenerator.kt:339 */)
          73  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          74  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'string' cannot be null"))?
          75  +
                                /* JsonParserGenerator.kt:611 */))
          76  +
                                /* JsonParserGenerator.kt:601 */
          77  +
                            }
          78  +
                            /* JsonParserGenerator.kt:634 */
   67     79   
                            variant => {
   68     80   
                                return Err(
   69     81   
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   70     82   
                                        format!("unexpected union variant: {}", variant),
   71     83   
                                    ),
   72     84   
                                )
   73         -
                        }
          85  +
                            } /* JsonParserGenerator.kt:598 */
   74     86   
                        };
          87  +
                        /* JsonParserGenerator.kt:686 */
   75     88   
                    }
          89  +
                    /* JsonParserGenerator.kt:695 */
   76     90   
                    other => {
   77     91   
                        return Err(
   78         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   79         -
                            "expected object key or end object, found: {:?}",
   80         -
                            other
   81         -
                        )),
          92  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          93  +
                                format!("expected object key or end object, found: {:?}", other),
          94  +
                            ),
   82     95   
                        )
          96  +
                    } /* JsonParserGenerator.kt:685 */
          97  +
                }
          98  +
                /* JsonParserGenerator.kt:684 */
   83     99   
            }
         100  +
            /* JsonParserGenerator.kt:568 */
   84    101   
        }
   85         -
        },
         102  +
        /* JsonParserGenerator.kt:642 */
   86    103   
        _ => {
   87    104   
            return Err(
   88    105   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   89    106   
                    "expected start object or null",
   90    107   
                ),
   91    108   
            )
         109  +
        } /* JsonParserGenerator.kt:567 */
   92    110   
    }
   93         -
    }
         111  +
    /* JsonParserGenerator.kt:649 */
   94    112   
    if variant.is_none() {
   95    113   
        return Err(
   96    114   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   97    115   
                "Union did not contain a valid variant.",
   98    116   
            ),
   99    117   
        );
  100    118   
    }
         119  +
    /* JsonParserGenerator.kt:657 */
  101    120   
    Ok(variant)
         121  +
    /* JsonParserGenerator.kt:551 */
  102    122   
}

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

@@ -1,1 +47,72 @@
    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_sparse_boolean_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::collections::HashMap<::std::string::String, ::std::option::Option<bool>>>,
    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_bool_or_null(
   26         -
                            tokens.next(),
   27         -
                        )?;
          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:298 */::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
          40  +
                        /* JsonParserGenerator.kt:474 */;
          41  +
                        /* JsonParserGenerator.kt:478 */
   28     42   
                        map.insert(key, value);
          43  +
                        /* JsonParserGenerator.kt:686 */
   29     44   
                    }
          45  +
                    /* JsonParserGenerator.kt:695 */
   30     46   
                    other => {
   31     47   
                        return Err(
   32     48   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   33     49   
                                format!("expected object key or end object, found: {:?}", other),
   34     50   
                            ),
   35     51   
                        )
          52  +
                    } /* JsonParserGenerator.kt:685 */
   36     53   
                }
          54  +
                /* JsonParserGenerator.kt:684 */
   37     55   
            }
   38         -
            }
          56  +
            /* JsonParserGenerator.kt:504 */
   39     57   
            Ok(Some(map))
          58  +
            /* JsonParserGenerator.kt:713 */
   40     59   
        }
   41         -
        _ => Err(
          60  +
        /* JsonParserGenerator.kt:722 */
          61  +
        _ => {
          62  +
            /* JsonParserGenerator.kt:723 */
          63  +
            Err(
   42     64   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   43     65   
                    "expected start object or null",
   44     66   
                ),
   45         -
        ),
          67  +
            )
          68  +
            /* JsonParserGenerator.kt:722 */
          69  +
        } /* JsonParserGenerator.kt:712 */
   46     70   
    }
          71  +
    /* JsonParserGenerator.kt:460 */
   47     72   
}

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

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

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

@@ -1,1 +45,79 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_sparse_json_lists_output_output_output(
    3      4   
    value: &crate::output::SparseJsonListsOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_sparse_json_lists_output::ser_sparse_json_lists_output_output(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_sparse_json_lists_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::SparseJsonListsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.sparse_short_list {
          27  +
        /* JsonSerializerGenerator.kt:484 */
   20     28   
        let mut array_2 = object.key("sparseShortList").start_array();
          29  +
        /* JsonSerializerGenerator.kt:524 */
   21     30   
        for item_3 in var_1 {
          31  +
            /* JsonSerializerGenerator.kt:382 */
   22     32   
            if let Some(var_4) = item_3 {
          33  +
                /* JsonSerializerGenerator.kt:432 */
   23     34   
                array_2.value().number(
   24     35   
                    #[allow(clippy::useless_conversion)]
   25     36   
                    ::aws_smithy_types::Number::NegInt((*var_4).into()),
   26     37   
                );
   27         -
            } else {
          38  +
            /* JsonSerializerGenerator.kt:382 */
          39  +
            }
          40  +
            /* JsonSerializerGenerator.kt:395 */
          41  +
            else {
          42  +
                /* JsonSerializerGenerator.kt:396 */
   28     43   
                array_2.value().null();
          44  +
                /* JsonSerializerGenerator.kt:395 */
   29     45   
            }
          46  +
            /* JsonSerializerGenerator.kt:524 */
   30     47   
        }
          48  +
        /* JsonSerializerGenerator.kt:486 */
   31     49   
        array_2.finish();
          50  +
        /* JsonSerializerGenerator.kt:382 */
   32     51   
    }
          52  +
    /* JsonSerializerGenerator.kt:382 */
   33     53   
    if let Some(var_5) = &input.sparse_string_list {
          54  +
        /* JsonSerializerGenerator.kt:484 */
   34     55   
        let mut array_6 = object.key("sparseStringList").start_array();
          56  +
        /* JsonSerializerGenerator.kt:524 */
   35     57   
        for item_7 in var_5 {
          58  +
            /* JsonSerializerGenerator.kt:382 */
   36     59   
            if let Some(var_8) = item_7 {
          60  +
                /* JsonSerializerGenerator.kt:423 */
   37     61   
                array_6.value().string(var_8.as_str());
   38         -
            } else {
          62  +
            /* JsonSerializerGenerator.kt:382 */
          63  +
            }
          64  +
            /* JsonSerializerGenerator.kt:395 */
          65  +
            else {
          66  +
                /* JsonSerializerGenerator.kt:396 */
   39     67   
                array_6.value().null();
          68  +
                /* JsonSerializerGenerator.kt:395 */
   40     69   
            }
          70  +
            /* JsonSerializerGenerator.kt:524 */
   41     71   
        }
          72  +
        /* JsonSerializerGenerator.kt:486 */
   42     73   
        array_6.finish();
          74  +
        /* JsonSerializerGenerator.kt:382 */
   43     75   
    }
          76  +
    /* JsonSerializerGenerator.kt:372 */
   44     77   
    Ok(())
          78  +
    /* JsonSerializerGenerator.kt:358 */
   45     79   
}

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

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

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

@@ -1,1 +95,182 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_sparse_json_maps_output_output_output(
    3      4   
    value: &crate::output::SparseJsonMapsOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_sparse_json_maps_output::ser_sparse_json_maps_output_output(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_sparse_json_maps_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::SparseJsonMapsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.sparse_boolean_map {
          27  +
        /* JsonSerializerGenerator.kt:495 */
   20     28   
        #[allow(unused_mut)]
          29  +
        /* JsonSerializerGenerator.kt:496 */
   21     30   
        let mut object_2 = object.key("sparseBooleanMap").start_object();
          31  +
        /* JsonSerializerGenerator.kt:537 */
   22     32   
        for (key_3, value_4) in var_1 {
          33  +
            /* JsonSerializerGenerator.kt:382 */
   23     34   
            if let Some(var_5) = value_4 {
          35  +
                /* JsonSerializerGenerator.kt:424 */
   24     36   
                object_2.key(key_3.as_str()).boolean(*var_5);
   25         -
            } else {
          37  +
            /* JsonSerializerGenerator.kt:382 */
          38  +
            }
          39  +
            /* JsonSerializerGenerator.kt:395 */
          40  +
            else {
          41  +
                /* JsonSerializerGenerator.kt:396 */
   26     42   
                object_2.key(key_3.as_str()).null();
          43  +
                /* JsonSerializerGenerator.kt:395 */
   27     44   
            }
          45  +
            /* JsonSerializerGenerator.kt:537 */
   28     46   
        }
          47  +
        /* JsonSerializerGenerator.kt:515 */
   29     48   
        object_2.finish();
          49  +
        /* JsonSerializerGenerator.kt:382 */
   30     50   
    }
          51  +
    /* JsonSerializerGenerator.kt:382 */
   31     52   
    if let Some(var_6) = &input.sparse_number_map {
          53  +
        /* JsonSerializerGenerator.kt:495 */
   32     54   
        #[allow(unused_mut)]
          55  +
        /* JsonSerializerGenerator.kt:496 */
   33     56   
        let mut object_7 = object.key("sparseNumberMap").start_object();
          57  +
        /* JsonSerializerGenerator.kt:537 */
   34     58   
        for (key_8, value_9) in var_6 {
          59  +
            /* JsonSerializerGenerator.kt:382 */
   35     60   
            if let Some(var_10) = value_9 {
          61  +
                /* JsonSerializerGenerator.kt:432 */
   36     62   
                object_7.key(key_8.as_str()).number(
   37     63   
                    #[allow(clippy::useless_conversion)]
   38     64   
                    ::aws_smithy_types::Number::NegInt((*var_10).into()),
   39     65   
                );
   40         -
            } else {
          66  +
            /* JsonSerializerGenerator.kt:382 */
          67  +
            }
          68  +
            /* JsonSerializerGenerator.kt:395 */
          69  +
            else {
          70  +
                /* JsonSerializerGenerator.kt:396 */
   41     71   
                object_7.key(key_8.as_str()).null();
          72  +
                /* JsonSerializerGenerator.kt:395 */
   42     73   
            }
          74  +
            /* JsonSerializerGenerator.kt:537 */
   43     75   
        }
          76  +
        /* JsonSerializerGenerator.kt:515 */
   44     77   
        object_7.finish();
          78  +
        /* JsonSerializerGenerator.kt:382 */
   45     79   
    }
          80  +
    /* JsonSerializerGenerator.kt:382 */
   46     81   
    if let Some(var_11) = &input.sparse_set_map {
          82  +
        /* JsonSerializerGenerator.kt:495 */
   47     83   
        #[allow(unused_mut)]
          84  +
        /* JsonSerializerGenerator.kt:496 */
   48     85   
        let mut object_12 = object.key("sparseSetMap").start_object();
          86  +
        /* JsonSerializerGenerator.kt:537 */
   49     87   
        for (key_13, value_14) in var_11 {
          88  +
            /* JsonSerializerGenerator.kt:382 */
   50     89   
            if let Some(var_15) = value_14 {
          90  +
                /* JsonSerializerGenerator.kt:484 */
   51     91   
                let mut array_16 = object_12.key(key_13.as_str()).start_array();
          92  +
                /* JsonSerializerGenerator.kt:524 */
   52     93   
                for item_17 in var_15 {
          94  +
                    /* SerializerUtil.kt:42 */
   53     95   
                    {
          96  +
                        /* JsonSerializerGenerator.kt:423 */
   54     97   
                        array_16.value().string(item_17.as_str());
          98  +
                        /* SerializerUtil.kt:42 */
   55     99   
                    }
         100  +
                    /* JsonSerializerGenerator.kt:524 */
   56    101   
                }
         102  +
                /* JsonSerializerGenerator.kt:486 */
   57    103   
                array_16.finish();
   58         -
            } else {
         104  +
            /* JsonSerializerGenerator.kt:382 */
         105  +
            }
         106  +
            /* JsonSerializerGenerator.kt:395 */
         107  +
            else {
         108  +
                /* JsonSerializerGenerator.kt:396 */
   59    109   
                object_12.key(key_13.as_str()).null();
         110  +
                /* JsonSerializerGenerator.kt:395 */
   60    111   
            }
         112  +
            /* JsonSerializerGenerator.kt:537 */
   61    113   
        }
         114  +
        /* JsonSerializerGenerator.kt:515 */
   62    115   
        object_12.finish();
         116  +
        /* JsonSerializerGenerator.kt:382 */
   63    117   
    }
         118  +
    /* JsonSerializerGenerator.kt:382 */
   64    119   
    if let Some(var_18) = &input.sparse_string_map {
         120  +
        /* JsonSerializerGenerator.kt:495 */
   65    121   
        #[allow(unused_mut)]
         122  +
        /* JsonSerializerGenerator.kt:496 */
   66    123   
        let mut object_19 = object.key("sparseStringMap").start_object();
         124  +
        /* JsonSerializerGenerator.kt:537 */
   67    125   
        for (key_20, value_21) in var_18 {
         126  +
            /* JsonSerializerGenerator.kt:382 */
   68    127   
            if let Some(var_22) = value_21 {
         128  +
                /* JsonSerializerGenerator.kt:423 */
   69    129   
                object_19.key(key_20.as_str()).string(var_22.as_str());
   70         -
            } else {
         130  +
            /* JsonSerializerGenerator.kt:382 */
         131  +
            }
         132  +
            /* JsonSerializerGenerator.kt:395 */
         133  +
            else {
         134  +
                /* JsonSerializerGenerator.kt:396 */
   71    135   
                object_19.key(key_20.as_str()).null();
         136  +
                /* JsonSerializerGenerator.kt:395 */
   72    137   
            }
         138  +
            /* JsonSerializerGenerator.kt:537 */
   73    139   
        }
         140  +
        /* JsonSerializerGenerator.kt:515 */
   74    141   
        object_19.finish();
         142  +
        /* JsonSerializerGenerator.kt:382 */
   75    143   
    }
         144  +
    /* JsonSerializerGenerator.kt:382 */
   76    145   
    if let Some(var_23) = &input.sparse_struct_map {
         146  +
        /* JsonSerializerGenerator.kt:495 */
   77    147   
        #[allow(unused_mut)]
         148  +
        /* JsonSerializerGenerator.kt:496 */
   78    149   
        let mut object_24 = object.key("sparseStructMap").start_object();
         150  +
        /* JsonSerializerGenerator.kt:537 */
   79    151   
        for (key_25, value_26) in var_23 {
         152  +
            /* JsonSerializerGenerator.kt:382 */
   80    153   
            if let Some(var_27) = value_26 {
         154  +
                /* JsonSerializerGenerator.kt:495 */
   81    155   
                #[allow(unused_mut)]
         156  +
                /* JsonSerializerGenerator.kt:496 */
   82    157   
                let mut object_28 = object_24.key(key_25.as_str()).start_object();
         158  +
                /* JsonSerializerGenerator.kt:375 */
   83    159   
                crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(
   84    160   
                    &mut object_28,
   85    161   
                    var_27,
   86    162   
                )?;
         163  +
                /* JsonSerializerGenerator.kt:515 */
   87    164   
                object_28.finish();
   88         -
            } else {
         165  +
            /* JsonSerializerGenerator.kt:382 */
         166  +
            }
         167  +
            /* JsonSerializerGenerator.kt:395 */
         168  +
            else {
         169  +
                /* JsonSerializerGenerator.kt:396 */
   89    170   
                object_24.key(key_25.as_str()).null();
         171  +
                /* JsonSerializerGenerator.kt:395 */
   90    172   
            }
         173  +
            /* JsonSerializerGenerator.kt:537 */
   91    174   
        }
         175  +
        /* JsonSerializerGenerator.kt:515 */
   92    176   
        object_24.finish();
         177  +
        /* JsonSerializerGenerator.kt:382 */
   93    178   
    }
         179  +
    /* JsonSerializerGenerator.kt:372 */
   94    180   
    Ok(())
         181  +
    /* JsonSerializerGenerator.kt:358 */
   95    182   
}

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

@@ -1,1 +49,74 @@
    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_sparse_number_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::collections::HashMap<::std::string::String, ::std::option::Option<i32>>>,
    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_number_or_null(
   26         -
                            tokens.next(),
   27         -
                        )?
          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:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
   28     40   
                                                .map(i32::try_from)
   29         -
                        .transpose()?;
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:474 */;
          43  +
                        /* JsonParserGenerator.kt:478 */
   30     44   
                        map.insert(key, value);
          45  +
                        /* JsonParserGenerator.kt:686 */
   31     46   
                    }
          47  +
                    /* JsonParserGenerator.kt:695 */
   32     48   
                    other => {
   33     49   
                        return Err(
   34     50   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   35     51   
                                format!("expected object key or end object, found: {:?}", other),
   36     52   
                            ),
   37     53   
                        )
          54  +
                    } /* JsonParserGenerator.kt:685 */
   38     55   
                }
          56  +
                /* JsonParserGenerator.kt:684 */
   39     57   
            }
   40         -
            }
          58  +
            /* JsonParserGenerator.kt:504 */
   41     59   
            Ok(Some(map))
          60  +
            /* JsonParserGenerator.kt:713 */
   42     61   
        }
   43         -
        _ => Err(
          62  +
        /* JsonParserGenerator.kt:722 */
          63  +
        _ => {
          64  +
            /* JsonParserGenerator.kt:723 */
          65  +
            Err(
   44     66   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   45     67   
                    "expected start object or null",
   46     68   
                ),
   47         -
        ),
          69  +
            )
          70  +
            /* JsonParserGenerator.kt:722 */
          71  +
        } /* JsonParserGenerator.kt:712 */
   48     72   
    }
          73  +
    /* JsonParserGenerator.kt:460 */
   49     74   
}

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

@@ -1,1 +47,74 @@
    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_sparse_set_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::sparse_set_map_unconstrained::SparseSetMapUnconstrained>,
    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 = crate::protocol_serde::shape_string_set::de_string_set(tokens)?;
          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:451 */crate::protocol_serde::shape_string_set::de_string_set(tokens)?
          40  +
                        /* JsonParserGenerator.kt:474 */;
          41  +
                        /* JsonParserGenerator.kt:478 */
   26     42   
                        map.insert(key, value);
          43  +
                        /* JsonParserGenerator.kt:686 */
   27     44   
                    }
          45  +
                    /* JsonParserGenerator.kt:695 */
   28     46   
                    other => {
   29     47   
                        return Err(
   30     48   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   31     49   
                                format!("expected object key or end object, found: {:?}", other),
   32     50   
                            ),
   33     51   
                        )
          52  +
                    } /* JsonParserGenerator.kt:685 */
   34     53   
                }
          54  +
                /* JsonParserGenerator.kt:684 */
   35     55   
            }
   36         -
            }
          56  +
            /* JsonParserGenerator.kt:502 */
   37     57   
            Ok(Some(
   38     58   
                crate::unconstrained::sparse_set_map_unconstrained::SparseSetMapUnconstrained(map),
   39     59   
            ))
          60  +
            /* JsonParserGenerator.kt:713 */
   40     61   
        }
   41         -
        _ => Err(
          62  +
        /* JsonParserGenerator.kt:722 */
          63  +
        _ => {
          64  +
            /* JsonParserGenerator.kt:723 */
          65  +
            Err(
   42     66   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   43     67   
                    "expected start object or null",
   44     68   
                ),
   45         -
        ),
          69  +
            )
          70  +
            /* JsonParserGenerator.kt:722 */
          71  +
        } /* JsonParserGenerator.kt:712 */
   46     72   
    }
          73  +
    /* JsonParserGenerator.kt:460 */
   47     74   
}

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

@@ -1,1 +45,67 @@
    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_sparse_short_list<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::vec::Vec<::std::option::Option<i16>>>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:415 */
   27     38   
                        items.push(
          39  +
                            /* JsonParserGenerator.kt:365 */
   28     40   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
   29     41   
                                tokens.next(),
   30     42   
                            )?
   31     43   
                            .map(i16::try_from)
   32         -
                            .transpose()?,
          44  +
                            .transpose()?, /* JsonParserGenerator.kt:415 */
   33     45   
                        );
          46  +
                        /* JsonParserGenerator.kt:413 */
          47  +
                    } /* JsonParserGenerator.kt:409 */
   34     48   
                }
          49  +
                /* JsonParserGenerator.kt:408 */
   35     50   
            }
   36         -
            }
          51  +
            /* JsonParserGenerator.kt:446 */
   37     52   
            Ok(Some(items))
          53  +
            /* JsonParserGenerator.kt:713 */
   38     54   
        }
   39         -
        _ => Err(
          55  +
        /* JsonParserGenerator.kt:722 */
          56  +
        _ => {
          57  +
            /* JsonParserGenerator.kt:723 */
          58  +
            Err(
   40     59   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   41     60   
                    "expected start array or null",
   42     61   
                ),
   43         -
        ),
          62  +
            )
          63  +
            /* JsonParserGenerator.kt:722 */
          64  +
        } /* JsonParserGenerator.kt:712 */
   44     65   
    }
          66  +
    /* JsonParserGenerator.kt:398 */
   45     67   
}