Server Test

Server Test

rev. 3c756f73b1f83a0eed4275d9d1e22df0b10b66fb (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_farewell.rs

@@ -0,1 +0,67 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_farewell(
           3  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
           4  +
    input: &crate::model::Farewell,
           5  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    {
           7  +
        object.key("phrase").string(input.phrase.as_str());
           8  +
    }
           9  +
    Ok(())
          10  +
}
          11  +
          12  +
pub(crate) fn de_farewell<'a, I>(
          13  +
    tokens: &mut ::std::iter::Peekable<I>,
          14  +
) -> ::std::result::Result<
          15  +
    Option<crate::model::Farewell>,
          16  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          17  +
>
          18  +
where
          19  +
    I: Iterator<
          20  +
        Item = Result<
          21  +
            ::aws_smithy_json::deserialize::Token<'a>,
          22  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          23  +
        >,
          24  +
    >,
          25  +
{
          26  +
    match tokens.next().transpose()? {
          27  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          28  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          29  +
            #[allow(unused_mut)]
          30  +
            let mut builder = crate::model::farewell::Builder::default();
          31  +
            loop {
          32  +
                match tokens.next().transpose()? {
          33  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          34  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          35  +
                        match key.to_unescaped()?.as_ref() {
          36  +
                            "phrase" => {
          37  +
                                if let Some(v) =
          38  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
          39  +
                                        tokens.next(),
          40  +
                                    )?
          41  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          42  +
                                    .transpose()?
          43  +
                                {
          44  +
                                    builder = builder.set_phrase(v);
          45  +
                                }
          46  +
                            }
          47  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          48  +
                        }
          49  +
                    }
          50  +
                    other => {
          51  +
                        return Err(
          52  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                                format!("expected object key or end object, found: {other:?}"),
          54  +
                            ),
          55  +
                        )
          56  +
                    }
          57  +
                }
          58  +
            }
          59  +
            Ok(Some(builder.build()))
          60  +
        }
          61  +
        _ => Err(
          62  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          63  +
                "expected start object or null",
          64  +
            ),
          65  +
        ),
          66  +
    }
          67  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_foo_error.rs

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_foo_error_error(
           3  +
    value: &crate::error::FooError,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_foo_error::ser_foo_error(&mut object, value)?;
           8  +
    object
           9  +
        .key("__type")
          10  +
        .string("aws.protocoltests.json10#FooError");
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_foo_error(
          16  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    #[allow(unused_variables)] input: &crate::error::FooError,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    Ok(())
          20  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_greeting_struct.rs

@@ -0,1 +0,65 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_greeting_struct<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::GreetingStruct>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    match tokens.next().transpose()? {
          17  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          18  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          19  +
            #[allow(unused_mut)]
          20  +
            let mut builder = crate::model::greeting_struct::Builder::default();
          21  +
            loop {
          22  +
                match tokens.next().transpose()? {
          23  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          24  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          25  +
                        match key.to_unescaped()?.as_ref() {
          26  +
                            "hi" => {
          27  +
                                builder = builder.set_hi(
          28  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
          29  +
                                        tokens.next(),
          30  +
                                    )?
          31  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          32  +
                                    .transpose()?,
          33  +
                                );
          34  +
                            }
          35  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          36  +
                        }
          37  +
                    }
          38  +
                    other => {
          39  +
                        return Err(
          40  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          41  +
                                format!("expected object key or end object, found: {other:?}"),
          42  +
                            ),
          43  +
                        )
          44  +
                    }
          45  +
                }
          46  +
            }
          47  +
            Ok(Some(builder.build()))
          48  +
        }
          49  +
        _ => Err(
          50  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                "expected start object or null",
          52  +
            ),
          53  +
        ),
          54  +
    }
          55  +
}
          56  +
          57  +
