Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

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

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

@@ -1,1 +93,150 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_operation_with_required_members_output_output_output(
    3      4   
    value: &crate::output::OperationWithRequiredMembersOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_operation_with_required_members_output::ser_operation_with_required_members_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_operation_with_required_members_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::OperationWithRequiredMembersOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* SerializerUtil.kt:42 */
   16     23   
    {
          24  +
        /* JsonSerializerGenerator.kt:423 */
   17     25   
        object
   18     26   
            .key("requiredString")
   19     27   
            .string(input.required_string.as_str());
          28  +
        /* SerializerUtil.kt:42 */
   20     29   
    }
          30  +
    /* SerializerUtil.kt:42 */
   21     31   
    {
          32  +
        /* JsonSerializerGenerator.kt:424 */
   22     33   
        object
   23     34   
            .key("requiredBoolean")
   24     35   
            .boolean(input.required_boolean);
          36  +
        /* SerializerUtil.kt:42 */
   25     37   
    }
          38  +
    /* SerializerUtil.kt:42 */
   26     39   
    {
          40  +
        /* JsonSerializerGenerator.kt:484 */
   27     41   
        let mut array_1 = object.key("requiredList").start_array();
          42  +
        /* JsonSerializerGenerator.kt:524 */
   28     43   
        for item_2 in &input.required_list {
          44  +
            /* SerializerUtil.kt:42 */
   29     45   
            {
          46  +
                /* JsonSerializerGenerator.kt:423 */
   30     47   
                array_1.value().string(item_2.as_str());
          48  +
                /* SerializerUtil.kt:42 */
   31     49   
            }
          50  +
            /* JsonSerializerGenerator.kt:524 */
   32     51   
        }
          52  +
        /* JsonSerializerGenerator.kt:486 */
   33     53   
        array_1.finish();
          54  +
        /* SerializerUtil.kt:42 */
   34     55   
    }
          56  +
    /* SerializerUtil.kt:42 */
   35     57   
    {
          58  +
        /* JsonSerializerGenerator.kt:448 */
   36     59   
        object.key("requiredTimestamp").date_time(
   37     60   
            &input.required_timestamp,
   38     61   
            ::aws_smithy_types::date_time::Format::EpochSeconds,
   39     62   
        )?;
          63  +
        /* SerializerUtil.kt:42 */
   40     64   
    }
          65  +
    /* SerializerUtil.kt:42 */
   41     66   
    {
          67  +
        /* JsonSerializerGenerator.kt:439 */
   42     68   
        object
   43     69   
            .key("requiredBlob")
   44     70   
            .string_unchecked(&::aws_smithy_types::base64::encode(&input.required_blob));
          71  +
        /* SerializerUtil.kt:42 */
   45     72   
    }
          73  +
    /* SerializerUtil.kt:42 */
   46     74   
    {
          75  +
        /* JsonSerializerGenerator.kt:432 */
   47     76   
        object.key("requiredByte").number(
   48     77   
            #[allow(clippy::useless_conversion)]
   49     78   
            ::aws_smithy_types::Number::NegInt((input.required_byte).into()),
   50     79   
        );
          80  +
        /* SerializerUtil.kt:42 */
   51     81   
    }
          82  +
    /* SerializerUtil.kt:42 */
   52     83   
    {
          84  +
        /* JsonSerializerGenerator.kt:432 */
   53     85   
        object.key("requiredShort").number(
   54     86   
            #[allow(clippy::useless_conversion)]
   55     87   
            ::aws_smithy_types::Number::NegInt((input.required_short).into()),
   56     88   
        );
          89  +
        /* SerializerUtil.kt:42 */
   57     90   
    }
          91  +
    /* SerializerUtil.kt:42 */
   58     92   
    {
          93  +
        /* JsonSerializerGenerator.kt:432 */
   59     94   
        object.key("requiredInteger").number(
   60     95   
            #[allow(clippy::useless_conversion)]
   61     96   
            ::aws_smithy_types::Number::NegInt((input.required_integer).into()),
   62     97   
        );
          98  +
        /* SerializerUtil.kt:42 */
   63     99   
    }
         100  +
    /* SerializerUtil.kt:42 */
   64    101   
    {
         102  +
        /* JsonSerializerGenerator.kt:432 */
   65    103   
        object.key("requiredLong").number(
   66    104   
            #[allow(clippy::useless_conversion)]
   67    105   
            ::aws_smithy_types::Number::NegInt((input.required_long).into()),
   68    106   
        );
         107  +
        /* SerializerUtil.kt:42 */
   69    108   
    }
         109  +
    /* SerializerUtil.kt:42 */
   70    110   
    {
         111  +
        /* JsonSerializerGenerator.kt:432 */
   71    112   
        object.key("requiredFloat").number(
   72    113   
            #[allow(clippy::useless_conversion)]
   73    114   
            ::aws_smithy_types::Number::Float((input.required_float).into()),
   74    115   
        );
         116  +
        /* SerializerUtil.kt:42 */
   75    117   
    }
         118  +
    /* SerializerUtil.kt:42 */
   76    119   
    {
         120  +
        /* JsonSerializerGenerator.kt:432 */
   77    121   
        object.key("requiredDouble").number(
   78    122   
            #[allow(clippy::useless_conversion)]
   79    123   
            ::aws_smithy_types::Number::Float((input.required_double).into()),
   80    124   
        );
         125  +
        /* SerializerUtil.kt:42 */
   81    126   
    }
         127  +
    /* SerializerUtil.kt:42 */
   82    128   
    {
         129  +
        /* JsonSerializerGenerator.kt:495 */
   83    130   
        #[allow(unused_mut)]
         131  +
        /* JsonSerializerGenerator.kt:496 */
   84    132   
        let mut object_3 = object.key("requiredMap").start_object();
         133  +
        /* JsonSerializerGenerator.kt:537 */
   85    134   
        for (key_4, value_5) in &input.required_map {
         135  +
            /* SerializerUtil.kt:42 */
   86    136   
            {
         137  +
                /* JsonSerializerGenerator.kt:423 */
   87    138   
                object_3.key(key_4.as_str()).string(value_5.as_str());
         139  +
                /* SerializerUtil.kt:42 */
   88    140   
            }
         141  +
            /* JsonSerializerGenerator.kt:537 */
   89    142   
        }
         143  +
        /* JsonSerializerGenerator.kt:515 */
   90    144   
        object_3.finish();
         145  +
        /* SerializerUtil.kt:42 */
   91    146   
    }
         147  +
    /* JsonSerializerGenerator.kt:372 */
   92    148   
    Ok(())
         149  +
    /* JsonSerializerGenerator.kt:358 */
   93    150   
}

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

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

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

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

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

@@ -1,1 +29,43 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_simple_scalar_properties_output_output_output(
    3      4   
    value: &crate::output::SimpleScalarPropertiesOutput,
    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_simple_scalar_properties_output::ser_simple_scalar_properties_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_simple_scalar_properties_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::SimpleScalarPropertiesOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.float_value {
          24  +
        /* JsonSerializerGenerator.kt:432 */
   17     25   
        object.key("floatValue").number(
   18     26   
            #[allow(clippy::useless_conversion)]
   19     27   
            ::aws_smithy_types::Number::Float((*var_1).into()),
   20     28   
        );
          29  +
        /* JsonSerializerGenerator.kt:382 */
   21     30   
    }
          31  +
    /* JsonSerializerGenerator.kt:382 */
   22     32   
    if let Some(var_2) = &input.double_value {
          33  +
        /* JsonSerializerGenerator.kt:432 */
   23     34   
        object.key("doubleValue").number(
   24     35   
            #[allow(clippy::useless_conversion)]
   25     36   
            ::aws_smithy_types::Number::Float((*var_2).into()),
   26     37   
        );
          38  +
        /* JsonSerializerGenerator.kt:382 */
   27     39   
    }
          40  +
    /* JsonSerializerGenerator.kt:372 */
   28     41   
    Ok(())
          42  +
    /* JsonSerializerGenerator.kt:358 */
   29     43   
}

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

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

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

@@ -1,1 +60,87 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
    2      3   
pub(crate) fn de_string_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
   19     23   
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
   21     27   
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
   22     29   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   23     30   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   24         -
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
   25         -
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
   26         -
                            tokens.next(),
   27         -
                        )?
   28         -
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   29         -
                        .transpose()?;
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:474 */;
          45  +
                        /* JsonParserGenerator.kt:481 */
   30     46   
                        match value {
   31     47   
                            Some(value) => {
   32     48   
                                map.insert(key, value);
   33     49   
                            }
   34     50   
                            None => {
   35     51   
                                return Err(
   36     52   
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     53   
                                        "dense map cannot contain null values",
   38     54   
                                    ),
   39     55   
                                )
   40     56   
                            }
   41     57   
                        }
          58  +
                        /* JsonParserGenerator.kt:686 */
   42     59   
                    }
          60  +
                    /* JsonParserGenerator.kt:695 */
   43     61   
                    other => {
   44     62   
                        return Err(
   45     63   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   46     64   
                                format!("expected object key or end object, found: {:?}", other),
   47     65   
                            ),
   48     66   
                        )
          67  +
                    } /* JsonParserGenerator.kt:685 */
   49     68   
                }
          69  +
                /* JsonParserGenerator.kt:684 */
   50     70   
            }
   51         -
            }
          71  +
            /* JsonParserGenerator.kt:504 */
   52     72   
            Ok(Some(map))
          73  +
            /* JsonParserGenerator.kt:713 */
   53     74   
        }
   54         -
        _ => Err(
          75  +
        /* JsonParserGenerator.kt:722 */
          76  +
        _ => {
          77  +
            /* JsonParserGenerator.kt:723 */
          78  +
            Err(
   55     79   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   56     80   
                    "expected start object or null",
   57     81   
                ),
   58         -
        ),
          82  +
            )
          83  +
            /* JsonParserGenerator.kt:722 */
          84  +
        } /* JsonParserGenerator.kt:712 */
   59     85   
    }
          86  +
    /* JsonParserGenerator.kt:460 */
   60     87   
}

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

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

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

@@ -1,1 +60,87 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
    2      3   
