Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_enum.rs

@@ -0,1 +0,172 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_enum_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedEnumInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_enum_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/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_malformed_enum::de_malformed_enum(
          29  +
                bytes.as_ref(),
          30  +
                input,
          31  +
            )?;
          32  +
        }
          33  +
        input.build()?
          34  +
    })
          35  +
}
          36  +
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
pub fn ser_malformed_enum_http_response(
          39  +
    #[allow(unused_variables)] output: crate::output::MalformedEnumOutput,
          40  +
) -> std::result::Result<
          41  +
    ::aws_smithy_legacy_http_server::response::Response,
          42  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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/json",
          51  +
        );
          52  +
        let http_status: u16 = 200;
          53  +
        builder = builder.status(http_status);
          54  +
        let payload = "";
          55  +
        let content_length = payload.len();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_LENGTH,
          59  +
            content_length,
          60  +
        );
          61  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          62  +
        builder.body(body)?
          63  +
    })
          64  +
}
          65  +
          66  +
#[allow(clippy::unnecessary_wraps)]
          67  +
pub fn ser_malformed_enum_http_error(
          68  +
    error: &crate::error::MalformedEnumError,
          69  +
) -> std::result::Result<
          70  +
    ::aws_smithy_legacy_http_server::response::Response,
          71  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          72  +
> {
          73  +
    Ok({
          74  +
        match error {
          75  +
            crate::error::MalformedEnumError::ValidationException(output) => {
          76  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          77  +
                #[allow(unused_mut)]
          78  +
                let mut builder = ::http::Response::builder();
          79  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
                    builder,
          81  +
                    ::http::header::CONTENT_TYPE,
          82  +
                    "application/json",
          83  +
                );
          84  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
                    builder,
          86  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          87  +
                    "ValidationException",
          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  +
        }
         100  +
    })
         101  +
}
         102  +
         103  +
pub(crate) fn de_malformed_enum(
         104  +
    value: &[u8],
         105  +
    mut builder: crate::input::malformed_enum_input::Builder,
         106  +
) -> ::std::result::Result<
         107  +
    crate::input::malformed_enum_input::Builder,
         108  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         109  +
> {
         110  +
    let mut tokens_owned =
         111  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         112  +
            .peekable();
         113  +
    let tokens = &mut tokens_owned;
         114  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         115  +
    loop {
         116  +
        match tokens.next().transpose()? {
         117  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         118  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                match key.to_unescaped()?.as_ref() {
         120  +
                    "list" => {
         121  +
                        builder = builder.set_list(
         122  +
                            crate::protocol_serde::shape_enum_list::de_enum_list(tokens)?,
         123  +
                        );
         124  +
                    }
         125  +
                    "map" => {
         126  +
                        builder = builder
         127  +
                            .set_map(crate::protocol_serde::shape_enum_map::de_enum_map(tokens)?);
         128  +
                    }
         129  +
                    "string" => {
         130  +
                        builder = builder.set_string(
         131  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         132  +
                                tokens.next(),
         133  +
                            )?
         134  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         135  +
                            .transpose()?,
         136  +
                        );
         137  +
                    }
         138  +
                    "stringWithEnumTrait" => {
         139  +
                        builder = builder.set_string_with_enum_trait(
         140  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         141  +
                                tokens.next(),
         142  +
                            )?
         143  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         144  +
                            .transpose()?,
         145  +
                        );
         146  +
                    }
         147  +
                    "union" => {
         148  +
                        builder = builder.set_union(
         149  +
                            crate::protocol_serde::shape_enum_union::de_enum_union(tokens)?,
         150  +
                        );
         151  +
                    }
         152  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         153  +
                }
         154  +
            }
         155  +
            other => {
         156  +
                return Err(
         157  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         158  +
                        "expected object key or end object, found: {other:?}"
         159  +
                    )),
         160  +
                )
         161  +
            }
         162  +
        }
         163  +
    }
         164  +
    if tokens.next().is_some() {
         165  +
        return Err(
         166  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         167  +
                "found more JSON tokens after completing parsing",
         168  +
            ),
         169  +
        );
         170  +
    }
         171  +
    Ok(builder)
         172  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_length.rs

