Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5 (ignoring whitespace)

Files changed:

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

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

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

@@ -0,1 +0,279 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_operation_with_defaults_output_output_output(
           4  +
    value: &crate::output::OperationWithDefaultsOutput,
           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_operation_with_defaults_output::ser_operation_with_defaults_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_operation_with_defaults_output_output(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::output::OperationWithDefaultsOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* SerializerUtil.kt:46 */
          23  +
    {
          24  +
        /* JsonSerializerGenerator.kt:439 */
          25  +
        object
          26  +
            .key("defaultBlob")
          27  +
            .string_unchecked(&::aws_smithy_types::base64::encode(&input.default_blob));
          28  +
        /* SerializerUtil.kt:46 */
          29  +
    }
          30  +
    /* SerializerUtil.kt:46 */
          31  +
    {
          32  +
        /* JsonSerializerGenerator.kt:424 */
          33  +
        object.key("defaultBoolean").boolean(input.default_boolean);
          34  +
        /* SerializerUtil.kt:46 */
          35  +
    }
          36  +
    /* SerializerUtil.kt:46 */
          37  +
    {
          38  +
        /* JsonSerializerGenerator.kt:432 */
          39  +
        object.key("defaultByte").number(
          40  +
            #[allow(clippy::useless_conversion)]
          41  +
            ::aws_smithy_types::Number::NegInt((input.default_byte).into()),
          42  +
        );
          43  +
        /* SerializerUtil.kt:46 */
          44  +
    }
          45  +
    /* SerializerUtil.kt:46 */
          46  +
    {
          47  +
        /* JsonSerializerGenerator.kt:474 */
          48  +
        object
          49  +
            .key("defaultDocumentBoolean")
          50  +
            .document(&input.default_document_boolean);
          51  +
        /* SerializerUtil.kt:46 */
          52  +
    }
          53  +
    /* SerializerUtil.kt:46 */
          54  +
    {
          55  +
        /* JsonSerializerGenerator.kt:474 */
          56  +
        object
          57  +
            .key("defaultDocumentList")
          58  +
            .document(&input.default_document_list);
          59  +
        /* SerializerUtil.kt:46 */
          60  +
    }
          61  +
    /* SerializerUtil.kt:46 */
          62  +
    {
          63  +
        /* JsonSerializerGenerator.kt:474 */
          64  +
        object
          65  +
            .key("defaultDocumentMap")
          66  +
            .document(&input.default_document_map);
          67  +
        /* SerializerUtil.kt:46 */
          68  +
    }
          69  +
    /* SerializerUtil.kt:46 */
          70  +
    {
          71  +
        /* JsonSerializerGenerator.kt:474 */
          72  +
        object
          73  +
            .key("defaultDocumentString")
          74  +
            .document(&input.default_document_string);
          75  +
        /* SerializerUtil.kt:46 */
          76  +
    }
          77  +
    /* SerializerUtil.kt:46 */
          78  +
    {
          79  +
        /* JsonSerializerGenerator.kt:432 */
          80  +
        object.key("defaultDouble").number(
          81  +
            #[allow(clippy::useless_conversion)]
          82  +
            ::aws_smithy_types::Number::Float((input.default_double).into()),
          83  +
        );
          84  +
        /* SerializerUtil.kt:46 */
          85  +
    }
          86  +
    /* SerializerUtil.kt:46 */
          87  +
    {
          88  +
        /* JsonSerializerGenerator.kt:423 */
          89  +
        object
          90  +
            .key("defaultEnum")
          91  +
            .string(input.default_enum.as_str());
          92  +
        /* SerializerUtil.kt:46 */
          93  +
    }
          94  +
    /* SerializerUtil.kt:46 */
          95  +
    {
          96  +
        /* JsonSerializerGenerator.kt:432 */
          97  +
        object.key("defaultFloat").number(
          98  +
            #[allow(clippy::useless_conversion)]
          99  +
            ::aws_smithy_types::Number::Float((input.default_float).into()),
         100  +
        );
         101  +
        /* SerializerUtil.kt:46 */
         102  +
    }
         103  +
    /* SerializerUtil.kt:46 */
         104  +
    {
         105  +
        /* JsonSerializerGenerator.kt:432 */
         106  +
        object.key("defaultIntEnum").number(
         107  +
            #[allow(clippy::useless_conversion)]
         108  +
            ::aws_smithy_types::Number::NegInt((input.default_int_enum).into()),
         109  +
        );
         110  +
        /* SerializerUtil.kt:46 */
         111  +
    }
         112  +
    /* SerializerUtil.kt:46 */
         113  +
    {
         114  +
        /* JsonSerializerGenerator.kt:432 */
         115  +
        object.key("defaultInteger").number(
         116  +
            #[allow(clippy::useless_conversion)]
         117  +
            ::aws_smithy_types::Number::NegInt((input.default_integer).into()),
         118  +
        );
         119  +
        /* SerializerUtil.kt:46 */
         120  +
    }
         121  +
    /* SerializerUtil.kt:46 */
         122  +
    {
         123  +
        /* JsonSerializerGenerator.kt:484 */
         124  +
        let mut array_1 = object.key("defaultList").start_array();
         125  +
        /* JsonSerializerGenerator.kt:524 */
         126  +
        for item_2 in &input.default_list {
         127  +
            /* SerializerUtil.kt:42 */
         128  +
            {
         129  +
                /* JsonSerializerGenerator.kt:423 */
         130  +
                array_1.value().string(item_2.as_str());
         131  +
                /* SerializerUtil.kt:42 */
         132  +
            }
         133  +
            /* JsonSerializerGenerator.kt:524 */
         134  +
        }
         135  +
        /* JsonSerializerGenerator.kt:486 */
         136  +
        array_1.finish();
         137  +
        /* SerializerUtil.kt:46 */
         138  +
    }
         139  +
    /* SerializerUtil.kt:46 */
         140  +
    {
         141  +
        /* JsonSerializerGenerator.kt:432 */
         142  +
        object.key("defaultLong").number(
         143  +
            #[allow(clippy::useless_conversion)]
         144  +
            ::aws_smithy_types::Number::NegInt((input.default_long).into()),
         145  +
        );
         146  +
        /* SerializerUtil.kt:46 */
         147  +
    }
         148  +
    /* SerializerUtil.kt:46 */
         149  +
    {
         150  +
        /* JsonSerializerGenerator.kt:495 */
         151  +
        #[allow(unused_mut)]
         152  +
        /* JsonSerializerGenerator.kt:496 */
         153  +
        let mut object_3 = object.key("defaultMap").start_object();
         154  +
        /* JsonSerializerGenerator.kt:537 */
         155  +
        for (key_4, value_5) in &input.default_map {
         156  +
            /* SerializerUtil.kt:42 */
         157  +
            {
         158  +
                /* JsonSerializerGenerator.kt:423 */
         159  +
                object_3.key(key_4.as_str()).string(value_5.as_str());
         160  +
                /* SerializerUtil.kt:42 */
         161  +
            }
         162  +
            /* JsonSerializerGenerator.kt:537 */
         163  +
        }
         164  +
        /* JsonSerializerGenerator.kt:515 */
         165  +
        object_3.finish();
         166  +
        /* SerializerUtil.kt:46 */
         167  +
    }
         168  +
    /* JsonSerializerGenerator.kt:382 */
         169  +
    if let Some(var_6) = &input.default_null_document {
         170  +
        /* JsonSerializerGenerator.kt:474 */
         171  +
        object.key("defaultNullDocument").document(var_6);
         172  +
        /* JsonSerializerGenerator.kt:382 */
         173  +
    }
         174  +
    /* SerializerUtil.kt:46 */
         175  +
    {
         176  +
        /* JsonSerializerGenerator.kt:432 */
         177  +
        object.key("defaultShort").number(
         178  +
            #[allow(clippy::useless_conversion)]
         179  +
            ::aws_smithy_types::Number::NegInt((input.default_short).into()),
         180  +
        );
         181  +
        /* SerializerUtil.kt:46 */
         182  +
    }
         183  +
    /* SerializerUtil.kt:46 */
         184  +
    {
         185  +
        /* JsonSerializerGenerator.kt:423 */
         186  +
        object
         187  +
            .key("defaultString")
         188  +
            .string(input.default_string.as_str());
         189  +
        /* SerializerUtil.kt:46 */
         190  +
    }
         191  +
    /* SerializerUtil.kt:46 */
         192  +
    {
         193  +
        /* JsonSerializerGenerator.kt:448 */
         194  +
        object.key("defaultTimestamp").date_time(
         195  +
            &input.default_timestamp,
         196  +
            ::aws_smithy_types::date_time::Format::EpochSeconds,
         197  +
        )?;
         198  +
        /* SerializerUtil.kt:46 */
         199  +
    }
         200  +
    /* SerializerUtil.kt:46 */
         201  +
    {
         202  +
        /* JsonSerializerGenerator.kt:439 */
         203  +
        object
         204  +
            .key("emptyBlob")
         205  +
            .string_unchecked(&::aws_smithy_types::base64::encode(&input.empty_blob));
         206  +
        /* SerializerUtil.kt:46 */
         207  +
    }
         208  +
    /* SerializerUtil.kt:46 */
         209  +
    {
         210  +
        /* JsonSerializerGenerator.kt:423 */
         211  +
        object
         212  +
            .key("emptyString")
         213  +
            .string(input.empty_string.as_str());
         214  +
        /* SerializerUtil.kt:46 */
         215  +
    }
         216  +
    /* SerializerUtil.kt:46 */
         217  +
    {
         218  +
        /* JsonSerializerGenerator.kt:424 */
         219  +
        object.key("falseBoolean").boolean(input.false_boolean);
         220  +
        /* SerializerUtil.kt:46 */
         221  +
    }
         222  +
    /* SerializerUtil.kt:46 */
         223  +
    {
         224  +
        /* JsonSerializerGenerator.kt:432 */
         225  +
        object.key("zeroByte").number(
         226  +
            #[allow(clippy::useless_conversion)]
         227  +
            ::aws_smithy_types::Number::NegInt((input.zero_byte).into()),
         228  +
        );
         229  +
        /* SerializerUtil.kt:46 */
         230  +
    }
         231  +
    /* SerializerUtil.kt:46 */
         232  +
    {
         233  +
        /* JsonSerializerGenerator.kt:432 */
         234  +
        object.key("zeroDouble").number(
         235  +
            #[allow(clippy::useless_conversion)]
         236  +
            ::aws_smithy_types::Number::Float((input.zero_double).into()),
         237  +
        );
         238  +
        /* SerializerUtil.kt:46 */
         239  +
    }
         240  +
    /* SerializerUtil.kt:46 */
         241  +
    {
         242  +
        /* JsonSerializerGenerator.kt:432 */
         243  +
        object.key("zeroFloat").number(
         244  +
            #[allow(clippy::useless_conversion)]
         245  +
            ::aws_smithy_types::Number::Float((input.zero_float).into()),
         246  +
        );
         247  +
        /* SerializerUtil.kt:46 */
         248  +
    }
         249  +
    /* SerializerUtil.kt:46 */
         250  +
    {
         251  +
        /* JsonSerializerGenerator.kt:432 */
         252  +
        object.key("zeroInteger").number(
         253  +
            #[allow(clippy::useless_conversion)]
         254  +
            ::aws_smithy_types::Number::NegInt((input.zero_integer).into()),
         255  +
        );
         256  +
        /* SerializerUtil.kt:46 */
         257  +
    }
         258  +
    /* SerializerUtil.kt:46 */
         259  +
    {
         260  +
        /* JsonSerializerGenerator.kt:432 */
         261  +
        object.key("zeroLong").number(
         262  +
            #[allow(clippy::useless_conversion)]
         263  +
            ::aws_smithy_types::Number::NegInt((input.zero_long).into()),
         264  +
        );
         265  +
        /* SerializerUtil.kt:46 */
         266  +
    }
         267  +
    /* SerializerUtil.kt:46 */
         268  +
    {
         269  +
        /* JsonSerializerGenerator.kt:432 */
         270  +
        object.key("zeroShort").number(
         271  +
            #[allow(clippy::useless_conversion)]
         272  +
            ::aws_smithy_types::Number::NegInt((input.zero_short).into()),
         273  +
        );
         274  +
        /* SerializerUtil.kt:46 */
         275  +
    }
         276  +
    /* JsonSerializerGenerator.kt:372 */
         277  +
    Ok(())
         278  +
    /* JsonSerializerGenerator.kt:358 */
         279  +
}

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

@@ -0,1 +0,208 @@
           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_operation_with_nested_structure_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::OperationWithNestedStructureInput,
           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::operation_with_nested_structure_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_operation_with_nested_structure::de_operation_with_nested_structure(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_operation_with_nested_structure_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::OperationWithNestedStructureOutput,
          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_operation_with_nested_structure_output::ser_operation_with_nested_structure_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_operation_with_nested_structure_http_error(
          96  +
    error: &crate::error::OperationWithNestedStructureError,
          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::OperationWithNestedStructureError::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_operation_with_nested_structure(
         146  +
    value: &[u8],
         147  +
    mut builder: crate::input::operation_with_nested_structure_input::Builder,
         148  +
) -> ::std::result::Result<
         149  +
    crate::input::operation_with_nested_structure_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  +
                    "topLevel" => {
         169  +
                        /* JsonParserGenerator.kt:276 */
         170  +
                        if let Some(v) =
         171  +
                            /* JsonParserGenerator.kt:544 */
         172  +
                            crate::protocol_serde::shape_top_level::de_top_level(tokens)?
         173  +
                        /* JsonParserGenerator.kt:278 */
         174  +
                        {
         175  +
                            builder = builder.set_top_level(v);
         176  +
                        }
         177  +
                        /* JsonParserGenerator.kt:262 */
         178  +
                    }
         179  +
                    /* JsonParserGenerator.kt:290 */
         180  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         181  +
                }
         182  +
                /* JsonParserGenerator.kt:686 */
         183  +
            }
         184  +
            /* JsonParserGenerator.kt:695 */
         185  +
            other => {
         186  +
                return Err(
         187  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         188  +
                        "expected object key or end object, found: {other:?}"
         189  +
                    )),
         190  +
                )
         191  +
            } /* JsonParserGenerator.kt:685 */
         192  +
        }
         193  +
        /* JsonParserGenerator.kt:684 */
         194  +
    }
         195  +
    /* JsonParserGenerator.kt:250 */
         196  +
    if tokens.next().is_some() {
         197  +
        /* JsonParserGenerator.kt:251 */
         198  +
        return Err(
         199  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         200  +
                "found more JSON tokens after completing parsing",
         201  +
            ),
         202  +
        );
         203  +
        /* JsonParserGenerator.kt:250 */
         204  +
    }
         205  +
    /* JsonParserGenerator.kt:163 */
         206  +
    Ok(builder)
         207  +
    /* JsonParserGenerator.kt:148 */
         208  +
}

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

