Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +144,205 @@
    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_type_complexity_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::TypeComplexityOperationInput,
    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::type_complexity_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: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_type_complexity_operation::de_type_complexity_operation(bytes.as_ref(), input)?;
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   29     40   
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   30     42   
        input.build()
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   31     44   
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   32     46   
}
   33     47   
          48  +
/* RustType.kt:516 */
   34     49   
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   35     51   
pub fn ser_type_complexity_operation_http_response(
   36     52   
    #[allow(unused_variables)] output: crate::output::TypeComplexityOperationOutput,
   37     53   
) -> std::result::Result<
   38     54   
    ::aws_smithy_http_server::response::Response,
   39     55   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   40     56   
> {
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   41     58   
    Ok({
          59  +
        /* RustType.kt:516 */
   42     60   
        #[allow(unused_mut)]
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   43     62   
        let mut builder = ::http::Response::builder();
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   44     64   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     65   
            builder,
   46     66   
            ::http::header::CONTENT_TYPE,
   47     67   
            "application/json",
   48     68   
        );
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   49     70   
        let http_status: u16 = 200;
   50     71   
        builder = builder.status(http_status);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   51     73   
        let payload =
   52         -
            crate::protocol_serde::shape_type_complexity_operation_output::ser_type_complexity_operation_output_output_output(&output)?
   53         -
        ;
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_type_complexity_operation_output::ser_type_complexity_operation_output_output_output(&output)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   54     77   
        let content_length = payload.len();
   55     78   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   56     79   
            builder,
   57     80   
            ::http::header::CONTENT_LENGTH,
   58     81   
            content_length,
   59     82   
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   60     84   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   61     86   
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   62     88   
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   63     90   
}
   64     91   
          92  +
/* RustType.kt:516 */
   65     93   
#[allow(clippy::unnecessary_wraps)]
          94  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   66     95   
pub fn ser_type_complexity_operation_http_error(
   67     96   
    error: &crate::error::TypeComplexityOperationError,
   68     97   
) -> std::result::Result<
   69     98   
    ::aws_smithy_http_server::response::Response,
   70     99   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   71    100   
> {
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   72    102   
    Ok({
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   73    104   
        match error {
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   74    106   
            crate::error::TypeComplexityOperationError::InternalServerError(output) => {
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   75    108   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         109  +
                /* RustType.kt:516 */
   76    110   
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   77    112   
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   78    114   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   79    115   
                    builder,
   80    116   
                    ::http::header::CONTENT_TYPE,
   81    117   
                    "application/json",
   82    118   
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   83    120   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   84    121   
                    builder,
   85    122   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   86    123   
                    "InternalServerError",
   87    124   
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   88    126   
                let content_length = payload.len();
   89    127   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   90    128   
                    builder,
   91    129   
                    ::http::header::CONTENT_LENGTH,
   92    130   
                    content_length,
   93    131   
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   94    133   
                builder
   95    134   
                    .status(500)
   96    135   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         137  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   97    138   
        }
   98         -
        }
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   99    140   
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  100    142   
}
  101    143   
         144  +
/* JsonParserGenerator.kt:148 */
  102    145   
pub(crate) fn de_type_complexity_operation(
  103    146   
    value: &[u8],
  104    147   
    mut builder: crate::input::type_complexity_operation_input_internal::Builder,
  105    148   
) -> ::std::result::Result<
  106    149   
    crate::input::type_complexity_operation_input_internal::Builder,
  107    150   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  108    151   
> {
         152  +
    /* JsonParserGenerator.kt:153 */
  109    153   
    let mut tokens_owned =
  110    154   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  111    155   
            .peekable();
  112    156   
    let tokens = &mut tokens_owned;
  113    157   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         158  +
    /* JsonParserGenerator.kt:684 */
  114    159   
    loop {
         160  +
        /* JsonParserGenerator.kt:685 */
  115    161   
        match tokens.next().transpose()? {
         162  +
            /* JsonParserGenerator.kt:686 */
  116    163   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  117    164   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         165  +
                /* JsonParserGenerator.kt:260 */
  118    166   
                match key.to_unescaped()?.as_ref() {
         167  +
                    /* JsonParserGenerator.kt:262 */
  119    168   
                    "list" => {
  120         -
                        builder = builder
  121         -
                            .set_list(crate::protocol_serde::shape_list_a::de_list_a(tokens)?);
         169  +
                        /* JsonParserGenerator.kt:272 */
         170  +
                        builder = builder.set_list(
         171  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_list_a::de_list_a(tokens)?
         172  +
                        /* JsonParserGenerator.kt:272 */);
         173  +
                        /* JsonParserGenerator.kt:262 */
  122    174   
                    }
  123         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         175  +
                    /* JsonParserGenerator.kt:290 */
         176  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  124    177   
                }
         178  +
                /* JsonParserGenerator.kt:686 */
  125    179   
            }
         180  +
            /* JsonParserGenerator.kt:695 */
  126    181   
            other => {
  127    182   
                return Err(
  128    183   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  129    184   
                        "expected object key or end object, found: {:?}",
  130    185   
                        other
  131    186   
                    )),
  132    187   
                )
         188  +
            } /* JsonParserGenerator.kt:685 */
  133    189   
        }
         190  +
        /* JsonParserGenerator.kt:684 */
  134    191   
    }
  135         -
    }
         192  +
    /* JsonParserGenerator.kt:250 */
  136    193   
    if tokens.next().is_some() {
         194  +
        /* JsonParserGenerator.kt:251 */
  137    195   
        return Err(
  138    196   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  139    197   
                "found more JSON tokens after completing parsing",
  140    198   
            ),
  141    199   
        );
         200  +
        /* JsonParserGenerator.kt:250 */
  142    201   
    }
         202  +
    /* JsonParserGenerator.kt:163 */
  143    203   
    Ok(builder)
         204  +
    /* JsonParserGenerator.kt:148 */
  144    205   
}

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

@@ -1,1 +49,88 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_type_complexity_operation_output_output_output(
    3      4   
    value: &crate::output::TypeComplexityOperationOutput,
    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_type_complexity_operation_output::ser_type_complexity_operation_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_type_complexity_operation_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::TypeComplexityOperationOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.list {
          24  +
        /* JsonSerializerGenerator.kt:484 */
   17     25   
        let mut array_2 = object.key("list").start_array();
          26  +
        /* JsonSerializerGenerator.kt:524 */
   18     27   
        for item_3 in var_1 {
          28  +
            /* SerializerUtil.kt:42 */
   19     29   
            {
          30  +
                /* JsonSerializerGenerator.kt:484 */
   20     31   
                let mut array_4 = array_2.value().start_array();
          32  +
                /* JsonSerializerGenerator.kt:524 */
   21     33   
                for item_5 in item_3 {
          34  +
                    /* SerializerUtil.kt:42 */
   22     35   
                    {
          36  +
                        /* JsonSerializerGenerator.kt:484 */
   23     37   
                        let mut array_6 = array_4.value().start_array();
          38  +
                        /* JsonSerializerGenerator.kt:524 */
   24     39   
                        for item_7 in item_5 {
          40  +
                            /* SerializerUtil.kt:42 */
   25     41   
                            {
          42  +
                                /* JsonSerializerGenerator.kt:495 */
   26     43   
                                #[allow(unused_mut)]
          44  +
                                /* JsonSerializerGenerator.kt:496 */
   27     45   
                                let mut object_8 = array_6.value().start_object();
          46  +
                                /* JsonSerializerGenerator.kt:537 */
   28     47   
                                for (key_9, value_10) in item_7 {
          48  +
                                    /* SerializerUtil.kt:42 */
   29     49   
                                    {
          50  +
                                        /* JsonSerializerGenerator.kt:495 */
   30     51   
                                        #[allow(unused_mut)]
          52  +
                                        /* JsonSerializerGenerator.kt:496 */
   31     53   
                                        let mut object_11 =
   32     54   
                                            object_8.key(key_9.as_str()).start_object();
          55  +
                                        /* JsonSerializerGenerator.kt:375 */
   33     56   
                                        crate::protocol_serde::shape_empty_structure::ser_empty_structure(&mut object_11, value_10)?;
          57  +
                                        /* JsonSerializerGenerator.kt:515 */
   34     58   
                                        object_11.finish();
          59  +
                                        /* SerializerUtil.kt:42 */
   35     60   
                                    }
          61  +
                                    /* JsonSerializerGenerator.kt:537 */
   36     62   
                                }
          63  +
                                /* JsonSerializerGenerator.kt:515 */
   37     64   
                                object_8.finish();
          65  +
                                /* SerializerUtil.kt:42 */
   38     66   
                            }
          67  +
                            /* JsonSerializerGenerator.kt:524 */
   39     68   
                        }
          69  +
                        /* JsonSerializerGenerator.kt:486 */
   40     70   
                        array_6.finish();
          71  +
                        /* SerializerUtil.kt:42 */
   41     72   
                    }
          73  +
                    /* JsonSerializerGenerator.kt:524 */
   42     74   
                }
          75  +
                /* JsonSerializerGenerator.kt:486 */
   43     76   
                array_4.finish();
          77  +
                /* SerializerUtil.kt:42 */
   44     78   
            }
          79  +
            /* JsonSerializerGenerator.kt:524 */
   45     80   
        }
          81  +
        /* JsonSerializerGenerator.kt:486 */
   46     82   
        array_2.finish();
          83  +
        /* JsonSerializerGenerator.kt:382 */
   47     84   
    }
          85  +
    /* JsonSerializerGenerator.kt:372 */
   48     86   
    Ok(())
          87  +
    /* JsonSerializerGenerator.kt:358 */
   49     88   
}

tmp-codegen-diff/codegen-server-test-python/misc/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/misc/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/misc/rust-server-codegen-python/src/python_module_export.rs

@@ -1,1 +96,130 @@
    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 = "misc")]
           4  +