@@ -0,1 +0,184 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_length_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedLengthInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_length_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/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_malformed_length::de_malformed_length(
          29  +
                bytes.as_ref(),
          30  +
                input,
          31  +
            )?;
          32  +
        }
          33  +
        input.build()?
          34  +
    })
          35  +
}
          36  +
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
pub fn ser_malformed_length_http_response(
          39  +
    #[allow(unused_variables)] output: crate::output::MalformedLengthOutput,
          40  +
) -> std::result::Result<
          41  +
    ::aws_smithy_legacy_http_server::response::Response,
          42  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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/json",
          51  +
        );
          52  +
        let http_status: u16 = 200;
          53  +
        builder = builder.status(http_status);
          54  +
        let payload = "";
          55  +
        let content_length = payload.len();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_LENGTH,
          59  +
            content_length,
          60  +
        );
          61  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          62  +
        builder.body(body)?
          63  +
    })
          64  +
}
          65  +
          66  +
#[allow(clippy::unnecessary_wraps)]
          67  +
pub fn ser_malformed_length_http_error(
          68  +
    error: &crate::error::MalformedLengthError,
          69  +
) -> std::result::Result<
          70  +
    ::aws_smithy_legacy_http_server::response::Response,
          71  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          72  +
> {
          73  +
    Ok({
          74  +
        match error {
          75  +
            crate::error::MalformedLengthError::ValidationException(output) => {
          76  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          77  +
                #[allow(unused_mut)]
          78  +
                let mut builder = ::http::Response::builder();
          79  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
                    builder,
          81  +
                    ::http::header::CONTENT_TYPE,
          82  +
                    "application/json",
          83  +
                );
          84  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
                    builder,
          86  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          87  +
                    "ValidationException",
          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  +
        }
         100  +
    })
         101  +
}
         102  +
         103  +
pub(crate) fn de_malformed_length(
         104  +
    value: &[u8],
         105  +
    mut builder: crate::input::malformed_length_input::Builder,
         106  +
) -> ::std::result::Result<
         107  +
    crate::input::malformed_length_input::Builder,
         108  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         109  +
> {
         110  +
    let mut tokens_owned =
         111  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         112  +
            .peekable();
         113  +
    let tokens = &mut tokens_owned;
         114  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         115  +
    loop {
         116  +
        match tokens.next().transpose()? {
         117  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         118  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                match key.to_unescaped()?.as_ref() {
         120  +
                    "blob" => {
         121  +
                        builder = builder.set_blob(
         122  +
                            ::aws_smithy_json::deserialize::token::expect_blob_or_null(
         123  +
                                tokens.next(),
         124  +
                            )?,
         125  +
                        );
         126  +
                    }
         127  +
                    "list" => {
         128  +
                        builder = builder.set_list(
         129  +
                            crate::protocol_serde::shape_length_list::de_length_list(tokens)?,
         130  +
                        );
         131  +
                    }
         132  +
                    "map" => {
         133  +
                        builder = builder.set_map(
         134  +
                            crate::protocol_serde::shape_length_map::de_length_map(tokens)?,
         135  +
                        );
         136  +
                    }
         137  +
                    "maxString" => {
         138  +
                        builder = builder.set_max_string(
         139  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         140  +
                                tokens.next(),
         141  +
                            )?
         142  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         143  +
                            .transpose()?,
         144  +
                        );
         145  +
                    }
         146  +
                    "minString" => {
         147  +
                        builder = builder.set_min_string(
         148  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         149  +
                                tokens.next(),
         150  +
                            )?
         151  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         152  +
                            .transpose()?,
         153  +
                        );
         154  +
                    }
         155  +
                    "string" => {
         156  +
                        builder = builder.set_string(
         157  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         158  +
                                tokens.next(),
         159  +
                            )?
         160  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         161  +
                            .transpose()?,
         162  +
                        );
         163  +
                    }
         164  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         165  +
                }
         166  +
            }
         167  +
            other => {
         168  +
                return Err(
         169  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         170  +
                        "expected object key or end object, found: {other:?}"
         171  +
                    )),
         172  +
                )
         173  +
            }
         174  +
        }
         175  +
    }
         176  +
    if tokens.next().is_some() {
         177  +
        return Err(
         178  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         179  +
                "found more JSON tokens after completing parsing",
         180  +
            ),
         181  +
        );
         182  +
    }
         183  +
    Ok(builder)
         184  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_length_override.rs

