Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943

Files changed:

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

@@ -1,1 +53,76 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_complex_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::complex_set_unconstrained::ComplexSetUnconstrained>,
    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::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
   27     38   
                        let value =
   28         -
                            crate::protocol_serde::shape_complex_set_struct::de_complex_set_struct(
   29         -
                                tokens,
   30         -
                            )?;
          39  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_complex_set_struct::de_complex_set_struct(tokens)?
          40  +
                        /* JsonParserGenerator.kt:419 */;
          41  +
                        /* JsonParserGenerator.kt:422 */
   31     42   
                        if let Some(value) = value {
   32     43   
                            items.push(value);
   33         -
                        } else {
          44  +
                        }
          45  +
                        /* JsonParserGenerator.kt:430 */
          46  +
                        else {
   34     47   
                            return Err(
   35     48   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   36     49   
                                    "dense list cannot contain null values",
   37     50   
                                ),
   38     51   
                            );
   39     52   
                        }
   40         -
                    }
          53  +
                        /* JsonParserGenerator.kt:413 */
          54  +
                    } /* JsonParserGenerator.kt:409 */
   41     55   
                }
          56  +
                /* JsonParserGenerator.kt:408 */
   42     57   
            }
          58  +
            /* JsonParserGenerator.kt:444 */
   43     59   
            Ok(Some(
   44     60   
                crate::unconstrained::complex_set_unconstrained::ComplexSetUnconstrained(items),
   45     61   
            ))
          62  +
            /* JsonParserGenerator.kt:713 */
   46     63   
        }
   47         -
        _ => Err(
   48         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   49         -
                "expected start array or null",
   50         -
            ),
   51         -
        ),
          64  +
        /* JsonParserGenerator.kt:722 */
          65  +
        _ => {
          66  +
            /* JsonParserGenerator.kt:723 */
          67  +
            Err(
          68  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          69  +
                    "expected start array or null",
          70  +
                ),
          71  +
            )
          72  +
            /* JsonParserGenerator.kt:722 */
          73  +
        } /* JsonParserGenerator.kt:712 */
   52     74   
    }
          75  +
    /* JsonParserGenerator.kt:398 */
   53     76   
}

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

@@ -1,1 +61,87 @@
    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_complex_set_struct<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::ComplexSetStruct>,
    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::complex_set_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   
                            "foo" => {
          37  +
                                /* JsonParserGenerator.kt:272 */
   27     38   
                                builder = builder.set_foo(
          39  +
                                    /* JsonParserGenerator.kt:298 */
   28     40   
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(
   29     41   
                                        tokens.next(),
   30         -
                                    )?,
          42  +
                                    )?, /* JsonParserGenerator.kt:272 */
   31     43   
                                );
          44  +
                                /* JsonParserGenerator.kt:262 */
   32     45   
                            }
          46  +
                            /* JsonParserGenerator.kt:262 */
   33     47   
                            "blob" => {
          48  +
                                /* JsonParserGenerator.kt:272 */
   34     49   
                                builder = builder.set_blob(
   35         -
                                    ::aws_smithy_json::deserialize::token::expect_blob_or_null(
   36         -
                                        tokens.next(),
   37         -
                                    )?
   38         -
                                    .map(::aws_smithy_http_server_python::types::Blob::from),
   39         -
                                );
          50  +
                                    /* JsonParserGenerator.kt:326 */::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
          51  +
                                    /* PythonServerProtocolLoader.kt:48 */.map(::aws_smithy_http_server_python::types::Blob::from)
          52  +
                                /* JsonParserGenerator.kt:272 */);
          53  +
                                /* JsonParserGenerator.kt:262 */
   40     54   
                            }
   41         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          55  +
                            /* JsonParserGenerator.kt:290 */
          56  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   42     57   
                        }
          58  +
                        /* JsonParserGenerator.kt:686 */
   43     59   
                    }
          60  +
                    /* JsonParserGenerator.kt:695 */
   44     61   
                    other => {
   45     62   
                        return Err(
   46     63   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   47     64   
                                format!("expected object key or end object, found: {:?}", other),
   48     65   
                            ),
   49     66   
                        )
   50         -
                    }
          67  +
                    } /* JsonParserGenerator.kt:685 */
   51     68   
                }
          69  +
                /* JsonParserGenerator.kt:684 */
   52     70   
            }
          71  +
            /* JsonParserGenerator.kt:540 */
   53     72   
            Ok(Some(builder.build()))
          73  +
            /* JsonParserGenerator.kt:713 */
   54     74   
        }
   55         -
        _ => Err(
   56         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   57         -
                "expected start object or null",
   58         -
            ),
   59         -
        ),
          75  +
        /* JsonParserGenerator.kt:722 */
          76  +
        _ => {
          77  +
            /* JsonParserGenerator.kt:723 */
          78  +
            Err(
          79  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          80  +
                    "expected start object or null",
          81  +
                ),
          82  +
            )
          83  +
            /* JsonParserGenerator.kt:722 */
          84  +
        } /* JsonParserGenerator.kt:712 */
   60     85   
    }
          86  +
    /* JsonParserGenerator.kt:516 */
   61     87   
}

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