#[pyo3(name = "misc")]
    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   
    output.add_class::<crate::output::ResponseCodeDefaultOperationOutput>()?;
          14  +
    /* PythonServerModuleGenerator.kt:96 */
   10     15   
    input.add_class::<crate::input::ResponseCodeDefaultOperationInput>()?;
          16  +
    /* PythonServerModuleGenerator.kt:96 */
   11     17   
    output.add_class::<crate::output::ResponseCodeHttpFallbackOperationOutput>()?;
          18  +
    /* PythonServerModuleGenerator.kt:96 */
   12     19   
    input.add_class::<crate::input::ResponseCodeHttpFallbackOperationInput>()?;
          20  +
    /* PythonServerModuleGenerator.kt:96 */
   13     21   
    output.add_class::<crate::output::ResponseCodeRequiredOperationOutput>()?;
          22  +
    /* PythonServerModuleGenerator.kt:96 */
   14     23   
    input.add_class::<crate::input::ResponseCodeRequiredOperationInput>()?;
          24  +
    /* PythonServerModuleGenerator.kt:96 */
   15     25   
    error.add_class::<crate::error::ValidationException>()?;
          26  +
    /* PythonServerModuleGenerator.kt:79 */
   16     27   
    let model = ::pyo3::types::PyModule::new(py, "model")?;
          28  +
    /* PythonServerModuleGenerator.kt:96 */
   17     29   
    model.add_class::<crate::model::ValidationExceptionField>()?;
          30  +
    /* PythonServerModuleGenerator.kt:96 */
   18     31   
    output.add_class::<crate::output::RequiredHeaderCollectionOperationOutput>()?;
          32  +
    /* PythonServerModuleGenerator.kt:96 */
   19     33   
    input.add_class::<crate::input::RequiredHeaderCollectionOperationInput>()?;
          34  +
    /* PythonServerModuleGenerator.kt:96 */
   20     35   
    output.add_class::<crate::output::RequiredInnerShapeOperationOutput>()?;
          36  +
    /* PythonServerModuleGenerator.kt:96 */
   21     37   
    model.add_class::<crate::model::InnerShape>()?;
          38  +
    /* PythonServerModuleGenerator.kt:96 */
   22     39   
    model.add_class::<crate::model::InnermostShape>()?;
          40  +
    /* PythonServerModuleGenerator.kt:89 */
   23     41   
    model.add_class::<crate::model::PyUnionMarkerAUnion>()?;
          42  +
    /* PythonServerModuleGenerator.kt:96 */
   24     43   
    input.add_class::<crate::input::RequiredInnerShapeOperationInput>()?;
          44  +
    /* PythonServerModuleGenerator.kt:96 */
   25     45   
    output.add_class::<crate::output::TypeComplexityOperationOutput>()?;
          46  +
    /* PythonServerModuleGenerator.kt:96 */
   26     47   
    model.add_class::<crate::model::EmptyStructure>()?;
          48  +
    /* PythonServerModuleGenerator.kt:96 */
   27     49   
    input.add_class::<crate::input::TypeComplexityOperationInput>()?;
          50  +
    /* PythonServerModuleGenerator.kt:105 */
   28     51   
    ::pyo3::py_run!(py, input, "import sys; sys.modules['misc.input'] = input");
   29     52   
    m.add_submodule(input)?;
   30     53   
    ::pyo3::py_run!(
   31     54   
        py,
   32     55   
        output,
   33     56   
        "import sys; sys.modules['misc.output'] = output"
   34     57   
    );
   35     58   
    m.add_submodule(output)?;
   36     59   
    ::pyo3::py_run!(py, error, "import sys; sys.modules['misc.error'] = error");
   37     60   
    m.add_submodule(error)?;
          61  +
    /* PythonServerModuleGenerator.kt:117 */
   38     62   
    ::pyo3::py_run!(py, model, "import sys; sys.modules['misc.model'] = model");
   39     63   
    m.add_submodule(model)?;
          64  +
    /* PythonServerModuleGenerator.kt:129 */
   40     65   
    let types = ::pyo3::types::PyModule::new(py, "types")?;
   41     66   
    types.add_class::<::aws_smithy_http_server_python::types::Blob>()?;
   42     67   
    types.add_class::<::aws_smithy_http_server_python::types::DateTime>()?;
   43     68   
    types.add_class::<::aws_smithy_http_server_python::types::Format>()?;
   44     69   
    types.add_class::<::aws_smithy_http_server_python::types::ByteStream>()?;
   45     70   
    ::pyo3::py_run!(py, types, "import sys; sys.modules['misc.types'] = types");
   46     71   
    m.add_submodule(types)?;
          72  +
    /* PythonServerModuleGenerator.kt:149 */
   47     73   
    let socket = ::pyo3::types::PyModule::new(py, "socket")?;
   48     74   
    socket.add_class::<::aws_smithy_http_server_python::PySocket>()?;
   49     75   
    ::pyo3::py_run!(
   50     76   
        py,
   51     77   
        socket,
   52     78   
        "import sys; sys.modules['misc.socket'] = socket"
   53     79   
    );
   54     80   
    m.add_submodule(socket)?;
          81  +
    /* PythonServerModuleGenerator.kt:166 */
   55     82   
    let logging = ::pyo3::types::PyModule::new(py, "logging")?;
   56     83   
    logging.add_function(::pyo3::wrap_pyfunction!(
   57     84   
        ::aws_smithy_http_server_python::py_tracing_event,
   58     85   
        m
   59     86   
    )?)?;
   60     87   
    logging.add_class::<::aws_smithy_http_server_python::PyTracingHandler>()?;
   61     88   
    ::pyo3::py_run!(
   62     89   
        py,
   63     90   
        logging,
   64     91   
        "import sys; sys.modules['misc.logging'] = logging"
   65     92   
    );
   66     93   
    m.add_submodule(logging)?;
          94  +
    /* PythonServerModuleGenerator.kt:183 */
   67     95   
    let middleware = ::pyo3::types::PyModule::new(py, "middleware")?;
   68     96   
    middleware.add_class::<::aws_smithy_http_server_python::PyRequest>()?;
   69     97   
    middleware.add_class::<::aws_smithy_http_server_python::PyResponse>()?;
   70     98   
    middleware.add_class::<::aws_smithy_http_server_python::PyMiddlewareException>()?;
   71     99   
    pyo3::py_run!(
   72    100   
        py,
   73    101   
        middleware,
   74    102   
        "import sys; sys.modules['misc.middleware'] = middleware"
   75    103   
    );
   76    104   
    m.add_submodule(middleware)?;
         105  +
    /* PythonServerModuleGenerator.kt:201 */
   77    106   
    let tls = ::pyo3::types::PyModule::new(py, "tls")?;
   78    107   
    tls.add_class::<::aws_smithy_http_server_python::tls::PyTlsConfig>()?;
   79    108   
    pyo3::py_run!(py, tls, "import sys; sys.modules['misc.tls'] = tls");
   80    109   
    m.add_submodule(tls)?;
         110  +
    /* PythonServerModuleGenerator.kt:217 */
   81    111   
    let aws_lambda = ::pyo3::types::PyModule::new(py, "aws_lambda")?;
   82    112   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyLambdaContext>()?;
   83    113   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientApplication>()?;
   84    114   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientContext>()?;
   85    115   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyCognitoIdentity>()?;
   86    116   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyConfig>()?;
   87    117   
    pyo3::py_run!(
   88    118   
        py,
   89    119   
        aws_lambda,
   90    120   
        "import sys; sys.modules['misc.aws_lambda'] = aws_lambda"
   91    121   
    );
   92    122   
    m.add_submodule(aws_lambda)?;
         123  +
    /* PythonServerModuleGenerator.kt:238 */
   93    124   
    m.add_class::<crate::python_server_application::App>()?;
         125  +
    /* PythonServerModuleGenerator.kt:243 */
   94    126   
    m.add("CODEGEN_VERSION", "ci")?;
         127  +
    /* PythonServerModuleGenerator.kt:58 */
   95    128   
    Ok(())
         129  +
    /* PythonServerModuleGenerator.kt:41 */
   96    130   
}

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

@@ -1,1 +306,312 @@
    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 `ResponseCodeDefaultOperation`.
    3      4   
pub(crate) async fn response_code_default_operation(
    4      5   
    input: crate::input::ResponseCodeDefaultOperationInput,
    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::ResponseCodeDefaultOperationOutput,
    9     10   
    crate::error::ResponseCodeDefaultOperationError,
   10     11   
> {
   11     12   
    // Async block used to run the handler and catch any Python error.
   12     13   
    let result = if handler.is_coroutine {
   13     14   
        ::tracing::trace!(
   14     15   
            name = "response_code_default_operation",
   15     16   
            "executing python handler coroutine"
   16     17   
        );
   17     18   
        let result = ::pyo3::Python::with_gil(|py| {
   18     19   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   19     20   
            let coroutine = if handler.args == 1 {
   20     21   
                pyhandler.call1((input,))?
   21     22   
            } else {
   22     23   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   23     24   
            };
   24     25   
            ::pyo3_asyncio::tokio::into_future(coroutine)
   25     26   
        })?;
   26     27   
        result.await.and_then(|r| {
   27     28   
            ::pyo3::Python::with_gil(|py| {
   28     29   
                r.extract::<crate::output::ResponseCodeDefaultOperationOutput>(py)
   29     30   
            })
   30     31   
        })
   31     32   
    } else {
   32     33   
        ::tracing::trace!(
   33     34   
            name = "response_code_default_operation",
   34     35   
            "executing python handler function"
   35     36   
        );
   36     37   
        ::pyo3::Python::with_gil(|py| {
   37     38   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   38     39   
            let output = if handler.args == 1 {
   39     40   
                pyhandler.call1((input,))?
   40     41   
            } else {
   41     42   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   42     43   
            };
   43     44   
            output.extract::<crate::output::ResponseCodeDefaultOperationOutput>()
   44     45   
        })
   45     46   
    };
   46     47   
    // Catch and record a Python traceback.
   47     48   
    result.map_err(|e| {
   48     49   
        let rich_py_err =
   49     50   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
   50     51   
                e.clone_ref(py)
   51     52   
            }));
   52     53   
        ::tracing::error!(error = ?rich_py_err, "handler error");
   53     54   
        e.into()
   54     55   
    })
   55     56   
}
   56     57   
          58  +
/* PythonServerOperationHandlerGenerator.kt:61 */
   57     59   
/// Python handler for operation `ResponseCodeHttpFallbackOperation`.
   58     60   
pub(crate) async fn response_code_http_fallback_operation(
   59     61   
    input: crate::input::ResponseCodeHttpFallbackOperationInput,
   60     62   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
   61     63   
    handler: ::aws_smithy_http_server_python::PyHandler,
   62     64   
) -> std::result::Result<
   63     65   
    crate::output::ResponseCodeHttpFallbackOperationOutput,
   64     66   
    crate::error::ResponseCodeHttpFallbackOperationError,
   65     67   
> {
   66     68   
    // Async block used to run the handler and catch any Python error.
   67     69   
    let result = if handler.is_coroutine {
   68     70   
        ::tracing::trace!(
   69     71   
            name = "response_code_http_fallback_operation",
   70     72   
            "executing python handler coroutine"
   71     73   
        );
   72     74   
        let result = ::pyo3::Python::with_gil(|py| {
   73     75   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   74     76   
            let coroutine = if handler.args == 1 {
   75     77   
                pyhandler.call1((input,))?
   76     78   
            } else {
   77     79   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   78     80   
            };
   79     81   
            ::pyo3_asyncio::tokio::into_future(coroutine)
   80     82   
        })?;
   81     83   
        result.await.and_then(|r| {
   82     84   
            ::pyo3::Python::with_gil(|py| {
   83     85   
                r.extract::<crate::output::ResponseCodeHttpFallbackOperationOutput>(py)
   84     86   
            })
   85     87   
        })
   86     88   
    } else {
   87     89   
        ::tracing::trace!(
   88     90   
            name = "response_code_http_fallback_operation",
   89     91   
            "executing python handler function"
   90     92   
        );
   91     93   
        ::pyo3::Python::with_gil(|py| {
   92     94   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   93     95   
            let output = if handler.args == 1 {
   94     96   
                pyhandler.call1((input,))?
   95     97   
            } else {
   96     98   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   97     99   
            };
   98    100   
            output.extract::<crate::output::ResponseCodeHttpFallbackOperationOutput>()
   99    101   
        })
  100    102   
    };
  101    103   
    // Catch and record a Python traceback.
  102    104   
    result.map_err(|e| {
  103    105   
        let rich_py_err =
  104    106   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  105    107   
                e.clone_ref(py)
  106    108   
            }));
  107    109   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  108    110   
        e.into()
  109    111   
    })
  110    112   
}
  111    113   
         114  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  112    115   