@@ -0,1 +0,87 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_operation_with_nested_structure_output_output_output(
           4  +
    value: &crate::output::OperationWithNestedStructureOutput,
           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_operation_with_nested_structure_output::ser_operation_with_nested_structure_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_operation_with_nested_structure_output_output(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::output::OperationWithNestedStructureOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* SerializerUtil.kt:42 */
          23  +
    {
          24  +
        /* JsonSerializerGenerator.kt:495 */
          25  +
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
          27  +
        let mut object_1 = object.key("dialog").start_object();
          28  +
        /* JsonSerializerGenerator.kt:375 */
          29  +
        crate::protocol_serde::shape_dialog::ser_dialog(&mut object_1, &input.dialog)?;
          30  +
        /* JsonSerializerGenerator.kt:515 */
          31  +
        object_1.finish();
          32  +
        /* SerializerUtil.kt:42 */
          33  +
    }
          34  +
    /* SerializerUtil.kt:46 */
          35  +
    {
          36  +
        /* JsonSerializerGenerator.kt:484 */
          37  +
        let mut array_2 = object.key("dialogList").start_array();
          38  +
        /* JsonSerializerGenerator.kt:524 */
          39  +
        for item_3 in &input.dialog_list {
          40  +
            /* SerializerUtil.kt:42 */
          41  +
            {
          42  +
                /* JsonSerializerGenerator.kt:495 */
          43  +
                #[allow(unused_mut)]
          44  +
                /* JsonSerializerGenerator.kt:496 */
          45  +
                let mut object_4 = array_2.value().start_object();
          46  +
                /* JsonSerializerGenerator.kt:375 */
          47  +
                crate::protocol_serde::shape_dialog::ser_dialog(&mut object_4, item_3)?;
          48  +
                /* JsonSerializerGenerator.kt:515 */
          49  +
                object_4.finish();
          50  +
                /* SerializerUtil.kt:42 */
          51  +
            }
          52  +
            /* JsonSerializerGenerator.kt:524 */
          53  +
        }
          54  +
        /* JsonSerializerGenerator.kt:486 */
          55  +
        array_2.finish();
          56  +
        /* SerializerUtil.kt:46 */
          57  +
    }
          58  +
    /* SerializerUtil.kt:46 */
          59  +
    {
          60  +
        /* JsonSerializerGenerator.kt:495 */
          61  +
        #[allow(unused_mut)]
          62  +
        /* JsonSerializerGenerator.kt:496 */
          63  +
        let mut object_5 = object.key("dialogMap").start_object();
          64  +
        /* JsonSerializerGenerator.kt:537 */
          65  +
        for (key_6, value_7) in &input.dialog_map {
          66  +
            /* SerializerUtil.kt:42 */
          67  +
            {
          68  +
                /* JsonSerializerGenerator.kt:495 */
          69  +
                #[allow(unused_mut)]
          70  +
                /* JsonSerializerGenerator.kt:496 */
          71  +
                let mut object_8 = object_5.key(key_6.as_str()).start_object();
          72  +
                /* JsonSerializerGenerator.kt:375 */
          73  +
                crate::protocol_serde::shape_dialog::ser_dialog(&mut object_8, value_7)?;
          74  +
                /* JsonSerializerGenerator.kt:515 */
          75  +
                object_8.finish();
          76  +
                /* SerializerUtil.kt:42 */
          77  +
            }
          78  +
            /* JsonSerializerGenerator.kt:537 */
          79  +
        }
          80  +
        /* JsonSerializerGenerator.kt:515 */
          81  +
        object_5.finish();
          82  +
        /* SerializerUtil.kt:46 */
          83  +
    }
          84  +
    /* JsonSerializerGenerator.kt:372 */
          85  +
    Ok(())
          86  +
    /* JsonSerializerGenerator.kt:358 */
          87  +
}

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

@@ -0,1 +0,130 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:175 */
           3  +
pub(crate) fn de_payload_config_payload(
           4  +
    input: &[u8],
           5  +
) -> ::std::result::Result<
           6  +
    crate::model::PayloadConfig,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* JsonParserGenerator.kt:187 */
          10  +
    let mut tokens_owned =
          11  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(input))
          12  +
            .peekable();
          13  +
    let tokens = &mut tokens_owned;
          14  +
    /* JsonParserGenerator.kt:194 */
          15  +
    let result =
          16  +
    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_payload_config::de_payload_config(tokens)?
          17  +
    /* JsonParserGenerator.kt:196 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          18  +
    /* JsonParserGenerator.kt:250 */
          19  +
    if tokens.next().is_some() {
          20  +
        /* JsonParserGenerator.kt:251 */
          21  +
        return Err(
          22  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          23  +
                "found more JSON tokens after completing parsing",
          24  +
            ),
          25  +
        );
          26  +
        /* JsonParserGenerator.kt:250 */
          27  +
    }
          28  +
    /* JsonParserGenerator.kt:198 */
          29  +
    result
          30  +
    /* JsonParserGenerator.kt:175 */
          31  +
}
          32  +
          33  +
