Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,14 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_foo_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<
           6  +
    ::std::option::Option<::std::string::String>,
           7  +
    ::aws_smithy_legacy_http::header::ParseError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
          10  +
    let headers = header_map.get_all("X-Foo");
          11  +
    /* HttpBindingGenerator.kt:398 */
          12  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:159 */
          14  +
}

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

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

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

@@ -0,1 +0,122 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
           3  +
pub(crate) fn de_simple_union<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::model::SimpleUnion>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:565 */
          18  +
    let mut variant = None;
          19  +
    /* JsonParserGenerator.kt:567 */
          20  +
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:568 */
          22  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
          23  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:576 */
          32  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          33  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          34  +
                        )) = tokens.peek()
          35  +
                        {
          36  +
                            let _ = tokens.next().expect("peek returned a token")?;
          37  +
                            continue;
          38  +
                        }
          39  +
                        /* JsonParserGenerator.kt:585 */
          40  +
                        let key = key.to_unescaped()?;
          41  +
                        if key == "__type" {
          42  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          43  +
                            continue;
          44  +
                        }
          45  +
                        if variant.is_some() {
          46  +
                            return Err(
          47  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          48  +
                                    "encountered mixed variants in union",
          49  +
                                ),
          50  +
                            );
          51  +
                        }
          52  +
                        /* JsonParserGenerator.kt:598 */
          53  +
                        variant = match key.as_ref() {
          54  +
                            /* JsonParserGenerator.kt:601 */
          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())?
          59  +
                                                        .map(i32::try_from)
          60  +
                                                        .transpose()?
          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 */
          79  +
                            variant => {
          80  +
                                return Err(
          81  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          82  +
                                        format!("unexpected union variant: {variant}"),
          83  +
                                    ),
          84  +
                                )
          85  +
                            } /* JsonParserGenerator.kt:598 */
          86  +
                        };
          87  +
                        /* JsonParserGenerator.kt:686 */
          88  +
                    }
          89  +
                    /* JsonParserGenerator.kt:695 */
          90  +
                    other => {
          91  +
                        return Err(
          92  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          93  +
                                format!("expected object key or end object, found: {other:?}"),
          94  +
                            ),
          95  +
                        )
          96  +
                    } /* JsonParserGenerator.kt:685 */
          97  +
                }
          98  +
                /* JsonParserGenerator.kt:684 */
          99  +
            }
         100  +
            /* JsonParserGenerator.kt:568 */
         101  +
        }
         102  +
        /* JsonParserGenerator.kt:642 */
         103  +
        _ => {
         104  +
            return Err(
         105  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         106  +
                    "expected start object or null",
         107  +
                ),
         108  +
            )
         109  +
        } /* JsonParserGenerator.kt:567 */
         110  +
    }
         111  +
    /* JsonParserGenerator.kt:649 */
         112  +
    if variant.is_none() {
         113  +
        return Err(
         114  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         115  +
                "Union did not contain a valid variant.",
         116  +
            ),
         117  +
        );
         118  +
    }
         119  +
    /* JsonParserGenerator.kt:657 */
         120  +
    Ok(variant)
         121  +
    /* JsonParserGenerator.kt:551 */
         122  +
}

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

@@ -0,1 +0,72 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_sparse_boolean_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::collections::HashMap<::std::string::String, ::std::option::Option<bool>>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt: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 */
          42  +
                        map.insert(key, value);
          43  +
                        /* JsonParserGenerator.kt:686 */
          44  +
                    }
          45  +
                    /* JsonParserGenerator.kt:695 */
          46  +
                    other => {
          47  +
                        return Err(
          48  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          49  +
                                format!("expected object key or end object, found: {other:?}"),
          50  +
                            ),
          51  +
                        )
          52  +
                    } /* JsonParserGenerator.kt:685 */
          53  +
                }
          54  +
                /* JsonParserGenerator.kt:684 */
          55  +
            }
          56  +
            /* JsonParserGenerator.kt:504 */
          57  +
            Ok(Some(map))
          58  +
            /* JsonParserGenerator.kt:713 */
          59  +
        }
          60  +
        /* JsonParserGenerator.kt:722 */
          61  +
        _ => {
          62  +
            /* JsonParserGenerator.kt:723 */
          63  +
            Err(
          64  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          65  +
                    "expected start object or null",
          66  +
                ),
          67  +
            )
          68  +
            /* JsonParserGenerator.kt:722 */
          69  +
        } /* JsonParserGenerator.kt:712 */
          70  +
    }
          71  +
    /* JsonParserGenerator.kt:460 */
          72  +
}

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

