Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +65,95 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:516 */
    2      3   
pub(crate) fn de_greeting_struct<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::GreetingStruct>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* RustType.kt:516 */
   19     23   
            #[allow(unused_mut)]
          24  +
            /* JsonParserGenerator.kt:526 */
   20     25   
            let mut builder = crate::model::greeting_struct_internal::Builder::default();
          26  +
            /* JsonParserGenerator.kt:684 */
   21     27   
            loop {
          28  +
                /* JsonParserGenerator.kt:685 */
   22     29   
                match tokens.next().transpose()? {
          30  +
                    /* JsonParserGenerator.kt:686 */
   23     31   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   24     32   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          33  +
                        /* JsonParserGenerator.kt:260 */
   25     34   
                        match key.to_unescaped()?.as_ref() {
          35  +
                            /* JsonParserGenerator.kt:262 */
   26     36   
                            "hi" => {
          37  +
                                /* JsonParserGenerator.kt:272 */
   27     38   
                                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         -
                                );
          39  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                        /* JsonParserGenerator.kt:339 */)
          43  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                                /* JsonParserGenerator.kt:272 */);
          45  +
                                /* JsonParserGenerator.kt:262 */
   34     46   
                            }
   35         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          47  +
                            /* JsonParserGenerator.kt:290 */
          48  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   36     49   
                        }
          50  +
                        /* JsonParserGenerator.kt:686 */
   37     51   
                    }
          52  +
                    /* JsonParserGenerator.kt:695 */
   38     53   
                    other => {
   39     54   
                        return Err(
   40     55   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   41     56   
                                format!("expected object key or end object, found: {:?}", other),
   42     57   
                            ),
   43     58   
                        )
          59  +
                    } /* JsonParserGenerator.kt:685 */
   44     60   
                }
          61  +
                /* JsonParserGenerator.kt:684 */
   45     62   
            }
   46         -
            }
          63  +
            /* JsonParserGenerator.kt:540 */
   47     64   
            Ok(Some(builder.build()))
          65  +
            /* JsonParserGenerator.kt:713 */
   48     66   
        }
   49         -
        _ => Err(
          67  +
        /* JsonParserGenerator.kt:722 */
          68  +
        _ => {
          69  +
            /* JsonParserGenerator.kt:723 */
          70  +
            Err(
   50     71   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   51     72   
                    "expected start object or null",
   52     73   
                ),
   53         -
        ),
          74  +
            )
          75  +
            /* JsonParserGenerator.kt:722 */
          76  +
        } /* JsonParserGenerator.kt:712 */
   54     77   
    }
          78  +
    /* JsonParserGenerator.kt:516 */
   55     79   
}
   56     80   
          81  +
/* JsonSerializerGenerator.kt:358 */
   57     82   
pub fn ser_greeting_struct(
   58     83   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   59     84   
    input: &crate::model::GreetingStruct,
   60     85   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          86  +
    /* JsonSerializerGenerator.kt:382 */
   61     87   
    if let Some(var_1) = &input.hi {
          88  +
        /* JsonSerializerGenerator.kt:423 */
   62     89   
        object.key("hi").string(var_1.as_str());
          90  +
        /* JsonSerializerGenerator.kt:382 */
   63     91   
    }
          92  +
    /* JsonSerializerGenerator.kt:372 */
   64     93   
    Ok(())
          94  +
    /* JsonSerializerGenerator.kt:358 */
   65     95   
}

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

@@ -1,1 +208,295 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_greeting_with_errors_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::GreetingWithErrorsInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::greeting_with_errors_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/x-amz-json-1.0"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_greeting_with_errors_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::GreetingWithErrorsOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/x-amz-json-1.0",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   54     76   
        let payload =
   55         -
            crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output_output(&output)?
   56         -
        ;
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output_output(&output)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   57     80   
        let content_length = payload.len();
   58     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   59     82   
            builder,
   60     83   
            ::http::header::CONTENT_LENGTH,
   61     84   
            content_length,
   62     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   63     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   64     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   65     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   66     93   
}
   67     94   
          95  +
/* RustType.kt:516 */
   68     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   69     98   
pub fn ser_greeting_with_errors_http_error(
   70     99   
    error: &crate::error::GreetingWithErrorsError,
   71    100   
) -> std::result::Result<
   72    101   
    ::aws_smithy_http_server::response::Response,
   73    102   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   74    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   75    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   76    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   77    109   
            crate::error::GreetingWithErrorsError::InvalidGreeting(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   78    111   
                let payload =
   79    112   
                    crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting_error(
   80    113   
                        output,
   81    114   
                    )?;
         115  +
                /* RustType.kt:516 */
   82    116   
                #[allow(unused_mut)]
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   83    118   
                let mut builder = ::http::Response::builder();
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    120   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    121   
                    builder,
   86    122   
                    ::http::header::CONTENT_TYPE,
   87    123   
                    "application/x-amz-json-1.0",
   88    124   
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    126   
                let content_length = payload.len();
   90    127   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    128   
                    builder,
   92    129   
                    ::http::header::CONTENT_LENGTH,
   93    130   
                    content_length,
   94    131   
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    133   
                builder
   96    134   
                    .status(400)
   97    135   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   98    137   
            }
         138  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   99    139   
            crate::error::GreetingWithErrorsError::ComplexError(output) => {
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  100    141   
                let payload =
  101    142   
                    crate::protocol_serde::shape_complex_error::ser_complex_error_error(output)?;
         143  +
                /* RustType.kt:516 */
  102    144   
                #[allow(unused_mut)]
         145  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  103    146   
                let mut builder = ::http::Response::builder();
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  104    148   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  105    149   
                    builder,
  106    150   
                    ::http::header::CONTENT_TYPE,
  107    151   
                    "application/x-amz-json-1.0",
  108    152   
                );
         153  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  109    154   
                let content_length = payload.len();
  110    155   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  111    156   
                    builder,
  112    157   
                    ::http::header::CONTENT_LENGTH,
  113    158   
                    content_length,
  114    159   
                );
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  115    161   
                builder
  116    162   
                    .status(400)
  117    163   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         164  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  118    165   
            }
         166  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  119    167   
            crate::error::GreetingWithErrorsError::FooError(output) => {
         168  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  120    169   
                let payload = crate::protocol_serde::shape_foo_error::ser_foo_error_error(output)?;
         170  +
                /* RustType.kt:516 */
  121    171   
                #[allow(unused_mut)]
         172  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  122    173   
                let mut builder = ::http::Response::builder();
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  123    175   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  124    176   
                    builder,
  125    177   
                    ::http::header::CONTENT_TYPE,
  126    178   
                    "application/x-amz-json-1.0",
  127    179   
                );
         180  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  128    181   
                let content_length = payload.len();
  129    182   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    183   
                    builder,
  131    184   
                    ::http::header::CONTENT_LENGTH,
  132    185   
                    content_length,
  133    186   
                );
         187  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  134    188   
                builder
  135    189   
                    .status(500)
  136    190   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         191  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  137    192   
            }
         193  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  138    194   
            crate::error::GreetingWithErrorsError::InternalServerError(output) => {
         195  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  139    196   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         197  +
                /* RustType.kt:516 */
  140    198   
                #[allow(unused_mut)]
         199  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  141    200   
                let mut builder = ::http::Response::builder();
         201  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  142    202   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  143    203   
                    builder,
  144    204   
                    ::http::header::CONTENT_TYPE,
  145    205   
                    "application/x-amz-json-1.0",
  146    206   
                );
         207  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  147    208   
                let content_length = payload.len();
  148    209   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  149    210   
                    builder,
  150    211   
                    ::http::header::CONTENT_LENGTH,
  151    212   
                    content_length,
  152    213   
                );
         214  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  153    215   
                builder
  154    216   
                    .status(500)
  155    217   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         218  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         219  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  156    220   
        }
  157         -
        }
         221  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  158    222   
    })
         223  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  159    224   
}
  160    225   
         226  +
/* JsonParserGenerator.kt:148 */
  161    227   