/// Python handler for operation `ResponseCodeRequiredOperation`.
  113    116   
pub(crate) async fn response_code_required_operation(
  114    117   
    input: crate::input::ResponseCodeRequiredOperationInput,
  115    118   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  116    119   
    handler: ::aws_smithy_http_server_python::PyHandler,
  117    120   
) -> std::result::Result<
  118    121   
    crate::output::ResponseCodeRequiredOperationOutput,
  119    122   
    crate::error::ResponseCodeRequiredOperationError,
  120    123   
> {
  121    124   
    // Async block used to run the handler and catch any Python error.
  122    125   
    let result = if handler.is_coroutine {
  123    126   
        ::tracing::trace!(
  124    127   
            name = "response_code_required_operation",
  125    128   
            "executing python handler coroutine"
  126    129   
        );
  127    130   
        let result = ::pyo3::Python::with_gil(|py| {
  128    131   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  129    132   
            let coroutine = if handler.args == 1 {
  130    133   
                pyhandler.call1((input,))?
  131    134   
            } else {
  132    135   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  133    136   
            };
  134    137   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  135    138   
        })?;
  136    139   
        result.await.and_then(|r| {
  137    140   
            ::pyo3::Python::with_gil(|py| {
  138    141   
                r.extract::<crate::output::ResponseCodeRequiredOperationOutput>(py)
  139    142   
            })
  140    143   
        })
  141    144   
    } else {
  142    145   
        ::tracing::trace!(
  143    146   
            name = "response_code_required_operation",
  144    147   
            "executing python handler function"
  145    148   
        );
  146    149   
        ::pyo3::Python::with_gil(|py| {
  147    150   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  148    151   
            let output = if handler.args == 1 {
  149    152   
                pyhandler.call1((input,))?
  150    153   
            } else {
  151    154   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  152    155   
            };
  153    156   
            output.extract::<crate::output::ResponseCodeRequiredOperationOutput>()
  154    157   
        })
  155    158   
    };
  156    159   
    // Catch and record a Python traceback.
  157    160   
    result.map_err(|e| {
  158    161   
        let rich_py_err =
  159    162   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  160    163   
                e.clone_ref(py)
  161    164   
            }));
  162    165   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  163    166   
        e.into()
  164    167   
    })
  165    168   
}
  166    169   
         170  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  167    171   
/// Python handler for operation `RequiredHeaderCollectionOperation`.
  168    172   
pub(crate) async fn required_header_collection_operation(
  169    173   
    input: crate::input::RequiredHeaderCollectionOperationInput,
  170    174   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  171    175   
    handler: ::aws_smithy_http_server_python::PyHandler,
  172    176   
) -> std::result::Result<
  173    177   
    crate::output::RequiredHeaderCollectionOperationOutput,
  174    178   
    crate::error::RequiredHeaderCollectionOperationError,
  175    179   
> {
  176    180   
    // Async block used to run the handler and catch any Python error.
  177    181   
    let result = if handler.is_coroutine {
  178    182   
        ::tracing::trace!(
  179    183   
            name = "required_header_collection_operation",
  180    184   
            "executing python handler coroutine"
  181    185   
        );
  182    186   
        let result = ::pyo3::Python::with_gil(|py| {
  183    187   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  184    188   
            let coroutine = if handler.args == 1 {
  185    189   
                pyhandler.call1((input,))?
  186    190   
            } else {
  187    191   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  188    192   
            };
  189    193   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  190    194   
        })?;
  191    195   
        result.await.and_then(|r| {
  192    196   
            ::pyo3::Python::with_gil(|py| {
  193    197   
                r.extract::<crate::output::RequiredHeaderCollectionOperationOutput>(py)
  194    198   
            })
  195    199   
        })
  196    200   
    } else {
  197    201   
        ::tracing::trace!(
  198    202   
            name = "required_header_collection_operation",
  199    203   
            "executing python handler function"
  200    204   
        );
  201    205   
        ::pyo3::Python::with_gil(|py| {
  202    206   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  203    207   
            let output = if handler.args == 1 {
  204    208   
                pyhandler.call1((input,))?
  205    209   
            } else {
  206    210   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  207    211   
            };
  208    212   
            output.extract::<crate::output::RequiredHeaderCollectionOperationOutput>()
  209    213   
        })
  210    214   
    };
  211    215   
    // Catch and record a Python traceback.
  212    216   
    result.map_err(|e| {
  213    217   
        let rich_py_err =
  214    218   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  215    219   
                e.clone_ref(py)
  216    220   
            }));
  217    221   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  218    222   
        e.into()
  219    223   
    })
  220    224   
}
  221    225   
         226  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  222    227   
/// Python handler for operation `RequiredInnerShapeOperation`.
  223    228   
pub(crate) async fn required_inner_shape_operation(
  224    229   
    input: crate::input::RequiredInnerShapeOperationInput,
  225    230   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  226    231   
    handler: ::aws_smithy_http_server_python::PyHandler,
  227    232   
) -> std::result::Result<
  228    233   
    crate::output::RequiredInnerShapeOperationOutput,
  229    234   
    crate::error::RequiredInnerShapeOperationError,
  230    235   
> {
  231    236   
    // Async block used to run the handler and catch any Python error.
  232    237   
    let result = if handler.is_coroutine {
  233    238   
        ::tracing::trace!(
  234    239   
            name = "required_inner_shape_operation",
  235    240   
            "executing python handler coroutine"
  236    241   
        );
  237    242   
        let result = ::pyo3::Python::with_gil(|py| {
  238    243   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  239    244   
            let coroutine = if handler.args == 1 {
  240    245   
                pyhandler.call1((input,))?
  241    246   
            } else {
  242    247   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  243    248   
            };
  244    249   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  245    250   
        })?;
  246    251   
        result.await.and_then(|r| {
  247    252   
            ::pyo3::Python::with_gil(|py| {
  248    253   
                r.extract::<crate::output::RequiredInnerShapeOperationOutput>(py)
  249    254   
            })
  250    255   
        })
  251    256   
    } else {
  252    257   
        ::tracing::trace!(
  253    258   
            name = "required_inner_shape_operation",
  254    259   
            "executing python handler function"
  255    260   
        );
  256    261   
        ::pyo3::Python::with_gil(|py| {
  257    262   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  258    263   
            let output = if handler.args == 1 {
  259    264   
                pyhandler.call1((input,))?
  260    265   
            } else {
  261    266   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  262    267   
            };
  263    268   
            output.extract::<crate::output::RequiredInnerShapeOperationOutput>()
  264    269   
        })
  265    270   
    };
  266    271   
    // Catch and record a Python traceback.
  267    272   
    result.map_err(|e| {
  268    273   
        let rich_py_err =
  269    274   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  270    275   
                e.clone_ref(py)
  271    276   
            }));
  272    277   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  273    278   
        e.into()
  274    279   
    })
  275    280   
}
  276    281   
         282  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  277    283   
/// Python handler for operation `TypeComplexityOperation`.
  278    284   
pub(crate) async fn type_complexity_operation(
  279    285   
    input: crate::input::TypeComplexityOperationInput,
  280    286   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  281    287   
    handler: ::aws_smithy_http_server_python::PyHandler,
  282    288   
) -> std::result::Result<
  283    289   
    crate::output::TypeComplexityOperationOutput,
  284    290   
    crate::error::TypeComplexityOperationError,
  285    291   