pub(crate) fn de_test_string_map<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
   19     23   
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
   21     27   
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
   22     29   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   23     30   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   24         -
                        let key = key.to_unescaped().map(|u| u.into_owned())?;
   25         -
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
   26         -
                            tokens.next(),
   27         -
                        )?
   28         -
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   29         -
                        .transpose()?;
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:474 */;
          45  +
                        /* JsonParserGenerator.kt:481 */
   30     46   
                        match value {
   31     47   
                            Some(value) => {
   32     48   
                                map.insert(key, value);
   33     49   
                            }
   34     50   
                            None => {
   35     51   
                                return Err(
   36     52   
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   37     53   
                                        "dense map cannot contain null values",
   38     54   
                                    ),
   39     55   
                                )
   40     56   
                            }
   41     57   
                        }
          58  +
                        /* JsonParserGenerator.kt:686 */
   42     59   
                    }
          60  +
                    /* JsonParserGenerator.kt:695 */
   43     61   
                    other => {
   44     62   
                        return Err(
   45     63   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   46     64   
                                format!("expected object key or end object, found: {:?}", other),
   47     65   
                            ),
   48     66   
                        )
          67  +
                    } /* JsonParserGenerator.kt:685 */
   49     68   
                }
          69  +
                /* JsonParserGenerator.kt:684 */
   50     70   
            }
   51         -
            }
          71  +
            /* JsonParserGenerator.kt:504 */
   52     72   
            Ok(Some(map))
          73  +
            /* JsonParserGenerator.kt:713 */
   53     74   
        }
   54         -
        _ => Err(
          75  +
        /* JsonParserGenerator.kt:722 */
          76  +
        _ => {
          77  +
            /* JsonParserGenerator.kt:723 */
          78  +
            Err(
   55     79   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   56     80   
                    "expected start object or null",
   57     81   
                ),
   58         -
        ),
          82  +
            )
          83  +
            /* JsonParserGenerator.kt:722 */
          84  +
        } /* JsonParserGenerator.kt:712 */
   59     85   
    }
          86  +
    /* JsonParserGenerator.kt:460 */
   60     87   
}

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

@@ -1,1 +67,107 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:516 */
    2      3   
pub(crate) fn de_top_level<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::top_level_internal::Builder>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* RustType.kt:516 */
   19     23   
            #[allow(unused_mut)]
          24  +
            /* JsonParserGenerator.kt:526 */
   20     25   
            let mut builder = crate::model::top_level_internal::Builder::default();
          26  +
            /* JsonParserGenerator.kt:684 */
   21     27   
            loop {
          28  +
                /* JsonParserGenerator.kt:685 */
   22     29   
                match tokens.next().transpose()? {
          30  +
                    /* JsonParserGenerator.kt:686 */
   23     31   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   24         -
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key
   25         -
                        .to_unescaped()?
   26         -
                        .as_ref()
   27         -
                    {
          32  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          33  +
                        /* JsonParserGenerator.kt:260 */
          34  +
                        match key.to_unescaped()?.as_ref() {
          35  +
                            /* JsonParserGenerator.kt:262 */
   28     36   
                            "dialog" => {
   29         -
                            if let Some(v) = crate::protocol_serde::shape_dialog::de_dialog(tokens)?
          37  +
                                /* JsonParserGenerator.kt:276 */
          38  +
                                if let Some(v) =
          39  +
                                    /* JsonParserGenerator.kt:544 */
          40  +
                                    crate::protocol_serde::shape_dialog::de_dialog(tokens)?
          41  +
                                /* JsonParserGenerator.kt:278 */
   30     42   
                                {
   31     43   
                                    builder = builder.set_dialog(v);
   32     44   
                                }
          45  +
                                /* JsonParserGenerator.kt:262 */
   33     46   
                            }
          47  +
                            /* JsonParserGenerator.kt:262 */
   34     48   
                            "dialogList" => {
          49  +
                                /* JsonParserGenerator.kt:276 */
   35     50   
                                if let Some(v) =
   36         -
                                crate::protocol_serde::shape_dialog_list::de_dialog_list(tokens)?
          51  +
                                    /* JsonParserGenerator.kt:451 */
          52  +
                                    crate::protocol_serde::shape_dialog_list::de_dialog_list(
          53  +
                                            tokens,
          54  +
                                        )?
          55  +
                                /* JsonParserGenerator.kt:278 */
   37     56   
                                {
   38     57   
                                    builder = builder.set_dialog_list(v);
   39     58   
                                }
          59  +
                                /* JsonParserGenerator.kt:262 */
   40     60   
                            }
          61  +
                            /* JsonParserGenerator.kt:262 */
   41     62   
                            "dialogMap" => {
          63  +
                                /* JsonParserGenerator.kt:276 */
   42     64   
                                if let Some(v) =
   43         -
                                crate::protocol_serde::shape_dialog_map::de_dialog_map(tokens)?
          65  +
                                    /* JsonParserGenerator.kt:509 */
          66  +
                                    crate::protocol_serde::shape_dialog_map::de_dialog_map(
          67  +
                                            tokens,
          68  +
                                        )?
          69  +
                                /* JsonParserGenerator.kt:278 */
   44     70   
                                {
   45     71   
                                    builder = builder.set_dialog_map(v);
   46     72   
                                }
          73  +
                                /* JsonParserGenerator.kt:262 */
          74  +
                            }
          75  +
                            /* JsonParserGenerator.kt:290 */
          76  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
          77  +
                        }
          78  +
                        /* JsonParserGenerator.kt:686 */
   47     79   
                    }
   48         -
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
   49         -
                    },
          80  +
                    /* JsonParserGenerator.kt:695 */
   50     81   
                    other => {
   51     82   
                        return Err(
   52     83   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   53     84   
                                format!("expected object key or end object, found: {:?}", other),
   54     85   
                            ),
   55     86   
                        )
          87  +
                    } /* JsonParserGenerator.kt:685 */
   56     88   
                }
          89  +
                /* JsonParserGenerator.kt:684 */
   57     90   
            }
   58         -
            }
          91  +
            /* JsonParserGenerator.kt:540 */
   59     92   
            Ok(Some(builder))
          93  +
            /* JsonParserGenerator.kt:713 */
   60     94   
        }
   61         -
        _ => Err(
          95  +
        /* JsonParserGenerator.kt:722 */
          96  +
        _ => {
          97  +
            /* JsonParserGenerator.kt:723 */
          98  +
            Err(
   62     99   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   63    100   
                    "expected start object or null",
   64    101   
                ),
   65         -
        ),
         102  +
            )
         103  +
            /* JsonParserGenerator.kt:722 */
         104  +
        } /* JsonParserGenerator.kt:712 */
   66    105   
    }
         106  +
    /* JsonParserGenerator.kt:516 */
   67    107   
}

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

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

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

@@ -1,1 +137,196 @@
    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 = "json_rpc10")]
           4  +
#[pyo3(name = "json_rpc10")]
    4      5   
