Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943

Files changed:

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

@@ -1,1 +133,180 @@
    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_constrained_http_payload_bound_shape_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::ConstrainedHttpPayloadBoundShapeOperationInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
   17         -
        let mut input = crate::input::constrained_http_payload_bound_shape_operation_input_internal::Builder::default();
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */let mut input = crate::input::constrained_http_payload_bound_shape_operation_input_internal::Builder::default();
          22  +
        /* RustType.kt:516 */
   18     23   
        #[allow(unused_variables)]
          24  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     25   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     26   
            uri, headers, body, ..
   21     27   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          28  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   22     29   
        if let Some(value) = {
   23     30   
            let bytes = ::hyper::body::to_bytes(body).await?;
   24     31   
            if !bytes.is_empty() {
   25     32   
                ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   26     33   
                    &headers,
   27     34   
                    Some("application/json"),
   28     35   
                )?;
   29     36   
            }
   30     37   
            crate::protocol_serde::shape_constrained_http_payload_bound_shape_operation_input::de_http_payload_bound_constrained_shape_payload(&bytes)?
   31     38   
        } {
   32     39   
            input = input.set_http_payload_bound_constrained_shape(value)
   33     40   
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   34     42   
        input.build()?
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   35     44   
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   36     46   
}
   37     47   
          48  +
/* RustType.kt:516 */
   38     49   
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   39     51   
pub fn ser_constrained_http_payload_bound_shape_operation_http_response(
   40     52   
    #[allow(unused_variables)]
   41     53   
    output: crate::output::ConstrainedHttpPayloadBoundShapeOperationOutput,
   42     54   
) -> std::result::Result<
   43     55   
    ::aws_smithy_http_server::response::Response,
   44     56   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   45     57   
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   46     59   
    Ok({
          60  +
        /* RustType.kt:516 */
   47     61   
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   48     63   
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   49     65   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   50     66   
            builder,
   51     67   
            ::http::header::CONTENT_TYPE,
   52     68   
            "application/json",
   53     69   
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   54     71   
        let http_status: u16 = 200;
   55     72   
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   56     74   
        let payload =
   57         -
            crate::protocol_serde::shape_constrained_http_payload_bound_shape_operation_output::ser_http_payload_bound_constrained_shape_http_payload(& output.http_payload_bound_constrained_shape)?
   58         -
        ;
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:350 */crate::protocol_serde::shape_constrained_http_payload_bound_shape_operation_output::ser_http_payload_bound_constrained_shape_http_payload(& output.http_payload_bound_constrained_shape)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   59     78   
        let content_length = payload.len();
   60     79   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   61     80   
            builder,
   62     81   
            ::http::header::CONTENT_LENGTH,
   63     82   
            content_length,
   64     83   
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   65     85   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   66     87   
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   67     89   
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   68     91   
}
   69     92   
          93  +
/* RustType.kt:516 */
   70     94   
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   71     96   
pub fn ser_constrained_http_payload_bound_shape_operation_http_error(
   72     97   
    error: &crate::error::ConstrainedHttpPayloadBoundShapeOperationError,
   73     98   
) -> std::result::Result<
   74     99   
    ::aws_smithy_http_server::response::Response,
   75    100   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   76    101   
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   77    103   
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   78    105   
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   79    107   
            crate::error::ConstrainedHttpPayloadBoundShapeOperationError::ValidationException(
   80    108   
                output,
   81    109   
            ) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   82    111   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         112  +
                /* RustType.kt:516 */
   83    113   
                #[allow(unused_mut)]
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   84    115   
                let mut builder = ::http::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   85    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   86    118   
                    builder,
   87    119   
                    ::http::header::CONTENT_TYPE,
   88    120   
                    "application/json",
   89    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   90    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    124   
                    builder,
   92    125   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   93    126   
                    "ValidationException",
   94    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   95    129   
                let content_length = payload.len();
   96    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   97    131   
                    builder,
   98    132   
                    ::http::header::CONTENT_LENGTH,
   99    133   
                    content_length,
  100    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  101    136   
                builder
  102    137   
                    .status(400)
  103    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  104    140   
            }
         141  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  105    142   
            crate::error::ConstrainedHttpPayloadBoundShapeOperationError::InternalServerError(
  106    143   
                output,
  107    144   
            ) => {
         145  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  108    146   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         147  +
                /* RustType.kt:516 */
  109    148   
                #[allow(unused_mut)]
         149  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  110    150   
                let mut builder = ::http::Response::builder();
         151  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  111    152   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  112    153   
                    builder,
  113    154   
                    ::http::header::CONTENT_TYPE,
  114    155   
                    "application/json",
  115    156   
                );
         157  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  116    158   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    159   
                    builder,
  118    160   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  119    161   
                    "InternalServerError",
  120    162   
                );
         163  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  121    164   
                let content_length = payload.len();
  122    165   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  123    166   
                    builder,
  124    167   
                    ::http::header::CONTENT_LENGTH,
  125    168   
                    content_length,
  126    169   
                );
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  127    171   
                builder
  128    172   
                    .status(500)
  129    173   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  130         -
            }
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         175  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  131    176   
        }
         177  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  132    178   
    })
         179  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  133    180   
}

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

@@ -1,1 +11,18 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:248 */
    2      3   
pub(crate) fn de_http_payload_bound_constrained_shape_payload(
    3      4   
    body: &[u8],
    4      5   
) -> std::result::Result<
    5      6   
    ::std::option::Option<crate::model::con_a_internal::Builder>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:319 */
    8     10   
    (!body.is_empty())
    9         -
        .then(|| crate::protocol_serde::shape_con_a::de_con_a_payload(body))
          11  +
        .then(|| {
          12  +
            /* ServerHttpBoundProtocolGenerator.kt:850 */
          13  +
            crate::protocol_serde::shape_con_a::de_con_a_payload(body)
          14  +
            /* HttpBindingGenerator.kt:319 */
          15  +
        })
   10     16   
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:248 */
   11     18   
}

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

@@ -1,1 +21,31 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:311 */
    2      3   
pub fn ser_http_payload_bound_constrained_shape_http_payload(
    3      4   
    payload: &crate::model::ConA,
    4      5   
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:345 */
    5      7   
    Ok(
    6         -
        crate::protocol_serde::shape_constrained_http_payload_bound_shape_operation_output::ser_http_payload_bound_constrained_shape_payload(payload)?
    7         -
    )
           8  +
        /* HttpBoundProtocolPayloadGenerator.kt:386 */crate::protocol_serde::shape_constrained_http_payload_bound_shape_operation_output::ser_http_payload_bound_constrained_shape_payload(payload)?
           9  +
    /* HttpBoundProtocolPayloadGenerator.kt:345 */)
          10  +
    /* HttpBoundProtocolPayloadGenerator.kt:311 */
    8     11   
}
    9     12   
          13  +
