Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5

Files changed:

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

@@ -0,1 +0,52 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_boolean_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::boolean_set_unconstrained::BooleanSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_bool_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?;
          30  +
                        if let Some(value) = value {
          31  +
                            items.push(value);
          32  +
                        } else {
          33  +
                            return Err(
          34  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          35  +
                                    "dense list cannot contain null values",
          36  +
                                ),
          37  +
                            );
          38  +
                        }
          39  +
                    }
          40  +
                }
          41  +
            }
          42  +
            Ok(Some(
          43  +
                crate::unconstrained::boolean_set_unconstrained::BooleanSetUnconstrained(items),
          44  +
            ))
          45  +
        }
          46  +
        _ => Err(
          47  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          48  +
                "expected start array or null",
          49  +
            ),
          50  +
        ),
          51  +
    }
          52  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_byte_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::byte_set_unconstrained::ByteSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(i8::try_from)
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::byte_set_unconstrained::ByteSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_date_time_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::date_time_set_unconstrained::DateTimeSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value =
          28  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
          29  +
                                tokens.next(),
          30  +
                                ::aws_smithy_types::date_time::Format::DateTime,
          31  +
                            )?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::date_time_set_unconstrained::DateTimeSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_enum_list<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::enum_list_unconstrained::EnumListUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::enum_list_unconstrained::EnumListUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,62 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_enum_map<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::enum_map_unconstrained::EnumMapUnconstrained>,
           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  +
            let mut map = ::std::collections::HashMap::new();
          20  +
            loop {
          21  +
                match tokens.next().transpose()? {
          22  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          23  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          24  +
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
          25  +
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
          26  +
                            tokens.next(),
          27  +
                        )?
          28  +
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          29  +
                        .transpose()?;
          30  +
                        match value {
          31  +
                            Some(value) => {
          32  +
                                map.insert(key, value);
          33  +
                            }
          34  +
                            None => {
          35  +
                                return Err(
          36  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                        "dense map cannot contain null values",
          38  +
                                    ),
          39  +
                                )
          40  +
                            }
          41  +
                        }
          42  +
                    }
          43  +
                    other => {
          44  +
                        return Err(
          45  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          46  +
                                format!("expected object key or end object, found: {other:?}"),
          47  +
                            ),
          48  +
                        )
          49  +
                    }
          50  +
                }
          51  +
            }
          52  +
            Ok(Some(
          53  +
                crate::unconstrained::enum_map_unconstrained::EnumMapUnconstrained(map),
          54  +
            ))
          55  +
        }
          56  +
        _ => Err(
          57  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          58  +
                "expected start object or null",
          59  +
            ),
          60  +
        ),
          61  +
    }
          62  +
}

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

@@ -0,1 +0,91 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_enum_union<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::enum_union_unconstrained::EnumUnionUnconstrained>,
           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  +
                            "first" => {
          44  +
                                Some(crate::unconstrained::enum_union_unconstrained::EnumUnionUnconstrained::First(
          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 'first' cannot be null"))?
          51  +
                                ))
          52  +
                            }
          53  +
                            "second" => {
          54  +
                                Some(crate::unconstrained::enum_union_unconstrained::EnumUnionUnconstrained::Second(
          55  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          56  +
                                        s.to_unescaped().map(|u|
          57  +
                                            u.into_owned()
          58  +
                                        )
          59  +
                                    ).transpose()?
          60  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'second' cannot be null"))?
          61  +
                                ))
          62  +
                            }
          63  +
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {variant}")))
          64  +
                        };
          65  +
                }
          66  +
                other => {
          67  +
                    return Err(
          68  +
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          69  +
                            "expected object key or end object, found: {other:?}"
          70  +
                        )),
          71  +
                    )
          72  +
                }
          73  +
            }
          74  +
        },
          75  +
        _ => {
          76  +
            return Err(
          77  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          78  +
                    "expected start object or null",
          79  +
                ),
          80  +
            )
          81  +
        }
          82  +
    }
          83  +
    if variant.is_none() {
          84  +
        return Err(
          85  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          86  +
                "Union did not contain a valid variant.",
          87  +
            ),
          88  +
        );
          89  +
    }
          90  +
    Ok(variant)
          91  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_foo_enum_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,101 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_foo_union<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::FooUnion>,
           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  +
                        "string" => Some(crate::model::FooUnion::String(
          44  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          45  +
                                tokens.next(),
          46  +
                            )?
          47  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          48  +
                            .transpose()?
          49  +
                            .ok_or_else(|| {
          50  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          51  +
                                    "value for 'string' cannot be null",
          52  +
                                )
          53  +
                            })?,
          54  +
                        )),
          55  +
                        "integer" => Some(crate::model::FooUnion::Integer(
          56  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
          57  +
                                tokens.next(),
          58  +
                            )?
          59  +
                            .map(i32::try_from)
          60  +
                            .transpose()?
          61  +
                            .ok_or_else(|| {
          62  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          63  +
                                    "value for 'integer' cannot be null",
          64  +
                                )
          65  +
                            })?,
          66  +
                        )),
          67  +
                        variant => {
          68  +
                            return Err(
          69  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          70  +
                                    format!("unexpected union variant: {variant}"),
          71  +
                                ),
          72  +
                            )
          73  +
                        }
          74  +
                    };
          75  +
                }
          76  +
                other => {
          77  +
                    return Err(
          78  +
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          79  +
                            "expected object key or end object, found: {other:?}"
          80  +
                        )),
          81  +
                    )
          82  +
                }
          83  +
            }
          84  +
        },
          85  +
        _ => {
          86  +
            return Err(
          87  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          88  +
                    "expected start object or null",
          89  +
                ),
          90  +
            )
          91  +
        }
          92  +
    }
          93  +
    if variant.is_none() {
          94  +
        return Err(
          95  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          96  +
                "Union did not contain a valid variant.",
          97  +
            ),
          98  +
        );
          99  +
    }
         100  +
    Ok(variant)
         101  +
}

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