pub fn python_library(py: ::pyo3::Python<'_>, m: &::pyo3::types::PyModule) -> ::pyo3::PyResult<()> {
           6  +
    /* PythonServerModuleGenerator.kt:65 */
    5      7   
    let input = ::pyo3::types::PyModule::new(py, "input")?;
    6      8   
    let output = ::pyo3::types::PyModule::new(py, "output")?;
    7      9   
    let error = ::pyo3::types::PyModule::new(py, "error")?;
          10  +
    /* PythonServerModuleGenerator.kt:96 */
    8     11   
    error.add_class::<crate::error::InternalServerError>()?;
          12  +
    /* PythonServerModuleGenerator.kt:96 */
    9     13   
    error.add_class::<crate::error::ValidationException>()?;
          14  +
    /* PythonServerModuleGenerator.kt:79 */
   10     15   
    let model = ::pyo3::types::PyModule::new(py, "model")?;
          16  +
    /* PythonServerModuleGenerator.kt:96 */
   11     17   
    model.add_class::<crate::model::ValidationExceptionField>()?;
          18  +
    /* PythonServerModuleGenerator.kt:96 */
   12     19   
    output.add_class::<crate::output::OperationWithNestedStructureOutput>()?;
          20  +
    /* PythonServerModuleGenerator.kt:96 */
   13     21   
    model.add_class::<crate::model::Dialog>()?;
          22  +
    /* PythonServerModuleGenerator.kt:96 */
   14     23   
    model.add_class::<crate::model::Farewell>()?;
          24  +
    /* PythonServerModuleGenerator.kt:96 */
   15     25   
    input.add_class::<crate::input::OperationWithNestedStructureInput>()?;
          26  +
    /* PythonServerModuleGenerator.kt:96 */
   16     27   
    model.add_class::<crate::model::TopLevel>()?;
          28  +
    /* PythonServerModuleGenerator.kt:96 */
   17     29   
    output.add_class::<crate::output::OperationWithRequiredMembersOutput>()?;
          30  +
    /* PythonServerModuleGenerator.kt:96 */
   18     31   
    input.add_class::<crate::input::OperationWithRequiredMembersInput>()?;
          32  +
    /* PythonServerModuleGenerator.kt:96 */
   19     33   
    output.add_class::<crate::output::OperationWithDefaultsOutput>()?;
          34  +
    /* PythonServerModuleGenerator.kt:96 */
   20     35   
    model.add_class::<crate::model::TestEnum>()?;
          36  +
    /* PythonServerModuleGenerator.kt:96 */
   21     37   
    input.add_class::<crate::input::OperationWithDefaultsInput>()?;
          38  +
    /* PythonServerModuleGenerator.kt:96 */
   22     39   
    model.add_class::<crate::model::ClientOptionalDefaults>()?;
          40  +
    /* PythonServerModuleGenerator.kt:96 */
   23     41   
    model.add_class::<crate::model::Defaults>()?;
          42  +
    /* PythonServerModuleGenerator.kt:96 */
   24     43   
    output.add_class::<crate::output::ContentTypeParametersOutput>()?;
          44  +
    /* PythonServerModuleGenerator.kt:96 */
   25     45   
    input.add_class::<crate::input::ContentTypeParametersInput>()?;
          46  +
    /* PythonServerModuleGenerator.kt:96 */
   26     47   
    output.add_class::<crate::output::PutWithContentEncodingOutput>()?;
          48  +
    /* PythonServerModuleGenerator.kt:96 */
   27     49   
    input.add_class::<crate::input::PutWithContentEncodingInput>()?;
          50  +
    /* PythonServerModuleGenerator.kt:96 */
   28     51   
    output.add_class::<crate::output::HostWithPathOperationOutput>()?;
          52  +
    /* PythonServerModuleGenerator.kt:96 */
   29     53   
    input.add_class::<crate::input::HostWithPathOperationInput>()?;
          54  +
    /* PythonServerModuleGenerator.kt:96 */
   30     55   
    output.add_class::<crate::output::EndpointWithHostLabelOperationOutput>()?;
          56  +
    /* PythonServerModuleGenerator.kt:96 */
   31     57   
    input.add_class::<crate::input::EndpointWithHostLabelOperationInput>()?;
          58  +
    /* PythonServerModuleGenerator.kt:96 */
   32     59   
    output.add_class::<crate::output::EndpointOperationOutput>()?;
          60  +
    /* PythonServerModuleGenerator.kt:96 */
   33     61   
    input.add_class::<crate::input::EndpointOperationInput>()?;
          62  +
    /* PythonServerModuleGenerator.kt:96 */
   34     63   
    output.add_class::<crate::output::JsonUnionsOutput>()?;
          64  +
    /* PythonServerModuleGenerator.kt:89 */
   35     65   
    model.add_class::<crate::model::PyUnionMarkerMyUnion>()?;
          66  +
    /* PythonServerModuleGenerator.kt:96 */
   36     67   
    model.add_class::<crate::model::GreetingStruct>()?;
          68  +
    /* PythonServerModuleGenerator.kt:96 */
   37     69   
    model.add_class::<crate::model::FooEnum>()?;
          70  +
    /* PythonServerModuleGenerator.kt:96 */
   38     71   
    input.add_class::<crate::input::JsonUnionsInput>()?;
          72  +
    /* PythonServerModuleGenerator.kt:96 */
   39     73   
    error.add_class::<crate::error::FooError>()?;
          74  +
    /* PythonServerModuleGenerator.kt:96 */
   40     75   
    error.add_class::<crate::error::ComplexError>()?;
          76  +
    /* PythonServerModuleGenerator.kt:96 */
   41     77   
    model.add_class::<crate::model::ComplexNestedErrorData>()?;
          78  +
    /* PythonServerModuleGenerator.kt:96 */
   42     79   
    error.add_class::<crate::error::InvalidGreeting>()?;
          80  +
    /* PythonServerModuleGenerator.kt:96 */
   43     81   
    output.add_class::<crate::output::GreetingWithErrorsOutput>()?;
          82  +
    /* PythonServerModuleGenerator.kt:96 */
   44     83   
    input.add_class::<crate::input::GreetingWithErrorsInput>()?;
          84  +
    /* PythonServerModuleGenerator.kt:96 */
   45     85   
    output.add_class::<crate::output::SimpleScalarPropertiesOutput>()?;
          86  +
    /* PythonServerModuleGenerator.kt:96 */
   46     87   
    input.add_class::<crate::input::SimpleScalarPropertiesInput>()?;
          88  +
    /* PythonServerModuleGenerator.kt:96 */
   47     89   
    output.add_class::<crate::output::EmptyInputAndEmptyOutputOutput>()?;
          90  +
    /* PythonServerModuleGenerator.kt:96 */
   48     91   
    input.add_class::<crate::input::EmptyInputAndEmptyOutputInput>()?;
          92  +
    /* PythonServerModuleGenerator.kt:96 */
   49     93   
    output.add_class::<crate::output::NoInputAndOutputOutput>()?;
          94  +
    /* PythonServerModuleGenerator.kt:96 */
   50     95   
    input.add_class::<crate::input::NoInputAndOutputInput>()?;
          96  +
    /* PythonServerModuleGenerator.kt:96 */
   51     97   
    output.add_class::<crate::output::NoInputAndNoOutputOutput>()?;
          98  +
    /* PythonServerModuleGenerator.kt:96 */
   52     99   
    input.add_class::<crate::input::NoInputAndNoOutputInput>()?;
         100  +
    /* PythonServerModuleGenerator.kt:105 */
   53    101   
    ::pyo3::py_run!(
   54    102   
        py,
   55    103   
        input,
   56    104   
        "import sys; sys.modules['json_rpc10.input'] = input"
   57    105   
    );
   58    106   
    m.add_submodule(input)?;
   59    107   
    ::pyo3::py_run!(
   60    108   
        py,
   61    109   
        output,
   62    110   
        "import sys; sys.modules['json_rpc10.output'] = output"
   63    111   
    );
   64    112   
    m.add_submodule(output)?;
   65    113   
    ::pyo3::py_run!(
   66    114   
        py,
   67    115   
        error,
   68    116   
        "import sys; sys.modules['json_rpc10.error'] = error"
   69    117   
    );
   70    118   
    m.add_submodule(error)?;
         119  +
    /* PythonServerModuleGenerator.kt:117 */
   71    120   
    ::pyo3::py_run!(
   72    121   
        py,
   73    122   
        model,
   74    123   
        "import sys; sys.modules['json_rpc10.model'] = model"
   75    124   
    );
   76    125   
    m.add_submodule(model)?;
         126  +
    /* PythonServerModuleGenerator.kt:129 */
   77    127   
    let types = ::pyo3::types::PyModule::new(py, "types")?;
   78    128   
    types.add_class::<::aws_smithy_http_server_python::types::Blob>()?;
   79    129   
    types.add_class::<::aws_smithy_http_server_python::types::DateTime>()?;
   80    130   
    types.add_class::<::aws_smithy_http_server_python::types::Format>()?;
   81    131   
    types.add_class::<::aws_smithy_http_server_python::types::ByteStream>()?;
   82    132   
    ::pyo3::py_run!(
   83    133   
        py,
   84    134   
        types,
   85    135   
        "import sys; sys.modules['json_rpc10.types'] = types"
   86    136   
    );
   87    137   
    m.add_submodule(types)?;
         138  +
    /* PythonServerModuleGenerator.kt:149 */
   88    139   
    let socket = ::pyo3::types::PyModule::new(py, "socket")?;
   89    140   
    socket.add_class::<::aws_smithy_http_server_python::PySocket>()?;
   90    141   
    ::pyo3::py_run!(
   91    142   
        py,
   92    143   
        socket,
   93    144   
        "import sys; sys.modules['json_rpc10.socket'] = socket"
   94    145   
    );
   95    146   
    m.add_submodule(socket)?;
         147  +
    /* PythonServerModuleGenerator.kt:166 */
   96    148   
    let logging = ::pyo3::types::PyModule::new(py, "logging")?;
   97    149   
    logging.add_function(::pyo3::wrap_pyfunction!(
   98    150   
        ::aws_smithy_http_server_python::py_tracing_event,
   99    151   
        m
  100    152   
    )?)?;
  101    153   
    logging.add_class::<::aws_smithy_http_server_python::PyTracingHandler>()?;
  102    154   
    ::pyo3::py_run!(
  103    155   
        py,
  104    156   
        logging,
  105    157   
        "import sys; sys.modules['json_rpc10.logging'] = logging"
  106    158   
    );
  107    159   
    m.add_submodule(logging)?;
         160  +
    /* PythonServerModuleGenerator.kt:183 */
  108    161   
    let middleware = ::pyo3::types::PyModule::new(py, "middleware")?;
  109    162   
    middleware.add_class::<::aws_smithy_http_server_python::PyRequest>()?;
  110    163   
    middleware.add_class::<::aws_smithy_http_server_python::PyResponse>()?;
  111    164   
    middleware.add_class::<::aws_smithy_http_server_python::PyMiddlewareException>()?;
  112    165   
    pyo3::py_run!(
  113    166   
        py,
  114    167   
        middleware,
  115    168   
        "import sys; sys.modules['json_rpc10.middleware'] = middleware"
  116    169   
    );
  117    170   
    m.add_submodule(middleware)?;
         171  +
    /* PythonServerModuleGenerator.kt:201 */
  118    172   
    let tls = ::pyo3::types::PyModule::new(py, "tls")?;
  119    173   
    tls.add_class::<::aws_smithy_http_server_python::tls::PyTlsConfig>()?;
  120    174   
    pyo3::py_run!(py, tls, "import sys; sys.modules['json_rpc10.tls'] = tls");
  121    175   
    m.add_submodule(tls)?;
         176  +
    /* PythonServerModuleGenerator.kt:217 */
  122    177   
    let aws_lambda = ::pyo3::types::PyModule::new(py, "aws_lambda")?;
  123    178   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyLambdaContext>()?;
  124    179   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientApplication>()?;
  125    180   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientContext>()?;
  126    181   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyCognitoIdentity>()?;
  127    182   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyConfig>()?;
  128    183   
    pyo3::py_run!(
  129    184   
        py,
  130    185   
        aws_lambda,
  131    186   
        "import sys; sys.modules['json_rpc10.aws_lambda'] = aws_lambda"
  132    187   
    );
  133    188   
    m.add_submodule(aws_lambda)?;
         189  +
    /* PythonServerModuleGenerator.kt:238 */
  134    190   
    m.add_class::<crate::python_server_application::App>()?;
         191  +
    /* PythonServerModuleGenerator.kt:243 */
  135    192   
    m.add("CODEGEN_VERSION", "ci")?;
         193  +
    /* PythonServerModuleGenerator.kt:58 */
  136    194   
    Ok(())
         195  +
    /* PythonServerModuleGenerator.kt:41 */
  137    196   
}

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

@@ -1,1 +725,739 @@
    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 `OperationWithNestedStructure`.
    3      4   
pub(crate) async fn operation_with_nested_structure(
    4      5   
    input: crate::input::OperationWithNestedStructureInput,
    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::OperationWithNestedStructureOutput,
    9     10   
    crate::error::OperationWithNestedStructureError,
   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 = "operation_with_nested_structure",
   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::OperationWithNestedStructureOutput>(py)
   29     30   
            })
   30     31   
        })
   31     32   
    } else {
   32     33   
        ::tracing::trace!(
   33     34   
            name = "operation_with_nested_structure",
   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::OperationWithNestedStructureOutput>()
   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 `OperationWithRequiredMembers`.
   58     60   
pub(crate) async fn operation_with_required_members(
   59     61   
    input: crate::input::OperationWithRequiredMembersInput,
   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::OperationWithRequiredMembersOutput,
   64     66   
    crate::error::OperationWithRequiredMembersError,
   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 = "operation_with_required_members",
   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::OperationWithRequiredMembersOutput>(py)
   84     86   
            })
   85     87   
        })
   86     88   
    } else {
   87     89   
        ::tracing::trace!(
   88     90   
            name = "operation_with_required_members",
   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::OperationWithRequiredMembersOutput>()
   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 `OperationWithDefaults`.
  113    116   
pub(crate) async fn operation_with_defaults(
  114    117   
    input: crate::input::OperationWithDefaultsInput,
  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::OperationWithDefaultsOutput,
  119    122   
    crate::error::OperationWithDefaultsError,
  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 = "operation_with_defaults",
  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::OperationWithDefaultsOutput>(py)
  139    142   
            })
  140    143   
        })
  141    144   
    } else {
  142    145   
        ::tracing::trace!(
  143    146   
            name = "operation_with_defaults",
  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::OperationWithDefaultsOutput>()
  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 `ContentTypeParameters`.
  168    172   
pub(crate) async fn content_type_parameters(
  169    173   
    input: crate::input::ContentTypeParametersInput,
  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::ContentTypeParametersOutput,
  174    178   
    crate::error::ContentTypeParametersError,
  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 = "content_type_parameters",
  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::ContentTypeParametersOutput>(py)
  194    198   
            })
  195    199   
        })
  196    200   
    } else {
  197    201   
        ::tracing::trace!(
  198    202   
            name = "content_type_parameters",
  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::ContentTypeParametersOutput>()
  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 `PutWithContentEncoding`.
  223    228   
pub(crate) async fn put_with_content_encoding(
  224    229   
    input: crate::input::PutWithContentEncodingInput,
  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::PutWithContentEncodingOutput,
  229    234   
    crate::error::PutWithContentEncodingError,
  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 = "put_with_content_encoding",
  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::PutWithContentEncodingOutput>(py)
  249    254   
            })
  250    255   
        })
  251    256   
    } else {
  252    257   
        ::tracing::trace!(
  253    258   
            name = "put_with_content_encoding",
  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::PutWithContentEncodingOutput>()
  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 `HostWithPathOperation`.
  278    284   
pub(crate) async fn host_with_path_operation(
  279    285   
    input: crate::input::HostWithPathOperationInput,
  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::HostWithPathOperationOutput,
  284    290   
    crate::error::HostWithPathOperationError,
  285    291   
> {
  286    292   
    // Async block used to run the handler and catch any Python error.
  287    293   
    let result = if handler.is_coroutine {
  288    294   
        ::tracing::trace!(
  289    295   
            name = "host_with_path_operation",
  290    296   
            "executing python handler coroutine"
  291    297   
        );
  292    298   
        let result = ::pyo3::Python::with_gil(|py| {
  293    299   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  294    300   
            let coroutine = if handler.args == 1 {
  295    301   
                pyhandler.call1((input,))?
  296    302   
            } else {
  297    303   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  298    304   
            };
  299    305   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  300    306   
        })?;
  301    307   
        result.await.and_then(|r| {
  302    308   
            ::pyo3::Python::with_gil(|py| {
  303    309   
                r.extract::<crate::output::HostWithPathOperationOutput>(py)
  304    310   
            })
  305    311   
        })
  306    312   
    } else {
  307    313   
        ::tracing::trace!(
  308    314   
            name = "host_with_path_operation",
  309    315   
            "executing python handler function"
  310    316   
        );
  311    317   
        ::pyo3::Python::with_gil(|py| {
  312    318   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  313    319   
            let output = if handler.args == 1 {
  314    320   
                pyhandler.call1((input,))?
  315    321   
            } else {
  316    322   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  317    323   
            };
  318    324   
            output.extract::<crate::output::HostWithPathOperationOutput>()
  319    325   
        })
  320    326   
    };
  321    327   
    // Catch and record a Python traceback.
  322    328   
    result.map_err(|e| {
  323    329   
        let rich_py_err =
  324    330   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  325    331   
                e.clone_ref(py)
  326    332   
            }));
  327    333   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  328    334   
        e.into()
  329    335   
    })
  330    336   
}
  331    337   
         338  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  332    339   