/* JsonSerializerGenerator.kt:240 */
   10     14   
pub fn ser_http_payload_bound_constrained_shape_payload(
   11     15   
    input: &crate::model::ConA,
   12     16   
) -> std::result::Result<
   13     17   
    ::std::vec::Vec<u8>,
   14     18   
    ::aws_smithy_types::error::operation::SerializationError,
   15     19   
> {
          20  +
    /* JsonSerializerGenerator.kt:245 */
   16     21   
    let mut out = String::new();
          22  +
    /* JsonSerializerGenerator.kt:246 */
   17     23   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          24  +
    /* JsonSerializerGenerator.kt:375 */
   18     25   
    crate::protocol_serde::shape_con_a::ser_con_a(&mut object, input)?;
          26  +
    /* JsonSerializerGenerator.kt:252 */
   19     27   
    object.finish();
          28  +
    /* JsonSerializerGenerator.kt:253 */
   20     29   
    Ok(out.into_bytes())
          30  +
    /* JsonSerializerGenerator.kt:240 */
   21     31   
}

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

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

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

@@ -1,1 +35,61 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_constrained_recursive_shapes_operation_output_output_output(
    3      4   
    value: &crate::output::ConstrainedRecursiveShapesOperationOutput,
    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_constrained_recursive_shapes_operation_output::ser_constrained_recursive_shapes_operation_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_constrained_recursive_shapes_operation_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::ConstrainedRecursiveShapesOperationOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.nested {
          24  +
        /* JsonSerializerGenerator.kt:495 */
   17     25   
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
   18     27   
        let mut object_2 = object.key("nested").start_object();
          28  +
        /* JsonSerializerGenerator.kt:375 */
   19     29   
        crate::protocol_serde::shape_recursive_shapes_input_output_nested1::ser_recursive_shapes_input_output_nested1(&mut object_2, var_1)?;
          30  +
        /* JsonSerializerGenerator.kt:515 */
   20     31   
        object_2.finish();
          32  +
        /* JsonSerializerGenerator.kt:382 */
   21     33   
    }
          34  +
    /* SerializerUtil.kt:42 */
   22     35   
    {
          36  +
        /* JsonSerializerGenerator.kt:484 */
   23     37   
        let mut array_3 = object.key("recursiveList").start_array();
          38  +
        /* JsonSerializerGenerator.kt:524 */
   24     39   
        for item_4 in &input.recursive_list {
          40  +
            /* SerializerUtil.kt:42 */
   25     41   
            {
          42  +
                /* JsonSerializerGenerator.kt:495 */
   26     43   
                #[allow(unused_mut)]
          44  +
                /* JsonSerializerGenerator.kt:496 */
   27     45   
                let mut object_5 = array_3.value().start_object();
          46  +
                /* JsonSerializerGenerator.kt:375 */
   28     47   
                crate::protocol_serde::shape_recursive_shapes_input_output_nested1::ser_recursive_shapes_input_output_nested1(&mut object_5, item_4)?;
          48  +
                /* JsonSerializerGenerator.kt:515 */
   29     49   
                object_5.finish();
          50  +
                /* SerializerUtil.kt:42 */
   30     51   
            }
          52  +
            /* JsonSerializerGenerator.kt:524 */
   31     53   
        }
          54  +
        /* JsonSerializerGenerator.kt:486 */
   32     55   
        array_3.finish();
          56  +
        /* SerializerUtil.kt:42 */
   33     57   
    }
          58  +
    /* JsonSerializerGenerator.kt:372 */
   34     59   
    Ok(())
          60  +
    /* JsonSerializerGenerator.kt:358 */
   35     61   
}

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

@@ -1,1 +95,133 @@
    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_constrained_shapes_only_in_output_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::ConstrainedShapesOnlyInOutputOperationInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
   17         -
        let mut input = crate::input::constrained_shapes_only_in_output_operation_input_internal::Builder::default();
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */let mut input = crate::input::constrained_shapes_only_in_output_operation_input_internal::Builder::default();
          22  +
        /* RustType.kt:516 */
   18     23   
        #[allow(unused_variables)]
          24  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     25   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     26   
            uri, headers, body, ..
   21     27   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          28  +
        /* ServerHttpBoundProtocolGenerator.kt:811 */
   22     29   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          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_constrained_shapes_only_in_output_operation_http_response(
   29     41   
    #[allow(unused_variables)] output: crate::output::ConstrainedShapesOnlyInOutputOperationOutput,
   30     42   
) -> std::result::Result<
   31     43   
    ::aws_smithy_http_server::response::Response,
   32     44   
    ::aws_smithy_http_server::protocol::rest_json_1::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/json",
   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_constrained_shapes_only_in_output_operation_output::ser_constrained_shapes_only_in_output_operation_output_output_output(&output)?
   46         -
        ;
          63  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_constrained_shapes_only_in_output_operation_output::ser_constrained_shapes_only_in_output_operation_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_constrained_shapes_only_in_output_operation_http_error(
   60     85   
    error: &crate::error::ConstrainedShapesOnlyInOutputOperationError,
   61     86   
) -> std::result::Result<
   62     87   
    ::aws_smithy_http_server::response::Response,
   63     88   
    ::aws_smithy_http_server::protocol::rest_json_1::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::ConstrainedShapesOnlyInOutputOperationError::InternalServerError(
   68     96   
                output,
   69     97   
            ) => {
          98  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   70     99   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         100  +
                /* RustType.kt:516 */
   71    101   
                #[allow(unused_mut)]
         102  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   72    103   
                let mut builder = ::http::Response::builder();
         104  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   73    105   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   74    106   
                    builder,
   75    107   
                    ::http::header::CONTENT_TYPE,
   76    108   
                    "application/json",
   77    109   
                );
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   78    111   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   79    112   
                    builder,
   80    113   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   81    114   
                    "InternalServerError",
   82    115   
                );
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   83    117   
                let content_length = payload.len();
   84    118   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    119   
                    builder,
   86    120   
                    ::http::header::CONTENT_LENGTH,
   87    121   
                    content_length,
   88    122   
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   89    124   
                builder
   90    125   
                    .status(500)
   91    126   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   92         -
            }
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         128  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   93    129   
        }
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
   94    131   
    })
         132  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
   95    133   
}

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

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

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

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

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