pub fn ser_greeting_struct(
          58  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          59  +
    input: &crate::model::GreetingStruct,
          60  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          61  +
    if let Some(var_1) = &input.hi {
          62  +
        object.key("hi").string(var_1.as_str());
          63  +
    }
          64  +
    Ok(())
          65  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_greeting_with_errors.rs

@@ -0,1 +0,188 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_greeting_with_errors_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::GreetingWithErrorsInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::greeting_with_errors_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          23  +
        if !bytes.is_empty() {
          24  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          25  +
                &headers,
          26  +
                Some("application/x-amz-json-1.0"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors(
          29  +
                bytes.as_ref(),
          30  +
                input,
          31  +
            )?;
          32  +
        }
          33  +
        input.build()
          34  +
    })
          35  +
}
          36  +
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
pub fn ser_greeting_with_errors_http_response(
          39  +
    #[allow(unused_variables)] output: crate::output::GreetingWithErrorsOutput,
          40  +
) -> std::result::Result<
          41  +
    ::aws_smithy_legacy_http_server::response::Response,
          42  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          43  +
> {
          44  +
    Ok({
          45  +
        #[allow(unused_mut)]
          46  +
        let mut builder = ::http::Response::builder();
          47  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          48  +
            builder,
          49  +
            ::http::header::CONTENT_TYPE,
          50  +
            "application/x-amz-json-1.0",
          51  +
        );
          52  +
        let http_status: u16 = 200;
          53  +
        builder = builder.status(http_status);
          54  +
        let payload =
          55  +
            crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output_output(&output)?
          56  +
        ;
          57  +
        let content_length = payload.len();
          58  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          59  +
            builder,
          60  +
            ::http::header::CONTENT_LENGTH,
          61  +
            content_length,
          62  +
        );
          63  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          64  +
        builder.body(body)?
          65  +
    })
          66  +
}
          67  +
          68  +
#[allow(clippy::unnecessary_wraps)]
          69  +
pub fn ser_greeting_with_errors_http_error(
          70  +
    error: &crate::error::GreetingWithErrorsError,
          71  +
) -> std::result::Result<
          72  +
    ::aws_smithy_legacy_http_server::response::Response,
          73  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          74  +
> {
          75  +
    Ok({
          76  +
        match error {
          77  +
            crate::error::GreetingWithErrorsError::InvalidGreeting(output) => {
          78  +
                let payload =
          79  +
                    crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting_error(
          80  +
                        output,
          81  +
                    )?;
          82  +
                #[allow(unused_mut)]
          83  +
                let mut builder = ::http::Response::builder();
          84  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
                    builder,
          86  +
                    ::http::header::CONTENT_TYPE,
          87  +
                    "application/x-amz-json-1.0",
          88  +
                );
          89  +
                let content_length = payload.len();
          90  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          91  +
                    builder,
          92  +
                    ::http::header::CONTENT_LENGTH,
          93  +
                    content_length,
          94  +
                );
          95  +
                builder
          96  +
                    .status(400)
          97  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          98  +
            }
          99  +
            crate::error::GreetingWithErrorsError::ComplexError(output) => {
         100  +
                let payload =
         101  +
                    crate::protocol_serde::shape_complex_error::ser_complex_error_error(output)?;
         102  +
                #[allow(unused_mut)]
         103  +
                let mut builder = ::http::Response::builder();
         104  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         105  +
                    builder,
         106  +
                    ::http::header::CONTENT_TYPE,
         107  +
                    "application/x-amz-json-1.0",
         108  +
                );
         109  +
                let content_length = payload.len();
         110  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         111  +
                    builder,
         112  +
                    ::http::header::CONTENT_LENGTH,
         113  +
                    content_length,
         114  +
                );
         115  +
                builder
         116  +
                    .status(400)
         117  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         118  +
            }
         119  +
            crate::error::GreetingWithErrorsError::FooError(output) => {
         120  +
                let payload = crate::protocol_serde::shape_foo_error::ser_foo_error_error(output)?;
         121  +
                #[allow(unused_mut)]
         122  +
                let mut builder = ::http::Response::builder();
         123  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         124  +
                    builder,
         125  +
                    ::http::header::CONTENT_TYPE,
         126  +
                    "application/x-amz-json-1.0",
         127  +
                );
         128  +
                let content_length = payload.len();
         129  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         130  +
                    builder,
         131  +
                    ::http::header::CONTENT_LENGTH,
         132  +
                    content_length,
         133  +
                );
         134  +
                builder
         135  +
                    .status(500)
         136  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         137  +
            }
         138  +
        }
         139  +
    })
         140  +
}
         141  +
         142  +