/// Python handler for operation `EndpointWithHostLabelOperation`.
  333    340   
pub(crate) async fn endpoint_with_host_label_operation(
  334    341   
    input: crate::input::EndpointWithHostLabelOperationInput,
  335    342   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  336    343   
    handler: ::aws_smithy_http_server_python::PyHandler,
  337    344   
) -> std::result::Result<
  338    345   
    crate::output::EndpointWithHostLabelOperationOutput,
  339    346   
    crate::error::EndpointWithHostLabelOperationError,
  340    347   
> {
  341    348   
    // Async block used to run the handler and catch any Python error.
  342    349   
    let result = if handler.is_coroutine {
  343    350   
        ::tracing::trace!(
  344    351   
            name = "endpoint_with_host_label_operation",
  345    352   
            "executing python handler coroutine"
  346    353   
        );
  347    354   
        let result = ::pyo3::Python::with_gil(|py| {
  348    355   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  349    356   
            let coroutine = if handler.args == 1 {
  350    357   
                pyhandler.call1((input,))?
  351    358   
            } else {
  352    359   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  353    360   
            };
  354    361   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  355    362   
        })?;
  356    363   
        result.await.and_then(|r| {
  357    364   
            ::pyo3::Python::with_gil(|py| {
  358    365   
                r.extract::<crate::output::EndpointWithHostLabelOperationOutput>(py)
  359    366   
            })
  360    367   
        })
  361    368   
    } else {
  362    369   
        ::tracing::trace!(
  363    370   
            name = "endpoint_with_host_label_operation",
  364    371   
            "executing python handler function"
  365    372   
        );
  366    373   
        ::pyo3::Python::with_gil(|py| {
  367    374   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  368    375   
            let output = if handler.args == 1 {
  369    376   
                pyhandler.call1((input,))?
  370    377   
            } else {
  371    378   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  372    379   
            };
  373    380   
            output.extract::<crate::output::EndpointWithHostLabelOperationOutput>()
  374    381   
        })
  375    382   
    };
  376    383   
    // Catch and record a Python traceback.
  377    384   
    result.map_err(|e| {
  378    385   
        let rich_py_err =
  379    386   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  380    387   
                e.clone_ref(py)
  381    388   
            }));
  382    389   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  383    390   
        e.into()
  384    391   
    })
  385    392   
}
  386    393   
         394  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  387    395   
/// Python handler for operation `EndpointOperation`.
  388    396   
pub(crate) async fn endpoint_operation(
  389    397   
    input: crate::input::EndpointOperationInput,
  390    398   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  391    399   
    handler: ::aws_smithy_http_server_python::PyHandler,
  392    400   
) -> std::result::Result<crate::output::EndpointOperationOutput, crate::error::EndpointOperationError>
  393    401   
{
  394    402   
    // Async block used to run the handler and catch any Python error.
  395    403   
    let result = if handler.is_coroutine {
  396    404   
        ::tracing::trace!(
  397    405   
            name = "endpoint_operation",
  398    406   
            "executing python handler coroutine"
  399    407   
        );
  400    408   
        let result = ::pyo3::Python::with_gil(|py| {
  401    409   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  402    410   
            let coroutine = if handler.args == 1 {
  403    411   
                pyhandler.call1((input,))?
  404    412   
            } else {
  405    413   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  406    414   
            };
  407    415   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  408    416   
        })?;
  409    417   
        result.await.and_then(|r| {
  410    418   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::EndpointOperationOutput>(py))
  411    419   
        })
  412    420   
    } else {
  413    421   
        ::tracing::trace!(
  414    422   
            name = "endpoint_operation",
  415    423   
            "executing python handler function"
  416    424   
        );
  417    425   
        ::pyo3::Python::with_gil(|py| {
  418    426   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  419    427   
            let output = if handler.args == 1 {
  420    428   
                pyhandler.call1((input,))?
  421    429   
            } else {
  422    430   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  423    431   
            };
  424    432   
            output.extract::<crate::output::EndpointOperationOutput>()
  425    433   
        })
  426    434   
    };
  427    435   
    // Catch and record a Python traceback.
  428    436   
    result.map_err(|e| {
  429    437   
        let rich_py_err =
  430    438   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  431    439   
                e.clone_ref(py)
  432    440   
            }));
  433    441   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  434    442   
        e.into()
  435    443   
    })
  436    444   
}
  437    445   
         446  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  438    447   
/// Python handler for operation `JsonUnions`.
  439    448   
pub(crate) async fn json_unions(
  440    449   
    input: crate::input::JsonUnionsInput,
  441    450   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  442    451   
    handler: ::aws_smithy_http_server_python::PyHandler,
  443    452   
) -> std::result::Result<crate::output::JsonUnionsOutput, crate::error::JsonUnionsError> {
  444    453   
    // Async block used to run the handler and catch any Python error.
  445    454   
    let result = if handler.is_coroutine {
  446    455   
        ::tracing::trace!(name = "json_unions", "executing python handler coroutine");
  447    456   
        let result = ::pyo3::Python::with_gil(|py| {
  448    457   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  449    458   
            let coroutine = if handler.args == 1 {
  450    459   
                pyhandler.call1((input,))?
  451    460   
            } else {
  452    461   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  453    462   
            };
  454    463   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  455    464   
        })?;
  456    465   
        result.await.and_then(|r| {
  457    466   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::JsonUnionsOutput>(py))
  458    467   
        })
  459    468   
    } else {
  460    469   
        ::tracing::trace!(name = "json_unions", "executing python handler function");
  461    470   
        ::pyo3::Python::with_gil(|py| {
  462    471   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  463    472   
            let output = if handler.args == 1 {
  464    473   
                pyhandler.call1((input,))?
  465    474   
            } else {
  466    475   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  467    476   
            };
  468    477   
            output.extract::<crate::output::JsonUnionsOutput>()
  469    478   
        })
  470    479   
    };
  471    480   
    // Catch and record a Python traceback.
  472    481   
    result.map_err(|e| {
  473    482   
        let rich_py_err =
  474    483   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  475    484   
                e.clone_ref(py)
  476    485   
            }));
  477    486   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  478    487   
        e.into()
  479    488   
    })
  480    489   
}
  481    490   
         491  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  482    492   
/// Python handler for operation `GreetingWithErrors`.
  483    493   
pub(crate) async fn greeting_with_errors(
  484    494   
    input: crate::input::GreetingWithErrorsInput,
  485    495   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  486    496   
    handler: ::aws_smithy_http_server_python::PyHandler,
  487    497   
) -> std::result::Result<
  488    498   
    crate::output::GreetingWithErrorsOutput,
  489    499   
    crate::error::GreetingWithErrorsError,
  490    500   
> {
  491    501   
    // Async block used to run the handler and catch any Python error.
  492    502   
    let result = if handler.is_coroutine {
  493    503   
        ::tracing::trace!(
  494    504   
            name = "greeting_with_errors",
  495    505   
            "executing python handler coroutine"
  496    506   
        );
  497    507   
        let result = ::pyo3::Python::with_gil(|py| {
  498    508   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  499    509   
            let coroutine = if handler.args == 1 {
  500    510   
                pyhandler.call1((input,))?
  501    511   
            } else {
  502    512   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  503    513   
            };
  504    514   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  505    515   
        })?;
  506    516   
        result.await.and_then(|r| {
  507    517   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::GreetingWithErrorsOutput>(py))
  508    518   
        })
  509    519   
    } else {
  510    520   
        ::tracing::trace!(
  511    521   
            name = "greeting_with_errors",
  512    522   
            "executing python handler function"
  513    523   
        );
  514    524   
        ::pyo3::Python::with_gil(|py| {
  515    525   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  516    526   
            let output = if handler.args == 1 {
  517    527   
                pyhandler.call1((input,))?
  518    528   
            } else {
  519    529   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  520    530   
            };
  521    531   
            output.extract::<crate::output::GreetingWithErrorsOutput>()
  522    532   
        })
  523    533   
    };
  524    534   
    // Catch and record a Python traceback.
  525    535   
    result.map_err(|e| {
  526    536   
        let rich_py_err =
  527    537   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  528    538   
                e.clone_ref(py)
  529    539   
            }));
  530    540   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  531    541   
        e.into()
  532    542   
    })
  533    543   
}
  534    544   
         545  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  535    546   
/// Python handler for operation `SimpleScalarProperties`.
  536    547   
pub(crate) async fn simple_scalar_properties(
  537    548   
    input: crate::input::SimpleScalarPropertiesInput,
  538    549   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  539    550   
    handler: ::aws_smithy_http_server_python::PyHandler,
  540    551   
) -> std::result::Result<
  541    552   
    crate::output::SimpleScalarPropertiesOutput,
  542    553   
    crate::error::SimpleScalarPropertiesError,
  543    554   
> {
  544    555   
    // Async block used to run the handler and catch any Python error.
  545    556   
    let result = if handler.is_coroutine {
  546    557   
        ::tracing::trace!(
  547    558   
            name = "simple_scalar_properties",
  548    559   
            "executing python handler coroutine"
  549    560   
        );
  550    561   
        let result = ::pyo3::Python::with_gil(|py| {
  551    562   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  552    563   
            let coroutine = if handler.args == 1 {
  553    564   
                pyhandler.call1((input,))?
  554    565   
            } else {
  555    566   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  556    567   
            };
  557    568   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  558    569   
        })?;
  559    570   
        result.await.and_then(|r| {
  560    571   
            ::pyo3::Python::with_gil(|py| {
  561    572   
                r.extract::<crate::output::SimpleScalarPropertiesOutput>(py)
  562    573   
            })
  563    574   
        })
  564    575   
    } else {
  565    576   
        ::tracing::trace!(
  566    577   
            name = "simple_scalar_properties",
  567    578   
            "executing python handler function"
  568    579   
        );
  569    580   
        ::pyo3::Python::with_gil(|py| {
  570    581   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  571    582   
            let output = if handler.args == 1 {
  572    583   
                pyhandler.call1((input,))?
  573    584   
            } else {
  574    585   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  575    586   
            };
  576    587   
            output.extract::<crate::output::SimpleScalarPropertiesOutput>()
  577    588   
        })
  578    589   
    };
  579    590   
    // Catch and record a Python traceback.
  580    591   
    result.map_err(|e| {
  581    592   
        let rich_py_err =
  582    593   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  583    594   
                e.clone_ref(py)
  584    595   
            }));
  585    596   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  586    597   
        e.into()
  587    598   
    })
  588    599   
}
  589    600   
         601  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  590    602   
