Server Test Python

Server Test Python

rev. 0b749be6d000fdc7ef59d1bc26f1dce00358d95c (ignoring whitespace)

Files changed:

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

@@ -1,1 +37,39 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
pub(crate) mod shape_all_query_string_types;
    3      3   
    4      4   
pub(crate) mod shape_constant_and_variable_query_string;
    5      5   
    6      6   
pub(crate) mod shape_constant_query_string;
    7      7   
           8  +
pub(crate) mod shape_content_type_parameters;
           9  +
    8     10   
pub(crate) mod shape_datetime_offsets;
    9     11   
   10     12   
pub(crate) mod shape_document_type;
   11     13   
   12     14   
pub(crate) mod shape_document_type_as_map_value;
   13     15   
   14     16   
pub(crate) mod shape_document_type_as_payload;
   15     17   
   16     18   
pub(crate) mod shape_empty_input_and_empty_output;
   17     19   
@@ -124,126 +239,249 @@
  144    146   
pub(crate) mod shape_no_input_and_output;
  145    147   
  146    148   
pub(crate) mod shape_null_and_empty_headers_client;
  147    149   
  148    150   
pub(crate) mod shape_null_and_empty_headers_server;
  149    151   
  150    152   
pub(crate) mod shape_omits_null_serializes_empty_string;
  151    153   
  152    154   
pub(crate) mod shape_omits_serializing_empty_lists;
  153    155   
         156  +
pub(crate) mod shape_operation_with_defaults;
         157  +
         158  +
pub(crate) mod shape_operation_with_nested_structure;
         159  +
  154    160   
pub(crate) mod shape_post_player_action;
  155    161   
  156    162   
pub(crate) mod shape_post_union_with_json_name;
  157    163   
  158    164   
pub(crate) mod shape_put_with_content_encoding;
  159    165   
  160    166   
pub(crate) mod shape_query_idempotency_token_auto_fill;
  161    167   
  162    168   
pub(crate) mod shape_query_params_as_string_list_map;
  163    169   
  164    170   
pub(crate) mod shape_query_precedence;
  165    171   
  166    172   
pub(crate) mod shape_recursive_shapes;
  167    173   
  168    174   
pub(crate) mod shape_simple_scalar_properties;
  169    175   
  170    176   
pub(crate) mod shape_sparse_json_lists;
  171    177   
  172    178   
pub(crate) mod shape_sparse_json_maps;
  173    179   
  174    180   
pub(crate) mod shape_streaming_traits;
  175    181   
  176    182   
pub(crate) mod shape_streaming_traits_require_length;
  177    183   
  178    184   
pub(crate) mod shape_streaming_traits_with_media_type;
  179    185   
  180    186   
pub(crate) mod shape_test_body_structure;
  181    187   
         188  +
pub(crate) mod shape_test_no_input_no_payload;
         189  +
  182    190   
pub(crate) mod shape_test_no_payload;
  183    191   
  184    192   
pub(crate) mod shape_test_payload_blob;
  185    193   
  186    194   
pub(crate) mod shape_test_payload_structure;
  187    195   
  188    196   
pub(crate) mod shape_timestamp_format_headers;
  189    197   
  190    198   
pub(crate) mod shape_unit_input_and_output;
  191    199   
  192    200   
pub(crate) mod shape_all_query_string_types_input;
  193    201   
  194    202   
pub(crate) mod shape_complex_error;
  195    203   
  196    204   
pub(crate) mod shape_constant_and_variable_query_string_input;
  197    205   
  198    206   
pub(crate) mod shape_constant_query_string_input;
  199    207   
  200         -
pub(crate) mod shape_datetime_offsets_output;
  201         -
  202    208   
pub(crate) fn or_empty_doc(data: &[u8]) -> &[u8] {
  203    209   
    if data.is_empty() {
  204    210   
        b"{}"
  205    211   
    } else {
  206    212   
        data
  207    213   
    }
  208    214   
}
  209    215   
         216  +
pub(crate) mod shape_content_type_parameters_output;
         217  +
         218  +
pub(crate) mod shape_datetime_offsets_output;
         219  +
  210    220   
pub(crate) mod shape_document_type_as_map_value_output;
  211    221   
  212    222   
pub(crate) mod shape_document_type_as_payload_input;
  213    223   
  214    224   