@@ -1,1 +23,37 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_constrained_shapes_operation_output_output_output(
    3      4   
    value: &crate::output::ConstrainedShapesOperationOutput,
    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_constrained_shapes_operation_output::ser_constrained_shapes_operation_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_constrained_shapes_operation_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::ConstrainedShapesOperationOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* SerializerUtil.kt:42 */
   16     23   
    {
          24  +
        /* JsonSerializerGenerator.kt:495 */
   17     25   
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
   18     27   
        let mut object_1 = object.key("conA").start_object();
          28  +
        /* JsonSerializerGenerator.kt:375 */
   19     29   
        crate::protocol_serde::shape_con_a::ser_con_a(&mut object_1, &input.con_a)?;
          30  +
        /* JsonSerializerGenerator.kt:515 */
   20     31   
        object_1.finish();
          32  +
        /* SerializerUtil.kt:42 */
   21     33   
    }
          34  +
    /* JsonSerializerGenerator.kt:372 */
   22     35   
    Ok(())
          36  +
    /* JsonSerializerGenerator.kt:358 */
   23     37   
}

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

@@ -1,1 +180,311 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
    2      3   
pub(crate) fn de_constrained_union<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:565 */
   16     18   
    let mut variant = None;
          19  +
    /* JsonParserGenerator.kt:567 */
   17     20   
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:568 */
   18     22   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
   19         -
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
   20         -
            match tokens.next().transpose()? {
   21         -
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   22         -
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
   23         -
                    if let ::std::option::Option::Some(::std::result::Result::Ok(
   24         -
                        ::aws_smithy_json::deserialize::Token::ValueNull { .. },
   25         -
                    )) = tokens.peek()
   26         -
                    {
   27         -
                        let _ = tokens.next().expect("peek returned a token")?;
   28         -
                        continue;
   29         -
                    }
   30         -
                    let key = key.to_unescaped()?;
   31         -
                    if key == "__type" {
   32         -
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
   33         -
                        continue;
   34         -
                    }
   35         -
                    if variant.is_some() {
   36         -
                        return Err(
   37         -
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   38         -
                                "encountered mixed variants in union",
   39         -
                            ),
   40         -
                        );
   41         -
                    }
   42         -
                    variant = match key.as_ref() {
          23  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:576 */
          32  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          33  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          34  +
                        )) = tokens.peek()
          35  +
                        {
          36  +
                            let _ = tokens.next().expect("peek returned a token")?;
          37  +
                            continue;
          38  +
                        }
          39  +
                        /* JsonParserGenerator.kt:585 */
          40  +
                        let key = key.to_unescaped()?;
          41  +
                        if key == "__type" {
          42  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          43  +
                            continue;
          44  +
                        }
          45  +
                        if variant.is_some() {
          46  +
                            return Err(
          47  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          48  +
                                    "encountered mixed variants in union",
          49  +
                                ),
          50  +
                            );
          51  +
                        }
          52  +
                        /* JsonParserGenerator.kt:598 */
          53  +
                        variant = match key.as_ref() {
          54  +
                            /* JsonParserGenerator.kt:601 */
   43     55   
                            "enumString" => {
          56  +
                                /* JsonParserGenerator.kt:611 */
   44     57   
                                Some(crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained::EnumString(
   45         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   46         -
                                        s.to_unescaped().map(|u|
   47         -
                                            u.into_owned()
   48         -
                                        )
   49         -
                                    ).transpose()?
   50         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumString' cannot be null"))?
   51         -
                                ))
          58  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          59  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          60  +
                                            /* JsonParserGenerator.kt:343 */u.into_owned()
          61  +
                                        /* JsonParserGenerator.kt:339 */)
          62  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          63  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumString' cannot be null"))?
          64  +
                                /* JsonParserGenerator.kt:611 */))
          65  +
                                /* JsonParserGenerator.kt:601 */
   52     66   
                            }
          67  +
                            /* JsonParserGenerator.kt:601 */
   53     68   
                            "lengthString" => {
          69  +
                                /* JsonParserGenerator.kt:611 */
   54     70   
                                Some(crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained::LengthString(
   55         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
   56         -
                                        s.to_unescaped().map(|u|
   57         -
                                            u.into_owned()
   58         -
                                        )
   59         -
                                    ).transpose()?
   60         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'lengthString' cannot be null"))?
   61         -
                                ))
          71  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          72  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          73  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          74  +
                                        /* JsonParserGenerator.kt:339 */)
          75  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          76  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'lengthString' cannot be null"))?
          77  +
                                /* JsonParserGenerator.kt:611 */))
          78  +
                                /* JsonParserGenerator.kt:601 */
   62     79   
                            }
          80  +
                            /* JsonParserGenerator.kt:601 */
   63     81   
                            "constrainedStructure" => {
          82  +
                                /* JsonParserGenerator.kt:611 */
   64     83   
                                Some(crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained::ConstrainedStructure(
   65         -
                                    crate::protocol_serde::shape_con_b::de_con_b(tokens)?
   66         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'constrainedStructure' cannot be null"))?
   67         -
                                ))
          84  +
                                    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_con_b::de_con_b(tokens)?
          85  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'constrainedStructure' cannot be null"))?
          86  +
                                /* JsonParserGenerator.kt:611 */))
          87  +
                                /* JsonParserGenerator.kt:601 */
   68     88   
                            }
          89  +
                            /* JsonParserGenerator.kt:601 */
   69     90   
                            "conBList" => {
          91  +
                                /* JsonParserGenerator.kt:611 */
   70     92   
                                Some(crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained::ConBList(
   71         -
                                    crate::protocol_serde::shape_con_b_list::de_con_b_list(tokens)?
   72         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'conBList' cannot be null"))?
   73         -
                                ))
          93  +
                                    /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_con_b_list::de_con_b_list(tokens)?
          94  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'conBList' cannot be null"))?
          95  +
                                /* JsonParserGenerator.kt:611 */))
          96  +
                                /* JsonParserGenerator.kt:601 */
   74     97   
                            }
          98  +
                            /* JsonParserGenerator.kt:601 */
   75     99   
                            "conBSet" => {
         100  +
                                /* JsonParserGenerator.kt:611 */
   76    101   
                                Some(crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained::ConBSet(
   77         -
                                    crate::protocol_serde::shape_con_b_set::de_con_b_set(tokens)?
   78         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'conBSet' cannot be null"))?
   79         -
                                ))
         102  +
                                    /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_con_b_set::de_con_b_set(tokens)?
         103  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'conBSet' cannot be null"))?
         104  +
                                /* JsonParserGenerator.kt:611 */))
         105  +
                                /* JsonParserGenerator.kt:601 */
   80    106   
                            }
         107  +
                            /* JsonParserGenerator.kt:601 */
   81    108   
                            "conBMap" => {
         109  +
                                /* JsonParserGenerator.kt:611 */
   82    110   
                                Some(crate::unconstrained::constrained_union_unconstrained::ConstrainedUnionUnconstrained::ConBMap(
   83         -
                                    crate::protocol_serde::shape_con_b_map::de_con_b_map(tokens)?
   84         -
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'conBMap' cannot be null"))?
   85         -
                                ))
         111  +
                                    /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_con_b_map::de_con_b_map(tokens)?
         112  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'conBMap' cannot be null"))?
         113  +
                                /* JsonParserGenerator.kt:611 */))
         114  +
                                /* JsonParserGenerator.kt:601 */
   86    115   
                            }
   87         -
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {}", variant)))
         116  +
                            /* JsonParserGenerator.kt:634 */
         117  +
                            variant => {
         118  +
                                return Err(
         119  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         120  +
                                        format!("unexpected union variant: {}", variant),
         121  +
                                    ),
         122  +
                                )
         123  +
                            } /* JsonParserGenerator.kt:598 */
   88    124   
                        };
         125  +
                        /* JsonParserGenerator.kt:686 */
         126  +
                    }
         127  +
                    /* JsonParserGenerator.kt:695 */
         128  +
                    other => {
         129  +
                        return Err(
         130  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         131  +
                                format!("expected object key or end object, found: {:?}", other),
         132  +
                            ),
         133  +
                        )
         134  +
                    } /* JsonParserGenerator.kt:685 */
   89    135   
                }
   90         -
                other => {
   91         -
                    return Err(
   92         -
                        ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   93         -
                            "expected object key or end object, found: {:?}",
   94         -
                            other
   95         -
                        )),
   96         -
                    )
   97         -
                }
         136  +
                /* JsonParserGenerator.kt:684 */
   98    137   
            }
   99         -
        },
         138  +
            /* JsonParserGenerator.kt:568 */
         139  +
        }
         140  +
        /* JsonParserGenerator.kt:642 */
  100    141   
        _ => {
  101    142   
            return Err(
  102    143   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  103    144   
                    "expected start object or null",
  104    145   
                ),
  105    146   
            )
  106         -
        }
         147  +
        } /* JsonParserGenerator.kt:567 */
  107    148   
    }
         149  +
    /* JsonParserGenerator.kt:649 */
  108    150   
    if variant.is_none() {
  109    151   
        return Err(
  110    152   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  111    153   
                "Union did not contain a valid variant.",
  112    154   
            ),
  113    155   
        );
  114    156   
    }
         157  +
    /* JsonParserGenerator.kt:657 */
  115    158   
    Ok(variant)
         159  +
    /* JsonParserGenerator.kt:551 */
  116    160   
}
  117    161   
         162  +