/* JsonParserGenerator.kt:516 */
          34  +
pub(crate) fn de_payload_config<'a, I>(
          35  +
    tokens: &mut ::std::iter::Peekable<I>,
          36  +
) -> ::std::result::Result<
          37  +
    Option<crate::model::PayloadConfig>,
          38  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          39  +
>
          40  +
where
          41  +
    I: Iterator<
          42  +
        Item = Result<
          43  +
            ::aws_smithy_json::deserialize::Token<'a>,
          44  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          45  +
        >,
          46  +
    >,
          47  +
{
          48  +
    /* JsonParserGenerator.kt:712 */
          49  +
    match tokens.next().transpose()? {
          50  +
        /* JsonParserGenerator.kt:713 */
          51  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          52  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          53  +
            /* RustType.kt:534 */
          54  +
            #[allow(unused_mut)]
          55  +
            /* JsonParserGenerator.kt:526 */
          56  +
            let mut builder = crate::model::payload_config::Builder::default();
          57  +
            /* JsonParserGenerator.kt:684 */
          58  +
            loop {
          59  +
                /* JsonParserGenerator.kt:685 */
          60  +
                match tokens.next().transpose()? {
          61  +
                    /* JsonParserGenerator.kt:686 */
          62  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          63  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          64  +
                        /* JsonParserGenerator.kt:260 */
          65  +
                        match key.to_unescaped()?.as_ref() {
          66  +
                            /* JsonParserGenerator.kt:262 */
          67  +
                            "data" => {
          68  +
                                /* JsonParserGenerator.kt:272 */
          69  +
                                builder = builder.set_data(
          70  +
                                    /* JsonParserGenerator.kt:365 */
          71  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
          72  +
                                        tokens.next(),
          73  +
                                    )?
          74  +
                                    .map(i32::try_from)
          75  +
                                    .transpose()?, /* JsonParserGenerator.kt:272 */
          76  +
                                );
          77  +
                                /* JsonParserGenerator.kt:262 */
          78  +
                            }
          79  +
                            /* JsonParserGenerator.kt:290 */
          80  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
          81  +
                        }
          82  +
                        /* JsonParserGenerator.kt:686 */
          83  +
                    }
          84  +
                    /* JsonParserGenerator.kt:695 */
          85  +
                    other => {
          86  +
                        return Err(
          87  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          88  +
                                format!("expected object key or end object, found: {other:?}"),
          89  +
                            ),
          90  +
                        )
          91  +
                    } /* JsonParserGenerator.kt:685 */
          92  +
                }
          93  +
                /* JsonParserGenerator.kt:684 */
          94  +
            }
          95  +
            /* JsonParserGenerator.kt:540 */
          96  +
            Ok(Some(builder.build()))
          97  +
            /* JsonParserGenerator.kt:713 */
          98  +
        }
          99  +
        /* JsonParserGenerator.kt:722 */
         100  +
        _ => {
         101  +
            /* JsonParserGenerator.kt:723 */
         102  +
            Err(
         103  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         104  +
                    "expected start object or null",
         105  +
                ),
         106  +
            )
         107  +
            /* JsonParserGenerator.kt:722 */
         108  +
        } /* JsonParserGenerator.kt:712 */
         109  +
    }
         110  +
    /* JsonParserGenerator.kt:516 */
         111  +
}
         112  +
         113  +