> {
  286    292   
    // Async block used to run the handler and catch any Python error.

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

@@ -1,1 +272,296 @@
    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 misc import input
   12     14   
/// from misc import output
          15  +
/* PythonApplicationGenerator.kt:406 */
   13     16   
/// from misc import error
          17  +
/* PythonApplicationGenerator.kt:408 */
   14     18   
/// from misc import middleware
   15     19   
/// from misc 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.required_header_collection_operation
   30     35   
/// def required_header_collection_operation(input: input::RequiredHeaderCollectionOperationInput, ctx: Context) -> output::RequiredHeaderCollectionOperationOutput:
   31     36   
///     raise NotImplementedError
   32     37   
///
   33     38   
/// # This operation tests that (de)serializing required values from a nested
   34     39   
/// # shape works correctly.
   35     40   
/// @app.required_inner_shape_operation
   36     41   
/// def required_inner_shape_operation(input: input::RequiredInnerShapeOperationInput, ctx: Context) -> output::RequiredInnerShapeOperationOutput:
   37     42   
///     raise NotImplementedError
   38     43   
///
   39     44   
/// # This operation tests that the response code defaults to 200 when no other
   40     45   
/// # code is set.
   41     46   
/// @app.response_code_default_operation
   42     47   
/// def response_code_default_operation(input: input::ResponseCodeDefaultOperationInput, ctx: Context) -> output::ResponseCodeDefaultOperationOutput:
   43     48   
///     raise NotImplementedError
   44     49   
///
   45     50   
/// # This operation tests that the response code defaults to `@http`'s code.
   46     51   
/// @app.response_code_http_fallback_operation
   47     52   
/// def response_code_http_fallback_operation(input: input::ResponseCodeHttpFallbackOperationInput, ctx: Context) -> output::ResponseCodeHttpFallbackOperationOutput:
   48     53   
///     raise NotImplementedError
   49     54   
///
   50     55   
/// # This operation tests that `@httpResponseCode` is `@required`
   51     56   
/// # and is used over `@http's` code.
   52     57   
/// @app.response_code_required_operation
   53     58   
/// def response_code_required_operation(input: input::ResponseCodeRequiredOperationInput, ctx: Context) -> output::ResponseCodeRequiredOperationOutput:
   54     59   
///     raise NotImplementedError
   55     60   
///
   56     61   
/// # An operation whose shapes generate complex Rust types.
   57     62   
/// # See https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity.
   58     63   
/// @app.type_complexity_operation
   59     64   
/// def type_complexity_operation(input: input::TypeComplexityOperationInput, ctx: Context) -> output::TypeComplexityOperationOutput:
   60     65   
///     raise NotImplementedError
          66  +
/* PythonApplicationGenerator.kt:428 */
   61     67   
///
   62     68   
/// app.run()
   63     69   
/// ```
   64     70   
///
   65     71   
/// Any of operations above can be written as well prepending the `async` keyword and
   66     72   
/// the Python application will automatically handle it and schedule it on the event loop for you.
          73  +
/* PythonApplicationGenerator.kt:112 */
   67     74   
#[::pyo3::pyclass]
   68     75   
#[derive(Debug)]
   69     76   
/// :generic Ctx:
   70     77   
/// :extends typing.Generic\[Ctx\]:
   71     78   
/// :rtype None:
   72     79   
pub struct App {
   73     80   
    handlers: ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler>,
   74     81   
    middlewares: Vec<::aws_smithy_http_server_python::PyMiddlewareHandler>,
   75     82   
    context: Option<::pyo3::PyObject>,
   76     83   
    workers: ::parking_lot::Mutex<Vec<::pyo3::PyObject>>,
   77     84   
}
          85  +
/* PythonApplicationGenerator.kt:149 */
   78     86   
impl Default for App {
   79     87   
    fn default() -> Self {
   80     88   
        Self {
   81     89   
            handlers: Default::default(),
   82     90   
            middlewares: vec![],
   83     91   
            context: None,
   84     92   
            workers: ::parking_lot::Mutex::new(vec![]),
   85     93   
        }
   86     94   
    }
   87     95   
}
          96  +
/* PythonApplicationGenerator.kt:131 */
   88     97   
impl Clone for App {
   89     98   
    fn clone(&self) -> Self {
   90     99   
        Self {
   91    100   
            handlers: self.handlers.clone(),
   92    101   
            middlewares: self.middlewares.clone(),
   93    102   
            context: self.context.clone(),
   94    103   
            workers: ::parking_lot::Mutex::new(vec![]),
   95    104   
        }
   96    105   
    }
   97    106   
}
         107  +
/* PythonApplicationGenerator.kt:168 */
   98    108   
impl ::aws_smithy_http_server_python::PyApp for App {
         109  +
    /* PythonApplicationGenerator.kt:174 */
   99    110   
    fn workers(&self) -> &::parking_lot::Mutex<Vec<::pyo3::PyObject>> {
  100    111   
        &self.workers
  101    112   
    }
  102    113   
    fn context(&self) -> &Option<::pyo3::PyObject> {
  103    114   
        &self.context
  104    115   
    }
  105    116   
    fn handlers(
  106    117   
        &mut self,
  107    118   
    ) -> &mut ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler> {
  108    119   
        &mut self.handlers
  109    120   
    }
         121  +
    /* PythonApplicationGenerator.kt:189 */
  110    122   
    fn build_service(
  111    123   
        &mut self,
  112    124   
        event_loop: &::pyo3::PyAny,
  113    125   
    ) -> ::pyo3::PyResult<
  114    126   
        ::tower::util::BoxCloneService<
  115    127   
            ::http::Request<::aws_smithy_http_server::body::Body>,
  116    128   
            ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  117    129   
            std::convert::Infallible,
  118    130   
        >,
  119    131   
    > {
         132  +
        /* PythonApplicationGenerator.kt:201 */
  120    133   
        let builder = crate::service::MiscService::builder_without_plugins();
         134  +
        /* PythonApplicationGenerator.kt:209 */
  121    135   
        let required_header_collection_operation_locals =
  122    136   
            ::pyo3_asyncio::TaskLocals::new(event_loop);
  123    137   
        let handler = self
  124    138   
            .handlers
  125    139   
            .get("required_header_collection_operation")
  126    140   
            .expect("Python handler for operation `required_header_collection_operation` not found")
  127    141   
            .clone();
  128    142   
        let builder = builder.required_header_collection_operation(move |input, state| {
  129    143   
            ::pyo3_asyncio::tokio::scope(
  130    144   
                required_header_collection_operation_locals.clone(),
  131    145   
                crate::python_operation_adaptor::required_header_collection_operation(
  132    146   
                    input,
  133    147   
                    state,
  134    148   
                    handler.clone(),
  135    149   
                ),
  136    150   
            )
  137    151   
        });
         152  +
        /* PythonApplicationGenerator.kt:209 */
  138    153   
        let required_inner_shape_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  139    154   
        let handler = self
  140    155   
            .handlers
  141    156   
            .get("required_inner_shape_operation")
  142    157   
            .expect("Python handler for operation `required_inner_shape_operation` not found")
  143    158   
            .clone();
  144    159   
        let builder = builder.required_inner_shape_operation(move |input, state| {
  145    160   
            ::pyo3_asyncio::tokio::scope(
  146    161   
                required_inner_shape_operation_locals.clone(),
  147    162   
                crate::python_operation_adaptor::required_inner_shape_operation(
  148    163   
                    input,
  149    164   
                    state,
  150    165   
                    handler.clone(),
  151    166   
                ),
  152    167   
            )
  153    168   
        });
         169  +
        /* PythonApplicationGenerator.kt:209 */
  154    170   
        let response_code_default_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  155    171   
        let handler = self
  156    172   
            .handlers
  157    173   
            .get("response_code_default_operation")
  158    174   
            .expect("Python handler for operation `response_code_default_operation` not found")
  159    175   
            .clone();
  160    176   
        let builder = builder.response_code_default_operation(move |input, state| {
  161    177   
            ::pyo3_asyncio::tokio::scope(
  162    178   
                response_code_default_operation_locals.clone(),
  163    179   
                crate::python_operation_adaptor::response_code_default_operation(
  164    180   
                    input,
  165    181   
                    state,
  166    182   
                    handler.clone(),
  167    183   
                ),
  168    184   
            )
  169    185   
        });
         186  +
        /* PythonApplicationGenerator.kt:209 */
  170    187   
        let response_code_http_fallback_operation_locals =
  171    188   
            ::pyo3_asyncio::TaskLocals::new(event_loop);
  172    189   
        let handler = self
  173    190   
            .handlers
  174    191   
            .get("response_code_http_fallback_operation")
  175    192   
            .expect(
  176    193   
                "Python handler for operation `response_code_http_fallback_operation` not found",
  177    194   
            )
  178    195   
            .clone();
  179    196   
        let builder = builder.response_code_http_fallback_operation(move |input, state| {
  180    197   
            ::pyo3_asyncio::tokio::scope(
  181    198   
                response_code_http_fallback_operation_locals.clone(),
  182    199   
                crate::python_operation_adaptor::response_code_http_fallback_operation(
  183    200   
                    input,
  184    201   
                    state,
  185    202   
                    handler.clone(),
  186    203   
                ),
  187    204   
            )
  188    205   
        });
         206  +
        /* PythonApplicationGenerator.kt:209 */
  189    207   
        let response_code_required_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  190    208   
        let handler = self
  191    209   
            .handlers
  192    210   
            .get("response_code_required_operation")
  193    211   
            .expect("Python handler for operation `response_code_required_operation` not found")
  194    212   
            .clone();
  195    213   
        let builder = builder.response_code_required_operation(move |input, state| {
  196    214   
            ::pyo3_asyncio::tokio::scope(
  197    215   
                response_code_required_operation_locals.clone(),
  198    216   
                crate::python_operation_adaptor::response_code_required_operation(
  199    217   
                    input,
  200    218   
                    state,
  201    219   
                    handler.clone(),
  202    220   
                ),
  203    221   
            )
  204    222   
        });
         223  +
        /* PythonApplicationGenerator.kt:209 */
  205    224   
        let type_complexity_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  206    225   
        let handler = self
  207    226   
            .handlers
  208    227   
            .get("type_complexity_operation")
  209    228   
            .expect("Python handler for operation `type_complexity_operation` not found")
  210    229   
            .clone();
  211    230   
        let builder = builder.type_complexity_operation(move |input, state| {
  212    231   
            ::pyo3_asyncio::tokio::scope(
  213    232   
                type_complexity_operation_locals.clone(),
  214    233   
                crate::python_operation_adaptor::type_complexity_operation(
  215    234   
                    input,
  216    235   
                    state,
  217    236   
                    handler.clone(),
  218    237   
                ),
  219    238   
            )
  220    239   
        });
         240  +
        /* PythonApplicationGenerator.kt:220 */
  221    241   
        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"));
  222    242   
  223    243   
        {
  224    244   
            use ::tower::Layer;
  225    245   
            ::tracing::trace!("adding middlewares to rust python router");
  226    246   
            let mut middlewares = self.middlewares.clone();
  227    247   
            // Reverse the middlewares, so they run with same order as they defined
  228    248   
            middlewares.reverse();
  229    249   
            for handler in middlewares {
  230    250   
                ::tracing::trace!(name = &handler.name, "adding python middleware");
  231    251   
                let locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  232    252   
                let layer = ::aws_smithy_http_server_python::PyMiddlewareLayer::<
  233    253   
                    ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  234    254   
                >::new(handler, locals);
  235    255   
                service = ::tower::util::BoxCloneService::new(layer.layer(service));
  236    256   
            }
  237    257   
        }
  238    258   
        Ok(service)
         259  +
        /* PythonApplicationGenerator.kt:189 */
  239    260   
    }
         261  +
    /* PythonApplicationGenerator.kt:168 */
  240    262   
}
         263  +
/* PythonApplicationGenerator.kt:247 */
  241    264   
#[::pyo3::pymethods]
  242    265   
impl App {
         266  +
    /* PythonApplicationGenerator.kt:260 */
  243    267   
    /// Create a new [App].
  244    268   
    #[new]
  245    269   
    pub fn new() -> Self {
  246    270   
        Self::default()
  247    271   
    }
  248    272   
  249    273   
    /// Register a context object that will be shared between handlers.
  250    274   
    ///
  251    275   
    /// :param context Ctx:
  252    276   
    /// :rtype None:
@@ -295,319 +409,440 @@
  315    339   
        py: pyo3::Python,
  316    340   
        socket: &pyo3::PyCell<::aws_smithy_http_server_python::PySocket>,
  317    341   
        worker_number: isize,
  318    342   
        tls: Option<::aws_smithy_http_server_python::tls::PyTlsConfig>,
  319    343   
    ) -> pyo3::PyResult<()> {
  320    344   
        use ::aws_smithy_http_server_python::PyApp;
  321    345   
        let event_loop = self.configure_python_event_loop(py)?;
  322    346   
        let service = self.build_and_configure_service(py, event_loop)?;
  323    347   
        self.start_hyper_worker(py, socket, event_loop, service, worker_number, tls)
  324    348   
    }
         349  +
    /* PythonApplicationGenerator.kt:366 */
  325    350   
    /// Method to register `required_header_collection_operation` Python implementation inside the handlers map.
  326    351   
    /// It can be used as a function decorator in Python.
  327    352   
    ///
  328    353   
    /// :param func typing.Union\[typing.Callable\[\[misc.input.RequiredHeaderCollectionOperationInput, Ctx\], typing.Union\[misc.output.RequiredHeaderCollectionOperationOutput, typing.Awaitable\[misc.output.RequiredHeaderCollectionOperationOutput\]\]\], typing.Callable\[\[misc.input.RequiredHeaderCollectionOperationInput\], typing.Union\[misc.output.RequiredHeaderCollectionOperationOutput, typing.Awaitable\[misc.output.RequiredHeaderCollectionOperationOutput\]\]\]\]:
  329    354   
    /// :rtype None:
  330    355   
    #[pyo3(text_signature = "($self, func)")]
  331    356   
    pub fn required_header_collection_operation(
  332    357   
        &mut self,
  333    358   
        py: ::pyo3::Python,
  334    359   
        func: ::pyo3::PyObject,
  335    360   
    ) -> ::pyo3::PyResult<()> {
  336    361   
        use ::aws_smithy_http_server_python::PyApp;
  337    362   
        self.register_operation(py, "required_header_collection_operation", func)
  338    363   
    }
         364  +
    /* PythonApplicationGenerator.kt:366 */
  339    365   
    /// Method to register `required_inner_shape_operation` Python implementation inside the handlers map.
  340    366   
    /// It can be used as a function decorator in Python.
  341    367   
    ///
  342    368   
    /// :param func typing.Union\[typing.Callable\[\[misc.input.RequiredInnerShapeOperationInput, Ctx\], typing.Union\[misc.output.RequiredInnerShapeOperationOutput, typing.Awaitable\[misc.output.RequiredInnerShapeOperationOutput\]\]\], typing.Callable\[\[misc.input.RequiredInnerShapeOperationInput\], typing.Union\[misc.output.RequiredInnerShapeOperationOutput, typing.Awaitable\[misc.output.RequiredInnerShapeOperationOutput\]\]\]\]:
  343    369   
    /// :rtype None:
  344    370   
    #[pyo3(text_signature = "($self, func)")]
  345    371   
    pub fn required_inner_shape_operation(
  346    372   
        &mut self,
  347    373   
        py: ::pyo3::Python,
  348    374   
        func: ::pyo3::PyObject,
  349    375   
    ) -> ::pyo3::PyResult<()> {
  350    376   
        use ::aws_smithy_http_server_python::PyApp;
  351    377   
        self.register_operation(py, "required_inner_shape_operation", func)
  352    378   
    }
         379  +
    /* PythonApplicationGenerator.kt:366 */
  353    380   
    /// Method to register `response_code_default_operation` Python implementation inside the handlers map.
  354    381   
    /// It can be used as a function decorator in Python.
  355    382   
    ///
  356    383   
    /// :param func typing.Union\[typing.Callable\[\[misc.input.ResponseCodeDefaultOperationInput, Ctx\], typing.Union\[misc.output.ResponseCodeDefaultOperationOutput, typing.Awaitable\[misc.output.ResponseCodeDefaultOperationOutput\]\]\], typing.Callable\[\[misc.input.ResponseCodeDefaultOperationInput\], typing.Union\[misc.output.ResponseCodeDefaultOperationOutput, typing.Awaitable\[misc.output.ResponseCodeDefaultOperationOutput\]\]\]\]:
  357    384   
    /// :rtype None:
  358    385   
    #[pyo3(text_signature = "($self, func)")]
  359    386   
    pub fn response_code_default_operation(
  360    387   
        &mut self,
  361    388   
        py: ::pyo3::Python,
  362    389   
        func: ::pyo3::PyObject,
  363    390   
    ) -> ::pyo3::PyResult<()> {
  364    391   
        use ::aws_smithy_http_server_python::PyApp;
  365    392   
        self.register_operation(py, "response_code_default_operation", func)
  366    393   
    }
         394  +
    /* PythonApplicationGenerator.kt:366 */
  367    395   
    /// Method to register `response_code_http_fallback_operation` Python implementation inside the handlers map.
  368    396   
    /// It can be used as a function decorator in Python.
  369    397   
    ///
  370    398   
    /// :param func typing.Union\[typing.Callable\[\[misc.input.ResponseCodeHttpFallbackOperationInput, Ctx\], typing.Union\[misc.output.ResponseCodeHttpFallbackOperationOutput, typing.Awaitable\[misc.output.ResponseCodeHttpFallbackOperationOutput\]\]\], typing.Callable\[\[misc.input.ResponseCodeHttpFallbackOperationInput\], typing.Union\[misc.output.ResponseCodeHttpFallbackOperationOutput, typing.Awaitable\[misc.output.ResponseCodeHttpFallbackOperationOutput\]\]\]\]:
  371    399   
    /// :rtype None:
  372    400   
    #[pyo3(text_signature = "($self, func)")]
  373    401   
    pub fn response_code_http_fallback_operation(
  374    402   
        &mut self,
  375    403   
        py: ::pyo3::Python,
  376    404   
        func: ::pyo3::PyObject,
  377    405   
    ) -> ::pyo3::PyResult<()> {
  378    406   
        use ::aws_smithy_http_server_python::PyApp;
  379    407   
        self.register_operation(py, "response_code_http_fallback_operation", func)
  380    408   
    }
         409  +
    /* PythonApplicationGenerator.kt:366 */
  381    410   
    /// Method to register `response_code_required_operation` Python implementation inside the handlers map.
  382    411   
    /// It can be used as a function decorator in Python.
  383    412   
    ///
  384    413   
    /// :param func typing.Union\[typing.Callable\[\[misc.input.ResponseCodeRequiredOperationInput, Ctx\], typing.Union\[misc.output.ResponseCodeRequiredOperationOutput, typing.Awaitable\[misc.output.ResponseCodeRequiredOperationOutput\]\]\], typing.Callable\[\[misc.input.ResponseCodeRequiredOperationInput\], typing.Union\[misc.output.ResponseCodeRequiredOperationOutput, typing.Awaitable\[misc.output.ResponseCodeRequiredOperationOutput\]\]\]\]:
  385    414   
    /// :rtype None:
  386    415   
    #[pyo3(text_signature = "($self, func)")]
  387    416   
    pub fn response_code_required_operation(
  388    417   
        &mut self,
  389    418   
        py: ::pyo3::Python,
  390    419   
        func: ::pyo3::PyObject,
  391    420   
    ) -> ::pyo3::PyResult<()> {
  392    421   
        use ::aws_smithy_http_server_python::PyApp;
  393    422   
        self.register_operation(py, "response_code_required_operation", func)
  394    423   
    }
         424  +
    /* PythonApplicationGenerator.kt:366 */
  395    425   
    /// Method to register `type_complexity_operation` Python implementation inside the handlers map.
  396    426   
    /// It can be used as a function decorator in Python.
  397    427   
    ///
  398    428   
    /// :param func typing.Union\[typing.Callable\[\[misc.input.TypeComplexityOperationInput, Ctx\], typing.Union\[misc.output.TypeComplexityOperationOutput, typing.Awaitable\[misc.output.TypeComplexityOperationOutput\]\]\], typing.Callable\[\[misc.input.TypeComplexityOperationInput\], typing.Union\[misc.output.TypeComplexityOperationOutput, typing.Awaitable\[misc.output.TypeComplexityOperationOutput\]\]\]\]:
  399    429   
    /// :rtype None:
  400    430   
    #[pyo3(text_signature = "($self, func)")]
  401    431   
    pub fn type_complexity_operation(
  402    432   
        &mut self,
  403    433   
        py: ::pyo3::Python,
  404    434   
        func: ::pyo3::PyObject,
  405    435   
    ) -> ::pyo3::PyResult<()> {
  406    436   
        use ::aws_smithy_http_server_python::PyApp;
  407    437   
        self.register_operation(py, "type_complexity_operation", func)
  408    438   
    }
         439  +
    /* PythonApplicationGenerator.kt:247 */
  409    440   
}