/* JsonSerializerGenerator.kt:547 */
  118    163   
pub fn ser_constrained_union(
  119    164   
    object_71: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
  120    165   
    input: &crate::model::ConstrainedUnion,
  121    166   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         167  +
    /* JsonSerializerGenerator.kt:556 */
  122    168   
    match input {
         169  +
        /* JsonSerializerGenerator.kt:564 */
  123    170   
        crate::model::ConstrainedUnion::EnumString(inner) => {
  124         -
            object_71.key("enumString").string(inner.as_str());
         171  +
            /* SerializerUtil.kt:42 */
         172  +
            {
         173  +
                /* JsonSerializerGenerator.kt:423 */
         174  +
                object_71.key("enumString").string(inner.as_str());
         175  +
                /* SerializerUtil.kt:42 */
         176  +
            }
         177  +
            /* JsonSerializerGenerator.kt:564 */
  125    178   
        }
         179  +
        /* JsonSerializerGenerator.kt:564 */
  126    180   
        crate::model::ConstrainedUnion::LengthString(inner) => {
  127         -
            object_71.key("lengthString").string(inner.as_str());
         181  +
            /* SerializerUtil.kt:42 */
         182  +
            {
         183  +
                /* JsonSerializerGenerator.kt:423 */
         184  +
                object_71.key("lengthString").string(inner.as_str());
         185  +
                /* SerializerUtil.kt:42 */
         186  +
            }
         187  +
            /* JsonSerializerGenerator.kt:564 */
  128    188   
        }
         189  +
        /* JsonSerializerGenerator.kt:564 */
  129    190   
        crate::model::ConstrainedUnion::ConstrainedStructure(inner) => {
  130         -
            #[allow(unused_mut)]
  131         -
            let mut object_1 = object_71.key("constrainedStructure").start_object();
  132         -
            crate::protocol_serde::shape_con_b::ser_con_b(&mut object_1, inner)?;
  133         -
            object_1.finish();
         191  +
            /* SerializerUtil.kt:42 */
         192  +
            {
         193  +
                /* JsonSerializerGenerator.kt:495 */
         194  +
                #[allow(unused_mut)]
         195  +
                /* JsonSerializerGenerator.kt:496 */
         196  +
                let mut object_1 = object_71.key("constrainedStructure").start_object();
         197  +
                /* JsonSerializerGenerator.kt:375 */
         198  +
                crate::protocol_serde::shape_con_b::ser_con_b(&mut object_1, inner)?;
         199  +
                /* JsonSerializerGenerator.kt:515 */
         200  +
                object_1.finish();
         201  +
                /* SerializerUtil.kt:42 */
         202  +
            }
         203  +
            /* JsonSerializerGenerator.kt:564 */
  134    204   
        }
         205  +
        /* JsonSerializerGenerator.kt:564 */
  135    206   
        crate::model::ConstrainedUnion::ConBList(inner) => {
  136         -
            let mut array_2 = object_71.key("conBList").start_array();
  137         -
            for item_3 in inner {
  138         -
                {
  139         -
                    let mut array_4 = array_2.value().start_array();
  140         -
                    for item_5 in item_3 {
  141         -
                        {
  142         -
                            #[allow(unused_mut)]
  143         -
                            let mut object_6 = array_4.value().start_object();
  144         -
                            crate::protocol_serde::shape_con_b::ser_con_b(&mut object_6, item_5)?;
  145         -
                            object_6.finish();
         207  +
            /* SerializerUtil.kt:42 */
         208  +
            {
         209  +
                /* JsonSerializerGenerator.kt:484 */
         210  +
                let mut array_2 = object_71.key("conBList").start_array();
         211  +
                /* JsonSerializerGenerator.kt:524 */
         212  +
                for item_3 in inner {
         213  +
                    /* SerializerUtil.kt:42 */
         214  +
                    {
         215  +
                        /* JsonSerializerGenerator.kt:484 */
         216  +
                        let mut array_4 = array_2.value().start_array();
         217  +
                        /* JsonSerializerGenerator.kt:524 */
         218  +
                        for item_5 in item_3 {
         219  +
                            /* SerializerUtil.kt:42 */
         220  +
                            {
         221  +
                                /* JsonSerializerGenerator.kt:495 */
         222  +
                                #[allow(unused_mut)]
         223  +
                                /* JsonSerializerGenerator.kt:496 */
         224  +
                                let mut object_6 = array_4.value().start_object();
         225  +
                                /* JsonSerializerGenerator.kt:375 */
         226  +
                                crate::protocol_serde::shape_con_b::ser_con_b(
         227  +
                                    &mut object_6,
         228  +
                                    item_5,
         229  +
                                )?;
         230  +
                                /* JsonSerializerGenerator.kt:515 */
         231  +
                                object_6.finish();
         232  +
                                /* SerializerUtil.kt:42 */
         233  +
                            }
         234  +
                            /* JsonSerializerGenerator.kt:524 */
  146    235   
                        }
         236  +
                        /* JsonSerializerGenerator.kt:486 */
         237  +
                        array_4.finish();
         238  +
                        /* SerializerUtil.kt:42 */
  147    239   
                    }
  148         -
                    array_4.finish();
         240  +
                    /* JsonSerializerGenerator.kt:524 */
  149    241   
                }
         242  +
                /* JsonSerializerGenerator.kt:486 */
         243  +
                array_2.finish();
         244  +
                /* SerializerUtil.kt:42 */
  150    245   
            }
  151         -
            array_2.finish();
         246  +
            /* JsonSerializerGenerator.kt:564 */
  152    247   
        }
         248  +
        /* JsonSerializerGenerator.kt:564 */
  153    249   
        crate::model::ConstrainedUnion::ConBSet(inner) => {
  154         -
            let mut array_7 = object_71.key("conBSet").start_array();
  155         -
            for item_8 in inner {
  156         -
                {
  157         -
                    let mut array_9 = array_7.value().start_array();
  158         -
                    for item_10 in item_8 {
  159         -
                        {
  160         -
                            array_9.value().string(item_10.as_str());
         250  +
            /* SerializerUtil.kt:42 */
         251  +
            {
         252  +
                /* JsonSerializerGenerator.kt:484 */
         253  +
                let mut array_7 = object_71.key("conBSet").start_array();
         254  +
                /* JsonSerializerGenerator.kt:524 */
         255  +
                for item_8 in inner {
         256  +
                    /* SerializerUtil.kt:42 */
         257  +
                    {
         258  +
                        /* JsonSerializerGenerator.kt:484 */
         259  +
                        let mut array_9 = array_7.value().start_array();
         260  +
                        /* JsonSerializerGenerator.kt:524 */
         261  +
                        for item_10 in item_8 {
         262  +
                            /* SerializerUtil.kt:42 */
         263  +
                            {
         264  +
                                /* JsonSerializerGenerator.kt:423 */
         265  +
                                array_9.value().string(item_10.as_str());
         266  +
                                /* SerializerUtil.kt:42 */
         267  +
                            }
         268  +
                            /* JsonSerializerGenerator.kt:524 */
  161    269   
                        }
         270  +
                        /* JsonSerializerGenerator.kt:486 */
         271  +
                        array_9.finish();
         272  +
                        /* SerializerUtil.kt:42 */
  162    273   
                    }
  163         -
                    array_9.finish();
         274  +
                    /* JsonSerializerGenerator.kt:524 */
  164    275   
                }
         276  +
                /* JsonSerializerGenerator.kt:486 */
         277  +
                array_7.finish();
         278  +
                /* SerializerUtil.kt:42 */
  165    279   
            }
  166         -
            array_7.finish();
         280  +
            /* JsonSerializerGenerator.kt:564 */
  167    281   
        }
         282  +
        /* JsonSerializerGenerator.kt:564 */
  168    283   
        crate::model::ConstrainedUnion::ConBMap(inner) => {
  169         -
            #[allow(unused_mut)]
  170         -
            let mut object_11 = object_71.key("conBMap").start_object();
  171         -
            for (key_12, value_13) in inner {
  172         -
                {
  173         -
                    object_11.key(key_12.as_str()).string(value_13.as_str());
         284  +
            /* SerializerUtil.kt:42 */
         285  +
            {
         286  +
                /* JsonSerializerGenerator.kt:495 */
         287  +
                #[allow(unused_mut)]
         288  +
                /* JsonSerializerGenerator.kt:496 */
         289  +
                let mut object_11 = object_71.key("conBMap").start_object();
         290  +
                /* JsonSerializerGenerator.kt:537 */
         291  +
                for (key_12, value_13) in inner {
         292  +
                    /* SerializerUtil.kt:42 */
         293  +
                    {
         294  +
                        /* JsonSerializerGenerator.kt:423 */
         295  +
                        object_11.key(key_12.as_str()).string(value_13.as_str());
         296  +
                        /* SerializerUtil.kt:42 */
         297  +
                    }
         298  +
                    /* JsonSerializerGenerator.kt:537 */
  174    299   
                }
         300  +
                /* JsonSerializerGenerator.kt:515 */
         301  +
                object_11.finish();
         302  +
                /* SerializerUtil.kt:42 */
  175    303   
            }
  176         -
            object_11.finish();
         304  +
            /* JsonSerializerGenerator.kt:564 */
  177    305   
        }
         306  +
        /* JsonSerializerGenerator.kt:556 */
  178    307   
    }
         308  +
    /* JsonSerializerGenerator.kt:576 */
  179    309   
    Ok(())
         310  +
    /* JsonSerializerGenerator.kt:547 */
  180    311   
}

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

@@ -1,1 +15,30 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:547 */
    2      3   
pub fn ser_constrained_union_in_output(
    3      4   
    object_4: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    4      5   
    input: &crate::model::ConstrainedUnionInOutput,
    5      6   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           7  +
    /* JsonSerializerGenerator.kt:556 */
    6      8   
    match input {
           9  +
        /* JsonSerializerGenerator.kt:564 */
    7     10   
        crate::model::ConstrainedUnionInOutput::Structure(inner) => {
    8         -
            #[allow(unused_mut)]
    9         -
            let mut object_1 = object_4.key("structure").start_object();
   10         -
            crate::protocol_serde::shape_transitively_constrained_structure_in_output::ser_transitively_constrained_structure_in_output(&mut object_1, inner)?;
   11         -
            object_1.finish();
          11  +
            /* SerializerUtil.kt:42 */
          12  +
            {
          13  +
                /* JsonSerializerGenerator.kt:495 */
          14  +
                #[allow(unused_mut)]
          15  +
                /* JsonSerializerGenerator.kt:496 */
          16  +
                let mut object_1 = object_4.key("structure").start_object();
          17  +
                /* JsonSerializerGenerator.kt:375 */
          18  +
                crate::protocol_serde::shape_transitively_constrained_structure_in_output::ser_transitively_constrained_structure_in_output(&mut object_1, inner)?;
          19  +
                /* JsonSerializerGenerator.kt:515 */
          20  +
                object_1.finish();
          21  +
                /* SerializerUtil.kt:42 */
          22  +
            }
          23  +
            /* JsonSerializerGenerator.kt:564 */
   12     24   
        }
          25  +
        /* JsonSerializerGenerator.kt:556 */
   13     26   
    }
          27  +
    /* JsonSerializerGenerator.kt:576 */
   14     28   
    Ok(())
          29  +
    /* JsonSerializerGenerator.kt:547 */
   15     30   
}

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

@@ -1,1 +16,23 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:240 */
    2      3   
pub fn ser_regular_message_payload(
    3      4   
    input: &crate::model::EventStreamRegularMessage,
    4      5   
) -> std::result::Result<
    5      6   
    ::std::vec::Vec<u8>,
    6      7   
    ::aws_smithy_types::error::operation::SerializationError,
    7      8   
> {
           9  +
    /* JsonSerializerGenerator.kt:245 */
    8     10   
    let mut out = String::new();
          11  +
    /* JsonSerializerGenerator.kt:246 */
    9     12   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          13  +
    /* JsonSerializerGenerator.kt:375 */
   10     14   
    crate::protocol_serde::shape_event_stream_regular_message::ser_event_stream_regular_message(
   11     15   
        &mut object,
   12     16   
        input,
   13     17   
    )?;
          18  +
    /* JsonSerializerGenerator.kt:252 */
   14     19   
    object.finish();
          20  +
    /* JsonSerializerGenerator.kt:253 */
   15     21   
    Ok(out.into_bytes())
          22  +
    /* JsonSerializerGenerator.kt:240 */
   16     23   
}

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

@@ -1,1 +72,105 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_event_stream_error_message_error(
    3      4   
    value: &crate::error::EventStreamErrorMessage,
    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_event_stream_error_message::ser_event_stream_error_message(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_event_stream_error_message(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::error::EventStreamErrorMessage,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
   19     26   
    if let Some(var_1) = &input.message_content {
          27  +
        /* JsonSerializerGenerator.kt:423 */
   20     28   
        object.key("messageContent").string(var_1.as_str());
          29  +
        /* JsonSerializerGenerator.kt:382 */
   21     30   
    }
          31  +
    /* JsonSerializerGenerator.kt:372 */
   22     32   
    Ok(())
          33  +
    /* JsonSerializerGenerator.kt:358 */
   23     34   
}
   24     35   
          36  +
/* JsonParserGenerator.kt:148 */
   25     37   
pub(crate) fn de_event_stream_error_message_json_err(
   26     38   
    value: &[u8],
   27     39   
    mut builder: crate::error::event_stream_error_message_internal::Builder,
   28     40   
) -> ::std::result::Result<
   29     41   
    crate::error::event_stream_error_message_internal::Builder,
   30     42   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   31     43   
> {
          44  +
    /* JsonParserGenerator.kt:153 */
   32     45   
    let mut tokens_owned =
   33     46   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   34     47   
            .peekable();
   35     48   
    let tokens = &mut tokens_owned;
   36     49   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          50  +
    /* JsonParserGenerator.kt:684 */
   37     51   
    loop {
          52  +
        /* JsonParserGenerator.kt:685 */
   38     53   
        match tokens.next().transpose()? {
          54  +
            /* JsonParserGenerator.kt:686 */
   39     55   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   40     56   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          57  +
                /* JsonParserGenerator.kt:260 */
   41     58   
                match key.to_unescaped()?.as_ref() {
          59  +
                    /* JsonParserGenerator.kt:262 */
   42     60   
                    "messageContent" => {
          61  +
                        /* JsonParserGenerator.kt:272 */
   43     62   
                        builder = builder.set_message_content(
          63  +
                            /* JsonParserGenerator.kt:354 */
   44     64   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
   45     65   
                                tokens.next(),
   46     66   
                            )?
   47         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   48         -
                            .transpose()?,
          67  +
                            .map(|s|
          68  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          69  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          70  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
          71  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
   49     72   
                        );
          73  +
                        /* JsonParserGenerator.kt:262 */
   50     74   
                    }
   51         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          75  +
                    /* JsonParserGenerator.kt:290 */
          76  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   52     77   
                }
          78  +
                /* JsonParserGenerator.kt:686 */
   53     79   
            }
          80  +
            /* JsonParserGenerator.kt:695 */
   54     81   
            other => {
   55     82   
                return Err(
   56     83   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   57     84   
                        "expected object key or end object, found: {:?}",
   58     85   
                        other
   59     86   
                    )),
   60     87   
                )
   61         -
            }
          88  +
            } /* JsonParserGenerator.kt:685 */
   62     89   
        }
          90  +
        /* JsonParserGenerator.kt:684 */
   63     91   
    }
          92  +
    /* JsonParserGenerator.kt:250 */
   64     93   
    if tokens.next().is_some() {
          94  +
        /* JsonParserGenerator.kt:251 */
   65     95   
        return Err(
   66     96   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   67     97   
                "found more JSON tokens after completing parsing",
   68     98   
            ),
   69     99   
        );
         100  +
        /* JsonParserGenerator.kt:250 */
   70    101   
    }
         102  +
    /* JsonParserGenerator.kt:163 */
   71    103   
    Ok(builder)
         104  +
    /* JsonParserGenerator.kt:148 */
   72    105   
}

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

@@ -1,1 +95,127 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:175 */
    2      3   
pub(crate) fn de_event_stream_regular_message_payload(
    3      4   
    input: &[u8],
    4      5   
) -> ::std::result::Result<
    5      6   
    crate::model::EventStreamRegularMessage,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
> {
           9  +
    /* JsonParserGenerator.kt:187 */
    8     10   
    let mut tokens_owned =
    9     11   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(input))
   10     12   
            .peekable();
   11     13   
    let tokens = &mut tokens_owned;
          14  +
    /* JsonParserGenerator.kt:194 */
   12     15   
    let result =
   13         -
        crate::protocol_serde::shape_event_stream_regular_message::de_event_stream_regular_message(
   14         -
            tokens,
   15         -
        )?
   16         -
        .ok_or_else(|| {
   17         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   18         -
                "expected payload member value",
   19         -
            )
   20         -
        });
          16  +
    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_event_stream_regular_message::de_event_stream_regular_message(tokens)?
          17  +
    /* JsonParserGenerator.kt:196 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          18  +
    /* JsonParserGenerator.kt:250 */
   21     19   
    if tokens.next().is_some() {
          20  +
        /* JsonParserGenerator.kt:251 */
   22     21   
        return Err(
   23     22   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   24     23   
                "found more JSON tokens after completing parsing",
   25     24   
            ),
   26     25   
        );
          26  +
        /* JsonParserGenerator.kt:250 */
   27     27   
    }
          28  +
    /* JsonParserGenerator.kt:198 */
   28     29   
    result
          30  +
    /* JsonParserGenerator.kt:175 */
   29     31   
}
   30     32   
          33  +
/* JsonSerializerGenerator.kt:358 */
   31     34   
pub fn ser_event_stream_regular_message(
   32     35   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   33     36   
    input: &crate::model::EventStreamRegularMessage,
   34     37   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          38  +
    /* JsonSerializerGenerator.kt:382 */
   35     39   
    if let Some(var_1) = &input.message_content {
          40  +
        /* JsonSerializerGenerator.kt:423 */
   36     41   
        object.key("messageContent").string(var_1.as_str());
          42  +
        /* JsonSerializerGenerator.kt:382 */
   37     43   
    }
          44  +
    /* JsonSerializerGenerator.kt:372 */
   38     45   
    Ok(())
          46  +
    /* JsonSerializerGenerator.kt:358 */
   39     47   
}
   40     48   
          49  +
/* JsonParserGenerator.kt:516 */
   41     50   
pub(crate) fn de_event_stream_regular_message<'a, I>(
   42     51   
    tokens: &mut ::std::iter::Peekable<I>,
   43     52   
) -> ::std::result::Result<
   44     53   
    Option<crate::model::EventStreamRegularMessage>,
   45     54   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   46     55   
>
   47     56   
where
   48     57   
    I: Iterator<
   49     58   
        Item = Result<
   50     59   
            ::aws_smithy_json::deserialize::Token<'a>,
   51     60   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   52     61   
        >,
   53     62   
    >,
   54     63   
{
          64  +
    /* JsonParserGenerator.kt:712 */
   55     65   
    match tokens.next().transpose()? {
          66  +
        /* JsonParserGenerator.kt:713 */
   56     67   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   57     68   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          69  +
            /* RustType.kt:516 */
   58     70   
            #[allow(unused_mut)]
          71  +
            /* JsonParserGenerator.kt:526 */
   59     72   
            let mut builder =
   60     73   
                crate::model::event_stream_regular_message_internal::Builder::default();
          74  +
            /* JsonParserGenerator.kt:684 */
   61     75   
            loop {
          76  +
                /* JsonParserGenerator.kt:685 */
   62     77   
                match tokens.next().transpose()? {
          78  +
                    /* JsonParserGenerator.kt:686 */
   63     79   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   64     80   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          81  +
                        /* JsonParserGenerator.kt:260 */
   65     82   
                        match key.to_unescaped()?.as_ref() {
          83  +
                            /* JsonParserGenerator.kt:262 */
   66     84   
                            "messageContent" => {
          85  +
                                /* JsonParserGenerator.kt:272 */
   67     86   
                                builder = builder.set_message_content(
   68         -
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
   69         -
                                        tokens.next(),
   70         -
                                    )?
   71         -
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   72         -
                                    .transpose()?,
   73         -
                                );
          87  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          88  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          89  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          90  +
                                        /* JsonParserGenerator.kt:339 */)
          91  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          92  +
                                /* JsonParserGenerator.kt:272 */);
          93  +
                                /* JsonParserGenerator.kt:262 */
   74     94   
                            }
   75         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          95  +
                            /* JsonParserGenerator.kt:290 */
          96  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   76     97   
                        }
          98  +
                        /* JsonParserGenerator.kt:686 */
   77     99   
                    }
         100  +
                    /* JsonParserGenerator.kt:695 */
   78    101   
                    other => {
   79    102   
                        return Err(
   80    103   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   81    104   
                                format!("expected object key or end object, found: {:?}", other),
   82    105   
                            ),
   83    106   
                        )
   84         -
                    }
         107  +
                    } /* JsonParserGenerator.kt:685 */
   85    108   
                }
         109  +
                /* JsonParserGenerator.kt:684 */
   86    110   
            }
         111  +
            /* JsonParserGenerator.kt:540 */
   87    112   
            Ok(Some(builder.build()))
         113  +
            /* JsonParserGenerator.kt:713 */
   88    114   
        }
   89         -
        _ => Err(
   90         -
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   91         -
                "expected start object or null",
   92         -
            ),
   93         -
        ),
         115  +
        /* JsonParserGenerator.kt:722 */
         116  +
        _ => {
         117  +
            /* JsonParserGenerator.kt:723 */
         118  +
            Err(
         119  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         120  +
                    "expected start object or null",
         121  +
                ),
         122  +
            )
         123  +
            /* JsonParserGenerator.kt:722 */
         124  +
        } /* JsonParserGenerator.kt:712 */
   94    125   
    }
         126  +
    /* JsonParserGenerator.kt:516 */
   95    127   
}

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