pub fn serialize_document(input: &::aws_smithy_types::Document) -> ::std::vec::Vec<u8> {
  215    225   
    let mut out = String::new();
  216    226   
    ::aws_smithy_json::serialize::JsonValueWriter::new(&mut out).document(input);
  217    227   
    out.into_bytes()
  218    228   
}
  219    229   
@@ -338,348 +453,473 @@
  358    368   
pub(crate) mod shape_null_and_empty_headers_client_input;
  359    369   
  360    370   
pub(crate) mod shape_null_and_empty_headers_client_output;
  361    371   
  362    372   
pub(crate) mod shape_null_and_empty_headers_server_input;
  363    373   
  364    374   
pub(crate) mod shape_null_and_empty_headers_server_output;
  365    375   
  366    376   
pub(crate) mod shape_omits_null_serializes_empty_string_input;
  367    377   
         378  +
pub(crate) mod shape_operation_with_defaults_output;
         379  +
         380  +
pub(crate) mod shape_operation_with_nested_structure_output;
         381  +
  368    382   
pub(crate) mod shape_post_player_action_output;
  369    383   
  370    384   
pub(crate) mod shape_post_union_with_json_name_output;
  371    385   
  372    386   
pub(crate) mod shape_put_with_content_encoding_input;
  373    387   
  374    388   
pub(crate) mod shape_query_idempotency_token_auto_fill_input;
  375    389   
  376    390   
pub(crate) mod shape_query_params_as_string_list_map_input;
  377    391   
  378    392   
pub(crate) mod shape_query_precedence_input;
  379    393   
  380    394   
pub(crate) mod shape_recursive_shapes_output;
  381    395   
  382    396   
pub(crate) mod shape_simple_scalar_properties_input;
  383    397   
  384    398   
pub(crate) mod shape_simple_scalar_properties_output;
  385    399   
  386    400   
pub(crate) mod shape_sparse_json_lists_output;
  387    401   
  388    402   
pub(crate) mod shape_sparse_json_maps_output;
  389    403   
  390    404   
pub(crate) mod shape_streaming_traits_input;
  391    405   
  392    406   
pub(crate) mod shape_streaming_traits_output;
  393    407   
  394    408   
pub(crate) mod shape_streaming_traits_require_length_input;
  395    409   
  396    410   
pub(crate) mod shape_streaming_traits_with_media_type_input;
  397    411   
  398    412   
pub(crate) mod shape_streaming_traits_with_media_type_output;
  399    413   
  400    414   
pub(crate) mod shape_test_body_structure_input;
  401    415   
  402    416   
pub(crate) mod shape_test_body_structure_output;
  403    417   
         418  +
pub(crate) mod shape_test_no_input_no_payload_output;
         419  +
  404    420   
pub(crate) mod shape_test_no_payload_input;
  405    421   
  406    422   
pub(crate) mod shape_test_no_payload_output;
  407    423   
  408    424   
pub(crate) mod shape_test_payload_blob_input;
  409    425   
  410    426   
pub(crate) mod shape_test_payload_blob_output;
  411    427   
  412    428   
pub(crate) mod shape_test_payload_structure_input;
  413    429   
  414    430   
pub(crate) mod shape_test_payload_structure_output;
  415    431   
  416    432   
pub(crate) mod shape_timestamp_format_headers_input;
  417    433   
  418    434   
pub(crate) mod shape_timestamp_format_headers_output;
  419    435   
  420    436   
pub(crate) mod shape_validation_exception;
  421    437   
  422    438   
pub(crate) mod shape_boolean_list;
  423    439   
         440  +
pub(crate) mod shape_client_optional_defaults;
         441  +
         442  +
pub(crate) mod shape_defaults;
         443  +
  424    444   
pub(crate) mod shape_dense_boolean_map;
  425    445   
  426    446   
pub(crate) mod shape_dense_number_map;
  427    447   
  428    448   
pub(crate) mod shape_dense_set_map;
  429    449   
  430    450   
pub(crate) mod shape_dense_string_map;
  431    451   
  432    452   
pub(crate) mod shape_dense_struct_map;
  433    453   
@@ -462,482 +0,542 @@
  482    502   
pub(crate) mod shape_string_list;
  483    503   
  484    504   
pub(crate) mod shape_string_set;
  485    505   
  486    506   