pub(crate) fn de_greeting_with_errors(
         143  +
    value: &[u8],
         144  +
    mut builder: crate::input::greeting_with_errors_input::Builder,
         145  +
) -> ::std::result::Result<
         146  +
    crate::input::greeting_with_errors_input::Builder,
         147  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         148  +
> {
         149  +
    let mut tokens_owned =
         150  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         151  +
            .peekable();
         152  +
    let tokens = &mut tokens_owned;
         153  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         154  +
    loop {
         155  +
        match tokens.next().transpose()? {
         156  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         157  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         158  +
                match key.to_unescaped()?.as_ref() {
         159  +
                    "greeting" => {
         160  +
                        builder = builder.set_greeting(
         161  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         162  +
                                tokens.next(),
         163  +
                            )?
         164  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         165  +
                            .transpose()?,
         166  +
                        );
         167  +
                    }
         168  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         169  +
                }
         170  +
            }
         171  +
            other => {
         172  +
                return Err(
         173  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         174  +
                        "expected object key or end object, found: {other:?}"
         175  +
                    )),
         176  +
                )
         177  +
            }
         178  +
        }
         179  +
    }
         180  +
    if tokens.next().is_some() {
         181  +
        return Err(
         182  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         183  +
                "found more JSON tokens after completing parsing",
         184  +
            ),
         185  +
        );
         186  +
    }
         187  +
    Ok(builder)
         188  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_greeting_with_errors_output.rs

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_greeting_with_errors_output_output_output(
           3  +
    value: &crate::output::GreetingWithErrorsOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output(&mut object, value)?;
           8  +
    object.finish();
           9  +
    Ok(out)
          10  +
}
          11  +
          12  +
pub fn ser_greeting_with_errors_output_output(
          13  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          14  +
    input: &crate::output::GreetingWithErrorsOutput,
          15  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          16  +
    if let Some(var_1) = &input.greeting {
          17  +
        object.key("greeting").string(var_1.as_str());
          18  +
    }
          19  +
    Ok(())
          20  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_host_with_path_operation.rs

@@ -0,1 +0,53 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_host_with_path_operation_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::HostWithPathOperationInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::host_with_path_operation_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        input.build()
          23  +
    })
          24  +
}
          25  +
          26  +
#[allow(clippy::unnecessary_wraps)]
          27  +
pub fn ser_host_with_path_operation_http_response(
          28  +
    #[allow(unused_variables)] output: crate::output::HostWithPathOperationOutput,
          29  +
) -> std::result::Result<
          30  +
    ::aws_smithy_legacy_http_server::response::Response,
          31  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          32  +
> {
          33  +
    Ok({
          34  +
        #[allow(unused_mut)]
          35  +
        let mut builder = ::http::Response::builder();
          36  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          37  +
            builder,
          38  +
            ::http::header::CONTENT_TYPE,
          39  +
            "application/x-amz-json-1.0",
          40  +
        );
          41  +
        let http_status: u16 = 200;
          42  +
        builder = builder.status(http_status);
          43  +
        let payload = "";
          44  +
        let content_length = payload.len();
          45  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          46  +
            builder,
          47  +
            ::http::header::CONTENT_LENGTH,
          48  +
            content_length,
          49  +
        );
          50  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          51  +
        builder.body(body)?
          52  +
    })
          53  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_invalid_greeting.rs