@@ -1,1 +151,210 @@
    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_event_streams_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::EventStreamsOperationInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
   12     14   
    B::Data: Send,
   13     15   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   14     16   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   15     17   
{
          18  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   16     19   
    Ok({
          20  +
        /* RustType.kt:516 */
   17     21   
        #[allow(unused_mut)]
          22  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   18     23   
        let mut input = crate::input::event_streams_operation_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:794 */
   23     31   
        if let Some(value) = {
   24     32   
            Some(
   25     33   
                crate::protocol_serde::shape_event_streams_operation_input::de_events_payload(
   26     34   
                    &mut body.into().into_inner(),
   27     35   
                )?,
   28     36   
            )
   29     37   
        } {
   30     38   
            input = input.set_events(value)
   31     39   
        }
          40  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   32     41   
        input.build()?
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   33     43   
    })
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   34     45   
}
   35     46   
          47  +
/* RustType.kt:516 */
   36     48   
#[allow(clippy::unnecessary_wraps)]
          49  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   37     50   
pub fn ser_event_streams_operation_http_response(
   38     51   
    #[allow(unused_variables)] output: crate::output::EventStreamsOperationOutput,
   39     52   
) -> std::result::Result<
   40     53   
    ::aws_smithy_http_server::response::Response,
   41     54   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   42     55   