pub(crate) mod shape_structure_list;
  487    507   
  488    508   
pub(crate) mod shape_test_config;
  489    509   
  490    510   
pub(crate) mod shape_timestamp_list;
  491    511   
         512  +
pub(crate) mod shape_top_level;
         513  +
  492    514   
pub(crate) mod shape_union_payload;
  493    515   
  494    516   
pub(crate) mod shape_union_with_json_name;
  495    517   
  496    518   
pub(crate) mod shape_complex_nested_error_data;
  497    519   
         520  +
pub(crate) mod shape_dialog;
         521  +
         522  +
pub(crate) mod shape_dialog_list;
         523  +
         524  +
pub(crate) mod shape_dialog_map;
         525  +
  498    526   
pub(crate) mod shape_greeting_struct;
  499    527   
  500    528   
pub(crate) mod shape_recursive_shapes_input_output_nested2;
  501    529   
  502    530   
pub(crate) mod shape_renamed_greeting;
  503    531   
  504    532   
pub(crate) mod shape_string_map;
  505    533   
  506    534   
pub(crate) mod shape_structure_list_member;
  507    535   
         536  +
pub(crate) mod shape_test_string_list;
         537  +
         538  +
pub(crate) mod shape_test_string_map;
         539  +
  508    540   
pub(crate) mod shape_validation_exception_field;
         541  +
         542  +
pub(crate) mod shape_farewell;

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_client_optional_defaults.rs

@@ -0,1 +0,57 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_client_optional_defaults<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> Result<
           5  +
    Option<crate::model::ClientOptionalDefaults>,
           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::client_optional_defaults_internal::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  +
                            "member" => {
          27  +
                                if let Some(v) =
          28  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
          29  +
                                        tokens.next(),
          30  +
                                    )?
          31  +
                                    .map(i32::try_from)
          32  +
                                    .transpose()?
          33  +
                                {
          34  +
                                    builder = builder.set_member(v);
          35  +
                                }
          36  +
                            }
          37  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          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(builder.build()))
          50  +
        }
          51  +
        _ => Err(
          52  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                "expected start object or null",
          54  +
            ),
          55  +
        ),
          56  +
    }
          57  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_content_type_parameters.rs

Renamed from tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/src/protocol_serde/shape_http_string_payload2.rs

@@ -1,1 +0,153 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
#[allow(clippy::unnecessary_wraps)]
    3         -
pub async fn de_http_string_payload2_http_request<B>(
           3  +
pub async fn de_content_type_parameters_http_request<B>(
    4      4   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      5   
) -> std::result::Result<
    6         -
    crate::input::HttpStringPayload2Input,
           6  +
    crate::input::ContentTypeParametersInput,
    7      7   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8      8   
>
    9      9   
where
   10     10   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     11   
    B::Data: Send,
   12     12   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     13   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     14   
{
   15     15   
    Ok({
   16     16   
        #[allow(unused_mut)]
   17         -
        let mut input = crate::input::http_string_payload2_input_internal::Builder::default();
          17  +
        let mut input = crate::input::content_type_parameters_input_internal::Builder::default();
   18     18   
        #[allow(unused_variables)]
   19     19   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     20   
            uri, headers, body, ..
   21     21   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        if let Some(value) = {
   23     22   
        let bytes = ::hyper::body::to_bytes(body).await?;
   24     23   
        if !bytes.is_empty() {
   25     24   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   26     25   
                &headers,
   27         -
                    Some("text/plain"),
          26  +
                Some("application/json"),
          27  +
            )?;
          28  +
            input =
          29  +
                crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters(
          30  +
                    bytes.as_ref(),
          31  +
                    input,
   28     32   
                )?;
   29         -
            }
   30         -
            crate::protocol_serde::shape_http_string_payload2_input::de_payload_payload(&bytes)?
   31         -
        } {
   32         -
            input = input.set_payload(Some(value))
   33     33   
        }
   34     34   
        input.build()
   35     35   
    })
   36     36   
}
   37     37   
   38     38   
#[allow(clippy::unnecessary_wraps)]
   39         -