@@ -0,1 +0,169 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_sparse_json_lists_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::SparseJsonListsInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::sparse_json_lists_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:801 */
          30  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
          32  +
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
          34  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          35  +
                &headers,
          36  +
                Some("application/json"),
          37  +
            )?;
          38  +
            input = crate::protocol_serde::shape_sparse_json_lists::de_sparse_json_lists(
          39  +
                bytes.as_ref(),
          40  +
                input,
          41  +
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          43  +
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          45  +
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          47  +
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          49  +
}
          50  +
          51  +
/* RustType.kt:534 */
          52  +
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          54  +
pub fn ser_sparse_json_lists_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::SparseJsonListsOutput,
          56  +
) -> std::result::Result<
          57  +
    ::aws_smithy_legacy_http_server::response::Response,
          58  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          59  +
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          61  +
    Ok({
          62  +
        /* RustType.kt:534 */
          63  +
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          67  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          68  +
            builder,
          69  +
            ::http::header::CONTENT_TYPE,
          70  +
            "application/json",
          71  +
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          73  +
        let http_status: u16 = 200;
          74  +
        builder = builder.status(http_status);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_sparse_json_lists_output::ser_sparse_json_lists_output_output_output(&output)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          80  +
        let content_length = payload.len();
          81  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
            builder,
          83  +
            ::http::header::CONTENT_LENGTH,
          84  +
            content_length,
          85  +
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          87  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          89  +
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          91  +
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          93  +
}
          94  +
          95  +
/* JsonParserGenerator.kt:148 */
          96  +
pub(crate) fn de_sparse_json_lists(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::sparse_json_lists_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::sparse_json_lists_input::Builder,
         101  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         102  +
> {
         103  +
    /* JsonParserGenerator.kt:153 */
         104  +
    let mut tokens_owned =
         105  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         106  +
            .peekable();
         107  +
    let tokens = &mut tokens_owned;
         108  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         109  +
    /* JsonParserGenerator.kt:684 */
         110  +
    loop {
         111  +
        /* JsonParserGenerator.kt:685 */
         112  +
        match tokens.next().transpose()? {
         113  +
            /* JsonParserGenerator.kt:686 */
         114  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         115  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                /* JsonParserGenerator.kt:260 */
         117  +
                match key.to_unescaped()?.as_ref() {
         118  +
                    /* JsonParserGenerator.kt:262 */
         119  +
                    "sparseShortList" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_sparse_short_list(
         122  +
                            /* JsonParserGenerator.kt:451 */
         123  +
                            crate::protocol_serde::shape_sparse_short_list::de_sparse_short_list(
         124  +
                                tokens,
         125  +
                            )?, /* JsonParserGenerator.kt:272 */
         126  +
                        );
         127  +
                        /* JsonParserGenerator.kt:262 */
         128  +
                    }
         129  +
                    /* JsonParserGenerator.kt:262 */
         130  +
                    "sparseStringList" => {
         131  +
                        /* JsonParserGenerator.kt:272 */
         132  +
                        builder = builder.set_sparse_string_list(
         133  +
                            /* JsonParserGenerator.kt:451 */
         134  +
                            crate::protocol_serde::shape_sparse_string_list::de_sparse_string_list(
         135  +
                                tokens,
         136  +
                            )?, /* JsonParserGenerator.kt:272 */
         137  +
                        );
         138  +
                        /* JsonParserGenerator.kt:262 */
         139  +
                    }
         140  +
                    /* JsonParserGenerator.kt:290 */
         141  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         142  +
                }
         143  +
                /* JsonParserGenerator.kt:686 */
         144  +
            }
         145  +
            /* JsonParserGenerator.kt:695 */
         146  +
            other => {
         147  +
                return Err(
         148  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         149  +
                        "expected object key or end object, found: {other:?}"
         150  +
                    )),
         151  +
                )
         152  +
            } /* JsonParserGenerator.kt:685 */
         153  +
        }
         154  +
        /* JsonParserGenerator.kt:684 */
         155  +
    }
         156  +
    /* JsonParserGenerator.kt:250 */
         157  +
    if tokens.next().is_some() {
         158  +
        /* JsonParserGenerator.kt:251 */
         159  +
        return Err(
         160  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         161  +
                "found more JSON tokens after completing parsing",
         162  +
            ),
         163  +
        );
         164  +
        /* JsonParserGenerator.kt:250 */
         165  +
    }
         166  +
    /* JsonParserGenerator.kt:163 */
         167  +
    Ok(builder)
         168  +
    /* JsonParserGenerator.kt:148 */
         169  +
}

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

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

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