@@ -1,1 +23,34 @@
    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  +
    /* 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_internal_server_error(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::error::InternalServerError,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* SerializerUtil.kt:42 */
   19     26   
    {
          27  +
        /* JsonSerializerGenerator.kt:423 */
   20     28   
        object.key("message").string(input.message.as_str());
          29  +
        /* SerializerUtil.kt:42 */
   21     30   
    }
          31  +
    /* JsonSerializerGenerator.kt:372 */
   22     32   
    Ok(())
          33  +
    /* JsonSerializerGenerator.kt:358 */
   23     34   
}

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

@@ -1,1 +175,249 @@
    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_malformed_unique_items_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedUniqueItemsInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::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::rest_json_1::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::malformed_unique_items_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/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items(
   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_malformed_unique_items_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedUniqueItemsOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::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/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* RustType.kt:516 */
   66     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     98   
pub fn ser_malformed_unique_items_http_error(
   68     99   
    error: &crate::error::MalformedUniqueItemsError,
   69    100   
) -> std::result::Result<
   70    101   
    ::aws_smithy_http_server::response::Response,
   71    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    109   
            crate::error::MalformedUniqueItemsError::ValidationException(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    111   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         112  +
                /* RustType.kt:516 */
   77    113   
                #[allow(unused_mut)]
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    115   
                let mut builder = ::http::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    118   
                    builder,
   81    119   
                    ::http::header::CONTENT_TYPE,
   82    120   
                    "application/json",
   83    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    124   
                    builder,
   86    125   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    126   
                    "ValidationException",
   88    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    129   
                let content_length = payload.len();
   90    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    131   
                    builder,
   92    132   
                    ::http::header::CONTENT_LENGTH,
   93    133   
                    content_length,
   94    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    136   
                builder
   96    137   
                    .status(400)
   97    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   98    140   
            }
         141  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   99    142   
            crate::error::MalformedUniqueItemsError::InternalServerError(output) => {
         143  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  100    144   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         145  +
                /* RustType.kt:516 */
  101    146   
                #[allow(unused_mut)]
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  102    148   
                let mut builder = ::http::Response::builder();
         149  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  103    150   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  104    151   
                    builder,
  105    152   
                    ::http::header::CONTENT_TYPE,
  106    153   
                    "application/json",
  107    154   
                );
         155  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  108    156   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  109    157   
                    builder,
  110    158   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  111    159   
                    "InternalServerError",
  112    160   
                );
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  113    162   
                let content_length = payload.len();
  114    163   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  115    164   
                    builder,
  116    165   
                    ::http::header::CONTENT_LENGTH,
  117    166   
                    content_length,
  118    167   
                );
         168  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  119    169   
                builder
  120    170   
                    .status(500)
  121    171   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  122         -
            }
         172  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         173  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  123    174   
        }
         175  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  124    176   
    })
         177  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  125    178   
}
  126    179   
         180  +
/* JsonParserGenerator.kt:148 */
  127    181   
pub(crate) fn de_malformed_unique_items(
  128    182   
    value: &[u8],
  129    183   
    mut builder: crate::input::malformed_unique_items_input_internal::Builder,
  130    184   
) -> ::std::result::Result<
  131    185   
    crate::input::malformed_unique_items_input_internal::Builder,
  132    186   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  133    187   
> {
         188  +
    /* JsonParserGenerator.kt:153 */
  134    189   
    let mut tokens_owned =
  135    190   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  136    191   
            .peekable();
  137    192   
    let tokens = &mut tokens_owned;
  138    193   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         194  +
    /* JsonParserGenerator.kt:684 */
  139    195   
    loop {
         196  +
        /* JsonParserGenerator.kt:685 */
  140    197   
        match tokens.next().transpose()? {
         198  +
            /* JsonParserGenerator.kt:686 */
  141    199   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  142    200   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         201  +
                /* JsonParserGenerator.kt:260 */
  143    202   
                match key.to_unescaped()?.as_ref() {
         203  +
                    /* JsonParserGenerator.kt:262 */
  144    204   
                    "complexSet" => {
         205  +
                        /* JsonParserGenerator.kt:272 */
  145    206   
                        builder = builder.set_complex_set(
  146         -
                            crate::protocol_serde::shape_complex_set::de_complex_set(tokens)?,
  147         -
                        );
         207  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_complex_set::de_complex_set(tokens)?
         208  +
                        /* JsonParserGenerator.kt:272 */);
         209  +
                        /* JsonParserGenerator.kt:262 */
  148    210   
                    }
         211  +
                    /* JsonParserGenerator.kt:262 */
  149    212   
                    "set" => {
         213  +
                        /* JsonParserGenerator.kt:272 */
  150    214   
                        builder = builder.set_set(
  151         -
                            crate::protocol_serde::shape_simple_set::de_simple_set(tokens)?,
  152         -
                        );
         215  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_simple_set::de_simple_set(tokens)?
         216  +
                        /* JsonParserGenerator.kt:272 */);
         217  +
                        /* JsonParserGenerator.kt:262 */
  153    218   
                    }
  154         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         219  +
                    /* JsonParserGenerator.kt:290 */
         220  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  155    221   
                }
         222  +
                /* JsonParserGenerator.kt:686 */
  156    223   
            }
         224  +
            /* JsonParserGenerator.kt:695 */
  157    225   
            other => {
  158    226   
                return Err(
  159    227   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  160    228   
                        "expected object key or end object, found: {:?}",
  161    229   
                        other
  162    230   
                    )),
  163    231   
                )
  164         -
            }
         232  +
            } /* JsonParserGenerator.kt:685 */
  165    233   
        }
         234  +
        /* JsonParserGenerator.kt:684 */
  166    235   
    }
         236  +
    /* JsonParserGenerator.kt:250 */
  167    237   
    if tokens.next().is_some() {
         238  +
        /* JsonParserGenerator.kt:251 */
  168    239   
        return Err(
  169    240   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  170    241   
                "found more JSON tokens after completing parsing",
  171    242   
            ),
  172    243   
        );
         244  +
        /* JsonParserGenerator.kt:250 */
  173    245   
    }
         246  +
    /* JsonParserGenerator.kt:163 */
  174    247   
    Ok(builder)
         248  +
    /* JsonParserGenerator.kt:148 */
  175    249   
}

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