@@ -0,1 +0,23 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_invalid_greeting_error(
           3  +
    value: &crate::error::InvalidGreeting,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting(&mut object, value)?;
           8  +
    object
           9  +
        .key("__type")
          10  +
        .string("aws.protocoltests.json10#InvalidGreeting");
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_invalid_greeting(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::error::InvalidGreeting,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    if let Some(var_1) = &input.message {
          20  +
        object.key("Message").string(var_1.as_str());
          21  +
    }
          22  +
    Ok(())
          23  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_json_unions.rs

@@ -0,1 +0,141 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_json_unions_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::JsonUnionsInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::json_unions_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          23  +
        if !bytes.is_empty() {
          24  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          25  +
                &headers,
          26  +
                Some("application/x-amz-json-1.0"),
          27  +
            )?;
          28  +
            input =
          29  +
                crate::protocol_serde::shape_json_unions::de_json_unions(bytes.as_ref(), input)?;
          30  +
        }
          31  +
        input.build()?
          32  +
    })
          33  +
}
          34  +
          35  +
#[allow(clippy::unnecessary_wraps)]
          36  +
pub fn ser_json_unions_http_response(
          37  +
    #[allow(unused_variables)] output: crate::output::JsonUnionsOutput,
          38  +
) -> std::result::Result<
          39  +
    ::aws_smithy_legacy_http_server::response::Response,
          40  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          41  +
> {
          42  +
    Ok({
          43  +
        #[allow(unused_mut)]
          44  +
        let mut builder = ::http::Response::builder();
          45  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          46  +
            builder,
          47  +
            ::http::header::CONTENT_TYPE,
          48  +
            "application/x-amz-json-1.0",
          49  +
        );
          50  +
        let http_status: u16 = 200;
          51  +
        builder = builder.status(http_status);
          52  +
        let payload =
          53  +
            crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output_output(
          54  +
                &output,
          55  +
            )?;
          56  +
        let content_length = payload.len();
          57  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          58  +
            builder,
          59  +
            ::http::header::CONTENT_LENGTH,
          60  +
            content_length,
          61  +
        );
          62  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          63  +
        builder.body(body)?
          64  +
    })
          65  +
}
          66  +
          67  +
#[allow(clippy::unnecessary_wraps)]
          68  +
pub fn ser_json_unions_http_error(
          69  +
    error: &crate::error::JsonUnionsError,
          70  +
) -> std::result::Result<
          71  +
    ::aws_smithy_legacy_http_server::response::Response,
          72  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          73  +
> {
          74  +
    Ok({
          75  +
        match error {
          76  +
            crate::error::JsonUnionsError::ValidationException(output) => {
          77  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          78  +
                #[allow(unused_mut)]
          79  +
                let mut builder = ::http::Response::builder();
          80  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          81  +
                    builder,
          82  +
                    ::http::header::CONTENT_TYPE,
          83  +
                    "application/x-amz-json-1.0",
          84  +
                );
          85  +
                let content_length = payload.len();
          86  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          87  +
                    builder,
          88  +
                    ::http::header::CONTENT_LENGTH,
          89  +
                    content_length,
          90  +
                );
          91  +
                builder
          92  +
                    .status(400)
          93  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          94  +
            }
          95  +
        }
          96  +
    })
          97  +
}
          98  +
          99  +
pub(crate) fn de_json_unions(
         100  +
    value: &[u8],
         101  +
    mut builder: crate::input::json_unions_input::Builder,
         102  +
) -> ::std::result::Result<
         103  +
    crate::input::json_unions_input::Builder,
         104  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         105  +
> {
         106  +
    let mut tokens_owned =
         107  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         108  +
            .peekable();
         109  +
    let tokens = &mut tokens_owned;
         110  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         111  +
    loop {
         112  +
        match tokens.next().transpose()? {
         113  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         114  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         115  +
                match key.to_unescaped()?.as_ref() {
         116  +
                    "contents" => {
         117  +
                        builder = builder.set_contents(
         118  +
                            crate::protocol_serde::shape_my_union::de_my_union(tokens)?,
         119  +
                        );
         120  +
                    }
         121  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         122  +
                }
         123  +
            }
         124  +
            other => {
         125  +
                return Err(
         126  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         127  +
                        "expected object key or end object, found: {other:?}"
         128  +
                    )),
         129  +
                )
         130  +
            }
         131  +
        }
         132  +
    }
         133  +
    if tokens.next().is_some() {
         134  +
        return Err(
         135  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         136  +
                "found more JSON tokens after completing parsing",
         137  +
            ),
         138  +
        );
         139  +
    }
         140  +
    Ok(builder)
         141  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_json_unions_output.rs