@@ -0,1 +0,255 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_sparse_json_maps_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::SparseJsonMapsInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::sparse_json_maps_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:801 */
          30  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
          32  +
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
          34  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          35  +
                &headers,
          36  +
                Some("application/json"),
          37  +
            )?;
          38  +
            input = crate::protocol_serde::shape_sparse_json_maps::de_sparse_json_maps(
          39  +
                bytes.as_ref(),
          40  +
                input,
          41  +
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          43  +
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          45  +
        input.build()?
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          47  +
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          49  +
}
          50  +
          51  +
/* RustType.kt:534 */
          52  +
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          54  +
pub fn ser_sparse_json_maps_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::SparseJsonMapsOutput,
          56  +
) -> std::result::Result<
          57  +
    ::aws_smithy_legacy_http_server::response::Response,
          58  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          59  +
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          61  +
    Ok({
          62  +
        /* RustType.kt:534 */
          63  +
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          67  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          68  +
            builder,
          69  +
            ::http::header::CONTENT_TYPE,
          70  +
            "application/json",
          71  +
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          73  +
        let http_status: u16 = 200;
          74  +
        builder = builder.status(http_status);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_sparse_json_maps_output::ser_sparse_json_maps_output_output_output(&output)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          80  +
        let content_length = payload.len();
          81  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
            builder,
          83  +
            ::http::header::CONTENT_LENGTH,
          84  +
            content_length,
          85  +
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          87  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          89  +
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          91  +
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          93  +
}
          94  +
          95  +
/* RustType.kt:534 */
          96  +
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          98  +
pub fn ser_sparse_json_maps_http_error(
          99  +
    error: &crate::error::SparseJsonMapsError,
         100  +
) -> std::result::Result<
         101  +
    ::aws_smithy_legacy_http_server::response::Response,
         102  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         103  +
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         105  +
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         107  +
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         109  +
            crate::error::SparseJsonMapsError::ValidationException(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         111  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         112  +
                /* RustType.kt:534 */
         113  +
                #[allow(unused_mut)]
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         115  +
                let mut builder = ::http::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         117  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         118  +
                    builder,
         119  +
                    ::http::header::CONTENT_TYPE,
         120  +
                    "application/json",
         121  +
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         123  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         124  +
                    builder,
         125  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         126  +
                    "ValidationException",
         127  +
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         129  +
                let content_length = payload.len();
         130  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         131  +
                    builder,
         132  +
                    ::http::header::CONTENT_LENGTH,
         133  +
                    content_length,
         134  +
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         136  +
                builder
         137  +
                    .status(400)
         138  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         141  +
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         143  +
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         145  +
}
         146  +
         147  +
/* JsonParserGenerator.kt:148 */
         148  +
pub(crate) fn de_sparse_json_maps(
         149  +
    value: &[u8],
         150  +
    mut builder: crate::input::sparse_json_maps_input::Builder,
         151  +
) -> ::std::result::Result<
         152  +
    crate::input::sparse_json_maps_input::Builder,
         153  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         154  +
> {
         155  +
    /* JsonParserGenerator.kt:153 */
         156  +
    let mut tokens_owned =
         157  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         158  +
            .peekable();
         159  +
    let tokens = &mut tokens_owned;
         160  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
         162  +
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
         164  +
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
         166  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         167  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
         169  +
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
         171  +
                    "sparseBooleanMap" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
         173  +
                        builder = builder.set_sparse_boolean_map(
         174  +
                            /* JsonParserGenerator.kt:509 */
         175  +
                            crate::protocol_serde::shape_sparse_boolean_map::de_sparse_boolean_map(
         176  +
                                tokens,
         177  +
                            )?, /* JsonParserGenerator.kt:272 */
         178  +
                        );
         179  +
                        /* JsonParserGenerator.kt:262 */
         180  +
                    }
         181  +
                    /* JsonParserGenerator.kt:262 */
         182  +
                    "sparseNumberMap" => {
         183  +
                        /* JsonParserGenerator.kt:272 */
         184  +
                        builder = builder.set_sparse_number_map(
         185  +
                            /* JsonParserGenerator.kt:509 */
         186  +
                            crate::protocol_serde::shape_sparse_number_map::de_sparse_number_map(
         187  +
                                tokens,
         188  +
                            )?, /* JsonParserGenerator.kt:272 */
         189  +
                        );
         190  +
                        /* JsonParserGenerator.kt:262 */
         191  +
                    }
         192  +
                    /* JsonParserGenerator.kt:262 */
         193  +
                    "sparseSetMap" => {
         194  +
                        /* JsonParserGenerator.kt:272 */
         195  +
                        builder =
         196  +
                            builder.set_sparse_set_map(
         197  +
                                /* JsonParserGenerator.kt:509 */
         198  +
                                crate::protocol_serde::shape_sparse_set_map::de_sparse_set_map(
         199  +
                                    tokens,
         200  +
                                )?, /* JsonParserGenerator.kt:272 */
         201  +
                            );
         202  +
                        /* JsonParserGenerator.kt:262 */
         203  +
                    }
         204  +
                    /* JsonParserGenerator.kt:262 */
         205  +
                    "sparseStringMap" => {
         206  +
                        /* JsonParserGenerator.kt:272 */
         207  +
                        builder = builder.set_sparse_string_map(
         208  +
                            /* JsonParserGenerator.kt:509 */
         209  +
                            crate::protocol_serde::shape_sparse_string_map::de_sparse_string_map(
         210  +
                                tokens,
         211  +
                            )?, /* JsonParserGenerator.kt:272 */
         212  +
                        );
         213  +
                        /* JsonParserGenerator.kt:262 */
         214  +
                    }
         215  +
                    /* JsonParserGenerator.kt:262 */
         216  +
                    "sparseStructMap" => {
         217  +
                        /* JsonParserGenerator.kt:272 */
         218  +
                        builder = builder.set_sparse_struct_map(
         219  +
                            /* JsonParserGenerator.kt:509 */
         220  +
                            crate::protocol_serde::shape_sparse_struct_map::de_sparse_struct_map(
         221  +
                                tokens,
         222  +
                            )?, /* JsonParserGenerator.kt:272 */
         223  +
                        );
         224  +
                        /* JsonParserGenerator.kt:262 */
         225  +
                    }
         226  +
                    /* JsonParserGenerator.kt:290 */
         227  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         228  +
                }
         229  +
                /* JsonParserGenerator.kt:686 */
         230  +
            }
         231  +
            /* JsonParserGenerator.kt:695 */
         232  +
            other => {
         233  +
                return Err(
         234  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         235  +
                        "expected object key or end object, found: {other:?}"
         236  +
                    )),
         237  +
                )
         238  +
            } /* JsonParserGenerator.kt:685 */
         239  +
        }
         240  +
        /* JsonParserGenerator.kt:684 */
         241  +
    }
         242  +
    /* JsonParserGenerator.kt:250 */
         243  +
    if tokens.next().is_some() {
         244  +
        /* JsonParserGenerator.kt:251 */
         245  +
        return Err(
         246  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         247  +
                "found more JSON tokens after completing parsing",
         248  +
            ),
         249  +
        );
         250  +
        /* JsonParserGenerator.kt:250 */
         251  +
    }
         252  +
    /* JsonParserGenerator.kt:163 */
         253  +
    Ok(builder)
         254  +
    /* JsonParserGenerator.kt:148 */
         255  +
}

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

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

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