@@ -1,1 +54,80 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_simple_set<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained>,
    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::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
   27         -
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
   28         -
                            tokens.next(),
   29         -
                        )?
   30         -
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   31         -
                        .transpose()?;
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          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:419 */;
          45  +
                        /* JsonParserGenerator.kt:422 */
   32     46   
                        if let Some(value) = value {
   33     47   
                            items.push(value);
   34         -
                        } else {
          48  +
                        }
          49  +
                        /* JsonParserGenerator.kt:430 */
          50  +
                        else {
   35     51   
                            return Err(
   36     52   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     53   
                                    "dense list cannot contain null values",
   38     54   
                                ),
   39     55   
                            );
   40     56   
                        }
   41         -
                    }
          57  +
                        /* JsonParserGenerator.kt:413 */
          58  +
                    } /* JsonParserGenerator.kt:409 */
   42     59   
                }
          60  +
                /* JsonParserGenerator.kt:408 */
   43     61   
            }
          62  +
            /* JsonParserGenerator.kt:444 */
   44     63   
            Ok(Some(
   45     64   
                crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained(items),
   46     65   
            ))
          66  +
            /* JsonParserGenerator.kt:713 */
   47     67   
        }
   48         -
        _ => Err(
   49         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   50         -
                "expected start array or null",
   51         -
            ),
   52         -
        ),
          68  +
        /* JsonParserGenerator.kt:722 */
          69  +
        _ => {
          70  +
            /* JsonParserGenerator.kt:723 */
          71  +
            Err(
          72  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          73  +
                    "expected start array or null",
          74  +
                ),
          75  +
            )
          76  +
            /* JsonParserGenerator.kt:722 */
          77  +
        } /* JsonParserGenerator.kt:712 */
   53     78   
    }
          79  +
    /* JsonParserGenerator.kt:398 */
   54     80   
}

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