/* JsonSerializerGenerator.kt:358 */
         114  +
pub fn ser_payload_config(
         115  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
         116  +
    input: &crate::model::PayloadConfig,
         117  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         118  +
    /* JsonSerializerGenerator.kt:382 */
         119  +
    if let Some(var_1) = &input.data {
         120  +
        /* JsonSerializerGenerator.kt:432 */
         121  +
        object.key("data").number(
         122  +
            #[allow(clippy::useless_conversion)]
         123  +
            ::aws_smithy_types::Number::NegInt((*var_1).into()),
         124  +
        );
         125  +
        /* JsonSerializerGenerator.kt:382 */
         126  +
    }
         127  +
    /* JsonSerializerGenerator.kt:372 */
         128  +
    Ok(())
         129  +
    /* JsonSerializerGenerator.kt:358 */
         130  +
}

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

@@ -0,1 +0,132 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
           3  +
pub(crate) fn de_player_action<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::model::PlayerAction>,
           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 =
          54  +
                            match key.as_ref() {
          55  +
                                /* JsonParserGenerator.kt:601 */
          56  +
                                "quit" => {
          57  +
                                    /* JsonParserGenerator.kt:603 */
          58  +
                                    ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          59  +
                                    Some(crate::model::PlayerAction::Quit)
          60  +
                                    /* JsonParserGenerator.kt:601 */
          61  +
                                }
          62  +
                                /* JsonParserGenerator.kt:634 */
          63  +
                                variant => return Err(
          64  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          65  +
                                        format!("unexpected union variant: {variant}"),
          66  +
                                    ),
          67  +
                                ), /* JsonParserGenerator.kt:598 */
          68  +
                            };
          69  +
                        /* JsonParserGenerator.kt:686 */
          70  +
                    }
          71  +
                    /* JsonParserGenerator.kt:695 */
          72  +
                    other => {
          73  +
                        return Err(
          74  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          75  +
                                format!("expected object key or end object, found: {other:?}"),
          76  +
                            ),
          77  +
                        )
          78  +
                    } /* JsonParserGenerator.kt:685 */
          79  +
                }
          80  +
                /* JsonParserGenerator.kt:684 */
          81  +
            }
          82  +
            /* JsonParserGenerator.kt:568 */
          83  +
        }
          84  +
        /* JsonParserGenerator.kt:642 */
          85  +
        _ => {
          86  +
            return Err(
          87  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          88  +
                    "expected start object or null",
          89  +
                ),
          90  +
            )
          91  +
        } /* JsonParserGenerator.kt:567 */
          92  +
    }
          93  +
    /* JsonParserGenerator.kt:649 */
          94  +
    if variant.is_none() {
          95  +
        return Err(
          96  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          97  +
                "Union did not contain a valid variant.",
          98  +
            ),
          99  +
        );
         100  +
    }
         101  +
    /* JsonParserGenerator.kt:657 */
         102  +
    Ok(variant)
         103  +
    /* JsonParserGenerator.kt:551 */
         104  +
}
         105  +
         106  +
/* JsonSerializerGenerator.kt:547 */
         107  +
pub fn ser_player_action(
         108  +
    object_1: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
         109  +
    input: &crate::model::PlayerAction,
         110  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         111  +
    /* JsonSerializerGenerator.kt:556 */
         112  +
    match input {
         113  +
        /* JsonSerializerGenerator.kt:564 */
         114  +
        crate::model::PlayerAction::Quit => {
         115  +
            /* SerializerUtil.kt:42 */
         116  +
            {
         117  +
                /* JsonSerializerGenerator.kt:495 */
         118  +
                #[allow(unused_mut)]
         119  +
                /* JsonSerializerGenerator.kt:496 */
         120  +
                let mut object_1 = object_1.key("quit").start_object();
         121  +
                /* JsonSerializerGenerator.kt:515 */
         122  +
                object_1.finish();
         123  +
                /* SerializerUtil.kt:42 */
         124  +
            }
         125  +
            /* JsonSerializerGenerator.kt:564 */
         126  +
        }
         127  +
        /* JsonSerializerGenerator.kt:556 */
         128  +
    }
         129  +
    /* JsonSerializerGenerator.kt:576 */
         130  +
    Ok(())
         131  +
    /* JsonSerializerGenerator.kt:547 */
         132  +
}