@@ -0,1 +0,181 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_length_override_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedLengthOverrideInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_length_override_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/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_malformed_length_override::de_malformed_length_override(bytes.as_ref(), input)?;
          29  +
        }
          30  +
        input.build()?
          31  +
    })
          32  +
}
          33  +
          34  +
#[allow(clippy::unnecessary_wraps)]
          35  +
pub fn ser_malformed_length_override_http_response(
          36  +
    #[allow(unused_variables)] output: crate::output::MalformedLengthOverrideOutput,
          37  +
) -> std::result::Result<
          38  +
    ::aws_smithy_legacy_http_server::response::Response,
          39  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          40  +
> {
          41  +
    Ok({
          42  +
        #[allow(unused_mut)]
          43  +
        let mut builder = ::http::Response::builder();
          44  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          45  +
            builder,
          46  +
            ::http::header::CONTENT_TYPE,
          47  +
            "application/json",
          48  +
        );
          49  +
        let http_status: u16 = 200;
          50  +
        builder = builder.status(http_status);
          51  +
        let payload = "";
          52  +
        let content_length = payload.len();
          53  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          54  +
            builder,
          55  +
            ::http::header::CONTENT_LENGTH,
          56  +
            content_length,
          57  +
        );
          58  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          59  +
        builder.body(body)?
          60  +
    })
          61  +
}
          62  +
          63  +
#[allow(clippy::unnecessary_wraps)]
          64  +
pub fn ser_malformed_length_override_http_error(
          65  +
    error: &crate::error::MalformedLengthOverrideError,
          66  +
) -> std::result::Result<
          67  +
    ::aws_smithy_legacy_http_server::response::Response,
          68  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          69  +
> {
          70  +
    Ok({
          71  +
        match error {
          72  +
            crate::error::MalformedLengthOverrideError::ValidationException(output) => {
          73  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          74  +
                #[allow(unused_mut)]
          75  +
                let mut builder = ::http::Response::builder();
          76  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          77  +
                    builder,
          78  +
                    ::http::header::CONTENT_TYPE,
          79  +
                    "application/json",
          80  +
                );
          81  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
                    builder,
          83  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          84  +
                    "ValidationException",
          85  +
                );
          86  +
                let content_length = payload.len();
          87  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          88  +
                    builder,
          89  +
                    ::http::header::CONTENT_LENGTH,
          90  +
                    content_length,
          91  +
                );
          92  +
                builder
          93  +
                    .status(400)
          94  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          95  +
            }
          96  +
        }
          97  +
    })
          98  +
}
          99  +
         100  +
pub(crate) fn de_malformed_length_override(
         101  +
    value: &[u8],
         102  +
    mut builder: crate::input::malformed_length_override_input::Builder,
         103  +
) -> ::std::result::Result<
         104  +
    crate::input::malformed_length_override_input::Builder,
         105  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         106  +