@@ -1,1 +35,58 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_validation_exception_error(
    3      4   
    value: &crate::error::ValidationException,
    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_validation_exception::ser_validation_exception(
    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_validation_exception(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::error::ValidationException,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.field_list {
          27  +
        /* JsonSerializerGenerator.kt:484 */
   20     28   
        let mut array_2 = object.key("fieldList").start_array();
          29  +
        /* JsonSerializerGenerator.kt:524 */
   21     30   
        for item_3 in var_1 {
          31  +
            /* SerializerUtil.kt:42 */
   22     32   
            {
          33  +
                /* JsonSerializerGenerator.kt:495 */
   23     34   
                #[allow(unused_mut)]
          35  +
                /* JsonSerializerGenerator.kt:496 */
   24     36   
                let mut object_4 = array_2.value().start_object();
          37  +
                /* JsonSerializerGenerator.kt:375 */
   25     38   
                crate::protocol_serde::shape_validation_exception_field::ser_validation_exception_field(&mut object_4, item_3)?;
          39  +
                /* JsonSerializerGenerator.kt:515 */
   26     40   
                object_4.finish();
          41  +
                /* SerializerUtil.kt:42 */
   27     42   
            }
          43  +
            /* JsonSerializerGenerator.kt:524 */
   28     44   
        }
          45  +
        /* JsonSerializerGenerator.kt:486 */
   29     46   
        array_2.finish();
          47  +
        /* JsonSerializerGenerator.kt:382 */
   30     48   
    }
          49  +
    /* SerializerUtil.kt:42 */
   31     50   
    {
          51  +
        /* JsonSerializerGenerator.kt:423 */
   32     52   
        object.key("message").string(input.message.as_str());
          53  +
        /* SerializerUtil.kt:42 */
   33     54   
    }
          55  +
    /* JsonSerializerGenerator.kt:372 */
   34     56   
    Ok(())
          57  +
    /* JsonSerializerGenerator.kt:358 */
   35     58   
}

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

@@ -1,1 +13,22 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:358 */
    2      3   
pub fn ser_validation_exception_field(
    3      4   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    4      5   
    input: &crate::model::ValidationExceptionField,
    5      6   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           7  +
    /* SerializerUtil.kt:42 */
    6      8   
    {
           9  +
        /* JsonSerializerGenerator.kt:423 */
    7     10   
        object.key("path").string(input.path.as_str());
          11  +
        /* SerializerUtil.kt:42 */
    8     12   
    }
          13  +
    /* SerializerUtil.kt:42 */
    9     14   
    {
          15  +
        /* JsonSerializerGenerator.kt:423 */
   10     16   
        object.key("message").string(input.message.as_str());
          17  +
        /* SerializerUtil.kt:42 */
   11     18   
    }
          19  +
    /* JsonSerializerGenerator.kt:372 */
   12     20   
    Ok(())
          21  +
    /* JsonSerializerGenerator.kt:358 */
   13     22   
}

tmp-codegen-diff/codegen-server-test-python/unique_items/rust-server-codegen-python/src/python_module_export.rs

@@ -1,1 +99,120 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* PythonServerModuleGenerator.kt:41 */
    2      3   
#[::pyo3::pymodule]
    3         -
#[::pyo3(name = "unique_items")]
           4  +
#[pyo3(name = "unique_items")]
    4      5   
pub fn python_library(py: ::pyo3::Python<'_>, m: &::pyo3::types::PyModule) -> ::pyo3::PyResult<()> {
           6  +
    /* PythonServerModuleGenerator.kt:65 */
    5      7   
    let input = ::pyo3::types::PyModule::new(py, "input")?;
    6      8   
    let output = ::pyo3::types::PyModule::new(py, "output")?;
    7      9   
    let error = ::pyo3::types::PyModule::new(py, "error")?;
          10  +
    /* PythonServerModuleGenerator.kt:96 */
    8     11   
    error.add_class::<crate::error::InternalServerError>()?;
          12  +
    /* PythonServerModuleGenerator.kt:96 */
    9     13   
    error.add_class::<crate::error::ValidationException>()?;
          14  +
    /* PythonServerModuleGenerator.kt:79 */
   10     15   
    let model = ::pyo3::types::PyModule::new(py, "model")?;
          16  +
    /* PythonServerModuleGenerator.kt:96 */
   11     17   
    model.add_class::<crate::model::ValidationExceptionField>()?;
          18  +
    /* PythonServerModuleGenerator.kt:96 */
   12     19   
    output.add_class::<crate::output::MalformedUniqueItemsOutput>()?;
          20  +
    /* PythonServerModuleGenerator.kt:96 */
   13     21   
    input.add_class::<crate::input::MalformedUniqueItemsInput>()?;
          22  +
    /* PythonServerModuleGenerator.kt:96 */
   14     23   
    model.add_class::<crate::model::ComplexSetStruct>()?;
          24  +
    /* PythonServerModuleGenerator.kt:105 */
   15     25   
    ::pyo3::py_run!(
   16     26   
        py,
   17     27   
        input,
   18     28   
        "import sys; sys.modules['unique_items.input'] = input"
   19     29   
    );
   20     30   
    m.add_submodule(input)?;
   21     31   
    ::pyo3::py_run!(
   22     32   
        py,
   23     33   
        output,
   24     34   
        "import sys; sys.modules['unique_items.output'] = output"
   25     35   
    );
   26     36   
    m.add_submodule(output)?;
   27     37   
    ::pyo3::py_run!(
   28     38   
        py,
   29     39   
        error,
   30     40   
        "import sys; sys.modules['unique_items.error'] = error"
   31     41   
    );
   32     42   
    m.add_submodule(error)?;
          43  +
    /* PythonServerModuleGenerator.kt:117 */
   33     44   
    ::pyo3::py_run!(
   34     45   
        py,
   35     46   
        model,
   36     47   
        "import sys; sys.modules['unique_items.model'] = model"
   37     48   
    );
   38     49   
    m.add_submodule(model)?;
          50  +
    /* PythonServerModuleGenerator.kt:129 */
   39     51   
    let types = ::pyo3::types::PyModule::new(py, "types")?;
   40     52   
    types.add_class::<::aws_smithy_http_server_python::types::Blob>()?;
   41     53   
    types.add_class::<::aws_smithy_http_server_python::types::DateTime>()?;
   42     54   
    types.add_class::<::aws_smithy_http_server_python::types::Format>()?;
   43     55   
    types.add_class::<::aws_smithy_http_server_python::types::ByteStream>()?;
   44     56   
    ::pyo3::py_run!(
   45     57   
        py,
   46     58   
        types,
   47     59   
        "import sys; sys.modules['unique_items.types'] = types"
   48     60   
    );
   49     61   
    m.add_submodule(types)?;
          62  +
    /* PythonServerModuleGenerator.kt:149 */
   50     63   
    let socket = ::pyo3::types::PyModule::new(py, "socket")?;
   51     64   
    socket.add_class::<::aws_smithy_http_server_python::PySocket>()?;
   52     65   
    ::pyo3::py_run!(
   53     66   
        py,
   54     67   
        socket,
   55     68   
        "import sys; sys.modules['unique_items.socket'] = socket"
   56     69   
    );
   57     70   
    m.add_submodule(socket)?;
          71  +
    /* PythonServerModuleGenerator.kt:166 */
   58     72   
    let logging = ::pyo3::types::PyModule::new(py, "logging")?;
   59     73   
    logging.add_function(::pyo3::wrap_pyfunction!(
   60     74   
        ::aws_smithy_http_server_python::py_tracing_event,
   61     75   
        m
   62     76   
    )?)?;
   63     77   
    logging.add_class::<::aws_smithy_http_server_python::PyTracingHandler>()?;
   64     78   
    ::pyo3::py_run!(
   65     79   
        py,
   66     80   
        logging,
   67     81   
        "import sys; sys.modules['unique_items.logging'] = logging"
   68     82   
    );
   69     83   
    m.add_submodule(logging)?;
          84  +
    /* PythonServerModuleGenerator.kt:183 */
   70     85   
    let middleware = ::pyo3::types::PyModule::new(py, "middleware")?;
   71     86   
    middleware.add_class::<::aws_smithy_http_server_python::PyRequest>()?;
   72     87   
    middleware.add_class::<::aws_smithy_http_server_python::PyResponse>()?;
   73     88   
    middleware.add_class::<::aws_smithy_http_server_python::PyMiddlewareException>()?;
   74     89   
    pyo3::py_run!(
   75     90   
        py,
   76     91   
        middleware,
   77     92   
        "import sys; sys.modules['unique_items.middleware'] = middleware"
   78     93   
    );
   79     94   
    m.add_submodule(middleware)?;
          95  +
    /* PythonServerModuleGenerator.kt:201 */
   80     96   
    let tls = ::pyo3::types::PyModule::new(py, "tls")?;
   81     97   
    tls.add_class::<::aws_smithy_http_server_python::tls::PyTlsConfig>()?;
   82     98   
    pyo3::py_run!(py, tls, "import sys; sys.modules['unique_items.tls'] = tls");
   83     99   
    m.add_submodule(tls)?;
         100  +
    /* PythonServerModuleGenerator.kt:217 */
   84    101   
    let aws_lambda = ::pyo3::types::PyModule::new(py, "aws_lambda")?;
   85    102   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyLambdaContext>()?;
   86    103   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientApplication>()?;
   87    104   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientContext>()?;
   88    105   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyCognitoIdentity>()?;
   89    106   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyConfig>()?;
   90    107   
    pyo3::py_run!(
   91    108   
        py,
   92    109   
        aws_lambda,
   93    110   
        "import sys; sys.modules['unique_items.aws_lambda'] = aws_lambda"
   94    111   
    );
   95    112   
    m.add_submodule(aws_lambda)?;
         113  +
    /* PythonServerModuleGenerator.kt:238 */
   96    114   
    m.add_class::<crate::python_server_application::App>()?;
         115  +
    /* PythonServerModuleGenerator.kt:243 */
   97    116   
    m.add("CODEGEN_VERSION", "ci")?;
         117  +
    /* PythonServerModuleGenerator.kt:58 */
   98    118   
    Ok(())
         119  +
    /* PythonServerModuleGenerator.kt:41 */
   99    120   
}

tmp-codegen-diff/codegen-server-test-python/unique_items/rust-server-codegen-python/src/python_operation_adaptor.rs

@@ -1,1 +31,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* PythonServerOperationHandlerGenerator.kt:61 */
    2      3   
/// Python handler for operation `MalformedUniqueItems`.
    3      4   
pub(crate) async fn malformed_unique_items(
    4      5   
    input: crate::input::MalformedUniqueItemsInput,
    5      6   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
    6      7   
    handler: ::aws_smithy_http_server_python::PyHandler,
    7      8   
) -> std::result::Result<
    8      9   
    crate::output::MalformedUniqueItemsOutput,
    9     10   
    crate::error::MalformedUniqueItemsError,
   10     11   
> {
   11     12   
    // Async block used to run the handler and catch any Python error.

tmp-codegen-diff/codegen-server-test-python/unique_items/rust-server-codegen-python/src/python_server_application.rs

@@ -1,1 +159,178 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* PythonApplicationGenerator.kt:386 */
    2      3   
#[allow(clippy::tabs_in_doc_comments)]
    3      4   
/// Main Python application, used to register operations and context and start multiple
    4      5   
/// workers on the same shared socket.
    5      6   
///
    6      7   
/// Operations can be registered using the application object as a decorator (`@app.operation_name`).
    7      8   
///
    8      9   
/// Here's a full example to get you started:
    9     10   
///
   10     11   
/// ```python
          12  +
/* PythonApplicationGenerator.kt:399 */
   11     13   
/// from unique_items import input
   12     14   
/// from unique_items import output
          15  +
/* PythonApplicationGenerator.kt:406 */
   13     16   
/// from unique_items import error
          17  +
/* PythonApplicationGenerator.kt:408 */
   14     18   
/// from unique_items import middleware
   15     19   
/// from unique_items import App
   16     20   
///
   17     21   
/// @dataclass
   18     22   
/// class Context:
   19     23   
///     counter: int = 0
   20     24   
///
   21     25   
/// app = App()
   22     26   
/// app.context(Context())
   23     27   
///
   24     28   
/// @app.request_middleware
   25     29   
/// def request_middleware(request: middleware::Request):
   26     30   
///     if request.get_header("x-amzn-id") != "secret":
   27     31   
///         raise middleware.MiddlewareException("Unsupported `x-amz-id` header", 401)
   28     32   
///
          33  +
/* PythonApplicationGenerator.kt:441 */
   29     34   
/// @app.malformed_unique_items
   30     35   
/// def malformed_unique_items(input: input::MalformedUniqueItemsInput, ctx: Context) -> output::MalformedUniqueItemsOutput:
   31     36   
///     raise NotImplementedError
          37  +
/* PythonApplicationGenerator.kt:428 */
   32     38   
///
   33     39   
/// app.run()
   34     40   
/// ```
   35     41   
///
   36     42   
/// Any of operations above can be written as well prepending the `async` keyword and
   37     43   
/// the Python application will automatically handle it and schedule it on the event loop for you.
          44  +
/* PythonApplicationGenerator.kt:112 */
   38     45   
#[::pyo3::pyclass]
   39     46   
#[derive(Debug)]
   40     47   
/// :generic Ctx:
   41     48   
/// :extends typing.Generic\[Ctx\]:
   42     49   
/// :rtype None:
   43     50   
pub struct App {
   44     51   
    handlers: ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler>,
   45     52   
    middlewares: Vec<::aws_smithy_http_server_python::PyMiddlewareHandler>,
   46     53   
    context: Option<::pyo3::PyObject>,
   47     54   
    workers: ::parking_lot::Mutex<Vec<::pyo3::PyObject>>,
   48     55   
}
          56  +
/* PythonApplicationGenerator.kt:149 */
   49     57   
impl Default for App {
   50     58   
    fn default() -> Self {
   51     59   
        Self {
   52     60   
            handlers: Default::default(),
   53     61   
            middlewares: vec![],
   54     62   
            context: None,
   55     63   
            workers: ::parking_lot::Mutex::new(vec![]),
   56     64   
        }
   57     65   
    }
   58     66   
}
          67  +
/* PythonApplicationGenerator.kt:131 */
   59     68   
impl Clone for App {
   60     69   
    fn clone(&self) -> Self {
   61     70   
        Self {
   62     71   
            handlers: self.handlers.clone(),
   63     72   
            middlewares: self.middlewares.clone(),
   64     73   
            context: self.context.clone(),
   65     74   
            workers: ::parking_lot::Mutex::new(vec![]),
   66     75   
        }
   67     76   
    }
   68     77   
}
          78  +
/* PythonApplicationGenerator.kt:168 */
   69     79   
impl ::aws_smithy_http_server_python::PyApp for App {
          80  +
    /* PythonApplicationGenerator.kt:174 */
   70     81   
    fn workers(&self) -> &::parking_lot::Mutex<Vec<::pyo3::PyObject>> {
   71     82   
        &self.workers
   72     83   
    }
   73     84   
    fn context(&self) -> &Option<::pyo3::PyObject> {
   74     85   
        &self.context
   75     86   
    }
   76     87   
    fn handlers(
   77     88   
        &mut self,
   78     89   
    ) -> &mut ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler> {
   79     90   
        &mut self.handlers
   80     91   
    }
          92  +
    /* PythonApplicationGenerator.kt:189 */
   81     93   
    fn build_service(
   82     94   
        &mut self,
   83     95   
        event_loop: &::pyo3::PyAny,
   84     96   
    ) -> ::pyo3::PyResult<
   85     97   
        ::tower::util::BoxCloneService<
   86     98   
            ::http::Request<::aws_smithy_http_server::body::Body>,
   87     99   
            ::http::Response<::aws_smithy_http_server::body::BoxBody>,
   88    100   
            std::convert::Infallible,
   89    101   
        >,
   90    102   
    > {
         103  +
        /* PythonApplicationGenerator.kt:201 */
   91    104   
        let builder = crate::service::UniqueItemsService::builder_without_plugins();
         105  +
        /* PythonApplicationGenerator.kt:209 */
   92    106   
        let malformed_unique_items_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
   93    107   
        let handler = self
   94    108   
            .handlers
   95    109   
            .get("malformed_unique_items")
   96    110   
            .expect("Python handler for operation `malformed_unique_items` not found")
   97    111   
            .clone();
   98    112   
        let builder = builder.malformed_unique_items(move |input, state| {
   99    113   
            ::pyo3_asyncio::tokio::scope(
  100    114   
                malformed_unique_items_locals.clone(),
  101    115   
                crate::python_operation_adaptor::malformed_unique_items(
  102    116   
                    input,
  103    117   
                    state,
  104    118   
                    handler.clone(),
  105    119   
                ),
  106    120   
            )
  107    121   
        });
         122  +
        /* PythonApplicationGenerator.kt:220 */
  108    123   
        let mut service = ::tower::util::BoxCloneService::new(builder.build().expect("one or more operations do not have a registered handler; this is a bug in the Python code generator, please file a bug report under https://github.com/smithy-lang/smithy-rs/issues"));
  109    124   
  110    125   
        {
  111    126   
            use ::tower::Layer;
  112    127   
            ::tracing::trace!("adding middlewares to rust python router");
  113    128   
            let mut middlewares = self.middlewares.clone();
  114    129   
            // Reverse the middlewares, so they run with same order as they defined
  115    130   
            middlewares.reverse();
  116    131   
            for handler in middlewares {
  117    132   
                ::tracing::trace!(name = &handler.name, "adding python middleware");
  118    133   
                let locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  119    134   
                let layer = ::aws_smithy_http_server_python::PyMiddlewareLayer::<
  120    135   
                    ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  121    136   
                >::new(handler, locals);
  122    137   
                service = ::tower::util::BoxCloneService::new(layer.layer(service));
  123    138   
            }
  124    139   
        }
  125    140   
        Ok(service)
         141  +
        /* PythonApplicationGenerator.kt:189 */
  126    142   
    }
         143  +
    /* PythonApplicationGenerator.kt:168 */
  127    144   
}
         145  +
/* PythonApplicationGenerator.kt:247 */
  128    146   
#[::pyo3::pymethods]
  129    147   
impl App {
         148  +
    /* PythonApplicationGenerator.kt:260 */
  130    149   
    /// Create a new [App].
  131    150   
    #[new]
  132    151   
    pub fn new() -> Self {
  133    152   
        Self::default()
  134    153   
    }
  135    154   
  136    155   
    /// Register a context object that will be shared between handlers.
  137    156   
    ///
  138    157   
    /// :param context Ctx:
  139    158   
    /// :rtype None:
@@ -182,201 +226,247 @@
  202    221   
        py: pyo3::Python,
  203    222   
        socket: &pyo3::PyCell<::aws_smithy_http_server_python::PySocket>,
  204    223   
        worker_number: isize,
  205    224   
        tls: Option<::aws_smithy_http_server_python::tls::PyTlsConfig>,
  206    225   
    ) -> pyo3::PyResult<()> {
  207    226   
        use ::aws_smithy_http_server_python::PyApp;
  208    227   
        let event_loop = self.configure_python_event_loop(py)?;
  209    228   
        let service = self.build_and_configure_service(py, event_loop)?;
  210    229   
        self.start_hyper_worker(py, socket, event_loop, service, worker_number, tls)
  211    230   
    }
         231  +
    /* PythonApplicationGenerator.kt:366 */
  212    232   
    /// Method to register `malformed_unique_items` Python implementation inside the handlers map.
  213    233   
    /// It can be used as a function decorator in Python.
  214    234   
    ///
  215    235   
    /// :param func typing.Union\[typing.Callable\[\[unique_items.input.MalformedUniqueItemsInput, Ctx\], typing.Union\[unique_items.output.MalformedUniqueItemsOutput, typing.Awaitable\[unique_items.output.MalformedUniqueItemsOutput\]\]\], typing.Callable\[\[unique_items.input.MalformedUniqueItemsInput\], typing.Union\[unique_items.output.MalformedUniqueItemsOutput, typing.Awaitable\[unique_items.output.MalformedUniqueItemsOutput\]\]\]\]:
  216    236   
    /// :rtype None:
  217    237   
    #[pyo3(text_signature = "($self, func)")]
  218    238   
    pub fn malformed_unique_items(
  219    239   
        &mut self,
  220    240   
        py: ::pyo3::Python,
  221    241   
        func: ::pyo3::PyObject,
  222    242   
    ) -> ::pyo3::PyResult<()> {
  223    243   
        use ::aws_smithy_http_server_python::PyApp;
  224    244   
        self.register_operation(py, "malformed_unique_items", func)
  225    245   
    }
         246  +
    /* PythonApplicationGenerator.kt:247 */
  226    247   
}

tmp-codegen-diff/codegen-server-test-python/unique_items/rust-server-codegen-python/src/service.rs

@@ -1,1 +31,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerServiceGenerator.kt:795 */
    2      3   
/// The service builder for [`UniqueItemsService`].
    3      4   
///
    4      5   
/// Constructed via [`UniqueItemsService::builder`].
    5      6   
pub struct UniqueItemsServiceBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    malformed_unique_items: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    layer: L,
    8      9   
    http_plugin: HttpPl,
    9     10   
    model_plugin: ModelPl,
   10     11   
}
   11     12   
@@ -480,481 +539,541 @@
  500    501   
            "com.amazonaws.constraints",
  501    502   
            "UniqueItemsService",
  502    503   
        );
  503    504   
  504    505   
    const VERSION: Option<&'static str> = Some("");
  505    506   
  506    507   
    type Protocol = ::aws_smithy_http_server::protocol::rest_json_1::RestJson1;
  507    508   
  508    509   
    type Operations = Operation;
  509    510   
}
         511  +