pub(crate) fn de_greeting_with_errors(
  162    228   
    value: &[u8],
  163    229   
    mut builder: crate::input::greeting_with_errors_input_internal::Builder,
  164    230   
) -> ::std::result::Result<
  165    231   
    crate::input::greeting_with_errors_input_internal::Builder,
  166    232   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  167    233   
> {
         234  +
    /* JsonParserGenerator.kt:153 */
  168    235   
    let mut tokens_owned =
  169    236   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  170    237   
            .peekable();
  171    238   
    let tokens = &mut tokens_owned;
  172    239   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         240  +
    /* JsonParserGenerator.kt:684 */
  173    241   
    loop {
         242  +
        /* JsonParserGenerator.kt:685 */
  174    243   
        match tokens.next().transpose()? {
         244  +
            /* JsonParserGenerator.kt:686 */
  175    245   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  176    246   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         247  +
                /* JsonParserGenerator.kt:260 */
  177    248   
                match key.to_unescaped()?.as_ref() {
         249  +
                    /* JsonParserGenerator.kt:262 */
  178    250   
                    "greeting" => {
         251  +
                        /* JsonParserGenerator.kt:272 */
  179    252   
                        builder = builder.set_greeting(
         253  +
                            /* JsonParserGenerator.kt:354 */
  180    254   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  181    255   
                                tokens.next(),
  182    256   
                            )?
  183         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  184         -
                            .transpose()?,
         257  +
                            .map(|s|
         258  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         259  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         260  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         261  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  185    262   
                        );
         263  +
                        /* JsonParserGenerator.kt:262 */
  186    264   
                    }
  187         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         265  +
                    /* JsonParserGenerator.kt:290 */
         266  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  188    267   
                }
         268  +
                /* JsonParserGenerator.kt:686 */
  189    269   
            }
         270  +
            /* JsonParserGenerator.kt:695 */
  190    271   
            other => {
  191    272   
                return Err(
  192    273   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  193    274   
                        "expected object key or end object, found: {:?}",
  194    275   
                        other
  195    276   
                    )),
  196    277   
                )
         278  +
            } /* JsonParserGenerator.kt:685 */
  197    279   
        }
         280  +
        /* JsonParserGenerator.kt:684 */
  198    281   
    }
  199         -
    }
         282  +
    /* JsonParserGenerator.kt:250 */
  200    283   
    if tokens.next().is_some() {
         284  +
        /* JsonParserGenerator.kt:251 */
  201    285   
        return Err(
  202    286   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  203    287   
                "found more JSON tokens after completing parsing",
  204    288   
            ),
  205    289   
        );
         290  +
        /* JsonParserGenerator.kt:250 */
  206    291   
    }
         292  +
    /* JsonParserGenerator.kt:163 */
  207    293   
    Ok(builder)
         294  +
    /* JsonParserGenerator.kt:148 */
  208    295   
}

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

@@ -1,1 +20,31 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_greeting_with_errors_output_output_output(
    3      4   
    value: &crate::output::GreetingWithErrorsOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_greeting_with_errors_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::GreetingWithErrorsOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.greeting {
          24  +
        /* JsonSerializerGenerator.kt:423 */
   17     25   
        object.key("greeting").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:382 */
   18     27   
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
   19     29   
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
   20     31   
}

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

@@ -1,1 +85,124 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_host_with_path_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::HostWithPathOperationInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::host_with_path_operation_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   22     30   
        input.build()
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   23     32   
    })
          33  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   24     34   
}
   25     35   
          36  +
/* RustType.kt:516 */
   26     37   
#[allow(clippy::unnecessary_wraps)]
          38  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   27     39   
pub fn ser_host_with_path_operation_http_response(
   28     40   
    #[allow(unused_variables)] output: crate::output::HostWithPathOperationOutput,
   29     41   
) -> std::result::Result<
   30     42   
    ::aws_smithy_http_server::response::Response,
   31     43   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   32     44   
> {
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   33     46   
    Ok({
          47  +
        /* RustType.kt:516 */
   34     48   
        #[allow(unused_mut)]
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   35     50   
        let mut builder = ::http::Response::builder();
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   36     52   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   37     53   
            builder,
   38     54   
            ::http::header::CONTENT_TYPE,
   39     55   
            "application/x-amz-json-1.0",
   40     56   
        );
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   41     58   
        let http_status: u16 = 200;
   42     59   
        builder = builder.status(http_status);
   43         -
        let payload = "";
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          61  +
        let payload =
          62  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   44     65   
        let content_length = payload.len();
   45     66   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   46     67   
            builder,
   47     68   
            ::http::header::CONTENT_LENGTH,
   48     69   
            content_length,
   49     70   
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   50     72   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   51     74   
        builder.body(body)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   52     76   
    })
          77  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   53     78   
}
   54     79   
          80  +
/* RustType.kt:516 */
   55     81   
#[allow(clippy::unnecessary_wraps)]
          82  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   56     83   
pub fn ser_host_with_path_operation_http_error(
   57     84   
    error: &crate::error::HostWithPathOperationError,
   58     85   
) -> std::result::Result<
   59     86   
    ::aws_smithy_http_server::response::Response,
   60     87   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   61     88   
> {
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   62     90   
    Ok({
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   63     92   
        match error {
          93  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   64     94   
            crate::error::HostWithPathOperationError::InternalServerError(output) => {
          95  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   65     96   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
          97  +
                /* RustType.kt:516 */
   66     98   
                #[allow(unused_mut)]
          99  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   67    100   
                let mut builder = ::http::Response::builder();
         101  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   68    102   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   69    103   
                    builder,
   70    104   
                    ::http::header::CONTENT_TYPE,
   71    105   
                    "application/x-amz-json-1.0",
   72    106   
                );
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   73    108   
                let content_length = payload.len();
   74    109   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   75    110   
                    builder,
   76    111   
                    ::http::header::CONTENT_LENGTH,
   77    112   
                    content_length,
   78    113   
                );
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   79    115   
                builder
   80    116   
                    .status(500)
   81    117   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         118  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         119  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   82    120   
        }
   83         -
        }
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   84    122   
    })
         123  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
   85    124   
}

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

@@ -1,1 +26,38 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_internal_server_error_error(
    3      4   
    value: &crate::error::InternalServerError,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_internal_server_error::ser_internal_server_error(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* ServerAwsJson.kt:95 */
   11     15   
    object
   12     16   
        .key("__type")
   13     17   
        .string("aws.protocoltests.json10#InternalServerError");
          18  +
    /* JsonSerializerGenerator.kt:227 */
   14     19   
    object.finish();
   15     20   
    Ok(out)
          21  +
    /* JsonSerializerGenerator.kt:213 */
   16     22   
}
   17     23   
          24  +
/* JsonSerializerGenerator.kt:358 */
   18     25   
pub fn ser_internal_server_error(
   19     26   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   20     27   
    input: &crate::error::InternalServerError,
   21     28   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          29  +
    /* SerializerUtil.kt:42 */
   22     30   
    {
          31  +
        /* JsonSerializerGenerator.kt:423 */
   23     32   
        object.key("message").string(input.message.as_str());
          33  +
        /* SerializerUtil.kt:42 */
   24     34   
    }
          35  +
    /* JsonSerializerGenerator.kt:372 */
   25     36   
    Ok(())
          37  +
    /* JsonSerializerGenerator.kt:358 */
   26     38   
}

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

@@ -1,1 +23,35 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_invalid_greeting_error(
    3      4   
    value: &crate::error::InvalidGreeting,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting(&mut object, value)?;
          11  +
    /* ServerAwsJson.kt:95 */
    8     12   
    object
    9     13   
        .key("__type")
   10     14   
        .string("aws.protocoltests.json10#InvalidGreeting");
          15  +
    /* JsonSerializerGenerator.kt:227 */
   11     16   
    object.finish();
   12     17   
    Ok(out)
          18  +
    /* JsonSerializerGenerator.kt:213 */
   13     19   
}
   14     20   
          21  +
/* JsonSerializerGenerator.kt:358 */
   15     22   
pub fn ser_invalid_greeting(
   16     23   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     24   
    input: &crate::error::InvalidGreeting,
   18     25   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          26  +
    /* JsonSerializerGenerator.kt:382 */
   19     27   
    if let Some(var_1) = &input.message {
          28  +
        /* JsonSerializerGenerator.kt:423 */
   20     29   
        object.key("Message").string(var_1.as_str());
          30  +
        /* JsonSerializerGenerator.kt:382 */
   21     31   
    }
          32  +
    /* JsonSerializerGenerator.kt:372 */
   22     33   
    Ok(())
          34  +
    /* JsonSerializerGenerator.kt:358 */
   23     35   
}

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

@@ -1,1 +161,227 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_json_unions_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::JsonUnionsInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::json_unions_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/x-amz-json-1.0"),
   27     37   
            )?;
   28     38   
            input =
   29     39   
                crate::protocol_serde::shape_json_unions::de_json_unions(bytes.as_ref(), input)?;
          40  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   30     41   
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   31     43   
        input.build()?
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   32     45   
    })
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   33     47   
}
   34     48   
          49  +