pub fn ser_http_string_payload2_http_response(
   40         -
    #[allow(unused_variables)] output: crate::output::HttpStringPayload2Output,
          39  +
pub fn ser_content_type_parameters_http_response(
          40  +
    #[allow(unused_variables)] output: crate::output::ContentTypeParametersOutput,
   41     41   
) -> std::result::Result<
   42     42   
    ::aws_smithy_http_server::response::Response,
   43     43   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   44     44   
> {
   45     45   
    Ok({
   46     46   
        #[allow(unused_mut)]
   47     47   
        let mut builder = ::http::Response::builder();
   48     48   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     49   
            builder,
   50     50   
            ::http::header::CONTENT_TYPE,
   51         -
            "text/plain",
          51  +
            "application/json",
   52     52   
        );
   53     53   
        let http_status: u16 = 200;
   54     54   
        builder = builder.status(http_status);
   55     55   
        let payload =
   56         -
            crate::protocol_serde::shape_http_string_payload2_output::ser_payload_http_payload(
   57         -
                output.payload,
   58         -
            )?;
          56  +
            crate::protocol_serde::shape_content_type_parameters_output::ser_content_type_parameters_output_output_output(&output)?
          57  +
        ;
   59     58   
        let content_length = payload.len();
   60     59   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   61     60   
            builder,
   62     61   
            ::http::header::CONTENT_LENGTH,
   63     62   
            content_length,
   64     63   
        );
   65     64   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
   66     65   
        builder.body(body)?
   67     66   
    })
   68     67   
}
   69     68   
   70     69   
#[allow(clippy::unnecessary_wraps)]
   71         -
pub fn ser_http_string_payload2_http_error(
   72         -
    error: &crate::error::HttpStringPayload2Error,
          70  +
pub fn ser_content_type_parameters_http_error(
          71  +
    error: &crate::error::ContentTypeParametersError,
   73     72   
) -> std::result::Result<
   74     73   
    ::aws_smithy_http_server::response::Response,
   75     74   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   76     75   
> {
   77     76   
    Ok({
   78     77   
        match error {
   79         -
            crate::error::HttpStringPayload2Error::ExtraError(output) => {
   80         -
                let payload =
   81         -
                    crate::protocol_serde::shape_extra_error::ser_extra_error_error(output)?;
   82         -
                #[allow(unused_mut)]
   83         -
                let mut builder = ::http::Response::builder();
   84         -
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85         -
                    builder,
   86         -
                    ::http::header::CONTENT_TYPE,
   87         -
                    "text/plain",
   88         -
                );
   89         -
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   90         -
                    builder,
   91         -
                    http::header::HeaderName::from_static("x-amzn-errortype"),
   92         -
                    "ExtraError",
   93         -
                );
   94         -
                let content_length = payload.len();
   95         -
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96         -
                    builder,
   97         -
                    ::http::header::CONTENT_LENGTH,
   98         -
                    content_length,
   99         -
                );
  100         -
                builder
  101         -
                    .status(500)
  102         -
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  103         -
            }
  104         -
            crate::error::HttpStringPayload2Error::InternalServerError(output) => {
          78  +
            crate::error::ContentTypeParametersError::InternalServerError(output) => {
  105     79   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
  106     80   
                #[allow(unused_mut)]
  107     81   
                let mut builder = ::http::Response::builder();
  108     82   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  109     83   
                    builder,
  110     84   
                    ::http::header::CONTENT_TYPE,
  111         -
                    "text/plain",
          85  +
                    "application/json",
  112     86   
                );
  113     87   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  114     88   
                    builder,
  115     89   
                    http::header::HeaderName::from_static("x-amzn-errortype"),
  116     90   
                    "InternalServerError",
  117     91   
                );
  118     92   
                let content_length = payload.len();
  119     93   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  120     94   
                    builder,
  121     95   
                    ::http::header::CONTENT_LENGTH,
  122     96   
                    content_length,
  123     97   
                );
  124     98   
                builder
  125     99   
                    .status(500)
  126    100   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  127    101   
            }
  128    102   
        }
  129    103   
    })
  130    104   
}
         105  +
         106  +
pub(crate) fn de_content_type_parameters(
         107  +
    value: &[u8],
         108  +
    mut builder: crate::input::content_type_parameters_input_internal::Builder,
         109  +
) -> Result<
         110  +
    crate::input::content_type_parameters_input_internal::Builder,
         111  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         112  +