/// Python handler for operation `EmptyInputAndEmptyOutput`.
  591    603   
pub(crate) async fn empty_input_and_empty_output(
  592    604   
    input: crate::input::EmptyInputAndEmptyOutputInput,
  593    605   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  594    606   
    handler: ::aws_smithy_http_server_python::PyHandler,
  595    607   
) -> std::result::Result<
  596    608   
    crate::output::EmptyInputAndEmptyOutputOutput,
  597    609   
    crate::error::EmptyInputAndEmptyOutputError,
  598    610   
> {
  599    611   
    // Async block used to run the handler and catch any Python error.
  600    612   
    let result = if handler.is_coroutine {
  601    613   
        ::tracing::trace!(
  602    614   
            name = "empty_input_and_empty_output",
  603    615   
            "executing python handler coroutine"
  604    616   
        );
  605    617   
        let result = ::pyo3::Python::with_gil(|py| {
  606    618   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  607    619   
            let coroutine = if handler.args == 1 {
  608    620   
                pyhandler.call1((input,))?
  609    621   
            } else {
  610    622   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  611    623   
            };
  612    624   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  613    625   
        })?;
  614    626   
        result.await.and_then(|r| {
  615    627   
            ::pyo3::Python::with_gil(|py| {
  616    628   
                r.extract::<crate::output::EmptyInputAndEmptyOutputOutput>(py)
  617    629   
            })
  618    630   
        })
  619    631   
    } else {
  620    632   
        ::tracing::trace!(
  621    633   
            name = "empty_input_and_empty_output",
  622    634   
            "executing python handler function"
  623    635   
        );
  624    636   
        ::pyo3::Python::with_gil(|py| {
  625    637   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  626    638   
            let output = if handler.args == 1 {
  627    639   
                pyhandler.call1((input,))?
  628    640   
            } else {
  629    641   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  630    642   
            };
  631    643   
            output.extract::<crate::output::EmptyInputAndEmptyOutputOutput>()
  632    644   
        })
  633    645   
    };
  634    646   
    // Catch and record a Python traceback.
  635    647   
    result.map_err(|e| {
  636    648   
        let rich_py_err =
  637    649   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  638    650   
                e.clone_ref(py)
  639    651   
            }));
  640    652   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  641    653   
        e.into()
  642    654   
    })
  643    655   
}
  644    656   
         657  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  645    658   
/// Python handler for operation `NoInputAndOutput`.
  646    659   
pub(crate) async fn no_input_and_output(
  647    660   
    input: crate::input::NoInputAndOutputInput,
  648    661   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  649    662   
    handler: ::aws_smithy_http_server_python::PyHandler,
  650    663   
) -> std::result::Result<crate::output::NoInputAndOutputOutput, crate::error::NoInputAndOutputError>
  651    664   
{
  652    665   
    // Async block used to run the handler and catch any Python error.
  653    666   
    let result = if handler.is_coroutine {
  654    667   
        ::tracing::trace!(
  655    668   
            name = "no_input_and_output",
  656    669   
            "executing python handler coroutine"
  657    670   
        );
  658    671   
        let result = ::pyo3::Python::with_gil(|py| {
  659    672   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  660    673   
            let coroutine = if handler.args == 1 {
  661    674   
                pyhandler.call1((input,))?
  662    675   
            } else {
  663    676   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  664    677   
            };
  665    678   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  666    679   
        })?;
  667    680   
        result.await.and_then(|r| {
  668    681   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::NoInputAndOutputOutput>(py))
  669    682   
        })
  670    683   
    } else {
  671    684   
        ::tracing::trace!(
  672    685   
            name = "no_input_and_output",
  673    686   
            "executing python handler function"
  674    687   
        );
  675    688   
        ::pyo3::Python::with_gil(|py| {
  676    689   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  677    690   
            let output = if handler.args == 1 {
  678    691   
                pyhandler.call1((input,))?
  679    692   
            } else {
  680    693   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  681    694   
            };
  682    695   
            output.extract::<crate::output::NoInputAndOutputOutput>()
  683    696   
        })
  684    697   
    };
  685    698   
    // Catch and record a Python traceback.
  686    699   
    result.map_err(|e| {
  687    700   
        let rich_py_err =
  688    701   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  689    702   
                e.clone_ref(py)
  690    703   
            }));
  691    704   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  692    705   
        e.into()
  693    706   
    })
  694    707   
}
  695    708   
         709  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  696    710   
/// Python handler for operation `NoInputAndNoOutput`.
  697    711   
pub(crate) async fn no_input_and_no_output(
  698    712   
    input: crate::input::NoInputAndNoOutputInput,
  699    713   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  700    714   
    handler: ::aws_smithy_http_server_python::PyHandler,
  701    715   
) -> std::result::Result<
  702    716   
    crate::output::NoInputAndNoOutputOutput,
  703    717   
    crate::error::NoInputAndNoOutputError,
  704    718   