/* RustType.kt:516 */
   35     50   
#[allow(clippy::unnecessary_wraps)]
          51  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   36     52   
pub fn ser_json_unions_http_response(
   37     53   
    #[allow(unused_variables)] output: crate::output::JsonUnionsOutput,
   38     54   
) -> std::result::Result<
   39     55   
    ::aws_smithy_http_server::response::Response,
   40     56   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   41     57   
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   42     59   
    Ok({
          60  +
        /* RustType.kt:516 */
   43     61   
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   44     63   
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   45     65   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   46     66   
            builder,
   47     67   
            ::http::header::CONTENT_TYPE,
   48     68   
            "application/x-amz-json-1.0",
   49     69   
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   50     71   
        let http_status: u16 = 200;
   51     72   
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   52     74   
        let payload =
   53         -
            crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output_output(
   54         -
                &output,
   55         -
            )?;
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output_output(&output)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   56     78   
        let content_length = payload.len();
   57     79   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   58     80   
            builder,
   59     81   
            ::http::header::CONTENT_LENGTH,
   60     82   
            content_length,
   61     83   
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   62     85   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   63     87   
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   64     89   
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   65     91   
}
   66     92   
          93  +
/* RustType.kt:516 */
   67     94   
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   68     96   
pub fn ser_json_unions_http_error(
   69     97   
    error: &crate::error::JsonUnionsError,
   70     98   
) -> std::result::Result<
   71     99   
    ::aws_smithy_http_server::response::Response,
   72    100   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   73    101   
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   74    103   
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   75    105   
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   76    107   
            crate::error::JsonUnionsError::ValidationException(output) => {
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   77    109   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                /* RustType.kt:516 */
   78    111   
                #[allow(unused_mut)]
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   79    113   
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   80    115   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   81    116   
                    builder,
   82    117   
                    ::http::header::CONTENT_TYPE,
   83    118   
                    "application/x-amz-json-1.0",
   84    119   
                );
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   85    121   
                let content_length = payload.len();
   86    122   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    123   
                    builder,
   88    124   
                    ::http::header::CONTENT_LENGTH,
   89    125   
                    content_length,
   90    126   
                );
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   91    128   
                builder
   92    129   
                    .status(400)
   93    130   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         131  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   94    132   
            }
         133  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   95    134   
            crate::error::JsonUnionsError::InternalServerError(output) => {
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   96    136   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         137  +
                /* RustType.kt:516 */
   97    138   
                #[allow(unused_mut)]
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   98    140   
                let mut builder = ::http::Response::builder();
         141  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   99    142   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  100    143   
                    builder,
  101    144   
                    ::http::header::CONTENT_TYPE,
  102    145   
                    "application/x-amz-json-1.0",
  103    146   
                );
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  104    148   
                let content_length = payload.len();
  105    149   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  106    150   
                    builder,
  107    151   
                    ::http::header::CONTENT_LENGTH,
  108    152   
                    content_length,
  109    153   
                );
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  110    155   
                builder
  111    156   
                    .status(500)
  112    157   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         159  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  113    160   
        }
  114         -
        }
         161  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  115    162   
    })
         163  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  116    164   
}
  117    165   
         166  +
/* JsonParserGenerator.kt:148 */
  118    167   
pub(crate) fn de_json_unions(
  119    168   
    value: &[u8],
  120    169   
    mut builder: crate::input::json_unions_input_internal::Builder,
  121    170   
) -> ::std::result::Result<
  122    171   
    crate::input::json_unions_input_internal::Builder,
  123    172   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  124    173   
> {
         174  +
    /* JsonParserGenerator.kt:153 */
  125    175   
    let mut tokens_owned =
  126    176   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  127    177   
            .peekable();
  128    178   
    let tokens = &mut tokens_owned;
  129    179   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         180  +
    /* JsonParserGenerator.kt:684 */
  130    181   
    loop {
         182  +
        /* JsonParserGenerator.kt:685 */
  131    183   
        match tokens.next().transpose()? {
         184  +
            /* JsonParserGenerator.kt:686 */
  132    185   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  133    186   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         187  +
                /* JsonParserGenerator.kt:260 */
  134    188   
                match key.to_unescaped()?.as_ref() {
         189  +
                    /* JsonParserGenerator.kt:262 */
  135    190   
                    "contents" => {
         191  +
                        /* JsonParserGenerator.kt:272 */
  136    192   
                        builder = builder.set_contents(
  137         -
                            crate::protocol_serde::shape_my_union::de_my_union(tokens)?,
  138         -
                        );
         193  +
                            /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_my_union::de_my_union(tokens)?
         194  +
                        /* JsonParserGenerator.kt:272 */);
         195  +
                        /* JsonParserGenerator.kt:262 */
  139    196   
                    }
  140         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         197  +
                    /* JsonParserGenerator.kt:290 */
         198  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  141    199   
                }
         200  +
                /* JsonParserGenerator.kt:686 */
  142    201   
            }
         202  +
            /* JsonParserGenerator.kt:695 */
  143    203   
            other => {
  144    204   
                return Err(
  145    205   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  146    206   
                        "expected object key or end object, found: {:?}",
  147    207   
                        other
  148    208   
                    )),
  149    209   
                )
         210  +
            } /* JsonParserGenerator.kt:685 */
  150    211   
        }
         212  +
        /* JsonParserGenerator.kt:684 */
  151    213   
    }
  152         -
    }
         214  +
    /* JsonParserGenerator.kt:250 */
  153    215   
    if tokens.next().is_some() {
         216  +
        /* JsonParserGenerator.kt:251 */
  154    217   
        return Err(
  155    218   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  156    219   
                "found more JSON tokens after completing parsing",
  157    220   
            ),
  158    221   
        );
         222  +
        /* JsonParserGenerator.kt:250 */
  159    223   
    }
         224  +
    /* JsonParserGenerator.kt:163 */
  160    225   
    Ok(builder)
         226  +
    /* JsonParserGenerator.kt:148 */
  161    227   
}

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