tmp-codegen-diff/codegen-server-test-python/misc/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 [`MiscService`].
    3      4   
///
    4      5   
/// Constructed via [`MiscService::builder`].
    5      6   
pub struct MiscServiceBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    required_header_collection_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    required_inner_shape_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
    8      9   
    response_code_default_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
    9     10   
    response_code_http_fallback_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
   10     11   
    response_code_required_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
   11     12   
    type_complexity_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
@@ -1509,1510 +1568,1570 @@
 1529   1530   
            "aws.protocoltests.misc",
 1530   1531   
            "MiscService",
 1531   1532   
        );
 1532   1533   
 1533   1534   
    const VERSION: Option<&'static str> = Some("");
 1534   1535   
 1535   1536   
    type Protocol = ::aws_smithy_http_server::protocol::rest_json_1::RestJson1;
 1536   1537   
 1537   1538   
    type Operations = Operation;
 1538   1539   
}
        1540  +
/* ServiceConfigGenerator.kt:178 */
 1539   1541   
/// Configuration for the [`MiscService`]. This is the central place where to register and
 1540   1542   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
 1541   1543   
///
 1542   1544   
/// ```rust,no_run
 1543   1545   
/// # use misc::MiscServiceConfig;
 1544   1546   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
 1545   1547   
/// # use ::tower::layer::util::Identity;
 1546   1548   
/// # let authentication_plugin = IdentityPlugin;
 1547   1549   
/// # let authorization_plugin = IdentityPlugin;
 1548   1550   
/// # let server_request_id_provider_layer = Identity::new();
@@ -1624,1626 +1683,1686 @@
 1644   1646   
 1645   1647   
    /// Build the configuration.
 1646   1648   
    pub fn build(self) -> super::MiscServiceConfig<L, H, M> {
 1647   1649   
        super::MiscServiceConfig {
 1648   1650   
            layers: self.layers,
 1649   1651   
            http_plugins: self.http_plugins,
 1650   1652   
            model_plugins: self.model_plugins,
 1651   1653   
        }
 1652   1654   
    }
 1653   1655   
}
        1656  +
/* ScopeMacroGenerator.kt:81 */
 1654   1657   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
 1655   1658   
///
 1656   1659   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
 1657   1660   
/// of the service and any operations _not_ specified will be placed in the opposing group.
 1658   1661   
///
 1659   1662   
/// # Example
 1660   1663   
///
 1661   1664   
/// ```rust
 1662   1665   
/// scope! {
 1663   1666   
///     /// Includes [`RequiredHeaderCollectionOperation`], excluding all other operations.

tmp-codegen-diff/codegen-server-test-python/misc/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/misc/rust-server-codegen-python/src/unconstrained.rs

@@ -1,1 +22,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
    3      3   