> {
         107  +
    let mut tokens_owned =
         108  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         109  +
            .peekable();
         110  +
    let tokens = &mut tokens_owned;
         111  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         112  +
    loop {
         113  +
        match tokens.next().transpose()? {
         114  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         115  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                match key.to_unescaped()?.as_ref() {
         117  +
                    "blob" => {
         118  +
                        builder = builder.set_blob(
         119  +
                            ::aws_smithy_json::deserialize::token::expect_blob_or_null(
         120  +
                                tokens.next(),
         121  +
                            )?,
         122  +
                        );
         123  +
                    }
         124  +
                    "list" => {
         125  +
                        builder = builder.set_list(
         126  +
                            crate::protocol_serde::shape_malformed_length_override_input_list::de_malformed_length_override_input_list(tokens)?
         127  +
                        );
         128  +
                    }
         129  +
                    "map" => {
         130  +
                        builder = builder.set_map(
         131  +
                            crate::protocol_serde::shape_malformed_length_override_input_map::de_malformed_length_override_input_map(tokens)?
         132  +
                        );
         133  +
                    }
         134  +
                    "maxString" => {
         135  +
                        builder = builder.set_max_string(
         136  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         137  +
                                tokens.next(),
         138  +
                            )?
         139  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         140  +
                            .transpose()?,
         141  +
                        );
         142  +
                    }
         143  +
                    "minString" => {
         144  +
                        builder = builder.set_min_string(
         145  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         146  +
                                tokens.next(),
         147  +
                            )?
         148  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         149  +
                            .transpose()?,
         150  +
                        );
         151  +
                    }
         152  +
                    "string" => {
         153  +
                        builder = builder.set_string(
         154  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         155  +
                                tokens.next(),
         156  +
                            )?
         157  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         158  +
                            .transpose()?,
         159  +
                        );
         160  +
                    }
         161  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         162  +
                }
         163  +
            }
         164  +
            other => {
         165  +
                return Err(
         166  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         167  +
                        "expected object key or end object, found: {other:?}"
         168  +
                    )),
         169  +
                )
         170  +
            }
         171  +
        }
         172  +
    }
         173  +
    if tokens.next().is_some() {
         174  +
        return Err(
         175  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         176  +
                "found more JSON tokens after completing parsing",
         177  +
            ),
         178  +
        );
         179  +
    }
         180  +
    Ok(builder)
         181  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_length_override_input_list.rs

@@ -0,1 +0,40 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_malformed_length_override_input_list<'a, I>(tokens: &mut ::std::iter::Peekable<I>) -> ::std::result::Result<Option<crate::input::malformed_length_override_input::malformed_length_override_input_list_unconstrained::MalformedLengthOverrideInputListUnconstrained>, ::aws_smithy_json::deserialize::error::DeserializeError>
           3  +
where I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>{
           4  +
    match tokens.next().transpose()? {
           5  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
           6  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
           7  +
            let mut items = Vec::new();
           8  +
            loop {
           9  +
                match tokens.peek() {
          10  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          11  +
                        tokens.next().transpose().unwrap();
          12  +
                        break;
          13  +
                    }
          14  +
                    _ => {
          15  +
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
          16  +
                            tokens.next(),
          17  +
                        )?
          18  +
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          19  +
                        .transpose()?;
          20  +
                        if let Some(value) = value {
          21  +
                            items.push(value);
          22  +
                        } else {
          23  +
                            return Err(
          24  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          25  +
                                    "dense list cannot contain null values",
          26  +
                                ),
          27  +
                            );
          28  +
                        }
          29  +
                    }
          30  +
                }
          31  +
            }
          32  +
            Ok(Some(crate::input::malformed_length_override_input::malformed_length_override_input_list_unconstrained::MalformedLengthOverrideInputListUnconstrained(items)))
          33  +
        }
          34  +
        _ => Err(
          35  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          36  +
                "expected start array or null",
          37  +
            ),
          38  +
        ),
          39  +
    }
          40  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_length_override_input_map.rs

@@ -0,1 +0,45 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_malformed_length_override_input_map<'a, I>(tokens: &mut ::std::iter::Peekable<I>) -> ::std::result::Result<Option<crate::input::malformed_length_override_input::malformed_length_override_input_map_unconstrained::MalformedLengthOverrideInputMapUnconstrained>, ::aws_smithy_json::deserialize::error::DeserializeError>
           3  +
where I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>{
           4  +
    match tokens.next().transpose()? {
           5  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
           6  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
           7  +
            let mut map = ::std::collections::HashMap::new();
           8  +
            loop {
           9  +
                match tokens.next().transpose()? {
          10  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          11  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          12  +
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
          13  +
                        let value =
          14  +
                            crate::protocol_serde::shape_length_list::de_length_list(tokens)?;
          15  +
                        match value {
          16  +
                            Some(value) => {
          17  +
                                map.insert(key, value);
          18  +
                            }
          19  +
                            None => {
          20  +
                                return Err(
          21  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          22  +
                                        "dense map cannot contain null values",
          23  +
                                    ),
          24  +
                                )
          25  +
                            }
          26  +
                        }
          27  +
                    }
          28  +
                    other => {
          29  +
                        return Err(
          30  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          31  +
                                format!("expected object key or end object, found: {other:?}"),
          32  +
                            ),
          33  +
                        )
          34  +
                    }
          35  +
                }
          36  +
            }
          37  +
            Ok(Some(crate::input::malformed_length_override_input::malformed_length_override_input_map_unconstrained::MalformedLengthOverrideInputMapUnconstrained(map)))
          38  +
        }
          39  +
        _ => Err(
          40  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          41  +
                "expected start object or null",
          42  +
            ),
          43  +
        ),
          44  +
    }
          45  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_length_query_string.rs