> {
  705    719   
    // Async block used to run the handler and catch any Python error.

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

@@ -1,1 +58,63 @@
    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 json_rpc10 import input
   12     14   
/// from json_rpc10 import output
          15  +
/* PythonApplicationGenerator.kt:406 */
   13     16   
/// from json_rpc10 import error
          17  +
/* PythonApplicationGenerator.kt:408 */
   14     18   
/// from json_rpc10 import middleware
   15     19   
/// from json_rpc10 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   
/// # The example tests how servers must support requests
   30     35   
/// # containing a `Content-Type` header with parameters.
   31     36   
/// @app.content_type_parameters
   32     37   
/// def content_type_parameters(input: input::ContentTypeParametersInput, ctx: Context) -> output::ContentTypeParametersOutput:
   33     38   
///     raise NotImplementedError
   34     39   
///
   35     40   
/// # The example tests how requests and responses are serialized when there's
   36     41   
/// # no request or response payload because the operation has an empty input
   37     42   
/// # and empty output structure that reuses the same shape. While this should
   38     43   
/// # be rare, code generators must support this.
@@ -76,81 +429,461 @@
   96    101   
/// def operation_with_required_members(input: input::OperationWithRequiredMembersInput, ctx: Context) -> output::OperationWithRequiredMembersOutput:
   97    102   
///     raise NotImplementedError
   98    103   
///
   99    104   
/// @app.put_with_content_encoding
  100    105   
/// def put_with_content_encoding(input: input::PutWithContentEncodingInput, ctx: Context) -> output::PutWithContentEncodingOutput:
  101    106   
///     raise NotImplementedError
  102    107   
///
  103    108   
/// @app.simple_scalar_properties
  104    109   
/// def simple_scalar_properties(input: input::SimpleScalarPropertiesInput, ctx: Context) -> output::SimpleScalarPropertiesOutput:
  105    110   
///     raise NotImplementedError
         111  +
/* PythonApplicationGenerator.kt:428 */
  106    112   
///
  107    113   
/// app.run()
  108    114   
/// ```
  109    115   
///
  110    116   
/// Any of operations above can be written as well prepending the `async` keyword and
  111    117   
/// the Python application will automatically handle it and schedule it on the event loop for you.
         118  +
/* PythonApplicationGenerator.kt:112 */
  112    119   
#[::pyo3::pyclass]
  113    120   
#[derive(Debug)]
  114    121   
/// :generic Ctx:
  115    122   
/// :extends typing.Generic\[Ctx\]:
  116    123   
/// :rtype None:
  117    124   
pub struct App {
  118    125   
    handlers: ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler>,
  119    126   
    middlewares: Vec<::aws_smithy_http_server_python::PyMiddlewareHandler>,
  120    127   
    context: Option<::pyo3::PyObject>,
  121    128   
    workers: ::parking_lot::Mutex<Vec<::pyo3::PyObject>>,
  122    129   
}
         130  +
/* PythonApplicationGenerator.kt:149 */
  123    131   
impl Default for App {
  124    132   
    fn default() -> Self {
  125    133   
        Self {
  126    134   
            handlers: Default::default(),
  127    135   
            middlewares: vec![],
  128    136   
            context: None,
  129    137   
            workers: ::parking_lot::Mutex::new(vec![]),
  130    138   
        }
  131    139   
    }
  132    140   
}
         141  +
/* PythonApplicationGenerator.kt:131 */
  133    142   
impl Clone for App {
  134    143   
    fn clone(&self) -> Self {
  135    144   
        Self {
  136    145   
            handlers: self.handlers.clone(),
  137    146   
            middlewares: self.middlewares.clone(),
  138    147   
            context: self.context.clone(),
  139    148   
            workers: ::parking_lot::Mutex::new(vec![]),
  140    149   
        }
  141    150   
    }
  142    151   
}
         152  +
/* PythonApplicationGenerator.kt:168 */
  143    153   
impl ::aws_smithy_http_server_python::PyApp for App {
         154  +
    /* PythonApplicationGenerator.kt:174 */
  144    155   
    fn workers(&self) -> &::parking_lot::Mutex<Vec<::pyo3::PyObject>> {
  145    156   
        &self.workers
  146    157   
    }
  147    158   
    fn context(&self) -> &Option<::pyo3::PyObject> {
  148    159   
        &self.context
  149    160   
    }
  150    161   
    fn handlers(
  151    162   
        &mut self,
  152    163   
    ) -> &mut ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler> {
  153    164   
        &mut self.handlers
  154    165   
    }
         166  +
    /* PythonApplicationGenerator.kt:189 */
  155    167   
    fn build_service(
  156    168   
        &mut self,
  157    169   
        event_loop: &::pyo3::PyAny,
  158    170   
    ) -> ::pyo3::PyResult<
  159    171   
        ::tower::util::BoxCloneService<
  160    172   
            ::http::Request<::aws_smithy_http_server::body::Body>,
  161    173   
            ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  162    174   
            std::convert::Infallible,
  163    175   
        >,
  164    176   
    > {
         177  +
        /* PythonApplicationGenerator.kt:201 */
  165    178   
        let builder = crate::service::JsonRpc10::builder_without_plugins();
         179  +
        /* PythonApplicationGenerator.kt:209 */
  166    180   
        let content_type_parameters_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  167    181   
        let handler = self
  168    182   
            .handlers
  169    183   
            .get("content_type_parameters")
  170    184   
            .expect("Python handler for operation `content_type_parameters` not found")
  171    185   
            .clone();
  172    186   
        let builder = builder.content_type_parameters(move |input, state| {
  173    187   
            ::pyo3_asyncio::tokio::scope(
  174    188   
                content_type_parameters_locals.clone(),
  175    189   
                crate::python_operation_adaptor::content_type_parameters(
  176    190   
                    input,
  177    191   
                    state,
  178    192   
                    handler.clone(),
  179    193   
                ),
  180    194   
            )
  181    195   
        });
         196  +
        /* PythonApplicationGenerator.kt:209 */
  182    197   
        let empty_input_and_empty_output_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  183    198   
        let handler = self
  184    199   
            .handlers
  185    200   
            .get("empty_input_and_empty_output")
  186    201   
            .expect("Python handler for operation `empty_input_and_empty_output` not found")
  187    202   
            .clone();
  188    203   
        let builder = builder.empty_input_and_empty_output(move |input, state| {
  189    204   
            ::pyo3_asyncio::tokio::scope(
  190    205   
                empty_input_and_empty_output_locals.clone(),
  191    206   
                crate::python_operation_adaptor::empty_input_and_empty_output(
  192    207   
                    input,
  193    208   
                    state,
  194    209   
                    handler.clone(),
  195    210   
                ),
  196    211   
            )
  197    212   
        });
         213  +
        /* PythonApplicationGenerator.kt:209 */
  198    214   
        let endpoint_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  199    215   
        let handler = self
  200    216   
            .handlers
  201    217   
            .get("endpoint_operation")
  202    218   
            .expect("Python handler for operation `endpoint_operation` not found")
  203    219   
            .clone();
  204    220   
        let builder = builder.endpoint_operation(move |input, state| {
  205    221   
            ::pyo3_asyncio::tokio::scope(
  206    222   
                endpoint_operation_locals.clone(),
  207    223   
                crate::python_operation_adaptor::endpoint_operation(input, state, handler.clone()),
  208    224   
            )
  209    225   
        });
         226  +
        /* PythonApplicationGenerator.kt:209 */
  210    227   
        let endpoint_with_host_label_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  211    228   
        let handler = self
  212    229   
            .handlers
  213    230   
            .get("endpoint_with_host_label_operation")
  214    231   
            .expect("Python handler for operation `endpoint_with_host_label_operation` not found")
  215    232   
            .clone();
  216    233   
        let builder = builder.endpoint_with_host_label_operation(move |input, state| {
  217    234   
            ::pyo3_asyncio::tokio::scope(
  218    235   
                endpoint_with_host_label_operation_locals.clone(),
  219    236   
                crate::python_operation_adaptor::endpoint_with_host_label_operation(
  220    237   
                    input,
  221    238   
                    state,
  222    239   
                    handler.clone(),
  223    240   
                ),
  224    241   
            )
  225    242   
        });
         243  +
        /* PythonApplicationGenerator.kt:209 */
  226    244   
        let greeting_with_errors_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  227    245   
        let handler = self
  228    246   
            .handlers
  229    247   
            .get("greeting_with_errors")
  230    248   
            .expect("Python handler for operation `greeting_with_errors` not found")
  231    249   
            .clone();
  232    250   
        let builder = builder.greeting_with_errors(move |input, state| {
  233    251   
            ::pyo3_asyncio::tokio::scope(
  234    252   
                greeting_with_errors_locals.clone(),
  235    253   
                crate::python_operation_adaptor::greeting_with_errors(
  236    254   
                    input,
  237    255   
                    state,
  238    256   
                    handler.clone(),
  239    257   
                ),
  240    258   
            )
  241    259   
        });
         260  +
        /* PythonApplicationGenerator.kt:209 */
  242    261   
        let host_with_path_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  243    262   
        let handler = self
  244    263   
            .handlers
  245    264   
            .get("host_with_path_operation")
  246    265   
            .expect("Python handler for operation `host_with_path_operation` not found")
  247    266   
            .clone();
  248    267   
        let builder = builder.host_with_path_operation(move |input, state| {
  249    268   
            ::pyo3_asyncio::tokio::scope(
  250    269   
                host_with_path_operation_locals.clone(),
  251    270   
                crate::python_operation_adaptor::host_with_path_operation(
  252    271   
                    input,
  253    272   
                    state,
  254    273   
                    handler.clone(),
  255    274   
                ),
  256    275   
            )
  257    276   
        });
         277  +
        /* PythonApplicationGenerator.kt:209 */
  258    278   
        let json_unions_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  259    279   
        let handler = self
  260    280   
            .handlers
  261    281   
            .get("json_unions")
  262    282   
            .expect("Python handler for operation `json_unions` not found")
  263    283   
            .clone();
  264    284   
        let builder = builder.json_unions(move |input, state| {
  265    285   
            ::pyo3_asyncio::tokio::scope(
  266    286   
                json_unions_locals.clone(),
  267    287   
                crate::python_operation_adaptor::json_unions(input, state, handler.clone()),
  268    288   
            )
  269    289   
        });
         290  +
        /* PythonApplicationGenerator.kt:209 */
  270    291   
        let no_input_and_no_output_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  271    292   
        let handler = self
  272    293   
            .handlers
  273    294   
            .get("no_input_and_no_output")
  274    295   
            .expect("Python handler for operation `no_input_and_no_output` not found")
  275    296   
            .clone();
  276    297   
        let builder = builder.no_input_and_no_output(move |input, state| {
  277    298   
            ::pyo3_asyncio::tokio::scope(
  278    299   
                no_input_and_no_output_locals.clone(),
  279    300   
                crate::python_operation_adaptor::no_input_and_no_output(
  280    301   
                    input,
  281    302   
                    state,
  282    303   
                    handler.clone(),
  283    304   
                ),
  284    305   
            )
  285    306   
        });
         307  +
        /* PythonApplicationGenerator.kt:209 */
  286    308   
        let no_input_and_output_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  287    309   
        let handler = self
  288    310   
            .handlers
  289    311   
            .get("no_input_and_output")
  290    312   
            .expect("Python handler for operation `no_input_and_output` not found")
  291    313   
            .clone();
  292    314   
        let builder = builder.no_input_and_output(move |input, state| {
  293    315   
            ::pyo3_asyncio::tokio::scope(
  294    316   
                no_input_and_output_locals.clone(),
  295    317   
                crate::python_operation_adaptor::no_input_and_output(input, state, handler.clone()),
  296    318   
            )
  297    319   
        });
         320  +
        /* PythonApplicationGenerator.kt:209 */
  298    321   
        let operation_with_defaults_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  299    322   
        let handler = self
  300    323   
            .handlers
  301    324   
            .get("operation_with_defaults")
  302    325   
            .expect("Python handler for operation `operation_with_defaults` not found")
  303    326   
            .clone();
  304    327   
        let builder = builder.operation_with_defaults(move |input, state| {
  305    328   
            ::pyo3_asyncio::tokio::scope(
  306    329   
                operation_with_defaults_locals.clone(),
  307    330   
                crate::python_operation_adaptor::operation_with_defaults(
  308    331   
                    input,
  309    332   
                    state,
  310    333   
                    handler.clone(),
  311    334   
                ),
  312    335   
            )
  313    336   
        });
         337  +
        /* PythonApplicationGenerator.kt:209 */
  314    338   
        let operation_with_nested_structure_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  315    339   
        let handler = self
  316    340   
            .handlers
  317    341   
            .get("operation_with_nested_structure")
  318    342   
            .expect("Python handler for operation `operation_with_nested_structure` not found")
  319    343   
            .clone();
  320    344   
        let builder = builder.operation_with_nested_structure(move |input, state| {
  321    345   
            ::pyo3_asyncio::tokio::scope(
  322    346   
                operation_with_nested_structure_locals.clone(),
  323    347   
                crate::python_operation_adaptor::operation_with_nested_structure(
  324    348   
                    input,
  325    349   
                    state,
  326    350   
                    handler.clone(),
  327    351   
                ),
  328    352   
            )
  329    353   
        });
         354  +
        /* PythonApplicationGenerator.kt:209 */
  330    355   
        let operation_with_required_members_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  331    356   
        let handler = self
  332    357   
            .handlers
  333    358   
            .get("operation_with_required_members")
  334    359   
            .expect("Python handler for operation `operation_with_required_members` not found")
  335    360   
            .clone();
  336    361   
        let builder = builder.operation_with_required_members(move |input, state| {
  337    362   
            ::pyo3_asyncio::tokio::scope(
  338    363   
                operation_with_required_members_locals.clone(),
  339    364   
                crate::python_operation_adaptor::operation_with_required_members(
  340    365   
                    input,
  341    366   
                    state,
  342    367   
                    handler.clone(),
  343    368   
                ),
  344    369   
            )
  345    370   
        });
         371  +
        /* PythonApplicationGenerator.kt:209 */
  346    372   
        let put_with_content_encoding_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  347    373   
        let handler = self
  348    374   
            .handlers
  349    375   
            .get("put_with_content_encoding")
  350    376   
            .expect("Python handler for operation `put_with_content_encoding` not found")
  351    377   
            .clone();
  352    378   
        let builder = builder.put_with_content_encoding(move |input, state| {
  353    379   
            ::pyo3_asyncio::tokio::scope(
  354    380   
                put_with_content_encoding_locals.clone(),
  355    381   
                crate::python_operation_adaptor::put_with_content_encoding(
  356    382   
                    input,
  357    383   
                    state,
  358    384   
                    handler.clone(),
  359    385   
                ),
  360    386   
            )
  361    387   
        });
         388  +
        /* PythonApplicationGenerator.kt:209 */
  362    389   
        let simple_scalar_properties_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  363    390   
        let handler = self
  364    391   
            .handlers
  365    392   
            .get("simple_scalar_properties")
  366    393   
            .expect("Python handler for operation `simple_scalar_properties` not found")
  367    394   
            .clone();
  368    395   
        let builder = builder.simple_scalar_properties(move |input, state| {
  369    396   
            ::pyo3_asyncio::tokio::scope(
  370    397   
                simple_scalar_properties_locals.clone(),
  371    398   
                crate::python_operation_adaptor::simple_scalar_properties(
  372    399   
                    input,
  373    400   
                    state,
  374    401   
                    handler.clone(),
  375    402   
                ),
  376    403   
            )
  377    404   
        });
         405  +
        /* PythonApplicationGenerator.kt:220 */
  378    406   
        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"));
  379    407   
  380    408   
        {
  381    409   
            use ::tower::Layer;
  382    410   
            ::tracing::trace!("adding middlewares to rust python router");
  383    411   
            let mut middlewares = self.middlewares.clone();
  384    412   
            // Reverse the middlewares, so they run with same order as they defined
  385    413   
            middlewares.reverse();
  386    414   
            for handler in middlewares {
  387    415   
                ::tracing::trace!(name = &handler.name, "adding python middleware");
  388    416   
                let locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  389    417   
                let layer = ::aws_smithy_http_server_python::PyMiddlewareLayer::<
  390    418   
                    ::aws_smithy_http_server::protocol::aws_json_10::AwsJson1_0,
  391    419   
                >::new(handler, locals);
  392    420   
                service = ::tower::util::BoxCloneService::new(layer.layer(service));
  393    421   
            }
  394    422   
        }
  395    423   
        Ok(service)
         424  +
        /* PythonApplicationGenerator.kt:189 */
  396    425   
    }
         426  +
    /* PythonApplicationGenerator.kt:168 */
  397    427   
}
         428  +
/* PythonApplicationGenerator.kt:247 */
  398    429   
#[::pyo3::pymethods]
  399    430   
impl App {
         431  +
    /* PythonApplicationGenerator.kt:260 */
  400    432   
    /// Create a new [App].
  401    433   
    #[new]
  402    434   
    pub fn new() -> Self {
  403    435   
        Self::default()
  404    436   
    }
  405    437   
  406    438   
    /// Register a context object that will be shared between handlers.
  407    439   
    ///
  408    440   
    /// :param context Ctx:
  409    441   
    /// :rtype None:
@@ -452,484 +678,725 @@
  472    504   
        py: pyo3::Python,
  473    505   
        socket: &pyo3::PyCell<::aws_smithy_http_server_python::PySocket>,
  474    506   
        worker_number: isize,
  475    507   
        tls: Option<::aws_smithy_http_server_python::tls::PyTlsConfig>,
  476    508   
    ) -> pyo3::PyResult<()> {
  477    509   
        use ::aws_smithy_http_server_python::PyApp;
  478    510   
        let event_loop = self.configure_python_event_loop(py)?;
  479    511   
        let service = self.build_and_configure_service(py, event_loop)?;
  480    512   
        self.start_hyper_worker(py, socket, event_loop, service, worker_number, tls)
  481    513   
    }
         514  +
    /* PythonApplicationGenerator.kt:366 */
  482    515   
    /// Method to register `content_type_parameters` Python implementation inside the handlers map.
  483    516   
    /// It can be used as a function decorator in Python.
  484    517   
    ///
  485    518   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.ContentTypeParametersInput, Ctx\], typing.Union\[json_rpc10.output.ContentTypeParametersOutput, typing.Awaitable\[json_rpc10.output.ContentTypeParametersOutput\]\]\], typing.Callable\[\[json_rpc10.input.ContentTypeParametersInput\], typing.Union\[json_rpc10.output.ContentTypeParametersOutput, typing.Awaitable\[json_rpc10.output.ContentTypeParametersOutput\]\]\]\]:
  486    519   
    /// :rtype None:
  487    520   
    #[pyo3(text_signature = "($self, func)")]
  488    521   
    pub fn content_type_parameters(
  489    522   
        &mut self,
  490    523   
        py: ::pyo3::Python,
  491    524   
        func: ::pyo3::PyObject,
  492    525   
    ) -> ::pyo3::PyResult<()> {
  493    526   
        use ::aws_smithy_http_server_python::PyApp;
  494    527   
        self.register_operation(py, "content_type_parameters", func)
  495    528   
    }
         529  +
    /* PythonApplicationGenerator.kt:366 */
  496    530   
    /// Method to register `empty_input_and_empty_output` Python implementation inside the handlers map.
  497    531   
    /// It can be used as a function decorator in Python.
  498    532   
    ///
  499    533   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.EmptyInputAndEmptyOutputInput, Ctx\], typing.Union\[json_rpc10.output.EmptyInputAndEmptyOutputOutput, typing.Awaitable\[json_rpc10.output.EmptyInputAndEmptyOutputOutput\]\]\], typing.Callable\[\[json_rpc10.input.EmptyInputAndEmptyOutputInput\], typing.Union\[json_rpc10.output.EmptyInputAndEmptyOutputOutput, typing.Awaitable\[json_rpc10.output.EmptyInputAndEmptyOutputOutput\]\]\]\]:
  500    534   
    /// :rtype None:
  501    535   
    #[pyo3(text_signature = "($self, func)")]
  502    536   
    pub fn empty_input_and_empty_output(
  503    537   
        &mut self,
  504    538   
        py: ::pyo3::Python,
  505    539   
        func: ::pyo3::PyObject,
  506    540   
    ) -> ::pyo3::PyResult<()> {
  507    541   
        use ::aws_smithy_http_server_python::PyApp;
  508    542   
        self.register_operation(py, "empty_input_and_empty_output", func)
  509    543   
    }
         544  +
    /* PythonApplicationGenerator.kt:366 */
  510    545   
    /// Method to register `endpoint_operation` Python implementation inside the handlers map.
  511    546   
    /// It can be used as a function decorator in Python.
  512    547   
    ///
  513    548   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.EndpointOperationInput, Ctx\], typing.Union\[json_rpc10.output.EndpointOperationOutput, typing.Awaitable\[json_rpc10.output.EndpointOperationOutput\]\]\], typing.Callable\[\[json_rpc10.input.EndpointOperationInput\], typing.Union\[json_rpc10.output.EndpointOperationOutput, typing.Awaitable\[json_rpc10.output.EndpointOperationOutput\]\]\]\]:
  514    549   
    /// :rtype None:
  515    550   
    #[pyo3(text_signature = "($self, func)")]
  516    551   
    pub fn endpoint_operation(
  517    552   
        &mut self,
  518    553   
        py: ::pyo3::Python,
  519    554   
        func: ::pyo3::PyObject,
  520    555   
    ) -> ::pyo3::PyResult<()> {
  521    556   
        use ::aws_smithy_http_server_python::PyApp;
  522    557   
        self.register_operation(py, "endpoint_operation", func)
  523    558   
    }
         559  +
    /* PythonApplicationGenerator.kt:366 */
  524    560   
    /// Method to register `endpoint_with_host_label_operation` Python implementation inside the handlers map.
  525    561   
    /// It can be used as a function decorator in Python.
  526    562   
    ///
  527    563   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.EndpointWithHostLabelOperationInput, Ctx\], typing.Union\[json_rpc10.output.EndpointWithHostLabelOperationOutput, typing.Awaitable\[json_rpc10.output.EndpointWithHostLabelOperationOutput\]\]\], typing.Callable\[\[json_rpc10.input.EndpointWithHostLabelOperationInput\], typing.Union\[json_rpc10.output.EndpointWithHostLabelOperationOutput, typing.Awaitable\[json_rpc10.output.EndpointWithHostLabelOperationOutput\]\]\]\]:
  528    564   
    /// :rtype None:
  529    565   
    #[pyo3(text_signature = "($self, func)")]
  530    566   
    pub fn endpoint_with_host_label_operation(
  531    567   
        &mut self,
  532    568   
        py: ::pyo3::Python,
  533    569   
        func: ::pyo3::PyObject,
  534    570   
    ) -> ::pyo3::PyResult<()> {
  535    571   
        use ::aws_smithy_http_server_python::PyApp;
  536    572   
        self.register_operation(py, "endpoint_with_host_label_operation", func)
  537    573   
    }
         574  +
    /* PythonApplicationGenerator.kt:366 */
  538    575   
    /// Method to register `greeting_with_errors` Python implementation inside the handlers map.
  539    576   
    /// It can be used as a function decorator in Python.
  540    577   
    ///
  541    578   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.GreetingWithErrorsInput, Ctx\], typing.Union\[json_rpc10.output.GreetingWithErrorsOutput, typing.Awaitable\[json_rpc10.output.GreetingWithErrorsOutput\]\]\], typing.Callable\[\[json_rpc10.input.GreetingWithErrorsInput\], typing.Union\[json_rpc10.output.GreetingWithErrorsOutput, typing.Awaitable\[json_rpc10.output.GreetingWithErrorsOutput\]\]\]\]:
  542    579   
    /// :rtype None:
  543    580   
    #[pyo3(text_signature = "($self, func)")]
  544    581   
    pub fn greeting_with_errors(
  545    582   
        &mut self,
  546    583   
        py: ::pyo3::Python,
  547    584   
        func: ::pyo3::PyObject,
  548    585   
    ) -> ::pyo3::PyResult<()> {
  549    586   
        use ::aws_smithy_http_server_python::PyApp;
  550    587   
        self.register_operation(py, "greeting_with_errors", func)
  551    588   
    }
         589  +
    /* PythonApplicationGenerator.kt:366 */
  552    590   
    /// Method to register `host_with_path_operation` Python implementation inside the handlers map.
  553    591   
    /// It can be used as a function decorator in Python.
  554    592   
    ///
  555    593   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.HostWithPathOperationInput, Ctx\], typing.Union\[json_rpc10.output.HostWithPathOperationOutput, typing.Awaitable\[json_rpc10.output.HostWithPathOperationOutput\]\]\], typing.Callable\[\[json_rpc10.input.HostWithPathOperationInput\], typing.Union\[json_rpc10.output.HostWithPathOperationOutput, typing.Awaitable\[json_rpc10.output.HostWithPathOperationOutput\]\]\]\]:
  556    594   
    /// :rtype None:
  557    595   
    #[pyo3(text_signature = "($self, func)")]
  558    596   
    pub fn host_with_path_operation(
  559    597   
        &mut self,
  560    598   
        py: ::pyo3::Python,
  561    599   
        func: ::pyo3::PyObject,
  562    600   
    ) -> ::pyo3::PyResult<()> {
  563    601   
        use ::aws_smithy_http_server_python::PyApp;
  564    602   
        self.register_operation(py, "host_with_path_operation", func)
  565    603   
    }
         604  +
    /* PythonApplicationGenerator.kt:366 */
  566    605   
    /// Method to register `json_unions` Python implementation inside the handlers map.
  567    606   
    /// It can be used as a function decorator in Python.
  568    607   
    ///
  569    608   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.JsonUnionsInput, Ctx\], typing.Union\[json_rpc10.output.JsonUnionsOutput, typing.Awaitable\[json_rpc10.output.JsonUnionsOutput\]\]\], typing.Callable\[\[json_rpc10.input.JsonUnionsInput\], typing.Union\[json_rpc10.output.JsonUnionsOutput, typing.Awaitable\[json_rpc10.output.JsonUnionsOutput\]\]\]\]:
  570    609   
    /// :rtype None:
  571    610   
    #[pyo3(text_signature = "($self, func)")]
  572    611   
    pub fn json_unions(
  573    612   
        &mut self,
  574    613   
        py: ::pyo3::Python,
  575    614   
        func: ::pyo3::PyObject,
  576    615   
    ) -> ::pyo3::PyResult<()> {
  577    616   
        use ::aws_smithy_http_server_python::PyApp;
  578    617   
        self.register_operation(py, "json_unions", func)
  579    618   
    }
         619  +
    /* PythonApplicationGenerator.kt:366 */
  580    620   
    /// Method to register `no_input_and_no_output` Python implementation inside the handlers map.
  581    621   
    /// It can be used as a function decorator in Python.
  582    622   
    ///
  583    623   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.NoInputAndNoOutputInput, Ctx\], typing.Union\[json_rpc10.output.NoInputAndNoOutputOutput, typing.Awaitable\[json_rpc10.output.NoInputAndNoOutputOutput\]\]\], typing.Callable\[\[json_rpc10.input.NoInputAndNoOutputInput\], typing.Union\[json_rpc10.output.NoInputAndNoOutputOutput, typing.Awaitable\[json_rpc10.output.NoInputAndNoOutputOutput\]\]\]\]:
  584    624   
    /// :rtype None:
  585    625   
    #[pyo3(text_signature = "($self, func)")]
  586    626   
    pub fn no_input_and_no_output(
  587    627   
        &mut self,
  588    628   
        py: ::pyo3::Python,
  589    629   
        func: ::pyo3::PyObject,
  590    630   
    ) -> ::pyo3::PyResult<()> {
  591    631   
        use ::aws_smithy_http_server_python::PyApp;
  592    632   
        self.register_operation(py, "no_input_and_no_output", func)
  593    633   
    }
         634  +
    /* PythonApplicationGenerator.kt:366 */
  594    635   
    /// Method to register `no_input_and_output` Python implementation inside the handlers map.
  595    636   
    /// It can be used as a function decorator in Python.
  596    637   
    ///
  597    638   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.NoInputAndOutputInput, Ctx\], typing.Union\[json_rpc10.output.NoInputAndOutputOutput, typing.Awaitable\[json_rpc10.output.NoInputAndOutputOutput\]\]\], typing.Callable\[\[json_rpc10.input.NoInputAndOutputInput\], typing.Union\[json_rpc10.output.NoInputAndOutputOutput, typing.Awaitable\[json_rpc10.output.NoInputAndOutputOutput\]\]\]\]:
  598    639   
    /// :rtype None:
  599    640   
    #[pyo3(text_signature = "($self, func)")]
  600    641   
    pub fn no_input_and_output(
  601    642   
        &mut self,
  602    643   
        py: ::pyo3::Python,
  603    644   
        func: ::pyo3::PyObject,
  604    645   
    ) -> ::pyo3::PyResult<()> {
  605    646   
        use ::aws_smithy_http_server_python::PyApp;
  606    647   
        self.register_operation(py, "no_input_and_output", func)
  607    648   
    }
         649  +
    /* PythonApplicationGenerator.kt:366 */
  608    650   
    /// Method to register `operation_with_defaults` Python implementation inside the handlers map.
  609    651   
    /// It can be used as a function decorator in Python.
  610    652   
    ///
  611    653   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.OperationWithDefaultsInput, Ctx\], typing.Union\[json_rpc10.output.OperationWithDefaultsOutput, typing.Awaitable\[json_rpc10.output.OperationWithDefaultsOutput\]\]\], typing.Callable\[\[json_rpc10.input.OperationWithDefaultsInput\], typing.Union\[json_rpc10.output.OperationWithDefaultsOutput, typing.Awaitable\[json_rpc10.output.OperationWithDefaultsOutput\]\]\]\]:
  612    654   
    /// :rtype None:
  613    655   
    #[pyo3(text_signature = "($self, func)")]
  614    656   
    pub fn operation_with_defaults(
  615    657   
        &mut self,
  616    658   
        py: ::pyo3::Python,
  617    659   
        func: ::pyo3::PyObject,
  618    660   
    ) -> ::pyo3::PyResult<()> {
  619    661   
        use ::aws_smithy_http_server_python::PyApp;
  620    662   
        self.register_operation(py, "operation_with_defaults", func)
  621    663   
    }
         664  +
    /* PythonApplicationGenerator.kt:366 */
  622    665   
    /// Method to register `operation_with_nested_structure` Python implementation inside the handlers map.
  623    666   
    /// It can be used as a function decorator in Python.
  624    667   
    ///
  625    668   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.OperationWithNestedStructureInput, Ctx\], typing.Union\[json_rpc10.output.OperationWithNestedStructureOutput, typing.Awaitable\[json_rpc10.output.OperationWithNestedStructureOutput\]\]\], typing.Callable\[\[json_rpc10.input.OperationWithNestedStructureInput\], typing.Union\[json_rpc10.output.OperationWithNestedStructureOutput, typing.Awaitable\[json_rpc10.output.OperationWithNestedStructureOutput\]\]\]\]:
  626    669   
    /// :rtype None:
  627    670   
    #[pyo3(text_signature = "($self, func)")]
  628    671   
    pub fn operation_with_nested_structure(
  629    672   
        &mut self,
  630    673   
        py: ::pyo3::Python,
  631    674   
        func: ::pyo3::PyObject,
  632    675   
    ) -> ::pyo3::PyResult<()> {
  633    676   
        use ::aws_smithy_http_server_python::PyApp;
  634    677   
        self.register_operation(py, "operation_with_nested_structure", func)
  635    678   
    }
         679  +
    /* PythonApplicationGenerator.kt:366 */
  636    680   
    /// Method to register `operation_with_required_members` Python implementation inside the handlers map.
  637    681   
    /// It can be used as a function decorator in Python.
  638    682   
    ///
  639    683   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.OperationWithRequiredMembersInput, Ctx\], typing.Union\[json_rpc10.output.OperationWithRequiredMembersOutput, typing.Awaitable\[json_rpc10.output.OperationWithRequiredMembersOutput\]\]\], typing.Callable\[\[json_rpc10.input.OperationWithRequiredMembersInput\], typing.Union\[json_rpc10.output.OperationWithRequiredMembersOutput, typing.Awaitable\[json_rpc10.output.OperationWithRequiredMembersOutput\]\]\]\]:
  640    684   
    /// :rtype None:
  641    685   
    #[pyo3(text_signature = "($self, func)")]
  642    686   
    pub fn operation_with_required_members(
  643    687   
        &mut self,
  644    688   
        py: ::pyo3::Python,
  645    689   
        func: ::pyo3::PyObject,
  646    690   
    ) -> ::pyo3::PyResult<()> {
  647    691   
        use ::aws_smithy_http_server_python::PyApp;
  648    692   
        self.register_operation(py, "operation_with_required_members", func)
  649    693   
    }
         694  +
    /* PythonApplicationGenerator.kt:366 */
  650    695   
    /// Method to register `put_with_content_encoding` Python implementation inside the handlers map.
  651    696   
    /// It can be used as a function decorator in Python.
  652    697   
    ///
  653    698   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.PutWithContentEncodingInput, Ctx\], typing.Union\[json_rpc10.output.PutWithContentEncodingOutput, typing.Awaitable\[json_rpc10.output.PutWithContentEncodingOutput\]\]\], typing.Callable\[\[json_rpc10.input.PutWithContentEncodingInput\], typing.Union\[json_rpc10.output.PutWithContentEncodingOutput, typing.Awaitable\[json_rpc10.output.PutWithContentEncodingOutput\]\]\]\]:
  654    699   
    /// :rtype None:
  655    700   
    #[pyo3(text_signature = "($self, func)")]
  656    701   
    pub fn put_with_content_encoding(
  657    702   
        &mut self,
  658    703   
        py: ::pyo3::Python,
  659    704   
        func: ::pyo3::PyObject,
  660    705   
    ) -> ::pyo3::PyResult<()> {
  661    706   
        use ::aws_smithy_http_server_python::PyApp;
  662    707   
        self.register_operation(py, "put_with_content_encoding", func)
  663    708   
    }
         709  +
    /* PythonApplicationGenerator.kt:366 */
  664    710   
    /// Method to register `simple_scalar_properties` Python implementation inside the handlers map.
  665    711   
    /// It can be used as a function decorator in Python.
  666    712   
    ///
  667    713   
    /// :param func typing.Union\[typing.Callable\[\[json_rpc10.input.SimpleScalarPropertiesInput, Ctx\], typing.Union\[json_rpc10.output.SimpleScalarPropertiesOutput, typing.Awaitable\[json_rpc10.output.SimpleScalarPropertiesOutput\]\]\], typing.Callable\[\[json_rpc10.input.SimpleScalarPropertiesInput\], typing.Union\[json_rpc10.output.SimpleScalarPropertiesOutput, typing.Awaitable\[json_rpc10.output.SimpleScalarPropertiesOutput\]\]\]\]:
  668    714   
    /// :rtype None:
  669    715   
    #[pyo3(text_signature = "($self, func)")]
  670    716   
    pub fn simple_scalar_properties(
  671    717   
        &mut self,
  672    718   
        py: ::pyo3::Python,
  673    719   
        func: ::pyo3::PyObject,
  674    720   
    ) -> ::pyo3::PyResult<()> {
  675    721   
        use ::aws_smithy_http_server_python::PyApp;
  676    722   
        self.register_operation(py, "simple_scalar_properties", func)
  677    723   
    }
         724  +
    /* PythonApplicationGenerator.kt:247 */
  678    725   
}