/* ServiceConfigGenerator.kt:178 */
  510    512   
/// Configuration for the [`UniqueItemsService`]. This is the central place where to register and
  511    513   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
  512    514   
///
  513    515   
/// ```rust,no_run
  514    516   
/// # use unique_items::UniqueItemsServiceConfig;
  515    517   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
  516    518   
/// # use ::tower::layer::util::Identity;
  517    519   
/// # let authentication_plugin = IdentityPlugin;
  518    520   
/// # let authorization_plugin = IdentityPlugin;
  519    521   
/// # let server_request_id_provider_layer = Identity::new();
@@ -601,603 +660,663 @@
  621    623   
  622    624   
    /// Build the configuration.
  623    625   
    pub fn build(self) -> super::UniqueItemsServiceConfig<L, H, M> {
  624    626   
        super::UniqueItemsServiceConfig {
  625    627   
            layers: self.layers,
  626    628   
            http_plugins: self.http_plugins,
  627    629   
            model_plugins: self.model_plugins,
  628    630   
        }
  629    631   
    }
  630    632   
}
         633  +
/* ScopeMacroGenerator.kt:81 */
  631    634   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
  632    635   
///
  633    636   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
  634    637   
/// of the service and any operations _not_ specified will be placed in the opposing group.
  635    638   