@@ -0,1 +0,103 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_length_query_string_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedLengthQueryStringInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_length_query_string_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 query_string = uri.query().unwrap_or("");
          23  +
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          24  +
        let mut string_seen = false;
          25  +
        for (k, v) in pairs {
          26  +
            if !string_seen && k == "string" {
          27  +
                input = input.set_string(
          28  +
                    crate::protocol_serde::shape_malformed_length_query_string_input::de_string(
          29  +
                        &v,
          30  +
                    )?,
          31  +
                );
          32  +
                string_seen = true;
          33  +
            }
          34  +
        }
          35  +
        input.build()?
          36  +
    })
          37  +
}
          38  +
          39  +
#[allow(clippy::unnecessary_wraps)]
          40  +
pub fn ser_malformed_length_query_string_http_response(
          41  +
    #[allow(unused_variables)] output: crate::output::MalformedLengthQueryStringOutput,
          42  +
) -> std::result::Result<
          43  +
    ::aws_smithy_legacy_http_server::response::Response,
          44  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          45  +
> {
          46  +
    Ok({
          47  +
        #[allow(unused_mut)]
          48  +
        let mut builder = ::http::Response::builder();
          49  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          50  +
            builder,
          51  +
            ::http::header::CONTENT_TYPE,
          52  +
            "application/json",
          53  +
        );
          54  +
        let http_status: u16 = 200;
          55  +
        builder = builder.status(http_status);
          56  +
        let payload = "";
          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_malformed_length_query_string_http_error(
          70  +
    error: &crate::error::MalformedLengthQueryStringError,
          71  +
) -> std::result::Result<
          72  +
    ::aws_smithy_legacy_http_server::response::Response,
          73  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          74  +
> {
          75  +
    Ok({
          76  +
        match error {
          77  +
            crate::error::MalformedLengthQueryStringError::ValidationException(output) => {
          78  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          79  +
                #[allow(unused_mut)]
          80  +
                let mut builder = ::http::Response::builder();
          81  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
                    builder,
          83  +
                    ::http::header::CONTENT_TYPE,
          84  +
                    "application/json",
          85  +
                );
          86  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          87  +
                    builder,
          88  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          89  +
                    "ValidationException",
          90  +
                );
          91  +
                let content_length = payload.len();
          92  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          93  +
                    builder,
          94  +
                    ::http::header::CONTENT_LENGTH,
          95  +
                    content_length,
          96  +
                );
          97  +
                builder
          98  +
                    .status(400)
          99  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         100  +
            }
         101  +
        }
         102  +
    })
         103  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_length_query_string_input.rs

@@ -0,1 +0,10 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_string(
           3  +
    value: &str,
           4  +
) -> std::result::Result<
           5  +
    ::std::option::Option<::std::string::String>,
           6  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           7  +
> {
           8  +
    let value = value.to_owned();
           9  +
    Ok(Some(value))
          10  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_pattern.rs

@@ -0,1 +0,173 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_pattern_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedPatternInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_pattern_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/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern(
          29  +
                bytes.as_ref(),
          30  +
                input,
          31  +
            )?;
          32  +
        }
          33  +
        input.build()?
          34  +
    })
          35  +
}
          36  +
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
pub fn ser_malformed_pattern_http_response(
          39  +
    #[allow(unused_variables)] output: crate::output::MalformedPatternOutput,
          40  +
) -> std::result::Result<
          41  +
    ::aws_smithy_legacy_http_server::response::Response,
          42  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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/json",
          51  +
        );
          52  +
        let http_status: u16 = 200;
          53  +
        builder = builder.status(http_status);
          54  +
        let payload = "";
          55  +
        let content_length = payload.len();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_LENGTH,
          59  +
            content_length,
          60  +
        );
          61  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          62  +
        builder.body(body)?
          63  +
    })
          64  +
}
          65  +
          66  +