> {
         113  +
    let mut tokens_owned =
         114  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         115  +
            .peekable();
         116  +
    let tokens = &mut tokens_owned;
         117  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         118  +
    loop {
         119  +
        match tokens.next().transpose()? {
         120  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         121  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         122  +
                match key.to_unescaped()?.as_ref() {
         123  +
                    "value" => {
         124  +
                        builder = builder.set_value(
         125  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         126  +
                                tokens.next(),
         127  +
                            )?
         128  +
                            .map(i32::try_from)
         129  +
                            .transpose()?,
         130  +
                        );
         131  +
                    }
         132  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         133  +
                }
         134  +
            }
         135  +
            other => {
         136  +
                return Err(
         137  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         138  +
                        "expected object key or end object, found: {:?}",
         139  +
                        other
         140  +
                    )),
         141  +
                )
         142  +
            }
         143  +
        }
         144  +
    }
         145  +
    if tokens.next().is_some() {
         146  +
        return Err(
         147  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         148  +
                "found more JSON tokens after completing parsing",
         149  +
            ),
         150  +
        );
         151  +
    }
         152  +
    Ok(builder)
         153  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_content_type_parameters_output.rs

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

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_defaults.rs

@@ -0,1 +0,325 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_defaults<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> Result<
           5  +
    Option<crate::model::defaults_internal::Builder>,
           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::defaults_internal::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  +
                            "defaultString" => {
          27  +
                                if let Some(v) =
          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  +
                                    builder = builder.set_default_string(v);
          35  +
                                }
          36  +
                            }
          37  +
                            "defaultBoolean" => {
          38  +
                                if let Some(v) =
          39  +
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(
          40  +
                                        tokens.next(),
          41  +
                                    )?
          42  +
                                {
          43  +
                                    builder = builder.set_default_boolean(v);
          44  +
                                }
          45  +
                            }
          46  +
                            "defaultList" => {
          47  +
                                if let Some(v) =
          48  +
                                crate::protocol_serde::shape_test_string_list::de_test_string_list(tokens)?
          49  +
                                {
          50  +
                                                                            builder = builder.set_default_list(v);
          51  +
                                                                        }
          52  +
                            }
          53  +
                            "defaultDocumentMap" => {
          54  +
                                if let Some(v) = Some(
          55  +
                                    ::aws_smithy_json::deserialize::token::expect_document(tokens)?,
          56  +
                                )
          57  +
                                .map(::aws_smithy_http_server_python::types::Document::from)
          58  +
                                {
          59  +
                                    builder = builder.set_default_document_map(v);
          60  +
                                }
          61  +
                            }
          62  +
                            "defaultDocumentString" => {
          63  +
                                if let Some(v) = Some(
          64  +
                                    ::aws_smithy_json::deserialize::token::expect_document(tokens)?,
          65  +
                                )
          66  +
                                .map(::aws_smithy_http_server_python::types::Document::from)
          67  +
                                {
          68  +
                                    builder = builder.set_default_document_string(v);
          69  +
                                }
          70  +
                            }
          71  +
                            "defaultDocumentBoolean" => {
          72  +
                                if let Some(v) = Some(
          73  +
                                    ::aws_smithy_json::deserialize::token::expect_document(tokens)?,
          74  +
                                )
          75  +
                                .map(::aws_smithy_http_server_python::types::Document::from)
          76  +
                                {
          77  +
                                    builder = builder.set_default_document_boolean(v);
          78  +
                                }
          79  +
                            }
          80  +
                            "defaultDocumentList" => {
          81  +
                                if let Some(v) = Some(
          82  +
                                    ::aws_smithy_json::deserialize::token::expect_document(tokens)?,
          83  +
                                )
          84  +
                                .map(::aws_smithy_http_server_python::types::Document::from)
          85  +
                                {
          86  +
                                    builder = builder.set_default_document_list(v);
          87  +
                                }
          88  +
                            }
          89  +
                            "defaultNullDocument" => {
          90  +
                                builder = builder.set_default_null_document(
          91  +
                                    Some(::aws_smithy_json::deserialize::token::expect_document(
          92  +
                                        tokens,
          93  +
                                    )?)
          94  +
                                    .map(::aws_smithy_http_server_python::types::Document::from),
          95  +
                                );
          96  +
                            }
          97  +
                            "defaultTimestamp" => {
          98  +
                                if let Some(v) =
          99  +
                                    ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         100  +
                                        tokens.next(),
         101  +
                                        ::aws_smithy_types::date_time::Format::EpochSeconds,
         102  +
                                    )?
         103  +
                                    .map(::aws_smithy_http_server_python::types::DateTime::from)
         104  +
                                {
         105  +
                                    builder = builder.set_default_timestamp(v);
         106  +
                                }
         107  +
                            }
         108  +
                            "defaultBlob" => {
         109  +
                                if let Some(v) =
         110  +
                                    ::aws_smithy_json::deserialize::token::expect_blob_or_null(
         111  +
                                        tokens.next(),
         112  +
                                    )?
         113  +
                                    .map(::aws_smithy_http_server_python::types::Blob::from)
         114  +
                                {
         115  +
                                    builder = builder.set_default_blob(v);
         116  +
                                }
         117  +
                            }
         118  +
                            "defaultByte" => {
         119  +
                                if let Some(v) =
         120  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         121  +
                                        tokens.next(),
         122  +
                                    )?
         123  +
                                    .map(i8::try_from)
         124  +
                                    .transpose()?
         125  +
                                {
         126  +
                                    builder = builder.set_default_byte(v);
         127  +
                                }
         128  +
                            }
         129  +
                            "defaultShort" => {
         130  +
                                if let Some(v) =
         131  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         132  +
                                        tokens.next(),
         133  +
                                    )?
         134  +
                                    .map(i16::try_from)
         135  +
                                    .transpose()?
         136  +
                                {
         137  +
                                    builder = builder.set_default_short(v);
         138  +
                                }
         139  +
                            }
         140  +
                            "defaultInteger" => {
         141  +
                                if let Some(v) =
         142  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         143  +
                                        tokens.next(),
         144  +
                                    )?
         145  +
                                    .map(i32::try_from)
         146  +
                                    .transpose()?
         147  +
                                {
         148  +
                                    builder = builder.set_default_integer(v);
         149  +
                                }
         150  +
                            }
         151  +
                            "defaultLong" => {
         152  +
                                if let Some(v) =
         153  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         154  +
                                        tokens.next(),
         155  +
                                    )?
         156  +
                                    .map(i64::try_from)
         157  +
                                    .transpose()?
         158  +
                                {
         159  +
                                    builder = builder.set_default_long(v);
         160  +
                                }
         161  +
                            }
         162  +
                            "defaultFloat" => {
         163  +
                                if let Some(v) =
         164  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         165  +
                                        tokens.next(),
         166  +
                                    )?
         167  +
                                    .map(|v| v.to_f32_lossy())
         168  +
                                {
         169  +
                                    builder = builder.set_default_float(v);
         170  +
                                }
         171  +
                            }
         172  +
                            "defaultDouble" => {
         173  +
                                if let Some(v) =
         174  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         175  +
                                        tokens.next(),
         176  +
                                    )?
         177  +
                                    .map(|v| v.to_f64_lossy())
         178  +
                                {
         179  +
                                    builder = builder.set_default_double(v);
         180  +
                                }
         181  +
                            }
         182  +
                            "defaultMap" => {
         183  +
                                if let Some(v) =
         184  +
                                crate::protocol_serde::shape_test_string_map::de_test_string_map(tokens)?
         185  +
                                {
         186  +
                                                                            builder = builder.set_default_map(v);
         187  +
                                                                        }
         188  +
                            }
         189  +
                            "defaultEnum" => {
         190  +
                                if let Some(v) =
         191  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
         192  +
                                        tokens.next(),
         193  +
                                    )?
         194  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         195  +
                                    .transpose()?
         196  +
                                {
         197  +
                                    builder = builder.set_default_enum(v);
         198  +
                                }
         199  +
                            }
         200  +
                            "defaultIntEnum" => {
         201  +
                                if let Some(v) =
         202  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         203  +
                                        tokens.next(),
         204  +
                                    )?
         205  +
                                    .map(i32::try_from)
         206  +
                                    .transpose()?
         207  +
                                {
         208  +
                                    builder = builder.set_default_int_enum(v);
         209  +
                                }
         210  +
                            }
         211  +
                            "emptyString" => {
         212  +
                                if let Some(v) =
         213  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
         214  +
                                        tokens.next(),
         215  +
                                    )?
         216  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         217  +
                                    .transpose()?
         218  +
                                {
         219  +
                                    builder = builder.set_empty_string(v);
         220  +
                                }
         221  +
                            }
         222  +
                            "falseBoolean" => {
         223  +
                                if let Some(v) =
         224  +
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(
         225  +
                                        tokens.next(),
         226  +
                                    )?
         227  +
                                {
         228  +
                                    builder = builder.set_false_boolean(v);
         229  +
                                }
         230  +
                            }
         231  +
                            "emptyBlob" => {
         232  +
                                if let Some(v) =
         233  +
                                    ::aws_smithy_json::deserialize::token::expect_blob_or_null(
         234  +
                                        tokens.next(),
         235  +
                                    )?
         236  +
                                    .map(::aws_smithy_http_server_python::types::Blob::from)
         237  +
                                {
         238  +
                                    builder = builder.set_empty_blob(v);
         239  +
                                }
         240  +
                            }
         241  +
                            "zeroByte" => {
         242  +
                                if let Some(v) =
         243  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         244  +
                                        tokens.next(),
         245  +
                                    )?
         246  +
                                    .map(i8::try_from)
         247  +
                                    .transpose()?
         248  +
                                {
         249  +
                                    builder = builder.set_zero_byte(v);
         250  +
                                }
         251  +
                            }
         252  +
                            "zeroShort" => {
         253  +
                                if let Some(v) =
         254  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         255  +
                                        tokens.next(),
         256  +
                                    )?
         257  +
                                    .map(i16::try_from)
         258  +
                                    .transpose()?
         259  +
                                {
         260  +
                                    builder = builder.set_zero_short(v);
         261  +
                                }
         262  +
                            }
         263  +
                            "zeroInteger" => {
         264  +
                                if let Some(v) =
         265  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         266  +
                                        tokens.next(),
         267  +
                                    )?
         268  +
                                    .map(i32::try_from)
         269  +
                                    .transpose()?
         270  +
                                {
         271  +
                                    builder = builder.set_zero_integer(v);
         272  +
                                }
         273  +
                            }
         274  +
                            "zeroLong" => {
         275  +
                                if let Some(v) =
         276  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         277  +
                                        tokens.next(),
         278  +
                                    )?
         279  +
                                    .map(i64::try_from)
         280  +
                                    .transpose()?
         281  +
                                {
         282  +
                                    builder = builder.set_zero_long(v);
         283  +
                                }
         284  +
                            }
         285  +
                            "zeroFloat" => {
         286  +
                                if let Some(v) =
         287  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         288  +
                                        tokens.next(),
         289  +
                                    )?
         290  +
                                    .map(|v| v.to_f32_lossy())
         291  +
                                {
         292  +
                                    builder = builder.set_zero_float(v);
         293  +
                                }
         294  +
                            }
         295  +
                            "zeroDouble" => {
         296  +
                                if let Some(v) =
         297  +
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(
         298  +
                                        tokens.next(),
         299  +
                                    )?
         300  +
                                    .map(|v| v.to_f64_lossy())
         301  +
                                {
         302  +
                                    builder = builder.set_zero_double(v);
         303  +
                                }
         304  +
                            }
         305  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         306  +
                        }
         307  +
                    }
         308  +
                    other => {
         309  +
                        return Err(
         310  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         311  +
                                format!("expected object key or end object, found: {:?}", other),
         312  +
                            ),
         313  +
                        )
         314  +
                    }
         315  +
                }
         316  +
            }
         317  +
            Ok(Some(builder))
         318  +
        }
         319  +
        _ => Err(
         320  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         321  +
                "expected start object or null",
         322  +
            ),
         323  +
        ),
         324  +
    }
         325  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_dialog.rs