pub(crate) mod header_set_unconstrained {
    4      4   
           5  +
    /* UnconstrainedCollectionGenerator.kt:77 */
    5      6   
    #[derive(Debug, Clone)]
    6      7   
    pub(crate) struct HeaderSetUnconstrained(pub(crate) std::vec::Vec<::std::string::String>);
    7      8   
    8      9   
    impl From<HeaderSetUnconstrained>
    9     10   
        for crate::constrained::MaybeConstrained<crate::model::HeaderSet>
   10     11   
    {
   11     12   
        fn from(value: HeaderSetUnconstrained) -> Self {
   12     13   
            Self::Unconstrained(value)
   13     14   
        }
   14     15   
    }
          16  +
    /* UnconstrainedCollectionGenerator.kt:97 */
   15     17   
    impl std::convert::TryFrom<HeaderSetUnconstrained> for crate::model::HeaderSet {
          18  +
        /* UnconstrainedCollectionGenerator.kt:98 */
   16     19   
        type Error = crate::model::header_set_internal::ConstraintViolation;
          20  +
        /* UnconstrainedCollectionGenerator.kt:100 */
   17     21   
        fn try_from(value: HeaderSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          22  +
            /* UnconstrainedCollectionGenerator.kt:185 */
   18     23   
            let inner = value.0;
          24  +
            /* UnconstrainedCollectionGenerator.kt:189 */
   19     25   
            Self::try_from(inner)
          26  +
            /* UnconstrainedCollectionGenerator.kt:100 */
   20     27   
        }
          28  +
        /* UnconstrainedCollectionGenerator.kt:97 */
   21     29   
    }
          30  +
          31  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   22     32   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_casing/rust-server-codegen-python/Cargo.toml

@@ -4,4 +56,56 @@
   24     24   
version = "0.3"
   25     25   
[dependencies.http]
   26     26   
version = "0.2.9"
   27     27   
[dependencies.mime]
   28     28   
version = "0.3"
   29     29   
[dependencies.parking_lot]
   30     30   
version = "0.12"
   31     31   
[dependencies.pin-project-lite]
   32     32   
version = "0.2"
   33     33   
[dependencies.pyo3]
   34         -
version = "0.18"
          34  +
version = "0.20"
   35     35   
[dependencies.pyo3-asyncio]
   36         -
version = "0.18"
          36  +
version = "0.20"
   37     37   
features = ["attributes", "tokio-runtime"]
   38     38   
[dependencies.tower]
   39     39   
version = "0.4"
   40     40   
[dependencies.tracing]
   41     41   
version = "0.1"
   42     42   
[dev-dependencies.hyper]
   43     43   
version = "0.14.12"
   44     44   
[dev-dependencies.tokio]
   45     45   
version = "1.23.1"
   46     46   
[features]

tmp-codegen-diff/codegen-server-test-python/naming_test_casing/rust-server-codegen-python/src/error.rs

@@ -1,1 +161,280 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerOperationErrorGenerator.kt:63 */
    2      3   
/// Error type for the `DoNothing` operation.
           4  +
/* ServerOperationErrorGenerator.kt:64 */
    3      5   
/// Each variant represents an error that can occur for the `DoNothing` operation.
           6  +
/* RustType.kt:516 */
    4      7   
#[derive(::std::fmt::Debug)]
    5         -
pub enum DoNothingError {
           8  +
pub /* ServerOperationErrorGenerator.kt:66 */ enum DoNothingError {
           9  +
    /* ServerOperationErrorGenerator.kt:68 */
    6     10   
    #[allow(missing_docs)] // documentation missing in model
          11  +
    /* ServerOperationErrorGenerator.kt:71 */
    7     12   
    InternalServerError(crate::error::InternalServerError),
          13  +
    /* ServerOperationErrorGenerator.kt:66 */
    8     14   
}
          15  +
/* ServerOperationErrorGenerator.kt:75 */
    9     16   
impl ::std::fmt::Display for DoNothingError {
          17  +
    /* ServerOperationErrorGenerator.kt:76 */
   10     18   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          19  +
        /* ServerOperationErrorGenerator.kt:139 */
   11     20   
        match &self {
   12         -
            DoNothingError::InternalServerError(_inner) => _inner.fmt(f),
          21  +
            /* ServerOperationErrorGenerator.kt:142 */
          22  +
            DoNothingError::InternalServerError(_inner) =>
          23  +
            /* ServerOperationErrorGenerator.kt:78 */
          24  +
            {
          25  +
                _inner.fmt(f)
          26  +
            }
          27  +
            /* ServerOperationErrorGenerator.kt:139 */
   13     28   
        }
          29  +
        /* ServerOperationErrorGenerator.kt:76 */
   14     30   
    }
          31  +
    /* ServerOperationErrorGenerator.kt:75 */
   15     32   
}
          33  +
/* ServerOperationErrorGenerator.kt:83 */
   16     34   
impl DoNothingError {
          35  +
    /* ServerOperationErrorGenerator.kt:87 */
   17     36   
    /// Returns `true` if the error kind is `DoNothingError::InternalServerError`.
          37  +
    /* ServerOperationErrorGenerator.kt:88 */
   18     38   
    pub fn is_internal_server_error(&self) -> bool {
          39  +
        /* ServerOperationErrorGenerator.kt:89 */
   19     40   
        matches!(&self, DoNothingError::InternalServerError(_))
          41  +
        /* ServerOperationErrorGenerator.kt:88 */
   20     42   
    }
          43  +
    /* ServerOperationErrorGenerator.kt:92 */
   21     44   
    /// Returns the error name string by matching the correct variant.
          45  +
    /* ServerOperationErrorGenerator.kt:93 */
   22     46   
    pub fn name(&self) -> &'static str {
          47  +
        /* ServerOperationErrorGenerator.kt:139 */
   23     48   
        match &self {
   24         -
            DoNothingError::InternalServerError(_inner) => _inner.name(),
          49  +
            /* ServerOperationErrorGenerator.kt:142 */
          50  +
            DoNothingError::InternalServerError(_inner) =>
          51  +
            /* ServerOperationErrorGenerator.kt:95 */
          52  +
            {
          53  +
                _inner.name()
   25     54   
            }
          55  +
            /* ServerOperationErrorGenerator.kt:139 */
   26     56   
        }
          57  +
        /* ServerOperationErrorGenerator.kt:93 */
          58  +
    }
          59  +
    /* ServerOperationErrorGenerator.kt:83 */
   27     60   
}
          61  +
/* ServerOperationErrorGenerator.kt:100 */
   28     62   
impl ::std::error::Error for DoNothingError {
          63  +
    /* ServerOperationErrorGenerator.kt:101 */
   29     64   
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
          65  +
        /* ServerOperationErrorGenerator.kt:139 */
   30     66   
        match &self {
   31         -
            DoNothingError::InternalServerError(_inner) => Some(_inner),
          67  +
            /* ServerOperationErrorGenerator.kt:142 */
          68  +
            DoNothingError::InternalServerError(_inner) =>
          69  +
            /* ServerOperationErrorGenerator.kt:103 */
          70  +
            {
          71  +
                Some(_inner)
          72  +
            }
          73  +
            /* ServerOperationErrorGenerator.kt:139 */
   32     74   
        }
          75  +
        /* ServerOperationErrorGenerator.kt:101 */
   33     76   
    }
          77  +
    /* ServerOperationErrorGenerator.kt:100 */
   34     78   
}
          79  +
/* ServerOperationErrorGenerator.kt:110 */
   35     80   
impl ::std::convert::From<crate::error::InternalServerError> for crate::error::DoNothingError {
          81  +
    /* ServerOperationErrorGenerator.kt:111 */
   36     82   
    fn from(variant: crate::error::InternalServerError) -> crate::error::DoNothingError {
          83  +
        /* ServerOperationErrorGenerator.kt:112 */
   37     84   
        Self::InternalServerError(variant)
          85  +
        /* ServerOperationErrorGenerator.kt:111 */
   38     86   
    }
          87  +
    /* ServerOperationErrorGenerator.kt:110 */
   39     88   
}
   40     89   
          90  +
/* PythonServerOperationErrorGenerator.kt:38 */
   41     91   
impl ::std::convert::From<::pyo3::PyErr> for crate::error::DoNothingError {
   42     92   
    fn from(variant: ::pyo3::PyErr) -> crate::error::DoNothingError {
   43     93   
        ::pyo3::Python::with_gil(|py| {
   44     94   
            let error = variant.value(py);
   45     95   
   46     96   
            crate::error::InternalServerError {
   47     97   
                message: error.to_string(),
   48     98   
            }
   49     99   
            .into()
   50    100   
        })
   51    101   
    }
   52    102   
}
   53    103   
         104  +
/* RustType.kt:516 */
   54    105   
#[::pyo3::pyclass(extends = ::pyo3::exceptions::PyException)]
         106  +
/* PythonServerStructureGenerator.kt:63 */
   55    107   
/// :param message str:
   56    108   
/// :rtype None:
         109  +
/* StructureGenerator.kt:197 */
   57    110   
#[allow(missing_docs)] // documentation missing in model
         111  +
/* RustType.kt:516 */
   58    112   
#[derive(
   59    113   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   60    114   
)]
   61         -
pub struct InternalServerError {
         115  +
pub /* StructureGenerator.kt:201 */ struct InternalServerError {
         116  +
    /* RustType.kt:516 */
   62    117   
    #[pyo3(get, set)]
         118  +
    /* PythonServerStructureGenerator.kt:80 */
   63    119   
    /// :type str:
         120  +
    /* StructureGenerator.kt:231 */
   64    121   
    #[allow(missing_docs)] // documentation missing in model
   65    122   
    pub message: ::std::string::String,
         123  +
    /* StructureGenerator.kt:201 */
   66    124   
}
         125  +
/* RustType.kt:516 */
   67    126   
#[allow(clippy::new_without_default)]
         127  +
/* RustType.kt:516 */
   68    128   
#[allow(clippy::too_many_arguments)]
         129  +
/* RustType.kt:516 */
   69    130   
#[::pyo3::pymethods]
         131  +
/* PythonServerStructureGenerator.kt:88 */
   70    132   
impl InternalServerError {
   71    133   
    #[new]
   72    134   
    pub fn new(message: ::std::string::String) -> Self {
   73    135   
        Self { message }
   74    136   
    }
   75    137   
    fn __repr__(&self) -> String {
   76    138   
        format!("{self:?}")
   77    139   
    }
   78    140   
    fn __str__(&self) -> String {
   79    141   
        format!("{self:?}")
   80    142   
    }
   81    143   
}
         144  +
/* ErrorImplGenerator.kt:99 */
   82    145   
impl InternalServerError {
         146  +
    /* ErrorImplGenerator.kt:128 */
   83    147   
    /// Returns the error message.
   84    148   
    pub fn message(&self) -> &str {
   85    149   
        &self.message
   86    150   
    }
         151  +
    /* ErrorImplGenerator.kt:141 */
   87    152   
    #[doc(hidden)]
   88    153   
    /// Returns the error name.
   89    154   
    pub fn name(&self) -> &'static str {
   90    155   
        "InternalServerError"
   91    156   
    }
         157  +
    /* ErrorImplGenerator.kt:99 */
   92    158   
}
         159  +
/* ErrorImplGenerator.kt:153 */
   93    160   