#[allow(clippy::unnecessary_wraps)]
          67  +
pub fn ser_malformed_pattern_http_error(
          68  +
    error: &crate::error::MalformedPatternError,
          69  +
) -> std::result::Result<
          70  +
    ::aws_smithy_legacy_http_server::response::Response,
          71  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          72  +
> {
          73  +
    Ok({
          74  +
        match error {
          75  +
            crate::error::MalformedPatternError::ValidationException(output) => {
          76  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          77  +
                #[allow(unused_mut)]
          78  +
                let mut builder = ::http::Response::builder();
          79  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
                    builder,
          81  +
                    ::http::header::CONTENT_TYPE,
          82  +
                    "application/json",
          83  +
                );
          84  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
                    builder,
          86  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          87  +
                    "ValidationException",
          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  +
        }
         100  +
    })
         101  +
}
         102  +
         103  +
pub(crate) fn de_malformed_pattern(
         104  +
    value: &[u8],
         105  +
    mut builder: crate::input::malformed_pattern_input::Builder,
         106  +
) -> ::std::result::Result<
         107  +
    crate::input::malformed_pattern_input::Builder,
         108  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         109  +
> {
         110  +
    let mut tokens_owned =
         111  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         112  +
            .peekable();
         113  +
    let tokens = &mut tokens_owned;
         114  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         115  +
    loop {
         116  +
        match tokens.next().transpose()? {
         117  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         118  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                match key.to_unescaped()?.as_ref() {
         120  +
                    "evilString" => {
         121  +
                        builder = builder.set_evil_string(
         122  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         123  +
                                tokens.next(),
         124  +
                            )?
         125  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         126  +
                            .transpose()?,
         127  +
                        );
         128  +
                    }
         129  +
                    "list" => {
         130  +
                        builder = builder.set_list(
         131  +
                            crate::protocol_serde::shape_pattern_list::de_pattern_list(tokens)?,
         132  +
                        );
         133  +
                    }
         134  +
                    "map" => {
         135  +
                        builder = builder.set_map(
         136  +
                            crate::protocol_serde::shape_pattern_map::de_pattern_map(tokens)?,
         137  +
                        );
         138  +
                    }
         139  +
                    "string" => {
         140  +
                        builder = builder.set_string(
         141  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         142  +
                                tokens.next(),
         143  +
                            )?
         144  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         145  +
                            .transpose()?,
         146  +
                        );
         147  +
                    }
         148  +
                    "union" => {
         149  +
                        builder = builder.set_union(
         150  +
                            crate::protocol_serde::shape_pattern_union::de_pattern_union(tokens)?,
         151  +
                        );
         152  +
                    }
         153  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         154  +
                }
         155  +
            }
         156  +
            other => {
         157  +
                return Err(
         158  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         159  +
                        "expected object key or end object, found: {other:?}"
         160  +
                    )),
         161  +
                )
         162  +
            }
         163  +
        }
         164  +
    }
         165  +
    if tokens.next().is_some() {
         166  +
        return Err(
         167  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         168  +
                "found more JSON tokens after completing parsing",
         169  +
            ),
         170  +
        );
         171  +
    }
         172  +
    Ok(builder)
         173  +
}

tmp-codegen-diff/codegen-server-test/rest_json_validation-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_pattern_override.rs

@@ -0,1 +0,161 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_pattern_override_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedPatternOverrideInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_pattern_override_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/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_malformed_pattern_override::de_malformed_pattern_override(bytes.as_ref(), input)?;
          29  +
        }
          30  +
        input.build()?
          31  +
    })
          32  +
}
          33  +
          34  +
#[allow(clippy::unnecessary_wraps)]
          35  +
pub fn ser_malformed_pattern_override_http_response(
          36  +
    #[allow(unused_variables)] output: crate::output::MalformedPatternOverrideOutput,
          37  +
) -> std::result::Result<
          38  +
    ::aws_smithy_legacy_http_server::response::Response,
          39  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          40  +