> {
          56  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   43     57   
    Ok({
          58  +
        /* RustType.kt:516 */
   44     59   
        #[allow(unused_mut)]
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   45     61   
        let mut builder = ::http::Response::builder();
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   46     63   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   47     64   
            builder,
   48     65   
            ::http::header::CONTENT_TYPE,
   49     66   
            "application/vnd.amazon.eventstream",
   50     67   
        );
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   51     69   
        let http_status: u16 = 200;
   52     70   
        builder = builder.status(http_status);
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:543 */
   53     72   
        let body = ::aws_smithy_http_server::body::boxed(
   54         -
            ::aws_smithy_http_server::body::Body::wrap_stream({
   55         -
                let error_marshaller = crate::event_stream_serde::EventErrorMarshaller::new();
   56         -
                let marshaller = crate::event_stream_serde::EventMarshaller::new();
   57         -
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
   58         -
                let adapter: ::aws_smithy_http::event_stream::MessageStreamAdapter<_, _> = output
   59         -
                    .events
   60         -
                    .into_body_stream(marshaller, error_marshaller, signer);
   61         -
                adapter
   62         -
            }),
          73  +
            ::aws_smithy_http_server::body::Body::wrap_stream(
          74  +
                /* ServerHttpBoundProtocolGenerator.kt:135 */
          75  +
                {
          76  +
                    let error_marshaller = crate::event_stream_serde::EventErrorMarshaller::new();
          77  +
                    let marshaller = crate::event_stream_serde::EventMarshaller::new();
          78  +
                    let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          79  +
                    let adapter: ::aws_smithy_http::event_stream::MessageStreamAdapter<_, _> =
          80  +
                        output
          81  +
                            .events
          82  +
                            .into_body_stream(marshaller, error_marshaller, signer);
          83  +
                    adapter
          84  +
                }, /* ServerHttpBoundProtocolGenerator.kt:543 */
          85  +
            ),
   63     86   
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   64     88   
        builder.body(body)?
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   65     90   
    })
          91  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   66     92   
}
   67     93   
          94  +