@@ -0,1 +0,26 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_json_unions_output_output_output(
           3  +
    value: &crate::output::JsonUnionsOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_json_unions_output_output(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::output::JsonUnionsOutput,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    if let Some(var_1) = &input.contents {
          20  +
        #[allow(unused_mut)]
          21  +
        let mut object_2 = object.key("contents").start_object();
          22  +
        crate::protocol_serde::shape_my_union::ser_my_union(&mut object_2, var_1)?;
          23  +
        object_2.finish();
          24  +
    }
          25  +
    Ok(())
          26  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_my_union.rs

@@ -0,1 +0,211 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_my_union<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    let mut variant = None;
          17  +
    match tokens.next().transpose()? {
          18  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
          19  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
          20  +
            match tokens.next().transpose()? {
          21  +
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          22  +
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          23  +
                    if let ::std::option::Option::Some(::std::result::Result::Ok(
          24  +
                        ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          25  +
                    )) = tokens.peek()
          26  +
                    {
          27  +
                        let _ = tokens.next().expect("peek returned a token")?;
          28  +
                        continue;
          29  +
                    }
          30  +
                    let key = key.to_unescaped()?;
          31  +
                    if key == "__type" {
          32  +
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          33  +
                        continue;
          34  +
                    }
          35  +
                    if variant.is_some() {
          36  +
                        return Err(
          37  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          38  +
                                "encountered mixed variants in union",
          39  +
                            ),
          40  +
                        );
          41  +
                    }
          42  +
                    variant = match key.as_ref() {
          43  +
                            "stringValue" => {
          44  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::StringValue(
          45  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          46  +
                                        s.to_unescaped().map(|u|
          47  +
                                            u.into_owned()
          48  +
                                        )
          49  +
                                    ).transpose()?
          50  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'stringValue' cannot be null"))?
          51  +
                                ))
          52  +
                            }
          53  +
                            "booleanValue" => {
          54  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::BooleanValue(
          55  +
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
          56  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'booleanValue' cannot be null"))?
          57  +
                                ))
          58  +
                            }
          59  +
                            "numberValue" => {
          60  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::NumberValue(
          61  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          62  +
                                                        .map(i32::try_from)
          63  +
                                                        .transpose()?
          64  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'numberValue' cannot be null"))?
          65  +
                                ))
          66  +
                            }
          67  +
                            "blobValue" => {
          68  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::BlobValue(
          69  +
                                    ::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
          70  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'blobValue' cannot be null"))?
          71  +
                                ))
          72  +
                            }
          73  +
                            "timestampValue" => {
          74  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::TimestampValue(
          75  +
                                    ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(tokens.next(), ::aws_smithy_types::date_time::Format::EpochSeconds)?
          76  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timestampValue' cannot be null"))?
          77  +
                                ))
          78  +
                            }
          79  +
                            "enumValue" => {
          80  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::EnumValue(
          81  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          82  +
                                        s.to_unescaped().map(|u|
          83  +
                                            u.into_owned()
          84  +
                                        )
          85  +
                                    ).transpose()?
          86  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumValue' cannot be null"))?
          87  +
                                ))
          88  +
                            }
          89  +
                            "intEnumValue" => {
          90  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::IntEnumValue(
          91  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          92  +
                                                        .map(i32::try_from)
          93  +
                                                        .transpose()?
          94  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'intEnumValue' cannot be null"))?
          95  +
                                ))
          96  +
                            }
          97  +
                            "listValue" => {
          98  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::ListValue(
          99  +
                                    crate::protocol_serde::shape_string_list::de_string_list(tokens)?
         100  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'listValue' cannot be null"))?
         101  +
                                ))
         102  +
                            }
         103  +
                            "mapValue" => {
         104  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::MapValue(
         105  +
                                    crate::protocol_serde::shape_string_map::de_string_map(tokens)?
         106  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mapValue' cannot be null"))?
         107  +
                                ))
         108  +
                            }
         109  +
                            "structureValue" => {
         110  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::StructureValue(
         111  +
                                    crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?
         112  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'structureValue' cannot be null"))?
         113  +
                                ))
         114  +
                            }
         115  +
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {variant}")))
         116  +
                        };
         117  +
                }
         118  +
                other => {
         119  +
                    return Err(
         120  +
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         121  +
                            "expected object key or end object, found: {other:?}"
         122  +
                        )),
         123  +
                    )
         124  +
                }
         125  +
            }
         126  +
        },
         127  +
        _ => {
         128  +
            return Err(
         129  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         130  +
                    "expected start object or null",
         131  +
                ),
         132  +
            )
         133  +
        }
         134  +
    }
         135  +
    if variant.is_none() {
         136  +
        return Err(
         137  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         138  +
                "Union did not contain a valid variant.",
         139  +
            ),
         140  +
        );
         141  +
    }
         142  +
    Ok(variant)
         143  +
}
         144  +
         145  +