impl ::std::fmt::Display for InternalServerError {
         161  +
    /* ErrorImplGenerator.kt:154 */
   94    162   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         163  +
        /* ErrorImplGenerator.kt:161 */
   95    164   
        ::std::write!(f, "InternalServerError")?;
         165  +
        /* ErrorImplGenerator.kt:166 */
   96    166   
        {
         167  +
            /* ErrorImplGenerator.kt:167 */
   97    168   
            ::std::write!(f, ": {}", &self.message)?;
         169  +
            /* ErrorImplGenerator.kt:166 */
   98    170   
        }
         171  +
        /* ErrorImplGenerator.kt:171 */
   99    172   
        Ok(())
         173  +
        /* ErrorImplGenerator.kt:154 */
  100    174   
    }
         175  +
    /* ErrorImplGenerator.kt:153 */
  101    176   
}
         177  +
/* ErrorImplGenerator.kt:175 */
  102    178   
impl ::std::error::Error for InternalServerError {}
         179  +
/* ServerCodegenVisitor.kt:370 */
  103    180   
impl InternalServerError {
  104         -
    /// Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         181  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         182  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
  105    183   
    pub fn builder() -> crate::error::internal_server_error::Builder {
         184  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
  106    185   
        crate::error::internal_server_error::Builder::default()
         186  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
  107    187   
    }
         188  +
    /* ServerCodegenVisitor.kt:370 */
  108    189   
}
  109         -
/// See [`InternalServerError`](crate::error::InternalServerError).
         190  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`InternalServerError`](crate::error::InternalServerError).
  110    191   
pub mod internal_server_error {
  111    192   
         193  +
    /* RustType.kt:516 */
  112    194   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  113         -
    /// Holds one variant for each of the ways the builder can fail.
  114         -
         195  +
    /// /* ServerBuilderConstraintViolations.kt:72 */Holds one variant for each of the ways the builder can fail.
         196  +
    /* ServerBuilderConstraintViolations.kt:75 */
  115    197   
    #[allow(clippy::enum_variant_names)]
  116    198   
    pub enum ConstraintViolation {
  117         -
        /// `message` was not provided but it is required when building `InternalServerError`.
         199  +
        /// /* ServerBuilderConstraintViolations.kt:138 */`message` was not provided but it is required when building `InternalServerError`.
         200  +
        /* ServerBuilderConstraintViolations.kt:143 */
  118    201   
        MissingMessage,
         202  +
        /* ServerBuilderConstraintViolations.kt:75 */
  119    203   
    }
         204  +
    /* ServerBuilderConstraintViolations.kt:117 */
  120    205   
    impl ::std::fmt::Display for ConstraintViolation {
         206  +
        /* ServerBuilderConstraintViolations.kt:118 */
  121    207   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         208  +
            /* ServerBuilderConstraintViolations.kt:119 */
  122    209   
            match self {
  123         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
  124         -
            }
         210  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
         211  +
            /* ServerBuilderConstraintViolations.kt:119 */}
         212  +
            /* ServerBuilderConstraintViolations.kt:118 */
  125    213   
        }
         214  +
        /* ServerBuilderConstraintViolations.kt:117 */
  126    215   
    }
         216  +
    /* ServerBuilderConstraintViolations.kt:84 */
  127    217   
    impl ::std::error::Error for ConstraintViolation {}
         218  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:254 */
  128    219   
    impl ::std::convert::TryFrom<Builder> for crate::error::InternalServerError {
  129    220   
        type Error = ConstraintViolation;
  130    221   
  131    222   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  132    223   
            builder.build()
  133    224   
        }
  134    225   
    }
  135         -
    /// A builder for [`InternalServerError`](crate::error::InternalServerError).
         226  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`InternalServerError`](crate::error::InternalServerError).
         227  +
    /* RustType.kt:516 */
  136    228   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         229  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  137    230   
    pub struct Builder {
         231  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  138    232   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         233  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  139    234   
    }
         235  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  140    236   
    impl Builder {
         237  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  141    238   
        #[allow(missing_docs)] // documentation missing in model
         239  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  142    240   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  143         -
            self.message = Some(input);
         241  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         242  +
            self.message =
         243  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:246 */Some(
         244  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         245  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:246 */)
         246  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  144    247   
            self
         248  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  145    249   
        }
  146         -
        /// Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
  147         -
        ///
         250  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
         251  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:152 */
  148    252   
        /// The builder fails to construct a [`InternalServerError`](crate::error::InternalServerError) if you do not provide a value for all non-`Option`al members.
  149    253   
        ///
         254  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
  150    255   
        pub fn build(self) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  151    256   
            self.build_enforcing_required_and_enum_traits()
  152    257   
        }
         258  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  153    259   
        fn build_enforcing_required_and_enum_traits(
  154    260   
            self,
  155    261   
        ) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  156         -
            Ok(crate::error::InternalServerError {
  157         -
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  158         -
            })
         262  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:175 */
         263  +
            Ok(
         264  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         265  +
                crate::error::InternalServerError {
         266  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
         267  +
                    message: self
         268  +
                        .message
         269  +
                        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:202 */
         270  +
                        .ok_or(ConstraintViolation::MissingMessage)?,
         271  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         272  +
                }, /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:175 */
         273  +
            )
         274  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  159    275   
        }
         276  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  160    277   
    }
         278  +
         279  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  161    280   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_casing/rust-server-codegen-python/src/input.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   
#[::pyo3::pyclass]
           4  +
/* PythonServerStructureGenerator.kt:63 */
    3      5   
/// :rtype None:
           6  +
/* StructureGenerator.kt:197 */
    4      7   
#[allow(missing_docs)] // documentation missing in model
           8  +
/* RustType.kt:516 */
    5      9   
#[derive(
    6     10   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    7     11   
)]
    8         -
pub struct DoNothingInput {}
          12  +
pub /* StructureGenerator.kt:201 */ struct DoNothingInput {/* StructureGenerator.kt:201 */}
          13  +
/* RustType.kt:516 */
    9     14   
#[allow(clippy::new_without_default)]
          15  +
/* RustType.kt:516 */
   10     16   
#[allow(clippy::too_many_arguments)]
          17  +
/* RustType.kt:516 */
   11     18   
#[::pyo3::pymethods]
          19  +
/* PythonServerStructureGenerator.kt:88 */
   12     20   
impl DoNothingInput {
   13     21   
    #[new]
   14     22   
    pub fn new() -> Self {
   15     23   
        Self {}
   16     24   
    }
   17     25   
    fn __repr__(&self) -> String {
   18     26   
        format!("{self:?}")
   19     27   
    }
   20     28   
    fn __str__(&self) -> String {
   21     29   
        format!("{self:?}")
   22     30   
    }
   23     31   
}
          32  +
/* PythonServerStructureGenerator.kt:111 */
   24     33   
impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<DoNothingInput> {
   25     34   
    fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
   26     35   
        ob.extract::<DoNothingInput>().map(Box::new)
   27     36   
    }
   28     37   
}
   29     38   
   30     39   
impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<DoNothingInput> {
   31     40   
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
   32     41   
        (*self).into_py(py)
   33     42   
    }
   34     43   
}
          44  +
/* ServerStructureConstrainedTraitImpl.kt:21 */
   35     45   
impl crate::constrained::Constrained for crate::input::DoNothingInput {
   36     46   
    type Unconstrained = crate::input::do_nothing_input_internal::Builder;
   37     47   
}
          48  +
/* ServerCodegenVisitor.kt:370 */
   38     49   
impl DoNothingInput {
   39         -
    /// Creates a new builder-style object to manufacture [`DoNothingInput`](crate::input::DoNothingInput).
          50  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`DoNothingInput`](crate::input::DoNothingInput).
          51  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   40     52   
    pub fn builder() -> crate::input::do_nothing_input::Builder {
          53  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
   41     54   
        crate::input::do_nothing_input::Builder::default()
          55  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   42     56   
    }
          57  +
    /* ServerCodegenVisitor.kt:370 */
   43     58   
}
   44         -
/// See [`DoNothingInput`](crate::input::DoNothingInput).
          59  +
/// /* ServerBuilderGenerator.kt:171 */See [`DoNothingInput`](crate::input::DoNothingInput).
   45     60   
pub(crate) mod do_nothing_input_internal {
   46     61   
          62  +
    /* ServerBuilderGenerator.kt:461 */
   47     63   
    impl ::std::convert::From<Builder> for crate::input::DoNothingInput {
   48     64   
        fn from(builder: Builder) -> Self {
   49     65   
            builder.build()
   50     66   
        }
   51     67   
    }
   52         -
    /// A builder for [`DoNothingInput`](crate::input::DoNothingInput).
          68  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`DoNothingInput`](crate::input::DoNothingInput).
          69  +
    /* RustType.kt:516 */
   53     70   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
   54         -
    pub(crate) struct Builder {}
          71  +
    /* ServerBuilderGenerator.kt:211 */
          72  +
    pub(crate) struct Builder {/* ServerBuilderGenerator.kt:211 */}
          73  +
    /* ServerBuilderGenerator.kt:215 */
   55     74   
    impl Builder {
   56         -
        /// Consumes the builder and constructs a [`DoNothingInput`](crate::input::DoNothingInput).
          75  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`DoNothingInput`](crate::input::DoNothingInput).
          76  +
        /* ServerBuilderGenerator.kt:271 */
   57     77   
        pub fn build(self) -> crate::input::DoNothingInput {
   58     78   
            self.build_enforcing_all_constraints()
   59     79   
        }
          80  +
        /* ServerBuilderGenerator.kt:283 */
   60     81   
        fn build_enforcing_all_constraints(self) -> crate::input::DoNothingInput {
   61         -
            crate::input::DoNothingInput {}
          82  +
            /* ServerBuilderGenerator.kt:542 */
          83  +
            crate::input::DoNothingInput {
          84  +
            /* ServerBuilderGenerator.kt:542 */}
          85  +
            /* ServerBuilderGenerator.kt:283 */
   62     86   
        }
          87  +
        /* ServerBuilderGenerator.kt:215 */
   63     88   
    }
          89  +
          90  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   64     91   
}
   65         -
/// See [`DoNothingInput`](crate::input::DoNothingInput).
          92  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`DoNothingInput`](crate::input::DoNothingInput).
   66     93   
pub mod do_nothing_input {
   67     94   
          95  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:269 */
   68     96   
    impl ::std::convert::From<Builder> for crate::input::DoNothingInput {
   69     97   
        fn from(builder: Builder) -> Self {
   70     98   
            builder.build()
   71     99   
        }
   72    100   
    }
   73         -
    /// A builder for [`DoNothingInput`](crate::input::DoNothingInput).
         101  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`DoNothingInput`](crate::input::DoNothingInput).
         102  +
    /* RustType.kt:516 */
   74    103   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
   75         -
    pub struct Builder {}
         104  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
         105  +
    pub struct Builder {/* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */}
         106  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   76    107   
    impl Builder {
   77         -
        /// Consumes the builder and constructs a [`DoNothingInput`](crate::input::DoNothingInput).
         108  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`DoNothingInput`](crate::input::DoNothingInput).
         109  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
   78    110   
        pub fn build(self) -> crate::input::DoNothingInput {
   79    111   
            self.build_enforcing_required_and_enum_traits()
   80    112   
        }
         113  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   81    114   
        fn build_enforcing_required_and_enum_traits(self) -> crate::input::DoNothingInput {
   82         -
            crate::input::DoNothingInput {}
         115  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         116  +
            crate::input::DoNothingInput {
         117  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */}
         118  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   83    119   
        }
         120  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   84    121   
    }
         122  +
         123  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   85    124   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_casing/rust-server-codegen-python/src/lib.rs