@@ -1,1 +26,40 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_json_unions_output_output_output(
    3      4   
    value: &crate::output::JsonUnionsOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_json_unions_output_output(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::output::JsonUnionsOutput,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.contents {
          27  +
        /* JsonSerializerGenerator.kt:495 */
   20     28   
        #[allow(unused_mut)]
          29  +
        /* JsonSerializerGenerator.kt:496 */
   21     30   
        let mut object_2 = object.key("contents").start_object();
          31  +
        /* JsonSerializerGenerator.kt:579 */
   22     32   
        crate::protocol_serde::shape_my_union::ser_my_union(&mut object_2, var_1)?;
          33  +
        /* JsonSerializerGenerator.kt:515 */
   23     34   
        object_2.finish();
          35  +
        /* JsonSerializerGenerator.kt:382 */
   24     36   
    }
          37  +
    /* JsonSerializerGenerator.kt:372 */
   25     38   
    Ok(())
          39  +
    /* JsonSerializerGenerator.kt:358 */
   26     40   
}

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

@@ -1,1 +214,361 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
    2      3   
pub(crate) fn de_my_union<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:565 */
   16     18   
    let mut variant = None;
          19  +
    /* JsonParserGenerator.kt:567 */
   17     20   
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:568 */
   18     22   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
   19         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
          23  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
   20     27   
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
   21     29   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   22     30   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:576 */
   23     32   
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
   24     33   
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
   25     34   
                        )) = tokens.peek()
   26     35   
                        {
   27     36   
                            let _ = tokens.next().expect("peek returned a token")?;
   28     37   
                            continue;
   29     38   
                        }
          39  +
                        /* JsonParserGenerator.kt:585 */
   30     40   
                        let key = key.to_unescaped()?;
   31     41   
                        if key == "__type" {
   32     42   
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   33     43   
                            continue;
   34     44   
                        }
   35     45   
                        if variant.is_some() {
   36     46   
                            return Err(
   37     47   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   38     48   
                                    "encountered mixed variants in union",
   39     49   
                                ),
   40     50   
                            );
   41     51   
                        }
          52  +
                        /* JsonParserGenerator.kt:598 */
   42     53   
                        variant = match key.as_ref() {
          54  +
                            /* JsonParserGenerator.kt:601 */
   43     55   
                            "stringValue" => {
          56  +
                                /* JsonParserGenerator.kt:611 */
   44     57   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::StringValue(
   45         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   46         -
                                        s.to_unescaped().map(|u|
   47         -
                                            u.into_owned()
   48         -
                                        )
   49         -
                                    ).transpose()?
   50         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'stringValue' cannot be null"))?
   51         -
                                ))
   52         -
                            }
          58  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          59  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          60  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          61  +
                                        /* JsonParserGenerator.kt:339 */)
          62  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          63  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'stringValue' cannot be null"))?
          64  +
                                /* JsonParserGenerator.kt:611 */))
          65  +
                                /* JsonParserGenerator.kt:601 */
          66  +
                            }
          67  +
                            /* JsonParserGenerator.kt:601 */
   53     68   
                            "booleanValue" => {
          69  +
                                /* JsonParserGenerator.kt:611 */
   54     70   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::BooleanValue(
   55         -
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
   56         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'booleanValue' cannot be null"))?
   57         -
                                ))
          71  +
                                    /* JsonParserGenerator.kt:298 */::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
          72  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'booleanValue' cannot be null"))?
          73  +
                                /* JsonParserGenerator.kt:611 */))
          74  +
                                /* JsonParserGenerator.kt:601 */
   58     75   
                            }
          76  +
                            /* JsonParserGenerator.kt:601 */
   59     77   
                            "numberValue" => {
          78  +
                                /* JsonParserGenerator.kt:611 */
   60     79   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::NumberValue(
   61         -
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          80  +
                                    /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
   62     81   
                                                        .map(i32::try_from)
   63     82   
                                                        .transpose()?
   64         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'numberValue' cannot be null"))?
   65         -
                                ))
          83  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'numberValue' cannot be null"))?
          84  +
                                /* JsonParserGenerator.kt:611 */))
          85  +
                                /* JsonParserGenerator.kt:601 */
   66     86   
                            }
          87  +
                            /* JsonParserGenerator.kt:601 */
   67     88   
                            "blobValue" => {
          89  +
                                /* JsonParserGenerator.kt:611 */
   68     90   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::BlobValue(
   69         -
                                    ::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
   70         -
                                    .map(::aws_smithy_http_server_python::types::Blob::from)
   71         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'blobValue' cannot be null"))?
   72         -
                                ))
          91  +
                                    /* JsonParserGenerator.kt:326 */::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
          92  +
                                    /* PythonServerProtocolLoader.kt:48 */.map(::aws_smithy_http_server_python::types::Blob::from)
          93  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'blobValue' cannot be null"))?
          94  +
                                /* JsonParserGenerator.kt:611 */))
          95  +
                                /* JsonParserGenerator.kt:601 */
   73     96   
                            }
          97  +
                            /* JsonParserGenerator.kt:601 */
   74     98   
                            "timestampValue" => {
          99  +
                                /* JsonParserGenerator.kt:611 */
   75    100   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::TimestampValue(
   76         -
                                    ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(tokens.next(), ::aws_smithy_types::date_time::Format::EpochSeconds)?
   77         -
                                    .map(::aws_smithy_http_server_python::types::DateTime::from)
   78         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timestampValue' cannot be null"))?
   79         -
                                ))
         101  +
                                    /* JsonParserGenerator.kt:384 */::aws_smithy_json::deserialize::token::expect_timestamp_or_null(tokens.next(), ::aws_smithy_types::date_time::Format::EpochSeconds)?
         102  +
                                    /* PythonServerProtocolLoader.kt:44 */.map(::aws_smithy_http_server_python::types::DateTime::from)
         103  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timestampValue' cannot be null"))?
         104  +
                                /* JsonParserGenerator.kt:611 */))
         105  +
                                /* JsonParserGenerator.kt:601 */
   80    106   
                            }
         107  +
                            /* JsonParserGenerator.kt:601 */
   81    108   
                            "enumValue" => {
         109  +
                                /* JsonParserGenerator.kt:611 */
   82    110   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::EnumValue(
   83         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   84         -
                                        s.to_unescaped().map(|u|
   85         -
                                            u.into_owned()
   86         -
                                        )
   87         -
                                    ).transpose()?
   88         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumValue' cannot be null"))?
   89         -
                                ))
   90         -
                            }
         111  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
         112  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         113  +
                                            /* JsonParserGenerator.kt:343 */u.into_owned()
         114  +
                                        /* JsonParserGenerator.kt:339 */)
         115  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
         116  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumValue' cannot be null"))?
         117  +
                                /* JsonParserGenerator.kt:611 */))
         118  +
                                /* JsonParserGenerator.kt:601 */
         119  +
                            }
         120  +
                            /* JsonParserGenerator.kt:601 */
   91    121   
                            "intEnumValue" => {
         122  +
                                /* JsonParserGenerator.kt:611 */
   92    123   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::IntEnumValue(
   93         -
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
         124  +
                                    /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
   94    125   
                                                        .map(i32::try_from)
   95    126   
                                                        .transpose()?
   96         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'intEnumValue' cannot be null"))?
   97         -
                                ))
         127  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'intEnumValue' cannot be null"))?
         128  +
                                /* JsonParserGenerator.kt:611 */))
         129  +
                                /* JsonParserGenerator.kt:601 */
   98    130   
                            }
         131  +
                            /* JsonParserGenerator.kt:601 */
   99    132   
                            "listValue" => {
         133  +
                                /* JsonParserGenerator.kt:611 */
  100    134   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::ListValue(
  101         -
                                    crate::protocol_serde::shape_string_list::de_string_list(tokens)?
  102         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'listValue' cannot be null"))?
  103         -
                                ))
         135  +
                                    /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_string_list::de_string_list(tokens)?
         136  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'listValue' cannot be null"))?
         137  +
                                /* JsonParserGenerator.kt:611 */))
         138  +
                                /* JsonParserGenerator.kt:601 */
  104    139   
                            }
         140  +
                            /* JsonParserGenerator.kt:601 */
  105    141   
                            "mapValue" => {
         142  +
                                /* JsonParserGenerator.kt:611 */
  106    143   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::MapValue(
  107         -
                                    crate::protocol_serde::shape_string_map::de_string_map(tokens)?
  108         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mapValue' cannot be null"))?
  109         -
                                ))
         144  +
                                    /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_string_map::de_string_map(tokens)?
         145  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mapValue' cannot be null"))?
         146  +
                                /* JsonParserGenerator.kt:611 */))
         147  +
                                /* JsonParserGenerator.kt:601 */
  110    148   
                            }
         149  +
                            /* JsonParserGenerator.kt:601 */
  111    150   
                            "structureValue" => {
         151  +
                                /* JsonParserGenerator.kt:611 */
  112    152   
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::StructureValue(
  113         -
                                    crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?
  114         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'structureValue' cannot be null"))?
  115         -
                                ))
         153  +
                                    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?
         154  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'structureValue' cannot be null"))?
         155  +
                                /* JsonParserGenerator.kt:611 */))
         156  +
                                /* JsonParserGenerator.kt:601 */
  116    157   
                            }
  117         -
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {}", variant)))
         158  +
                            /* JsonParserGenerator.kt:634 */
         159  +
                            variant => {
         160  +
                                return Err(
         161  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         162  +
                                        format!("unexpected union variant: {}", variant),
         163  +
                                    ),
         164  +
                                )
         165  +
                            } /* JsonParserGenerator.kt:598 */
  118    166   
                        };
         167  +
                        /* JsonParserGenerator.kt:686 */
  119    168   
                    }
         169  +
                    /* JsonParserGenerator.kt:695 */
  120    170   
                    other => {
  121    171   
                        return Err(
  122         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  123         -
                            "expected object key or end object, found: {:?}",
  124         -
                            other
  125         -
                        )),
         172  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         173  +
                                format!("expected object key or end object, found: {:?}", other),
         174  +
                            ),
  126    175   
                        )
         176  +
                    } /* JsonParserGenerator.kt:685 */
  127    177   
                }
         178  +
                /* JsonParserGenerator.kt:684 */
  128    179   
            }
  129         -
        },
         180  +
            /* JsonParserGenerator.kt:568 */
         181  +
        }
         182  +
        /* JsonParserGenerator.kt:642 */
  130    183   
        _ => {
  131    184   
            return Err(
  132    185   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  133    186   
                    "expected start object or null",
  134    187   
                ),
  135    188   
            )
         189  +
        } /* JsonParserGenerator.kt:567 */
  136    190   
    }
  137         -
    }
         191  +
    /* JsonParserGenerator.kt:649 */
  138    192   
    if variant.is_none() {
  139    193   
        return Err(
  140    194   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  141    195   
                "Union did not contain a valid variant.",
  142    196   
            ),
  143    197   
        );
  144    198   
    }
         199  +
    /* JsonParserGenerator.kt:657 */
  145    200   
    Ok(variant)
         201  +
    /* JsonParserGenerator.kt:551 */
  146    202   
}
  147    203   
         204  +