pub fn ser_my_union(
         146  +
    object_2: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
         147  +
    input: &crate::model::MyUnion,
         148  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         149  +
    match input {
         150  +
        crate::model::MyUnion::StringValue(inner) => {
         151  +
            object_2.key("stringValue").string(inner.as_str());
         152  +
        }
         153  +
        crate::model::MyUnion::BooleanValue(inner) => {
         154  +
            object_2.key("booleanValue").boolean(*inner);
         155  +
        }
         156  +
        crate::model::MyUnion::NumberValue(inner) => {
         157  +
            object_2.key("numberValue").number(
         158  +
                #[allow(clippy::useless_conversion)]
         159  +
                ::aws_smithy_types::Number::NegInt((*inner).into()),
         160  +
            );
         161  +
        }
         162  +
        crate::model::MyUnion::BlobValue(inner) => {
         163  +
            object_2
         164  +
                .key("blobValue")
         165  +
                .string_unchecked(&::aws_smithy_types::base64::encode(inner));
         166  +
        }
         167  +
        crate::model::MyUnion::TimestampValue(inner) => {
         168  +
            object_2
         169  +
                .key("timestampValue")
         170  +
                .date_time(inner, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
         171  +
        }
         172  +
        crate::model::MyUnion::EnumValue(inner) => {
         173  +
            object_2.key("enumValue").string(inner.as_str());
         174  +
        }
         175  +
        crate::model::MyUnion::IntEnumValue(inner) => {
         176  +
            object_2.key("intEnumValue").number(
         177  +
                #[allow(clippy::useless_conversion)]
         178  +
                ::aws_smithy_types::Number::NegInt((*inner).into()),
         179  +
            );
         180  +
        }
         181  +
        crate::model::MyUnion::ListValue(inner) => {
         182  +
            let mut array_1 = object_2.key("listValue").start_array();
         183  +
            for item_2 in inner {
         184  +
                {
         185  +
                    array_1.value().string(item_2.as_str());
         186  +
                }
         187  +
            }
         188  +
            array_1.finish();
         189  +
        }
         190  +
        crate::model::MyUnion::MapValue(inner) => {
         191  +
            #[allow(unused_mut)]
         192  +
            let mut object_3 = object_2.key("mapValue").start_object();
         193  +
            for (key_4, value_5) in inner {
         194  +
                {
         195  +
                    object_3.key(key_4.as_str()).string(value_5.as_str());
         196  +
                }
         197  +
            }
         198  +
            object_3.finish();
         199  +
        }
         200  +
        crate::model::MyUnion::StructureValue(inner) => {
         201  +
            #[allow(unused_mut)]
         202  +
            let mut object_6 = object_2.key("structureValue").start_object();
         203  +
            crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(
         204  +
                &mut object_6,
         205  +
                inner,
         206  +
            )?;
         207  +
            object_6.finish();
         208  +
        }
         209  +
    }
         210  +
    Ok(())
         211  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_no_input_and_no_output.rs

@@ -0,1 +0,53 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_no_input_and_no_output_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::NoInputAndNoOutputInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::no_input_and_no_output_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        input.build()
          23  +
    })
          24  +
}
          25  +
          26  +