@@ -0,1 +0,87 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_dialog(
           3  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
           4  +
    input: &crate::model::Dialog,
           5  +
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    if let Some(var_1) = &input.language {
           7  +
        object.key("language").string(var_1.as_str());
           8  +
    }
           9  +
    {
          10  +
        object.key("greeting").string(input.greeting.as_str());
          11  +
    }
          12  +
    if let Some(var_2) = &input.farewell {
          13  +
        #[allow(unused_mut)]
          14  +
        let mut object_3 = object.key("farewell").start_object();
          15  +
        crate::protocol_serde::shape_farewell::ser_farewell(&mut object_3, var_2)?;
          16  +
        object_3.finish();
          17  +
    }
          18  +
    Ok(())
          19  +
}
          20  +
          21  +
pub(crate) fn de_dialog<'a, I>(
          22  +
    tokens: &mut ::std::iter::Peekable<I>,
          23  +
) -> Result<Option<crate::model::Dialog>, ::aws_smithy_json::deserialize::error::DeserializeError>
          24  +
where
          25  +
    I: Iterator<
          26  +
        Item = Result<
          27  +
            ::aws_smithy_json::deserialize::Token<'a>,
          28  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          29  +
        >,
          30  +
    >,
          31  +
{
          32  +
    match tokens.next().transpose()? {
          33  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          34  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          35  +
            #[allow(unused_mut)]
          36  +
            let mut builder = crate::model::dialog_internal::Builder::default();
          37  +
            loop {
          38  +
                match tokens.next().transpose()? {
          39  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          40  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          41  +
                        match key.to_unescaped()?.as_ref() {
          42  +
                            "language" => {
          43  +
                                builder = builder.set_language(
          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  +
                                );
          50  +
                            }
          51  +
                            "greeting" => {
          52  +
                                if let Some(v) =
          53  +
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
          54  +
                                        tokens.next(),
          55  +
                                    )?
          56  +
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          57  +
                                    .transpose()?
          58  +
                                {
          59  +
                                    builder = builder.set_greeting(v);
          60  +
                                }
          61  +
                            }
          62  +
                            "farewell" => {
          63  +
                                builder = builder.set_farewell(
          64  +
                                    crate::protocol_serde::shape_farewell::de_farewell(tokens)?,
          65  +
                                );
          66  +
                            }
          67  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          68  +
                        }
          69  +
                    }
          70  +
                    other => {
          71  +
                        return Err(
          72  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          73  +
                                format!("expected object key or end object, found: {:?}", other),
          74  +
                            ),
          75  +
                        )
          76  +
                    }
          77  +
                }
          78  +
            }
          79  +
            Ok(Some(builder.build()))
          80  +
        }
          81  +
        _ => Err(
          82  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          83  +
                "expected start object or null",
          84  +
            ),
          85  +
        ),
          86  +
    }
          87  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_dialog_list.rs