///
  636    639   
/// # Example
  637    640   
///
  638    641   
/// ```rust
  639    642   
/// scope! {
  640    643   
///     /// Includes [`MalformedUniqueItems`], excluding all other operations.

tmp-codegen-diff/codegen-server-test-python/unique_items/rust-server-codegen-python/src/types.rs

@@ -1,1 +0,7 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* SmithyTypesPubUseExtra.kt:66 */
    2      3   
pub use ::aws_smithy_types::date_time::Format as DateTimeFormat;
           4  +
/* ServerRequiredCustomizations.kt:69 */
    3      5   
pub use ::aws_smithy_types::error::display::DisplayErrorContext;
    4      6   
pub use ::aws_smithy_types::Blob;
    5         -
pub use ::aws_smithy_types::DateTime;
           7  +
/* SmithyTypesPubUseExtra.kt:69 */ pub use ::aws_smithy_types::DateTime;

tmp-codegen-diff/codegen-server-test-python/unique_items/rust-server-codegen-python/src/unconstrained.rs

@@ -1,1 +44,64 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
    3      3   
pub(crate) mod complex_set_unconstrained {
    4      4   
           5  +
    /* UnconstrainedCollectionGenerator.kt:77 */
    5      6   
    #[derive(Debug, Clone)]
    6      7   
    pub(crate) struct ComplexSetUnconstrained(
    7      8   
        pub(crate) std::vec::Vec<crate::model::ComplexSetStruct>,
    8      9   
    );
    9     10   
   10     11   
    impl From<ComplexSetUnconstrained>
   11     12   
        for crate::constrained::MaybeConstrained<crate::model::ComplexSet>
   12     13   
    {
   13     14   
        fn from(value: ComplexSetUnconstrained) -> Self {
   14     15   
            Self::Unconstrained(value)
   15     16   
        }
   16     17   
    }
          18  +
    /* UnconstrainedCollectionGenerator.kt:97 */
   17     19   
    impl std::convert::TryFrom<ComplexSetUnconstrained> for crate::model::ComplexSet {
          20  +
        /* UnconstrainedCollectionGenerator.kt:98 */
   18     21   
        type Error = crate::model::complex_set_internal::ConstraintViolation;
          22  +
        /* UnconstrainedCollectionGenerator.kt:100 */
   19     23   
        fn try_from(value: ComplexSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          24  +
            /* UnconstrainedCollectionGenerator.kt:185 */
   20     25   
            let inner = value.0;
          26  +
            /* UnconstrainedCollectionGenerator.kt:189 */
   21     27   
            Self::try_from(inner)
          28  +
            /* UnconstrainedCollectionGenerator.kt:100 */
   22     29   
        }
          30  +
        /* UnconstrainedCollectionGenerator.kt:97 */
   23     31   
    }
          32  +
          33  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   24     34   
}
   25     35   