#[allow(clippy::unnecessary_wraps)]
          27  +
pub fn ser_no_input_and_no_output_http_response(
          28  +
    #[allow(unused_variables)] output: crate::output::NoInputAndNoOutputOutput,
          29  +
) -> std::result::Result<
          30  +
    ::aws_smithy_legacy_http_server::response::Response,
          31  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          32  +
> {
          33  +
    Ok({
          34  +
        #[allow(unused_mut)]
          35  +
        let mut builder = ::http::Response::builder();
          36  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          37  +
            builder,
          38  +
            ::http::header::CONTENT_TYPE,
          39  +
            "application/x-amz-json-1.0",
          40  +
        );
          41  +
        let http_status: u16 = 200;
          42  +
        builder = builder.status(http_status);
          43  +
        let payload = "";
          44  +
        let content_length = payload.len();
          45  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          46  +
            builder,
          47  +
            ::http::header::CONTENT_LENGTH,
          48  +
            content_length,
          49  +
        );
          50  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          51  +
        builder.body(body)?
          52  +
    })
          53  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_no_input_and_output.rs

@@ -0,1 +0,55 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_no_input_and_output_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::NoInputAndOutputInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::no_input_and_output_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        input.build()
          23  +
    })
          24  +
}
          25  +
          26  +
#[allow(clippy::unnecessary_wraps)]
          27  +
pub fn ser_no_input_and_output_http_response(
          28  +
    #[allow(unused_variables)] output: crate::output::NoInputAndOutputOutput,
          29  +
) -> std::result::Result<
          30  +
    ::aws_smithy_legacy_http_server::response::Response,
          31  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          32  +
> {
          33  +
    Ok({
          34  +
        #[allow(unused_mut)]
          35  +
        let mut builder = ::http::Response::builder();
          36  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          37  +
            builder,
          38  +
            ::http::header::CONTENT_TYPE,
          39  +
            "application/x-amz-json-1.0",
          40  +
        );
          41  +
        let http_status: u16 = 200;
          42  +
        builder = builder.status(http_status);
          43  +
        let payload =
          44  +
            crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
          45  +
        ;
          46  +
        let content_length = payload.len();
          47  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          48  +
            builder,
          49  +
            ::http::header::CONTENT_LENGTH,
          50  +
            content_length,
          51  +
        );
          52  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          53  +
        builder.body(body)?
          54  +
    })
          55  +
}

tmp-codegen-diff/codegen-server-test/json_rpc10-http0x/rust-server-codegen/src/protocol_serde/shape_no_input_and_output_output.rs

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_no_input_and_output_output_output_output(
           3  +
    value: &crate::output::NoInputAndOutputOutput,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_no_input_and_output_output_output(
          16  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    #[allow(unused_variables)] input: &crate::output::NoInputAndOutputOutput,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    Ok(())
          20  +
}

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

@@ -0,1 +0,170 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_operation_with_defaults_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::OperationWithDefaultsInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::operation_with_defaults_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          23  +
        if !bytes.is_empty() {
          24  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          25  +
                &headers,
          26  +
                Some("application/x-amz-json-1.0"),
          27  +
            )?;
          28  +
            input =
          29  +
                crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults(
          30  +
                    bytes.as_ref(),
          31  +
                    input,
          32  +
                )?;
          33  +
        }
          34  +
        input.build()?
          35  +
    })
          36  +
}
          37  +
          38  +
#[allow(clippy::unnecessary_wraps)]
          39  +
pub fn ser_operation_with_defaults_http_response(
          40  +
    #[allow(unused_variables)] output: crate::output::OperationWithDefaultsOutput,
          41  +
) -> std::result::Result<
          42  +
    ::aws_smithy_legacy_http_server::response::Response,
          43  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          44  +