/* JsonSerializerGenerator.kt:547 */
  148    205   
pub fn ser_my_union(
  149    206   
    object_2: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
  150    207   
    input: &crate::model::MyUnion,
  151    208   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         209  +
    /* JsonSerializerGenerator.kt:556 */
  152    210   
    match input {
         211  +
        /* JsonSerializerGenerator.kt:564 */
  153    212   
        crate::model::MyUnion::StringValue(inner) => {
         213  +
            /* SerializerUtil.kt:42 */
         214  +
            {
         215  +
                /* JsonSerializerGenerator.kt:423 */
  154    216   
                object_2.key("stringValue").string(inner.as_str());
         217  +
                /* SerializerUtil.kt:42 */
         218  +
            }
         219  +
            /* JsonSerializerGenerator.kt:564 */
  155    220   
        }
         221  +
        /* JsonSerializerGenerator.kt:564 */
  156    222   
        crate::model::MyUnion::BooleanValue(inner) => {
         223  +
            /* SerializerUtil.kt:42 */
         224  +
            {
         225  +
                /* JsonSerializerGenerator.kt:424 */
  157    226   
                object_2.key("booleanValue").boolean(*inner);
         227  +
                /* SerializerUtil.kt:42 */
         228  +
            }
         229  +
            /* JsonSerializerGenerator.kt:564 */
  158    230   
        }
         231  +
        /* JsonSerializerGenerator.kt:564 */
  159    232   
        crate::model::MyUnion::NumberValue(inner) => {
         233  +
            /* SerializerUtil.kt:42 */
         234  +
            {
         235  +
                /* JsonSerializerGenerator.kt:432 */
  160    236   
                object_2.key("numberValue").number(
  161    237   
                    #[allow(clippy::useless_conversion)]
  162    238   
                    ::aws_smithy_types::Number::NegInt((*inner).into()),
  163    239   
                );
         240  +
                /* SerializerUtil.kt:42 */
         241  +
            }
         242  +
            /* JsonSerializerGenerator.kt:564 */
  164    243   
        }
         244  +
        /* JsonSerializerGenerator.kt:564 */
  165    245   
        crate::model::MyUnion::BlobValue(inner) => {
         246  +
            /* SerializerUtil.kt:42 */
         247  +
            {
         248  +
                /* JsonSerializerGenerator.kt:439 */
  166    249   
                object_2
  167    250   
                    .key("blobValue")
  168    251   
                    .string_unchecked(&::aws_smithy_types::base64::encode(inner));
         252  +
                /* SerializerUtil.kt:42 */
         253  +
            }
         254  +
            /* JsonSerializerGenerator.kt:564 */
  169    255   
        }
         256  +
        /* JsonSerializerGenerator.kt:564 */
  170    257   
        crate::model::MyUnion::TimestampValue(inner) => {
         258  +
            /* SerializerUtil.kt:42 */
         259  +
            {
         260  +
                /* JsonSerializerGenerator.kt:448 */
  171    261   
                object_2
  172    262   
                    .key("timestampValue")
  173    263   
                    .date_time(inner, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
         264  +
                /* SerializerUtil.kt:42 */
         265  +
            }
         266  +
            /* JsonSerializerGenerator.kt:564 */
  174    267   
        }
         268  +
        /* JsonSerializerGenerator.kt:564 */
  175    269   
        crate::model::MyUnion::EnumValue(inner) => {
         270  +
            /* SerializerUtil.kt:42 */
         271  +
            {
         272  +
                /* JsonSerializerGenerator.kt:423 */
  176    273   
                object_2.key("enumValue").string(inner.as_str());
         274  +
                /* SerializerUtil.kt:42 */
         275  +
            }
         276  +
            /* JsonSerializerGenerator.kt:564 */
  177    277   
        }
         278  +
        /* JsonSerializerGenerator.kt:564 */
  178    279   
        crate::model::MyUnion::IntEnumValue(inner) => {
         280  +
            /* SerializerUtil.kt:42 */
         281  +
            {
         282  +
                /* JsonSerializerGenerator.kt:432 */
  179    283   
                object_2.key("intEnumValue").number(
  180    284   
                    #[allow(clippy::useless_conversion)]
  181    285   
                    ::aws_smithy_types::Number::NegInt((*inner).into()),
  182    286   
                );
         287  +
                /* SerializerUtil.kt:42 */
         288  +
            }
         289  +
            /* JsonSerializerGenerator.kt:564 */
  183    290   
        }
         291  +
        /* JsonSerializerGenerator.kt:564 */
  184    292   
        crate::model::MyUnion::ListValue(inner) => {
         293  +
            /* SerializerUtil.kt:42 */
         294  +
            {
         295  +
                /* JsonSerializerGenerator.kt:484 */
  185    296   
                let mut array_1 = object_2.key("listValue").start_array();
         297  +
                /* JsonSerializerGenerator.kt:524 */
  186    298   
                for item_2 in inner {
         299  +
                    /* SerializerUtil.kt:42 */
  187    300   
                    {
         301  +
                        /* JsonSerializerGenerator.kt:423 */
  188    302   
                        array_1.value().string(item_2.as_str());
         303  +
                        /* SerializerUtil.kt:42 */
  189    304   
                    }
         305  +
                    /* JsonSerializerGenerator.kt:524 */
  190    306   
                }
         307  +
                /* JsonSerializerGenerator.kt:486 */
  191    308   
                array_1.finish();
         309  +
                /* SerializerUtil.kt:42 */
         310  +
            }
         311  +
            /* JsonSerializerGenerator.kt:564 */
  192    312   
        }
         313  +
        /* JsonSerializerGenerator.kt:564 */
  193    314   
        crate::model::MyUnion::MapValue(inner) => {
         315  +
            /* SerializerUtil.kt:42 */
         316  +
            {
         317  +
                /* JsonSerializerGenerator.kt:495 */
  194    318   
                #[allow(unused_mut)]
         319  +
                /* JsonSerializerGenerator.kt:496 */
  195    320   
                let mut object_3 = object_2.key("mapValue").start_object();
         321  +
                /* JsonSerializerGenerator.kt:537 */
  196    322   
                for (key_4, value_5) in inner {
         323  +
                    /* SerializerUtil.kt:42 */
  197    324   
                    {
         325  +
                        /* JsonSerializerGenerator.kt:423 */
  198    326   
                        object_3.key(key_4.as_str()).string(value_5.as_str());
         327  +
                        /* SerializerUtil.kt:42 */
  199    328   
                    }
         329  +
                    /* JsonSerializerGenerator.kt:537 */
  200    330   
                }
         331  +
                /* JsonSerializerGenerator.kt:515 */
  201    332   
                object_3.finish();
         333  +
                /* SerializerUtil.kt:42 */
         334  +
            }
         335  +
            /* JsonSerializerGenerator.kt:564 */
  202    336   
        }
         337  +
        /* JsonSerializerGenerator.kt:564 */
  203    338   
        crate::model::MyUnion::StructureValue(inner) => {
         339  +
            /* SerializerUtil.kt:42 */
         340  +
            {
         341  +
                /* JsonSerializerGenerator.kt:495 */
  204    342   
                #[allow(unused_mut)]
         343  +
                /* JsonSerializerGenerator.kt:496 */
  205    344   
                let mut object_6 = object_2.key("structureValue").start_object();
         345  +
                /* JsonSerializerGenerator.kt:375 */
  206    346   
                crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(
  207    347   
                    &mut object_6,
  208    348   
                    inner,
  209    349   
                )?;
         350  +
                /* JsonSerializerGenerator.kt:515 */
  210    351   
                object_6.finish();
         352  +
                /* SerializerUtil.kt:42 */
         353  +
            }
         354  +
            /* JsonSerializerGenerator.kt:564 */
  211    355   
        }
         356  +
        /* JsonSerializerGenerator.kt:556 */
  212    357   
    }
         358  +
    /* JsonSerializerGenerator.kt:576 */
  213    359   
    Ok(())
         360  +
    /* JsonSerializerGenerator.kt:547 */
  214    361   
}

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

@@ -1,1 +85,124 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_no_input_and_no_output_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NoInputAndNoOutputInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::no_input_and_no_output_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   22     30   
        input.build()
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   23     32   
    })
          33  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   24     34   
}
   25     35   
          36  +