pub(crate) mod simple_set_unconstrained {
   26     36   
          37  +
    /* UnconstrainedCollectionGenerator.kt:77 */
   27     38   
    #[derive(Debug, Clone)]
   28     39   
    pub(crate) struct SimpleSetUnconstrained(pub(crate) std::vec::Vec<::std::string::String>);
   29     40   
   30     41   
    impl From<SimpleSetUnconstrained>
   31     42   
        for crate::constrained::MaybeConstrained<crate::model::SimpleSet>
   32     43   
    {
   33     44   
        fn from(value: SimpleSetUnconstrained) -> Self {
   34     45   
            Self::Unconstrained(value)
   35     46   
        }
   36     47   
    }
          48  +
    /* UnconstrainedCollectionGenerator.kt:97 */
   37     49   
    impl std::convert::TryFrom<SimpleSetUnconstrained> for crate::model::SimpleSet {
          50  +
        /* UnconstrainedCollectionGenerator.kt:98 */
   38     51   
        type Error = crate::model::simple_set_internal::ConstraintViolation;
          52  +
        /* UnconstrainedCollectionGenerator.kt:100 */
   39     53   
        fn try_from(value: SimpleSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          54  +
            /* UnconstrainedCollectionGenerator.kt:185 */
   40     55   
            let inner = value.0;
          56  +
            /* UnconstrainedCollectionGenerator.kt:189 */
   41     57   
            Self::try_from(inner)
          58  +
            /* UnconstrainedCollectionGenerator.kt:100 */
   42     59   
        }
          60  +
        /* UnconstrainedCollectionGenerator.kt:97 */
   43     61   
    }
          62  +
          63  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   44     64   
}