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_json_enums_output.rs

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

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

@@ -0,1 +0,271 @@
           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_json_int_enums_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::JsonIntEnumsInput,
           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::json_int_enums_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_json_int_enums::de_json_int_enums(
          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_json_int_enums_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::JsonIntEnumsOutput,
          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_json_int_enums_output::ser_json_int_enums_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_json_int_enums_http_error(
          99  +
    error: &crate::error::JsonIntEnumsError,
         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::JsonIntEnumsError::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_json_int_enums(
         149  +
    value: &[u8],
         150  +
    mut builder: crate::input::json_int_enums_input::Builder,
         151  +
) -> ::std::result::Result<
         152  +
    crate::input::json_int_enums_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  +
                    "integerEnum1" => {
         172  +
                        /* JsonParserGenerator.kt:272 */
         173  +
                        builder = builder.set_integer_enum1(
         174  +
                            /* JsonParserGenerator.kt:365 */
         175  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         176  +
                                tokens.next(),
         177  +
                            )?
         178  +
                            .map(i32::try_from)
         179  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         180  +
                        );
         181  +
                        /* JsonParserGenerator.kt:262 */
         182  +
                    }
         183  +
                    /* JsonParserGenerator.kt:262 */
         184  +
                    "integerEnum2" => {
         185  +
                        /* JsonParserGenerator.kt:272 */
         186  +
                        builder = builder.set_integer_enum2(
         187  +
                            /* JsonParserGenerator.kt:365 */
         188  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         189  +
                                tokens.next(),
         190  +
                            )?
         191  +
                            .map(i32::try_from)
         192  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         193  +
                        );
         194  +
                        /* JsonParserGenerator.kt:262 */
         195  +
                    }
         196  +
                    /* JsonParserGenerator.kt:262 */
         197  +
                    "integerEnum3" => {
         198  +
                        /* JsonParserGenerator.kt:272 */
         199  +
                        builder = builder.set_integer_enum3(
         200  +
                            /* JsonParserGenerator.kt:365 */
         201  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         202  +
                                tokens.next(),
         203  +
                            )?
         204  +
                            .map(i32::try_from)
         205  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         206  +
                        );
         207  +
                        /* JsonParserGenerator.kt:262 */
         208  +
                    }
         209  +
                    /* JsonParserGenerator.kt:262 */
         210  +
                    "integerEnumList" => {
         211  +
                        /* JsonParserGenerator.kt:272 */
         212  +
                        builder = builder.set_integer_enum_list(
         213  +
                            /* JsonParserGenerator.kt:451 */
         214  +
                            crate::protocol_serde::shape_integer_enum_list::de_integer_enum_list(
         215  +
                                tokens,
         216  +
                            )?, /* JsonParserGenerator.kt:272 */
         217  +
                        );
         218  +
                        /* JsonParserGenerator.kt:262 */
         219  +
                    }
         220  +
                    /* JsonParserGenerator.kt:262 */
         221  +
                    "integerEnumMap" => {
         222  +
                        /* JsonParserGenerator.kt:272 */
         223  +
                        builder = builder.set_integer_enum_map(
         224  +
                            /* JsonParserGenerator.kt:509 */
         225  +
                            crate::protocol_serde::shape_integer_enum_map::de_integer_enum_map(
         226  +
                                tokens,
         227  +
                            )?, /* JsonParserGenerator.kt:272 */
         228  +
                        );
         229  +
                        /* JsonParserGenerator.kt:262 */
         230  +
                    }
         231  +
                    /* JsonParserGenerator.kt:262 */
         232  +
                    "integerEnumSet" => {
         233  +
                        /* JsonParserGenerator.kt:272 */
         234  +
                        builder = builder.set_integer_enum_set(
         235  +
                            /* JsonParserGenerator.kt:451 */
         236  +
                            crate::protocol_serde::shape_integer_enum_set::de_integer_enum_set(
         237  +
                                tokens,
         238  +
                            )?, /* JsonParserGenerator.kt:272 */
         239  +
                        );
         240  +
                        /* JsonParserGenerator.kt:262 */
         241  +
                    }
         242  +
                    /* JsonParserGenerator.kt:290 */
         243  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         244  +
                }
         245  +
                /* JsonParserGenerator.kt:686 */
         246  +
            }
         247  +
            /* JsonParserGenerator.kt:695 */
         248  +
            other => {
         249  +
                return Err(
         250  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         251  +
                        "expected object key or end object, found: {other:?}"
         252  +
                    )),
         253  +
                )
         254  +
            } /* JsonParserGenerator.kt:685 */
         255  +
        }
         256  +
        /* JsonParserGenerator.kt:684 */
         257  +
    }
         258  +
    /* JsonParserGenerator.kt:250 */
         259  +
    if tokens.next().is_some() {
         260  +
        /* JsonParserGenerator.kt:251 */
         261  +
        return Err(
         262  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         263  +
                "found more JSON tokens after completing parsing",
         264  +
            ),
         265  +
        );
         266  +
        /* JsonParserGenerator.kt:250 */
         267  +
    }
         268  +
    /* JsonParserGenerator.kt:163 */
         269  +
    Ok(builder)
         270  +
    /* JsonParserGenerator.kt:148 */
         271  +
}

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

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

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

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

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

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

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

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