/* RustType.kt:516 */
   26     37   
#[allow(clippy::unnecessary_wraps)]
          38  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   27     39   
pub fn ser_no_input_and_no_output_http_response(
   28     40   
    #[allow(unused_variables)] output: crate::output::NoInputAndNoOutputOutput,
   29     41   
) -> std::result::Result<
   30     42   
    ::aws_smithy_http_server::response::Response,
   31     43   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   32     44   
> {
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   33     46   
    Ok({
          47  +
        /* RustType.kt:516 */
   34     48   
        #[allow(unused_mut)]
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   35     50   
        let mut builder = ::http::Response::builder();
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   36     52   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   37     53   
            builder,
   38     54   
            ::http::header::CONTENT_TYPE,
   39     55   
            "application/x-amz-json-1.0",
   40     56   
        );
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   41     58   
        let http_status: u16 = 200;
   42     59   
        builder = builder.status(http_status);
   43         -
        let payload = "";
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          61  +
        let payload =
          62  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   44     65   
        let content_length = payload.len();
   45     66   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   46     67   
            builder,
   47     68   
            ::http::header::CONTENT_LENGTH,
   48     69   
            content_length,
   49     70   
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   50     72   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   51     74   
        builder.body(body)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   52     76   
    })
          77  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   53     78   
}
   54     79   
          80  +
/* RustType.kt:516 */
   55     81   
#[allow(clippy::unnecessary_wraps)]
          82  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   56     83   
pub fn ser_no_input_and_no_output_http_error(
   57     84   
    error: &crate::error::NoInputAndNoOutputError,
   58     85   
) -> std::result::Result<
   59     86   
    ::aws_smithy_http_server::response::Response,
   60     87   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   61     88   
> {
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   62     90   
    Ok({
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   63     92   
        match error {
          93  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   64     94   
            crate::error::NoInputAndNoOutputError::InternalServerError(output) => {
          95  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   65     96   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
          97  +
                /* RustType.kt:516 */
   66     98   
                #[allow(unused_mut)]
          99  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   67    100   
                let mut builder = ::http::Response::builder();
         101  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   68    102   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   69    103   
                    builder,
   70    104   
                    ::http::header::CONTENT_TYPE,
   71    105   
                    "application/x-amz-json-1.0",
   72    106   
                );
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   73    108   
                let content_length = payload.len();
   74    109   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   75    110   
                    builder,
   76    111   
                    ::http::header::CONTENT_LENGTH,
   77    112   
                    content_length,
   78    113   
                );
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   79    115   
                builder
   80    116   
                    .status(500)
   81    117   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         118  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         119  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   82    120   
        }
   83         -
        }
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   84    122   
    })
         123  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
   85    124   
}

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

@@ -1,1 +87,124 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_no_input_and_output_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NoInputAndOutputInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::no_input_and_output_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   22     30   
        input.build()
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   23     32   
    })
          33  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   24     34   
}
   25     35   
          36  +
/* RustType.kt:516 */
   26     37   
#[allow(clippy::unnecessary_wraps)]
          38  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   27     39   
pub fn ser_no_input_and_output_http_response(
   28     40   
    #[allow(unused_variables)] output: crate::output::NoInputAndOutputOutput,
   29     41   
) -> std::result::Result<
   30     42   
    ::aws_smithy_http_server::response::Response,
   31     43   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   32     44   
> {
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   33     46   
    Ok({
          47  +
        /* RustType.kt:516 */
   34     48   
        #[allow(unused_mut)]
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   35     50   
        let mut builder = ::http::Response::builder();
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   36     52   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   37     53   
            builder,
   38     54   
            ::http::header::CONTENT_TYPE,
   39     55   
            "application/x-amz-json-1.0",
   40     56   
        );
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   41     58   
        let http_status: u16 = 200;
   42     59   
        builder = builder.status(http_status);
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   43     61   
        let payload =
   44         -
            crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
   45         -
        ;
          62  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   46     65   
        let content_length = payload.len();
   47     66   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     67   
            builder,
   49     68   
            ::http::header::CONTENT_LENGTH,
   50     69   
            content_length,
   51     70   
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   52     72   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   53     74   
        builder.body(body)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   54     76   
    })
          77  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   55     78   
}
   56     79   
          80  +
/* RustType.kt:516 */
   57     81   
#[allow(clippy::unnecessary_wraps)]
          82  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   58     83   
pub fn ser_no_input_and_output_http_error(
   59     84   
    error: &crate::error::NoInputAndOutputError,
   60     85   
) -> std::result::Result<
   61     86   
    ::aws_smithy_http_server::response::Response,
   62     87   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   63     88   
> {
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   64     90   
    Ok({
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   65     92   
        match error {
          93  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   66     94   
            crate::error::NoInputAndOutputError::InternalServerError(output) => {
          95  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   67     96   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
          97  +
                /* RustType.kt:516 */
   68     98   
                #[allow(unused_mut)]
          99  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   69    100   
                let mut builder = ::http::Response::builder();
         101  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   70    102   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   71    103   
                    builder,
   72    104   
                    ::http::header::CONTENT_TYPE,
   73    105   
                    "application/x-amz-json-1.0",
   74    106   
                );
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   75    108   
                let content_length = payload.len();
   76    109   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    110   
                    builder,
   78    111   
                    ::http::header::CONTENT_LENGTH,
   79    112   
                    content_length,
   80    113   
                );
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   81    115   
                builder
   82    116   
                    .status(500)
   83    117   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         118  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         119  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   84    120   
        }
   85         -
        }
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   86    122   
    })
         123  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
   87    124   
}

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

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

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