/* RustType.kt:516 */
   68     95   
#[allow(clippy::unnecessary_wraps)]
          96  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   69     97   
pub fn ser_event_streams_operation_http_error(
   70     98   
    error: &crate::error::EventStreamsOperationError,
   71     99   
) -> std::result::Result<
   72    100   
    ::aws_smithy_http_server::response::Response,
   73    101   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   74    102   
> {
         103  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   75    104   
    Ok({
         105  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   76    106   
        match error {
         107  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   77    108   
            crate::error::EventStreamsOperationError::ValidationException(output) => {
         109  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   78    110   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         111  +
                /* RustType.kt:516 */
   79    112   
                #[allow(unused_mut)]
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   80    114   
                let mut builder = ::http::Response::builder();
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   81    116   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82    117   
                    builder,
   83    118   
                    ::http::header::CONTENT_TYPE,
   84    119   
                    "application/vnd.amazon.eventstream",
   85    120   
                );
         121  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   86    122   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    123   
                    builder,
   88    124   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   89    125   
                    "ValidationException",
   90    126   
                );
         127  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   91    128   
                let content_length = payload.len();
   92    129   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   93    130   
                    builder,
   94    131   
                    ::http::header::CONTENT_LENGTH,
   95    132   
                    content_length,
   96    133   
                );
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   97    135   
                builder
   98    136   
                    .status(400)
   99    137   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         138  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  100    139   
            }
         140  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  101    141   
            crate::error::EventStreamsOperationError::EventStreamErrorMessage(output) => {
         142  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  102    143   
                let payload = crate::protocol_serde::shape_event_stream_error_message::ser_event_stream_error_message_error(output)?;
         144  +
                /* RustType.kt:516 */
  103    145   
                #[allow(unused_mut)]
         146  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  104    147   
                let mut builder = ::http::Response::builder();
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  105    149   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  106    150   
                    builder,
  107    151   
                    ::http::header::CONTENT_TYPE,
  108    152   
                    "application/vnd.amazon.eventstream",
  109    153   
                );
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  110    155   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  111    156   
                    builder,
  112    157   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  113    158   
                    "EventStreamErrorMessage",
  114    159   
                );
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  115    161   
                let content_length = payload.len();
  116    162   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    163   
                    builder,
  118    164   
                    ::http::header::CONTENT_LENGTH,
  119    165   
                    content_length,
  120    166   
                );
         167  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  121    168   
                builder
  122    169   
                    .status(500)
  123    170   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         171  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
  124    172   
            }
         173  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  125    174   
            crate::error::EventStreamsOperationError::InternalServerError(output) => {
         175  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  126    176   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         177  +
                /* RustType.kt:516 */
  127    178   
                #[allow(unused_mut)]
         179  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  128    180   
                let mut builder = ::http::Response::builder();
         181  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  129    182   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    183   
                    builder,
  131    184   
                    ::http::header::CONTENT_TYPE,
  132    185   
                    "application/vnd.amazon.eventstream",
  133    186   
                );
         187  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  134    188   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  135    189   
                    builder,
  136    190   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  137    191   
                    "InternalServerError",
  138    192   
                );
         193  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  139    194   
                let content_length = payload.len();
  140    195   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  141    196   
                    builder,
  142    197   
                    ::http::header::CONTENT_LENGTH,
  143    198   
                    content_length,
  144    199   
                );
         200  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  145    201   
                builder
  146    202   
                    .status(500)
  147    203   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  148         -
            }
         204  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         205  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  149    206   
        }
         207  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  150    208   
    })
         209  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  151    210   
}

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

@@ -1,1 +16,19 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:230 */
    2      3   
pub fn de_events_payload(
    3      4   
    body: &mut ::aws_smithy_types::body::SdkBody,
    4      5   
) -> std::result::Result<
    5      6   
    crate::python_event_stream::EventStreamsOperationInputEventsReceiver,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:272 */
    8     10   
    let unmarshaller = crate::event_stream_serde::EventUnmarshaller::new();
    9     11   
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
   10     12   
    Ok(
   11     13   
        crate::python_event_stream::EventStreamsOperationInputEventsReceiver::new(
   12     14   
            unmarshaller,
   13     15   
            body,
   14     16   
        ),
   15     17   
    )
          18  +
    /* HttpBindingGenerator.kt:230 */
   16     19   
}