@@ -0,1 +0,48 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_dialog_list<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> Result<
           5  +
    Option<::std::vec::Vec<crate::model::Dialog>>,
           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 = crate::protocol_serde::shape_dialog::de_dialog(tokens)?;
          28  +
                        if let Some(value) = value {
          29  +
                            items.push(value);
          30  +
                        } else {
          31  +
                            return Err(
          32  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          33  +
                                    "dense list cannot contain null values",
          34  +
                                ),
          35  +
                            );
          36  +
                        }
          37  +
                    }
          38  +
                }
          39  +
            }
          40  +
            Ok(Some(items))
          41  +
        }
          42  +
        _ => Err(
          43  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          44  +
                "expected start array or null",
          45  +
            ),
          46  +
        ),
          47  +
    }
          48  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_dialog_map.rs

@@ -0,1 +0,56 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_dialog_map<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> Result<
           5  +
    Option<::std::collections::HashMap<::std::string::String, crate::model::Dialog>>,
           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 = crate::protocol_serde::shape_dialog::de_dialog(tokens)?;
          26  +
                        match value {
          27  +
                            Some(value) => {
          28  +
                                map.insert(key, value);
          29  +
                            }
          30  +
                            None => {
          31  +
                                return Err(
          32  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          33  +
                                        "dense map cannot contain null values",
          34  +
                                    ),
          35  +
                                )
          36  +
                            }
          37  +
                        }
          38  +
                    }
          39  +
                    other => {
          40  +
                        return Err(
          41  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          42  +
                                format!("expected object key or end object, found: {:?}", other),
          43  +
                            ),
          44  +
                        )
          45  +
                    }
          46  +
                }
          47  +
            }
          48  +
            Ok(Some(map))
          49  +
        }
          50  +
        _ => Err(
          51  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          52  +
                "expected start object or null",
          53  +
            ),
          54  +
        ),
          55  +
    }
          56  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_farewell.rs

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

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

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