@@ -1,1 +190,273 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_operation_with_defaults_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OperationWithDefaultsInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::operation_with_defaults_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/x-amz-json-1.0"),
   27     37   
            )?;
   28     38   
            input =
   29     39   
                crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults(
   30     40   
                    bytes.as_ref(),
   31     41   
                    input,
   32     42   
                )?;
          43  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   33     44   
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   34     46   
        input.build()?
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   35     48   
    })
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   36     50   
}
   37     51   
          52  +
/* RustType.kt:516 */
   38     53   
#[allow(clippy::unnecessary_wraps)]
          54  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   39     55   
pub fn ser_operation_with_defaults_http_response(
   40     56   
    #[allow(unused_variables)] output: crate::output::OperationWithDefaultsOutput,
   41     57   
) -> std::result::Result<
   42     58   
    ::aws_smithy_http_server::response::Response,
   43     59   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   44     60   
> {
          61  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   45     62   
    Ok({
          63  +
        /* RustType.kt:516 */
   46     64   
        #[allow(unused_mut)]
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   47     66   
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   48     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     69   
            builder,
   50     70   
            ::http::header::CONTENT_TYPE,
   51     71   
            "application/x-amz-json-1.0",
   52     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   53     74   
        let http_status: u16 = 200;
   54     75   
        builder = builder.status(http_status);
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   55     77   
        let payload =
   56         -
            crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output_output(&output)?
   57         -
        ;
          78  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output_output(&output)?
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   58     81   
        let content_length = payload.len();
   59     82   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   60     83   
            builder,
   61     84   
            ::http::header::CONTENT_LENGTH,
   62     85   
            content_length,
   63     86   
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   64     88   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   65     90   
        builder.body(body)?
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   66     92   
    })
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   67     94   
}
   68     95   
          96  +
/* RustType.kt:516 */
   69     97   
#[allow(clippy::unnecessary_wraps)]
          98  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   70     99   
pub fn ser_operation_with_defaults_http_error(
   71    100   
    error: &crate::error::OperationWithDefaultsError,
   72    101   
) -> std::result::Result<
   73    102   
    ::aws_smithy_http_server::response::Response,
   74    103   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   75    104   
> {
         105  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   76    106   
    Ok({
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   77    108   
        match error {
         109  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   78    110   
            crate::error::OperationWithDefaultsError::ValidationException(output) => {
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   79    112   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         113  +
                /* RustType.kt:516 */
   80    114   
                #[allow(unused_mut)]
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   81    116   
                let mut builder = ::http::Response::builder();
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   82    118   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    119   
                    builder,
   84    120   
                    ::http::header::CONTENT_TYPE,
   85    121   
                    "application/x-amz-json-1.0",
   86    122   
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   87    124   
                let content_length = payload.len();
   88    125   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   89    126   
                    builder,
   90    127   
                    ::http::header::CONTENT_LENGTH,
   91    128   
                    content_length,
   92    129   
                );
         130  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   93    131   
                builder
   94    132   
                    .status(400)
   95    133   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   96    135   
            }
         136  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   97    137   
            crate::error::OperationWithDefaultsError::InternalServerError(output) => {
         138  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   98    139   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         140  +
                /* RustType.kt:516 */
   99    141   
                #[allow(unused_mut)]
         142  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  100    143   
                let mut builder = ::http::Response::builder();
         144  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  101    145   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  102    146   
                    builder,
  103    147   
                    ::http::header::CONTENT_TYPE,
  104    148   
                    "application/x-amz-json-1.0",
  105    149   
                );
         150  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  106    151   
                let content_length = payload.len();
  107    152   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  108    153   
                    builder,
  109    154   
                    ::http::header::CONTENT_LENGTH,
  110    155   
                    content_length,
  111    156   
                );
         157  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  112    158   
                builder
  113    159   
                    .status(500)
  114    160   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         162  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  115    163   
        }
  116         -
        }
         164  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  117    165   
    })
         166  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  118    167   
}
  119    168   
         169  +
/* JsonParserGenerator.kt:148 */
  120    170   
pub(crate) fn de_operation_with_defaults(
  121    171   
    value: &[u8],
  122    172   
    mut builder: crate::input::operation_with_defaults_input_internal::Builder,
  123    173   
) -> ::std::result::Result<
  124    174   
    crate::input::operation_with_defaults_input_internal::Builder,
  125    175   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  126    176   
> {
         177  +
    /* JsonParserGenerator.kt:153 */
  127    178   
    let mut tokens_owned =
  128    179   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  129    180   
            .peekable();
  130    181   
    let tokens = &mut tokens_owned;
  131    182   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         183  +
    /* JsonParserGenerator.kt:684 */
  132    184   
    loop {
         185  +
        /* JsonParserGenerator.kt:685 */
  133    186   
        match tokens.next().transpose()? {
         187  +
            /* JsonParserGenerator.kt:686 */
  134    188   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  135    189   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         190  +
                /* JsonParserGenerator.kt:260 */
  136    191   
                match key.to_unescaped()?.as_ref() {
         192  +
                    /* JsonParserGenerator.kt:262 */
  137    193   
                    "defaults" => {
         194  +
                        /* JsonParserGenerator.kt:272 */
  138    195   
                        builder = builder.set_defaults(
  139         -
                            crate::protocol_serde::shape_defaults::de_defaults(tokens)?,
  140         -
                        );
         196  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_defaults::de_defaults(tokens)?
         197  +
                        /* JsonParserGenerator.kt:272 */);
         198  +
                        /* JsonParserGenerator.kt:262 */
  141    199   
                    }
         200  +
                    /* JsonParserGenerator.kt:262 */
  142    201   
                    "clientOptionalDefaults" => {
         202  +
                        /* JsonParserGenerator.kt:272 */
  143    203   
                        builder = builder.set_client_optional_defaults(
  144         -
                            crate::protocol_serde::shape_client_optional_defaults::de_client_optional_defaults(tokens)?
  145         -
                        );
         204  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_client_optional_defaults::de_client_optional_defaults(tokens)?
         205  +
                        /* JsonParserGenerator.kt:272 */);
         206  +
                        /* JsonParserGenerator.kt:262 */
  146    207   
                    }
         208  +
                    /* JsonParserGenerator.kt:262 */
  147    209   
                    "topLevelDefault" => {
         210  +
                        /* JsonParserGenerator.kt:276 */
  148    211   
                        if let Some(v) =
         212  +
                            /* JsonParserGenerator.kt:354 */
  149    213   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  150    214   
                                    tokens.next(),
  151    215   
                                )?
  152         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
         216  +
                                .map(|s|
         217  +
                            /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         218  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
         219  +
                            /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
  153    220   
                                .transpose()?
         221  +
                        /* JsonParserGenerator.kt:278 */
  154    222   
                        {
  155    223   
                            builder = builder.set_top_level_default(v);
  156    224   
                        }
         225  +
                        /* JsonParserGenerator.kt:262 */
  157    226   
                    }
         227  +
                    /* JsonParserGenerator.kt:262 */
  158    228   
                    "otherTopLevelDefault" => {
         229  +
                        /* JsonParserGenerator.kt:276 */
  159    230   
                        if let Some(v) =
         231  +
                            /* JsonParserGenerator.kt:365 */
  160    232   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  161    233   
                                    tokens.next(),
  162    234   
                                )?
  163    235   
                                .map(i32::try_from)
  164    236   
                                .transpose()?
         237  +
                        /* JsonParserGenerator.kt:278 */
  165    238   
                        {
  166    239   
                            builder = builder.set_other_top_level_default(v);
  167    240   
                        }
         241  +
                        /* JsonParserGenerator.kt:262 */
  168    242   
                    }
  169         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         243  +
                    /* JsonParserGenerator.kt:290 */
         244  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  170    245   
                }
         246  +
                /* JsonParserGenerator.kt:686 */
  171    247   
            }
         248  +
            /* JsonParserGenerator.kt:695 */
  172    249   
            other => {
  173    250   
                return Err(
  174    251   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  175    252   
                        "expected object key or end object, found: {:?}",
  176    253   
                        other
  177    254   
                    )),
  178    255   
                )
         256  +
            } /* JsonParserGenerator.kt:685 */
  179    257   
        }
         258  +
        /* JsonParserGenerator.kt:684 */
  180    259   
    }
  181         -
    }
         260  +
    /* JsonParserGenerator.kt:250 */
  182    261   
    if tokens.next().is_some() {
         262  +
        /* JsonParserGenerator.kt:251 */
  183    263   
        return Err(
  184    264   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  185    265   
                "found more JSON tokens after completing parsing",
  186    266   
            ),
  187    267   
        );
         268  +
        /* JsonParserGenerator.kt:250 */
  188    269   
    }
         270  +
    /* JsonParserGenerator.kt:163 */
  189    271   
    Ok(builder)
         272  +
    /* JsonParserGenerator.kt:148 */
  190    273   
}

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

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

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