tmp-codegen-diff/codegen-server-test-python/json_rpc10/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 [`JsonRpc10`].
    3      4   
///
    4      5   
/// Constructed via [`JsonRpc10::builder`].
    5      6   
pub struct JsonRpc10Builder<Body, L, HttpPl, ModelPl> {
    6      7   
    content_type_parameters: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    empty_input_and_empty_output: Option<::aws_smithy_http_server::routing::Route<Body>>,
    8      9   
    endpoint_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
    9     10   
    endpoint_with_host_label_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
   10     11   
    greeting_with_errors: Option<::aws_smithy_http_server::routing::Route<Body>>,
   11     12   
    host_with_path_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
@@ -2928,2929 +2987,2989 @@
 2948   2949   
            "aws.protocoltests.json10",
 2949   2950   
            "JsonRpc10",
 2950   2951   
        );
 2951   2952   
 2952   2953   
    const VERSION: Option<&'static str> = Some("2020-07-14");
 2953   2954   
 2954   2955   
    type Protocol = ::aws_smithy_http_server::protocol::aws_json_10::AwsJson1_0;
 2955   2956   
 2956   2957   
    type Operations = Operation;
 2957   2958   
}
        2959  +
/* ServiceConfigGenerator.kt:178 */
 2958   2960   
/// Configuration for the [`JsonRpc10`]. This is the central place where to register and
 2959   2961   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
 2960   2962   