> {
          45  +
    Ok({
          46  +
        #[allow(unused_mut)]
          47  +
        let mut builder = ::http::Response::builder();
          48  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          49  +
            builder,
          50  +
            ::http::header::CONTENT_TYPE,
          51  +
            "application/x-amz-json-1.0",
          52  +
        );
          53  +
        let http_status: u16 = 200;
          54  +
        builder = builder.status(http_status);
          55  +
        let payload =
          56  +
            crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output_output(&output)?
          57  +
        ;
          58  +
        let content_length = payload.len();
          59  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          60  +
            builder,
          61  +
            ::http::header::CONTENT_LENGTH,
          62  +
            content_length,
          63  +
        );
          64  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          65  +
        builder.body(body)?
          66  +
    })
          67  +
}
          68  +
          69  +
#[allow(clippy::unnecessary_wraps)]
          70  +
pub fn ser_operation_with_defaults_http_error(
          71  +
    error: &crate::error::OperationWithDefaultsError,
          72  +
) -> std::result::Result<
          73  +
    ::aws_smithy_legacy_http_server::response::Response,
          74  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          75  +
> {
          76  +
    Ok({
          77  +
        match error {
          78  +
            crate::error::OperationWithDefaultsError::ValidationException(output) => {
          79  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          80  +
                #[allow(unused_mut)]
          81  +
                let mut builder = ::http::Response::builder();
          82  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          83  +
                    builder,
          84  +
                    ::http::header::CONTENT_TYPE,
          85  +
                    "application/x-amz-json-1.0",
          86  +
                );
          87  +
                let content_length = payload.len();
          88  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          89  +
                    builder,
          90  +
                    ::http::header::CONTENT_LENGTH,
          91  +
                    content_length,
          92  +
                );
          93  +
                builder
          94  +
                    .status(400)
          95  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          96  +
            }
          97  +
        }
          98  +
    })
          99  +
}
         100  +
         101  +
pub(crate) fn de_operation_with_defaults(
         102  +
    value: &[u8],
         103  +
    mut builder: crate::input::operation_with_defaults_input::Builder,
         104  +
) -> ::std::result::Result<
         105  +
    crate::input::operation_with_defaults_input::Builder,
         106  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         107  +
> {
         108  +
    let mut tokens_owned =
         109  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         110  +
            .peekable();
         111  +
    let tokens = &mut tokens_owned;
         112  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         113  +
    loop {
         114  +
        match tokens.next().transpose()? {
         115  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         116  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         117  +
                match key.to_unescaped()?.as_ref() {
         118  +
                    "defaults" => {
         119  +
                        builder = builder.set_defaults(
         120  +
                            crate::protocol_serde::shape_defaults::de_defaults(tokens)?,
         121  +
                        );
         122  +
                    }
         123  +
                    "clientOptionalDefaults" => {
         124  +
                        builder = builder.set_client_optional_defaults(
         125  +
                            crate::protocol_serde::shape_client_optional_defaults::de_client_optional_defaults(tokens)?
         126  +
                        );
         127  +
                    }
         128  +
                    "topLevelDefault" => {
         129  +
                        if let Some(v) =
         130  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         131  +
                                tokens.next(),
         132  +
                            )?
         133  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         134  +
                            .transpose()?
         135  +
                        {
         136  +
                            builder = builder.set_top_level_default(v);
         137  +
                        }
         138  +
                    }
         139  +
                    "otherTopLevelDefault" => {
         140  +
                        if let Some(v) =
         141  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         142  +
                                tokens.next(),
         143  +
                            )?
         144  +
                            .map(i32::try_from)
         145  +
                            .transpose()?
         146  +
                        {
         147  +
                            builder = builder.set_other_top_level_default(v);
         148  +
                        }
         149  +
                    }
         150  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         151  +
                }
         152  +
            }
         153  +
            other => {
         154  +
                return Err(
         155  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         156  +
                        "expected object key or end object, found: {other:?}"
         157  +
                    )),
         158  +
                )
         159  +
            }
         160  +
        }
         161  +
    }
         162  +
    if tokens.next().is_some() {
         163  +
        return Err(
         164  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         165  +
                "found more JSON tokens after completing parsing",
         166  +
            ),
         167  +
        );
         168  +
    }
         169  +
    Ok(builder)
         170  +
}