@@ -1,1 +52,53 @@
   13     13   
#![allow(clippy::result_large_err)]
   14     14   
#![allow(clippy::unnecessary_map_on_constructor)]
   15     15   
#![allow(rustdoc::bare_urls)]
   16     16   
#![allow(rustdoc::redundant_explicit_links)]
   17     17   
#![allow(rustdoc::invalid_html_tags)]
   18     18   
#![forbid(unsafe_code)]
   19     19   
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
   20     20   
//! Confounds model generation machinery with lots of problematic casing
   21     21   
   22     22   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
          23  +
/* ServerRootGenerator.kt:65 */
   23     24   
//! A fast and customizable Rust implementation of the AcronymInsideService Smithy service.
   24     25   
//!
   25     26   
//! # Using AcronymInsideService
   26     27   
//!
   27     28   
//! The primary entrypoint is [`AcronymInsideService`]: it satisfies the [`Service<http::Request, Response = http::Response>`](::tower::Service)
   28     29   
//! trait and therefore can be handed to a [`hyper` server](https://github.com/hyperium/hyper) via [`AcronymInsideService::into_make_service`]
   29     30   
//! or used in AWS Lambda
   30     31   
#![cfg_attr(
   31     32   
    feature = "aws-lambda",
   32     33   
    doc = " via [`LambdaHandler`](crate::server::routing::LambdaHandler)."
@@ -167,168 +256,269 @@
  187    188   
//! }
  188    189   
//!
  189    190   
//! ```
  190    191   
//!
  191    192   
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
  192    193   
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
  193    194   
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
  194    195   
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
  195    196   
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  196    197   
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         198  +
/* ServerRootGenerator.kt:261 */
  197    199   
pub use crate::service::{
  198    200   
    AcronymInsideService, AcronymInsideServiceBuilder, AcronymInsideServiceConfig,
  199    201   
    AcronymInsideServiceConfigBuilder, MissingOperationsError,
  200    202   
};
  201    203   
  202         -
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
         204  +
/// /* ServerRustModule.kt:55 */Contains the types that are re-exported from the `aws-smithy-http-server` crate.
  203    205   
pub mod server {
  204    206   
    // Re-export all types from the `aws-smithy-http-server` crate.
  205    207   
    pub use ::aws_smithy_http_server::*;
         208  +
         209  +
    /* CodegenDelegator.kt:200 */
  206    210   
}
  207    211   
         212  +
/* CrateVersionCustomization.kt:23 */
  208    213   
/// Crate version number.
  209    214   
pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
  210    215   
  211         -
/// All error types that operations can return. Documentation on these types is copied from the model.
         216  +
/// /* ServerRustModule.kt:55 */All error types that operations can return. Documentation on these types is copied from the model.
  212    217   
pub mod error;
  213    218   
  214         -
/// Input structures for operations. Documentation on these types is copied from the model.
         219  +
/// /* ServerRustModule.kt:55 */Input structures for operations. Documentation on these types is copied from the model.
  215    220   
pub mod input;
  216    221   
  217         -
/// All operations that this crate can perform.
         222  +
/// /* ServerRustModule.kt:55 */All operations that this crate can perform.
  218    223   
pub mod operation;
  219    224   
         225  +
/* ServerRustModule.kt:79 */
  220    226   
/// A collection of types representing each operation defined in the service closure.
  221    227   
///
  222    228   
/// The [plugin system](::aws_smithy_http_server::plugin) makes use of these
  223    229   
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
  224    230   
/// parameterize [`Plugin`](::aws_smithy_http_server::plugin::Plugin) implementations. Their traits, such as
  225    231   
/// [`OperationShape`](::aws_smithy_http_server::operation::OperationShape), can be used to provide
  226    232   
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
  227    233   
pub mod operation_shape;
  228    234   
  229         -
/// Output structures for operations. Documentation on these types is copied from the model.
         235  +
/// /* ServerRustModule.kt:55 */Output structures for operations. Documentation on these types is copied from the model.
  230    236   
pub mod output;
  231    237   
  232         -
/// Export PyO3 symbols in the shared library
         238  +
/// /* PythonServerRustModule.kt:23 */Export PyO3 symbols in the shared library
  233    239   
pub mod python_module_export;
  234    240   
  235         -
/// Operation adapters that delegate to Python handlers.
         241  +
/// /* PythonServerRustModule.kt:23 */Operation adapters that delegate to Python handlers.
  236    242   
pub mod python_operation_adaptor;
  237    243   
  238         -
/// Python server and application implementation.
         244  +
/// /* PythonServerRustModule.kt:23 */Python server and application implementation.
  239    245   
pub mod python_server_application;
  240    246   
         247  +
/* RustModule.kt:172 */
  241    248   
mod service;
  242    249   
  243         -
/// Data primitives referenced by other data types.
         250  +
/// /* ServerRustModule.kt:55 */Data primitives referenced by other data types.
  244    251   
pub mod types;
  245    252   
  246         -
/// Constrained types for constrained shapes.
         253  +
/// /* ServerRustModule.kt:55 */Constrained types for constrained shapes.
         254  +
/* RustModule.kt:172 */
  247    255   
mod constrained;
  248    256   
  249    257   
pub(crate) mod protocol_serde;
  250    258   
  251         -
/// Re-exported Python types from supporting crates.
         259  +
/// /* PythonServerCodegenDecorator.kt:57 */Re-exported Python types from supporting crates.
         260  +
/* PythonServerCodegenDecorator.kt:58 */
  252    261   
pub mod python_types {
         262  +
    /* PythonServerCodegenDecorator.kt:59 */
  253    263   
    pub use ::aws_smithy_http_server_python::types::Blob;
         264  +
    /* PythonServerCodegenDecorator.kt:60 */
  254    265   
    pub use ::aws_smithy_http_server_python::types::DateTime;
         266  +
    /* PythonServerCodegenDecorator.kt:61 */
  255    267   
    pub use ::aws_smithy_http_server_python::types::Document;
         268  +
    /* PythonServerCodegenDecorator.kt:58 */
  256    269   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_casing/rust-server-codegen-python/src/operation.rs

@@ -1,1 +31,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:266 */
    2      3   
static CONTENT_TYPE_DONOTHING: std::sync::LazyLock<::mime::Mime> = std::sync::LazyLock::new(|| {
    3      4   
    "application/x-amz-json-1.1"
    4      5   
        .parse::<::mime::Mime>()
    5      6   
        .expect("BUG: MIME parsing failed, content_type is not valid")
    6      7   
});
    7      8   
::pin_project_lite::pin_project! {
    8      9   
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
    9     10   
    /// [`DoNothingInput`](crate::input::DoNothingInput) using modelled bindings.
   10     11   
    pub struct DoNothingInputFuture {
   11     12   
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::DoNothingInput, ::aws_smithy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
@@ -40,41 +116,119 @@
   60     61   
            |e: ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection| {
   61     62   
                ::tracing::debug!(error = %e, "failed to deserialize request");
   62     63   
                ::aws_smithy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
   63     64   
            },
   64     65   
        );
   65     66   
        DoNothingInputFuture {
   66     67   
            inner: Box::pin(fut),
   67     68   
        }
   68     69   
    }
   69     70   
}
          71  +
/* ServerHttpBoundProtocolGenerator.kt:329 */
   70     72   
impl
   71     73   
    ::aws_smithy_http_server::response::IntoResponse<
   72     74   
        ::aws_smithy_http_server::protocol::aws_json_11::AwsJson1_1,
   73     75   
    > for crate::output::DoNothingOutput
   74     76   
{
   75     77   
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   76     78   
        match crate::protocol_serde::shape_do_nothing::ser_do_nothing_http_response(self) {
   77     79   
            Ok(response) => response,
   78     80   
            Err(e) => {
   79     81   
                ::tracing::error!(error = %e, "failed to serialize response");
   80     82   
                ::aws_smithy_http_server::response::IntoResponse::<
   81     83   
                    ::aws_smithy_http_server::protocol::aws_json_11::AwsJson1_1,
   82     84   
                >::into_response(
   83     85   
                    ::aws_smithy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(
   84     86   
                        e,
   85     87   
                    ),
   86     88   
                )
   87     89   
            }
   88     90   
        }
   89     91   
    }
   90     92   
}
          93  +
/* ServerHttpBoundProtocolGenerator.kt:350 */
   91     94   
impl
   92     95   
    ::aws_smithy_http_server::response::IntoResponse<
   93     96   
        ::aws_smithy_http_server::protocol::aws_json_11::AwsJson1_1,
   94     97   
    > for crate::error::DoNothingError
   95     98   
{
   96     99   
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   97    100   
        match crate::protocol_serde::shape_do_nothing::ser_do_nothing_http_error(&self) {
   98    101   
            Ok(mut response) => {
   99    102   
                response.extensions_mut().insert(
  100    103   
                    ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),

tmp-codegen-diff/codegen-server-test-python/naming_test_casing/rust-server-codegen-python/src/operation_shape.rs

@@ -1,1 +0,28 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerOperationGenerator.kt:48 */
    2      3   
#[allow(missing_docs)] // documentation missing in model
           4  +
                       /* ServerOperationGenerator.kt:55 */
    3      5   
pub struct DoNothing;
    4      6   
    5      7   
impl ::aws_smithy_http_server::operation::OperationShape for DoNothing {
    6      8   
    const ID: ::aws_smithy_http_server::shape_id::ShapeId =
    7      9   
        ::aws_smithy_http_server::shape_id::ShapeId::new("casing#DoNothing", "casing", "DoNothing");
    8     10   
    9     11   
    type Input = crate::input::DoNothingInput;
   10     12   
    type Output = crate::output::DoNothingOutput;
   11     13   
    type Error = crate::error::DoNothingError;
   12     14   
}
   13     15   
   14     16   
impl ::aws_smithy_http_server::instrumentation::sensitivity::Sensitivity for DoNothing {
   15     17   
    type RequestFmt = ::aws_smithy_http_server::instrumentation::sensitivity::DefaultRequestFmt;
   16     18   
    type ResponseFmt = ::aws_smithy_http_server::instrumentation::sensitivity::DefaultResponseFmt;
   17     19   
   18     20   
    fn request_fmt() -> Self::RequestFmt {
   19     21   
        ::aws_smithy_http_server::instrumentation::sensitivity::RequestFmt::new()
   20     22   
    }
   21     23   
   22     24   
    fn response_fmt() -> Self::ResponseFmt {
   23     25   
        ::aws_smithy_http_server::instrumentation::sensitivity::ResponseFmt::new()
   24     26   
    }
   25     27   
}
          28  +
/* ServerOperationGenerator.kt:88 */