@@ -0,1 +0,74 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_sparse_number_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::collections::HashMap<::std::string::String, ::std::option::Option<i32>>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt: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())?
          40  +
                                                .map(i32::try_from)
          41  +
                                                .transpose()?
          42  +
                        /* JsonParserGenerator.kt:474 */;
          43  +
                        /* JsonParserGenerator.kt:478 */
          44  +
                        map.insert(key, value);
          45  +
                        /* JsonParserGenerator.kt:686 */
          46  +
                    }
          47  +
                    /* JsonParserGenerator.kt:695 */
          48  +
                    other => {
          49  +
                        return Err(
          50  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                                format!("expected object key or end object, found: {other:?}"),
          52  +
                            ),
          53  +
                        )
          54  +
                    } /* JsonParserGenerator.kt:685 */
          55  +
                }
          56  +
                /* JsonParserGenerator.kt:684 */
          57  +
            }
          58  +
            /* JsonParserGenerator.kt:504 */
          59  +
            Ok(Some(map))
          60  +
            /* JsonParserGenerator.kt:713 */
          61  +
        }
          62  +
        /* JsonParserGenerator.kt:722 */
          63  +
        _ => {
          64  +
            /* JsonParserGenerator.kt:723 */
          65  +
            Err(
          66  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          67  +
                    "expected start object or null",
          68  +
                ),
          69  +
            )
          70  +
            /* JsonParserGenerator.kt:722 */
          71  +
        } /* JsonParserGenerator.kt:712 */
          72  +
    }
          73  +
    /* JsonParserGenerator.kt:460 */
          74  +
}