@@ -0,1 +0,55 @@
           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  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_http_date_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::http_date_set_unconstrained::HttpDateSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value =
          28  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
          29  +
                                tokens.next(),
          30  +
                                ::aws_smithy_types::date_time::Format::HttpDate,
          31  +
                            )?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::http_date_set_unconstrained::HttpDateSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,56 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_integer_enum_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(i32::try_from)
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained(
          46  +
                    items,
          47  +
                ),
          48  +
            ))
          49  +
        }
          50  +
        _ => Err(
          51  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          52  +
                "expected start array or null",
          53  +
            ),
          54  +
        ),
          55  +
    }
          56  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_integer_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::integer_set_unconstrained::IntegerSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(i32::try_from)
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::integer_set_unconstrained::IntegerSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_length_list<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::length_list_unconstrained::LengthListUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::length_list_unconstrained::LengthListUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,59 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_length_map<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::length_map_unconstrained::LengthMapUnconstrained>,
           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  +
            let mut map = ::std::collections::HashMap::new();
          20  +
            loop {
          21  +
                match tokens.next().transpose()? {
          22  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          23  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          24  +
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
          25  +
                        let value =
          26  +
                            crate::protocol_serde::shape_length_list::de_length_list(tokens)?;
          27  +
                        match value {
          28  +
                            Some(value) => {
          29  +
                                map.insert(key, value);
          30  +
                            }
          31  +
                            None => {
          32  +
                                return Err(
          33  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          34  +
                                        "dense map cannot contain null values",
          35  +
                                    ),
          36  +
                                )
          37  +
                            }
          38  +
                        }
          39  +
                    }
          40  +
                    other => {
          41  +
                        return Err(
          42  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          43  +
                                format!("expected object key or end object, found: {other:?}"),
          44  +
                            ),
          45  +
                        )
          46  +
                    }
          47  +
                }
          48  +
            }
          49  +
            Ok(Some(
          50  +
                crate::unconstrained::length_map_unconstrained::LengthMapUnconstrained(map),
          51  +
            ))
          52  +
        }
          53  +
        _ => Err(
          54  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          55  +
                "expected start object or null",
          56  +
            ),
          57  +
        ),
          58  +
    }
          59  +
}

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

@@ -0,1 +0,51 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_list_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::list_set_unconstrained::ListSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value =
          28  +
                            crate::protocol_serde::shape_string_list::de_string_list(tokens)?;
          29  +
                        if let Some(value) = value {
          30  +
                            items.push(value);
          31  +
                        } else {
          32  +
                            return Err(
          33  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          34  +
                                    "dense list cannot contain null values",
          35  +
                                ),
          36  +
                            );
          37  +
                        }
          38  +
                    }
          39  +
                }
          40  +
            }
          41  +
            Ok(Some(
          42  +
                crate::unconstrained::list_set_unconstrained::ListSetUnconstrained(items),
          43  +
            ))
          44  +
        }
          45  +
        _ => Err(
          46  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          47  +
                "expected start array or null",
          48  +
            ),
          49  +
        ),
          50  +
    }
          51  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_long_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::long_set_unconstrained::LongSetUnconstrained>,
           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::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(i64::try_from)
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::long_set_unconstrained::LongSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}