///
 2961   2963   
/// ```rust,no_run
 2962   2964   
/// # use json_rpc10::JsonRpc10Config;
 2963   2965   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
 2964   2966   
/// # use ::tower::layer::util::Identity;
 2965   2967   
/// # let authentication_plugin = IdentityPlugin;
 2966   2968   
/// # let authorization_plugin = IdentityPlugin;
 2967   2969   
/// # let server_request_id_provider_layer = Identity::new();
@@ -3043,3045 +3102,3105 @@
 3063   3065   
 3064   3066   
    /// Build the configuration.
 3065   3067   
    pub fn build(self) -> super::JsonRpc10Config<L, H, M> {
 3066   3068   
        super::JsonRpc10Config {
 3067   3069   
            layers: self.layers,
 3068   3070   
            http_plugins: self.http_plugins,
 3069   3071   
            model_plugins: self.model_plugins,
 3070   3072   
        }
 3071   3073   
    }
 3072   3074   
}
        3075  +
/* ScopeMacroGenerator.kt:81 */
 3073   3076   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
 3074   3077   
///
 3075   3078   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
 3076   3079   
/// of the service and any operations _not_ specified will be placed in the opposing group.
 3077   3080   
///
 3078   3081   
/// # Example
 3079   3082   
///
 3080   3083   
/// ```rust
 3081   3084   
/// scope! {
 3082   3085   
///     /// Includes [`ContentTypeParameters`], excluding all other operations.