> {
          41  +
    Ok({
          42  +
        #[allow(unused_mut)]
          43  +
        let mut builder = ::http::Response::builder();
          44  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          45  +
            builder,
          46  +
            ::http::header::CONTENT_TYPE,
          47  +
            "application/json",
          48  +
        );
          49  +
        let http_status: u16 = 200;
          50  +
        builder = builder.status(http_status);
          51  +
        let payload = "";
          52  +
        let content_length = payload.len();
          53  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          54  +
            builder,
          55  +
            ::http::header::CONTENT_LENGTH,
          56  +
            content_length,
          57  +
        );
          58  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          59  +
        builder.body(body)?
          60  +
    })
          61  +
}
          62  +
          63  +
#[allow(clippy::unnecessary_wraps)]
          64  +
pub fn ser_malformed_pattern_override_http_error(
          65  +
    error: &crate::error::MalformedPatternOverrideError,
          66  +
) -> std::result::Result<
          67  +
    ::aws_smithy_legacy_http_server::response::Response,
          68  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          69  +
> {
          70  +
    Ok({
          71  +
        match error {
          72  +
            crate::error::MalformedPatternOverrideError::ValidationException(output) => {
          73  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          74  +
                #[allow(unused_mut)]
          75  +
                let mut builder = ::http::Response::builder();
          76  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          77  +
                    builder,
          78  +
                    ::http::header::CONTENT_TYPE,
          79  +
                    "application/json",
          80  +
                );
          81  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
                    builder,
          83  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          84  +
                    "ValidationException",
          85  +
                );
          86  +
                let content_length = payload.len();
          87  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          88  +
                    builder,
          89  +
                    ::http::header::CONTENT_LENGTH,
          90  +
                    content_length,
          91  +
                );
          92  +
                builder
          93  +
                    .status(400)
          94  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          95  +
            }
          96  +
        }
          97  +
    })
          98  +
}
          99  +
         100  +
pub(crate) fn de_malformed_pattern_override(
         101  +
    value: &[u8],
         102  +
    mut builder: crate::input::malformed_pattern_override_input::Builder,
         103  +
) -> ::std::result::Result<
         104  +
    crate::input::malformed_pattern_override_input::Builder,
         105  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         106  +
> {
         107  +
    let mut tokens_owned =
         108  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         109  +
            .peekable();
         110  +
    let tokens = &mut tokens_owned;
         111  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         112  +
    loop {
         113  +
        match tokens.next().transpose()? {
         114  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         115  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                match key.to_unescaped()?.as_ref() {
         117  +
                    "list" => {
         118  +
                        builder = builder.set_list(
         119  +
                            crate::protocol_serde::shape_pattern_list_override::de_pattern_list_override(tokens)?
         120  +
                        );
         121  +
                    }
         122  +
                    "map" => {
         123  +
                        builder = builder.set_map(
         124  +
                            crate::protocol_serde::shape_pattern_map_override::de_pattern_map_override(tokens)?
         125  +
                        );
         126  +
                    }
         127  +
                    "string" => {
         128  +
                        builder = builder.set_string(
         129  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         130  +
                                tokens.next(),
         131  +
                            )?
         132  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         133  +
                            .transpose()?,
         134  +
                        );
         135  +
                    }
         136  +
                    "union" => {
         137  +
                        builder = builder.set_union(
         138  +
                            crate::protocol_serde::shape_pattern_union_override::de_pattern_union_override(tokens)?
         139  +
                        );
         140  +
                    }
         141  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         142  +
                }
         143  +
            }
         144  +
            other => {
         145  +
                return Err(
         146  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         147  +
                        "expected object key or end object, found: {other:?}"
         148  +
                    )),
         149  +
                )
         150  +
            }
         151  +
        }
         152  +
    }
         153  +
    if tokens.next().is_some() {
         154  +
        return Err(
         155  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         156  +
                "found more JSON tokens after completing parsing",
         157  +
            ),
         158  +
        );
         159  +
    }
         160  +
    Ok(builder)
         161  +
}