@@ -1,1 +162,231 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_operation_with_nested_structure_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OperationWithNestedStructureInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input =
   18     23   
            crate::input::operation_with_nested_structure_input_internal::Builder::default();
          24  +
        /* RustType.kt:516 */
   19     25   
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   20     27   
        let ::aws_smithy_runtime_api::http::RequestParts {
   21     28   
            uri, headers, body, ..
   22     29   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   23     31   
        let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   24     33   
        if !bytes.is_empty() {
          34  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   25     35   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   26     36   
                &headers,
   27     37   
                Some("application/x-amz-json-1.0"),
   28     38   
            )?;
   29     39   
            input = crate::protocol_serde::shape_operation_with_nested_structure::de_operation_with_nested_structure(bytes.as_ref(), input)?;
          40  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   30     41   
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   31     43   
        input.build()?
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   32     45   
    })
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   33     47   
}
   34     48   
          49  +
/* RustType.kt:516 */
   35     50   
#[allow(clippy::unnecessary_wraps)]
          51  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   36     52   
pub fn ser_operation_with_nested_structure_http_response(
   37     53   
    #[allow(unused_variables)] output: crate::output::OperationWithNestedStructureOutput,
   38     54   
) -> std::result::Result<
   39     55   
    ::aws_smithy_http_server::response::Response,
   40     56   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   41     57   
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   42     59   
    Ok({
          60  +
        /* RustType.kt:516 */
   43     61   
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   44     63   
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   45     65   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   46     66   
            builder,
   47     67   
            ::http::header::CONTENT_TYPE,
   48     68   
            "application/x-amz-json-1.0",
   49     69   
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   50     71   
        let http_status: u16 = 200;
   51     72   
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   52     74   
        let payload =
   53         -
            crate::protocol_serde::shape_operation_with_nested_structure_output::ser_operation_with_nested_structure_output_output_output(&output)?
   54         -
        ;
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_operation_with_nested_structure_output::ser_operation_with_nested_structure_output_output_output(&output)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     78   
        let content_length = payload.len();
   56     79   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     80   
            builder,
   58     81   
            ::http::header::CONTENT_LENGTH,
   59     82   
            content_length,
   60     83   
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     85   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     87   
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     89   
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     91   
}
   65     92   
          93  +
/* RustType.kt:516 */
   66     94   
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     96   
pub fn ser_operation_with_nested_structure_http_error(
   68     97   
    error: &crate::error::OperationWithNestedStructureError,
   69     98   
) -> std::result::Result<
   70     99   
    ::aws_smithy_http_server::response::Response,
   71    100   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   72    101   
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    103   
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    105   
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    107   
            crate::error::OperationWithNestedStructureError::ValidationException(output) => {
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    109   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                /* RustType.kt:516 */
   77    111   
                #[allow(unused_mut)]
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    113   
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    115   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    116   
                    builder,
   81    117   
                    ::http::header::CONTENT_TYPE,
   82    118   
                    "application/x-amz-json-1.0",
   83    119   
                );
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   84    121   
                let content_length = payload.len();
   85    122   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   86    123   
                    builder,
   87    124   
                    ::http::header::CONTENT_LENGTH,
   88    125   
                    content_length,
   89    126   
                );
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   90    128   
                builder
   91    129   
                    .status(400)
   92    130   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         131  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   93    132   
            }
         133  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   94    134   
            crate::error::OperationWithNestedStructureError::InternalServerError(output) => {
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   95    136   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         137  +
                /* RustType.kt:516 */
   96    138   
                #[allow(unused_mut)]
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   97    140   
                let mut builder = ::http::Response::builder();
         141  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   98    142   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   99    143   
                    builder,
  100    144   
                    ::http::header::CONTENT_TYPE,
  101    145   
                    "application/x-amz-json-1.0",
  102    146   
                );
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  103    148   
                let content_length = payload.len();
  104    149   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  105    150   
                    builder,
  106    151   
                    ::http::header::CONTENT_LENGTH,
  107    152   
                    content_length,
  108    153   
                );
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  109    155   
                builder
  110    156   
                    .status(500)
  111    157   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         159  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  112    160   
        }
  113         -
        }
         161  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  114    162   
    })
         163  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  115    164   
}
  116    165   
         166  +
/* JsonParserGenerator.kt:148 */
  117    167   
pub(crate) fn de_operation_with_nested_structure(
  118    168   
    value: &[u8],
  119    169   
    mut builder: crate::input::operation_with_nested_structure_input_internal::Builder,
  120    170   
) -> ::std::result::Result<
  121    171   
    crate::input::operation_with_nested_structure_input_internal::Builder,
  122    172   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  123    173   
> {
         174  +
    /* JsonParserGenerator.kt:153 */
  124    175   
    let mut tokens_owned =
  125    176   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  126    177   
            .peekable();
  127    178   
    let tokens = &mut tokens_owned;
  128    179   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         180  +
    /* JsonParserGenerator.kt:684 */
  129    181   
    loop {
         182  +
        /* JsonParserGenerator.kt:685 */
  130    183   
        match tokens.next().transpose()? {
         184  +
            /* JsonParserGenerator.kt:686 */
  131    185   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  132    186   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         187  +
                /* JsonParserGenerator.kt:260 */
  133    188   
                match key.to_unescaped()?.as_ref() {
         189  +
                    /* JsonParserGenerator.kt:262 */
  134    190   
                    "topLevel" => {
         191  +
                        /* JsonParserGenerator.kt:276 */
  135    192   
                        if let Some(v) =
         193  +
                            /* JsonParserGenerator.kt:544 */
  136    194   
                            crate::protocol_serde::shape_top_level::de_top_level(tokens)?
         195  +
                        /* JsonParserGenerator.kt:278 */
  137    196   
                        {
  138    197   
                            builder = builder.set_top_level(v);
  139    198   
                        }
         199  +
                        /* JsonParserGenerator.kt:262 */
  140    200   
                    }
  141         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         201  +
                    /* JsonParserGenerator.kt:290 */
         202  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  142    203   
                }
         204  +
                /* JsonParserGenerator.kt:686 */
  143    205   
            }
         206  +
            /* JsonParserGenerator.kt:695 */
  144    207   
            other => {
  145    208   
                return Err(
  146    209   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  147    210   
                        "expected object key or end object, found: {:?}",
  148    211   
                        other
  149    212   
                    )),
  150    213   
                )
         214  +
            } /* JsonParserGenerator.kt:685 */
  151    215   
        }
         216  +
        /* JsonParserGenerator.kt:684 */
  152    217   
    }
  153         -
    }
         218  +
    /* JsonParserGenerator.kt:250 */
  154    219   
    if tokens.next().is_some() {
         220  +
        /* JsonParserGenerator.kt:251 */
  155    221   
        return Err(
  156    222   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  157    223   
                "found more JSON tokens after completing parsing",
  158    224   
            ),
  159    225   
        );
         226  +
        /* JsonParserGenerator.kt:250 */
  160    227   
    }
         228  +
    /* JsonParserGenerator.kt:163 */
  161    229   
    Ok(builder)
         230  +
    /* JsonParserGenerator.kt:148 */
  162    231   
}

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

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