Server Test Python

Server Test Python

rev. d838bf488731ae5e751cce0fe13f339a5b9be858 (ignoring whitespace)

Files changed:

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

@@ -1,1 +95,107 @@
    8      8   
pub(crate) mod shape_content_type_parameters;
    9      9   
   10     10   
pub(crate) mod shape_datetime_offsets;
   11     11   
   12     12   
pub(crate) mod shape_document_type;
   13     13   
   14     14   
pub(crate) mod shape_document_type_as_map_value;
   15     15   
   16     16   
pub(crate) mod shape_document_type_as_payload;
   17     17   
          18  +
pub(crate) mod shape_duplex_stream;
          19  +
          20  +
pub(crate) mod shape_duplex_stream_with_distinct_streams;
          21  +
          22  +
pub(crate) mod shape_duplex_stream_with_initial_messages;
          23  +
   18     24   
pub(crate) mod shape_empty_input_and_empty_output;
   19     25   
   20     26   
pub(crate) mod shape_endpoint_operation;
   21     27   
   22     28   
pub(crate) mod shape_endpoint_with_host_label_operation;
   23     29   
   24     30   
pub(crate) mod shape_fractional_seconds;
   25     31   
   26     32   
pub(crate) mod shape_greeting_with_errors;
   27     33   
   28     34   
pub(crate) mod shape_host_with_path_operation;
   29     35   
   30     36   
pub(crate) mod shape_http_checksum_required;
   31     37   
   32     38   
pub(crate) mod shape_http_empty_prefix_headers;
   33     39   
   34     40   
pub(crate) mod shape_http_enum_payload;
   35     41   
   36     42   
pub(crate) mod shape_http_payload_traits;
   37     43   
   38     44   
pub(crate) mod shape_http_payload_traits_with_media_type;
   39     45   
   40     46   
pub(crate) mod shape_http_payload_with_structure;
   41     47   
   42     48   
pub(crate) mod shape_http_payload_with_union;
   43     49   
   44     50   
pub(crate) mod shape_http_prefix_headers;
   45     51   
   46     52   
pub(crate) mod shape_http_prefix_headers_in_response;
   47     53   
          54  +
pub(crate) mod shape_http_query_params_only_operation;
          55  +
   48     56   
pub(crate) mod shape_http_request_with_float_labels;
   49     57   
   50     58   
pub(crate) mod shape_http_request_with_greedy_label_in_path;
   51     59   
   52     60   
pub(crate) mod shape_http_request_with_labels;
   53     61   
   54     62   
pub(crate) mod shape_http_request_with_labels_and_timestamp_format;
   55     63   
   56     64   
pub(crate) mod shape_http_request_with_regex_literal;
   57     65   
   58     66   
pub(crate) mod shape_http_response_code;
   59     67   
   60     68   
pub(crate) mod shape_http_string_payload;
   61     69   
   62     70   
pub(crate) mod shape_ignore_query_params_in_response;
   63     71   
   64     72   
pub(crate) mod shape_input_and_output_with_headers;
   65     73   
          74  +
pub(crate) mod shape_input_stream;
          75  +
          76  +
pub(crate) mod shape_input_stream_with_initial_request;
          77  +
   66     78   
pub(crate) mod shape_json_blobs;
   67     79   
   68     80   
pub(crate) mod shape_json_enums;
   69     81   
   70     82   
pub(crate) mod shape_json_int_enums;
   71     83   
   72     84   
pub(crate) mod shape_json_lists;
   73     85   
   74     86   
pub(crate) mod shape_json_maps;
   75     87   
@@ -134,146 +193,209 @@
  154    166   
pub(crate) mod shape_null_and_empty_headers_server;
  155    167   
  156    168   
pub(crate) mod shape_omits_null_serializes_empty_string;
  157    169   
  158    170   
pub(crate) mod shape_omits_serializing_empty_lists;
  159    171   
  160    172   
pub(crate) mod shape_operation_with_defaults;
  161    173   
  162    174   
pub(crate) mod shape_operation_with_nested_structure;
  163    175   
         176  +
pub(crate) mod shape_output_stream;
         177  +
         178  +
pub(crate) mod shape_output_stream_with_initial_response;
         179  +
  164    180   
pub(crate) mod shape_post_player_action;
  165    181   
  166    182   
pub(crate) mod shape_post_union_with_json_name;
  167    183   
  168    184   
pub(crate) mod shape_put_with_content_encoding;
  169    185   
  170    186   
pub(crate) mod shape_query_idempotency_token_auto_fill;
  171    187   
  172    188   
pub(crate) mod shape_query_params_as_string_list_map;
  173    189   
@@ -216,232 +345,375 @@
  236    252   
pub fn serialize_document(input: &::aws_smithy_types::Document) -> ::std::vec::Vec<u8> {
  237    253   
    let mut out = String::new();
  238    254   
    ::aws_smithy_json::serialize::JsonValueWriter::new(&mut out).document(input);
  239    255   
    out.into_bytes()
  240    256   
}
  241    257   
  242    258   
pub(crate) mod shape_document_type_as_payload_output;
  243    259   
  244    260   
pub(crate) mod shape_document_type_output;
  245    261   
         262  +
pub(crate) mod shape_duplex_stream_input;
         263  +
         264  +
pub(crate) mod shape_duplex_stream_with_distinct_streams_input;
         265  +
         266  +
pub fn rest_json_unset_union_payload() -> ::std::vec::Vec<u8> {
         267  +
    ::std::vec::Vec::new()
         268  +
}
         269  +
         270  +
pub(crate) mod shape_duplex_stream_with_distinct_streams_output;
         271  +
         272  +
pub(crate) mod shape_duplex_stream_with_initial_messages_input;
         273  +
  246    274   
pub(crate) mod shape_empty_input_and_empty_output_output;
  247    275   
         276  +
pub(crate) mod shape_error_event;
         277  +
  248    278   
pub(crate) mod shape_foo_error;
  249    279   
  250    280   
pub(crate) mod shape_fractional_seconds_output;
  251    281   
  252    282   
pub(crate) mod shape_greeting_with_errors_output;
  253    283   
  254    284   
pub(crate) mod shape_http_checksum_required_output;
  255    285   
  256    286   
pub(crate) mod shape_http_empty_prefix_headers_input;
  257    287   
  258    288   
pub(crate) mod shape_http_empty_prefix_headers_output;
  259    289   
  260    290   
pub(crate) mod shape_http_enum_payload_input;
  261    291   
  262    292   
pub(crate) mod shape_http_enum_payload_output;
  263    293   
  264    294   
pub(crate) mod shape_http_payload_traits_input;
  265    295   
  266    296   
pub(crate) mod shape_http_payload_traits_output;
  267    297   
  268    298   
pub(crate) mod shape_http_payload_traits_with_media_type_input;
  269    299   
  270    300   
pub(crate) mod shape_http_payload_traits_with_media_type_output;
  271    301   
  272    302   
pub(crate) mod shape_http_payload_with_structure_input;
  273    303   
  274    304   
pub fn rest_json_unset_struct_payload() -> ::std::vec::Vec<u8> {
  275    305   
    b"{}"[..].into()
  276    306   
}
  277    307   
  278    308   
pub(crate) mod shape_http_payload_with_structure_output;
  279    309   
  280    310   
pub(crate) mod shape_http_payload_with_union_input;
  281    311   
  282         -
pub fn rest_json_unset_union_payload() -> ::std::vec::Vec<u8> {
  283         -
    ::std::vec::Vec::new()
  284         -
}
  285         -
  286    312   
pub(crate) mod shape_http_payload_with_union_output;
  287    313   
  288    314   
pub(crate) mod shape_http_prefix_headers_in_response_output;
  289    315   
  290    316   
pub(crate) mod shape_http_prefix_headers_input;
  291    317   
  292    318   
pub(crate) mod shape_http_prefix_headers_output;
  293    319   
  294    320   
pub(crate) mod shape_http_request_with_float_labels_input;
  295    321   
  296    322   
pub(crate) mod shape_http_request_with_greedy_label_in_path_input;
  297    323   
  298    324   
pub(crate) mod shape_http_request_with_labels_and_timestamp_format_input;
  299    325   
  300    326   
pub(crate) mod shape_http_request_with_labels_input;
  301    327   
  302    328   
pub(crate) mod shape_http_request_with_regex_literal_input;
  303    329   
  304    330   
pub(crate) mod shape_http_response_code_output;
  305    331   
  306    332   
pub(crate) mod shape_http_string_payload_input;
  307    333   
  308    334   
pub(crate) mod shape_http_string_payload_output;
  309    335   
  310    336   
pub(crate) mod shape_ignore_query_params_in_response_output;
  311    337   
  312    338   
pub(crate) mod shape_input_and_output_with_headers_input;
  313    339   
  314    340   
pub(crate) mod shape_input_and_output_with_headers_output;
  315    341   
         342  +
pub(crate) mod shape_input_stream_input;
         343  +
         344  +
pub(crate) mod shape_input_stream_with_initial_request_input;
         345  +
  316    346   
pub(crate) mod shape_internal_server_error;
  317    347   
  318    348   
pub(crate) mod shape_invalid_greeting;
  319    349   
  320    350   
pub(crate) mod shape_json_blobs_output;
  321    351   
  322    352   
pub(crate) mod shape_json_enums_output;
  323    353   
  324    354   
pub(crate) mod shape_json_int_enums_output;
  325    355   
@@ -388,418 +447,479 @@
  408    438   
pub(crate) mod shape_query_params_as_string_list_map_input;
  409    439   
  410    440   
pub(crate) mod shape_query_precedence_input;
  411    441   
  412    442   
pub(crate) mod shape_recursive_shapes_output;
  413    443   
  414    444   
pub(crate) mod shape_response_code_http_fallback_output;
  415    445   
  416    446   
pub(crate) mod shape_response_code_required_output;
  417    447   
         448  +
pub(crate) mod shape_service_unavailable_error;
         449  +
  418    450   
pub(crate) mod shape_simple_scalar_properties_input;
  419    451   
  420    452   
pub(crate) mod shape_simple_scalar_properties_output;
  421    453   
  422    454   
pub(crate) mod shape_sparse_json_lists_output;
  423    455   
  424    456   
pub(crate) mod shape_sparse_json_maps_output;
  425    457   
  426    458   
pub(crate) mod shape_streaming_traits_input;
  427    459   
@@ -462,494 +0,620 @@
  482    514   
pub(crate) mod shape_document;
  483    515   
  484    516   
pub(crate) mod shape_document_valued_map;
  485    517   
  486    518   
pub(crate) mod shape_foo_enum_list;
  487    519   
  488    520   
pub(crate) mod shape_foo_enum_map;
  489    521   
  490    522   
pub(crate) mod shape_foo_enum_set;
  491    523   
         524  +
pub(crate) mod shape_headers_and_explicit_payload_event;
         525  +
  492    526   
pub(crate) mod shape_integer_enum_list;
  493    527   
  494    528   
pub(crate) mod shape_integer_enum_map;
  495    529   
  496    530   
pub(crate) mod shape_integer_enum_set;
  497    531   
  498    532   
pub(crate) mod shape_integer_list;
  499    533   
  500    534   
pub(crate) mod shape_my_union;
  501    535   
  502    536   
pub(crate) mod shape_nested_payload;
  503    537   
  504    538   
pub(crate) mod shape_nested_string_list;
  505    539   
  506    540   
pub(crate) mod shape_payload_config;
  507    541   
  508    542   
pub(crate) mod shape_player_action;
  509    543   
  510    544   
pub(crate) mod shape_recursive_shapes_input_output_nested1;
  511    545   
  512    546   
pub(crate) mod shape_simple_list;
  513    547   
  514    548   
pub(crate) mod shape_simple_map;
  515    549   
  516    550   
pub(crate) mod shape_simple_union;
  517    551   
  518    552   
pub(crate) mod shape_sparse_boolean_map;
  519    553   
  520    554   
pub(crate) mod shape_sparse_number_map;
  521    555   
  522    556   
pub(crate) mod shape_sparse_set_map;
  523    557   
  524    558   
pub(crate) mod shape_sparse_short_list;
  525    559   
  526    560   
pub(crate) mod shape_sparse_string_list;
  527    561   
  528    562   
pub(crate) mod shape_sparse_string_map;
  529    563   
  530    564   
pub(crate) mod shape_sparse_struct_map;
  531    565   
  532    566   
pub(crate) mod shape_string_list;
  533    567   
  534    568   
pub(crate) mod shape_string_set;
  535    569   
  536    570   
pub(crate) mod shape_structure_list;
  537    571   
         572  +
pub(crate) mod shape_structure_payload_event;
         573  +
  538    574   
pub(crate) mod shape_test_config;
  539    575   
  540    576   
pub(crate) mod shape_timestamp_list;
  541    577   
  542    578   
pub(crate) mod shape_top_level;
  543    579   
  544    580   
pub(crate) mod shape_union_payload;
  545    581   
         582  +
pub(crate) mod shape_union_payload_event;
         583  +
  546    584   
pub(crate) mod shape_union_with_json_name;
  547    585   
  548    586   
pub(crate) mod shape_complex_nested_error_data;
  549    587   
  550    588   
pub(crate) mod shape_dialog;
  551    589   
  552    590   
pub(crate) mod shape_dialog_list;
  553    591   
  554    592   
pub(crate) mod shape_dialog_map;
  555    593   
  556    594   
pub(crate) mod shape_greeting_struct;
  557    595   
         596  +
pub(crate) mod shape_headers_and_implicit_payload_event;
         597  +
         598  +
pub(crate) mod shape_payload_structure;
         599  +
         600  +
pub(crate) mod shape_payload_union;
         601  +
  558    602   
pub(crate) mod shape_recursive_shapes_input_output_nested2;
  559    603   
  560    604   
pub(crate) mod shape_renamed_greeting;
  561    605   
         606  +
pub(crate) mod shape_singleton_event_stream;
         607  +
  562    608   
pub(crate) mod shape_string_map;
  563    609   
  564    610   
pub(crate) mod shape_structure_list_member;
  565    611   
  566    612   
pub(crate) mod shape_test_string_list;
  567    613   
  568    614   
pub(crate) mod shape_test_string_map;
  569    615   
  570    616   
pub(crate) mod shape_validation_exception_field;
  571    617   
  572    618   
pub(crate) mod shape_farewell;
         619  +
         620  +
pub(crate) mod shape_singleton_event;

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream.rs

@@ -0,1 +0,161 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_duplex_stream_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::DuplexStreamInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
          12  +
    B::Data: Send,
          13  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          14  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          15  +
{
          16  +
    Ok({
          17  +
        #[allow(unused_mut)]
          18  +
        let mut input = crate::input::duplex_stream_input_internal::Builder::default();
          19  +
        #[allow(unused_variables)]
          20  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          21  +
            uri, headers, body, ..
          22  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          23  +
        if let Some(value) = {
          24  +
            let mut receiver = crate::protocol_serde::shape_duplex_stream_input::de_stream_payload(
          25  +
                &mut body.into().into_inner(),
          26  +
            )?;
          27  +
            if let Some(_initial_event) = receiver
          28  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          29  +
                                                .await
          30  +
                                                .map_err(
          31  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          32  +
                                                        #[allow(clippy::useless_conversion)]
          33  +
                                                        format!("{ev_error}").into()
          34  +
                                                    )
          35  +
                                                )? {
          36  +
                                                
          37  +
                                            }
          38  +
            Some(receiver)
          39  +
        } {
          40  +
            input = input.set_stream(value)
          41  +
        }
          42  +
        input.build()?
          43  +
    })
          44  +
}
          45  +
          46  +
#[allow(clippy::unnecessary_wraps)]
          47  +
pub fn ser_duplex_stream_http_response(
          48  +
    #[allow(unused_variables)] output: crate::output::DuplexStreamOutput,
          49  +
) -> std::result::Result<
          50  +
    ::aws_smithy_legacy_http_server::response::Response,
          51  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          52  +
> {
          53  +
    Ok({
          54  +
        #[allow(unused_mut)]
          55  +
        let mut builder = ::http::Response::builder();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_TYPE,
          59  +
            "application/vnd.amazon.eventstream",
          60  +
        );
          61  +
        let http_status: u16 = 200;
          62  +
        builder = builder.status(http_status);
          63  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          64  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          65  +
                let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
          66  +
                let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          67  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          68  +
                output
          69  +
                    .stream
          70  +
                    .into_body_stream(marshaller, error_marshaller, signer)
          71  +
            }),
          72  +
        );
          73  +
        builder.body(body)?
          74  +
    })
          75  +
}
          76  +
          77  +
#[allow(clippy::unnecessary_wraps)]
          78  +
pub fn ser_duplex_stream_http_error(
          79  +
    error: &crate::error::DuplexStreamError,
          80  +
) -> std::result::Result<
          81  +
    ::aws_smithy_legacy_http_server::response::Response,
          82  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          83  +
> {
          84  +
    Ok({
          85  +
        match error {
          86  +
            crate::error::DuplexStreamError::ValidationException(output) => {
          87  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          88  +
                #[allow(unused_mut)]
          89  +
                let mut builder = ::http::Response::builder();
          90  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          91  +
                    builder,
          92  +
                    ::http::header::CONTENT_TYPE,
          93  +
                    "application/vnd.amazon.eventstream",
          94  +
                );
          95  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          96  +
                    builder,
          97  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          98  +
                    "ValidationException",
          99  +
                );
         100  +
                let content_length = payload.len();
         101  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         102  +
                    builder,
         103  +
                    ::http::header::CONTENT_LENGTH,
         104  +
                    content_length,
         105  +
                );
         106  +
                builder
         107  +
                    .status(400)
         108  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         109  +
            }
         110  +
            crate::error::DuplexStreamError::ErrorEvent(output) => {
         111  +
                let payload =
         112  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         113  +
                #[allow(unused_mut)]
         114  +
                let mut builder = ::http::Response::builder();
         115  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
                    builder,
         117  +
                    ::http::header::CONTENT_TYPE,
         118  +
                    "application/vnd.amazon.eventstream",
         119  +
                );
         120  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         121  +
                    builder,
         122  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         123  +
                    "ErrorEvent",
         124  +
                );
         125  +
                let content_length = payload.len();
         126  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         127  +
                    builder,
         128  +
                    ::http::header::CONTENT_LENGTH,
         129  +
                    content_length,
         130  +
                );
         131  +
                builder
         132  +
                    .status(400)
         133  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         134  +
            }
         135  +
            crate::error::DuplexStreamError::InternalServerError(output) => {
         136  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         137  +
                #[allow(unused_mut)]
         138  +
                let mut builder = ::http::Response::builder();
         139  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         140  +
                    builder,
         141  +
                    ::http::header::CONTENT_TYPE,
         142  +
                    "application/vnd.amazon.eventstream",
         143  +
                );
         144  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         145  +
                    builder,
         146  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         147  +
                    "InternalServerError",
         148  +
                );
         149  +
                let content_length = payload.len();
         150  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         151  +
                    builder,
         152  +
                    ::http::header::CONTENT_LENGTH,
         153  +
                    content_length,
         154  +
                );
         155  +
                builder
         156  +
                    .status(500)
         157  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         158  +
            }
         159  +
        }
         160  +
    })
         161  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream_input.rs

@@ -0,1 +0,13 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_stream_payload(
           3  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           4  +
) -> std::result::Result<
           5  +
    crate::python_event_stream::DuplexStreamInputStreamReceiver,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
> {
           8  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
           9  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          10  +
    let receiver =
          11  +
        crate::python_event_stream::DuplexStreamInputStreamReceiver::new(unmarshaller, body);
          12  +
    Ok(receiver)
          13  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream_with_distinct_streams.rs

@@ -0,1 +0,160 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_duplex_stream_with_distinct_streams_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::DuplexStreamWithDistinctStreamsInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
          12  +
    B::Data: Send,
          13  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          14  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          15  +
{
          16  +
    Ok({
          17  +
        #[allow(unused_mut)]
          18  +
        let mut input =
          19  +
            crate::input::duplex_stream_with_distinct_streams_input_internal::Builder::default();
          20  +
        #[allow(unused_variables)]
          21  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          22  +
            uri, headers, body, ..
          23  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          24  +
        if let Some(value) = {
          25  +
            let mut receiver = crate::protocol_serde::shape_duplex_stream_with_distinct_streams_input::de_stream_payload(&mut body.into().into_inner())?;
          26  +
            if let Some(_initial_event) = receiver
          27  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          28  +
                                                .await
          29  +
                                                .map_err(
          30  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          31  +
                                                        #[allow(clippy::useless_conversion)]
          32  +
                                                        format!("{ev_error}").into()
          33  +
                                                    )
          34  +
                                                )? {
          35  +
                                                
          36  +
                                            }
          37  +
            Some(receiver)
          38  +
        } {
          39  +
            input = input.set_stream(value)
          40  +
        }
          41  +
        input.build()?
          42  +
    })
          43  +
}
          44  +
          45  +
#[allow(clippy::unnecessary_wraps)]
          46  +
pub fn ser_duplex_stream_with_distinct_streams_http_response(
          47  +
    #[allow(unused_variables)] output: crate::output::DuplexStreamWithDistinctStreamsOutput,
          48  +
) -> std::result::Result<
          49  +
    ::aws_smithy_legacy_http_server::response::Response,
          50  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          51  +
> {
          52  +
    Ok({
          53  +
        #[allow(unused_mut)]
          54  +
        let mut builder = ::http::Response::builder();
          55  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          56  +
            builder,
          57  +
            ::http::header::CONTENT_TYPE,
          58  +
            "application/json",
          59  +
        );
          60  +
        let http_status: u16 = 200;
          61  +
        builder = builder.status(http_status);
          62  +
        let payload =
          63  +
            crate::protocol_serde::shape_duplex_stream_with_distinct_streams_output::ser_stream_http_payload(& output.stream)?
          64  +
        ;
          65  +
        let content_length = payload.len();
          66  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          67  +
            builder,
          68  +
            ::http::header::CONTENT_LENGTH,
          69  +
            content_length,
          70  +
        );
          71  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          72  +
        builder.body(body)?
          73  +
    })
          74  +
}
          75  +
          76  +
#[allow(clippy::unnecessary_wraps)]
          77  +
pub fn ser_duplex_stream_with_distinct_streams_http_error(
          78  +
    error: &crate::error::DuplexStreamWithDistinctStreamsError,
          79  +
) -> std::result::Result<
          80  +
    ::aws_smithy_legacy_http_server::response::Response,
          81  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          82  +
> {
          83  +
    Ok({
          84  +
        match error {
          85  +
            crate::error::DuplexStreamWithDistinctStreamsError::ValidationException(output) => {
          86  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          87  +
                #[allow(unused_mut)]
          88  +
                let mut builder = ::http::Response::builder();
          89  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          90  +
                    builder,
          91  +
                    ::http::header::CONTENT_TYPE,
          92  +
                    "application/json",
          93  +
                );
          94  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          95  +
                    builder,
          96  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          97  +
                    "ValidationException",
          98  +
                );
          99  +
                let content_length = payload.len();
         100  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         101  +
                    builder,
         102  +
                    ::http::header::CONTENT_LENGTH,
         103  +
                    content_length,
         104  +
                );
         105  +
                builder
         106  +
                    .status(400)
         107  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         108  +
            }
         109  +
            crate::error::DuplexStreamWithDistinctStreamsError::ErrorEvent(output) => {
         110  +
                let payload =
         111  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         112  +
                #[allow(unused_mut)]
         113  +
                let mut builder = ::http::Response::builder();
         114  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         115  +
                    builder,
         116  +
                    ::http::header::CONTENT_TYPE,
         117  +
                    "application/json",
         118  +
                );
         119  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         120  +
                    builder,
         121  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         122  +
                    "ErrorEvent",
         123  +
                );
         124  +
                let content_length = payload.len();
         125  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         126  +
                    builder,
         127  +
                    ::http::header::CONTENT_LENGTH,
         128  +
                    content_length,
         129  +
                );
         130  +
                builder
         131  +
                    .status(400)
         132  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         133  +
            }
         134  +
            crate::error::DuplexStreamWithDistinctStreamsError::InternalServerError(output) => {
         135  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         136  +
                #[allow(unused_mut)]
         137  +
                let mut builder = ::http::Response::builder();
         138  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         139  +
                    builder,
         140  +
                    ::http::header::CONTENT_TYPE,
         141  +
                    "application/json",
         142  +
                );
         143  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         144  +
                    builder,
         145  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         146  +
                    "InternalServerError",
         147  +
                );
         148  +
                let content_length = payload.len();
         149  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         150  +
                    builder,
         151  +
                    ::http::header::CONTENT_LENGTH,
         152  +
                    content_length,
         153  +
                );
         154  +
                builder
         155  +
                    .status(500)
         156  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         157  +
            }
         158  +
        }
         159  +
    })
         160  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream_with_distinct_streams_input.rs

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

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream_with_distinct_streams_output.rs

@@ -0,1 +0,28 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_stream_http_payload(
           3  +
    payload: &::std::option::Option<crate::model::SingletonEventStream>,
           4  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           5  +
    let payload = match payload.as_ref() {
           6  +
        Some(t) => t,
           7  +
        None => return Ok(crate::protocol_serde::rest_json_unset_union_payload()),
           8  +
    };
           9  +
    Ok(
          10  +
        crate::protocol_serde::shape_duplex_stream_with_distinct_streams_output::ser_stream_payload(payload)?
          11  +
    )
          12  +
}
          13  +
          14  +
pub fn ser_stream_payload(
          15  +
    input: &crate::model::SingletonEventStream,
          16  +
) -> std::result::Result<
          17  +
    ::std::vec::Vec<u8>,
          18  +
    ::aws_smithy_types::error::operation::SerializationError,
          19  +
> {
          20  +
    let mut out = String::new();
          21  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          22  +
    crate::protocol_serde::shape_singleton_event_stream::ser_singleton_event_stream(
          23  +
        &mut object,
          24  +
        input,
          25  +
    )?;
          26  +
    object.finish();
          27  +
    Ok(out.into_bytes())
          28  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream_with_initial_messages.rs

@@ -0,1 +0,212 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_duplex_stream_with_initial_messages_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::DuplexStreamWithInitialMessagesInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
          12  +
    B::Data: Send,
          13  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          14  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          15  +
{
          16  +
    Ok({
          17  +
        #[allow(unused_mut)]
          18  +
        let mut input =
          19  +
            crate::input::duplex_stream_with_initial_messages_input_internal::Builder::default();
          20  +
        #[allow(unused_variables)]
          21  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          22  +
            uri, headers, body, ..
          23  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          24  +
        if let Some(value) = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_initial_request_member_header(&headers)? {
          25  +
                                input = input.set_initial_request_member(value)
          26  +
                            }
          27  +
        if let Some(value) = {
          28  +
            let mut receiver = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_stream_payload(&mut body.into().into_inner())?;
          29  +
            if let Some(_initial_event) = receiver
          30  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          31  +
                                                .await
          32  +
                                                .map_err(
          33  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          34  +
                                                        #[allow(clippy::useless_conversion)]
          35  +
                                                        format!("{ev_error}").into()
          36  +
                                                    )
          37  +
                                                )? {
          38  +
                                                
          39  +
                                            }
          40  +
            Some(receiver)
          41  +
        } {
          42  +
            input = input.set_stream(value)
          43  +
        }
          44  +
        input.build()?
          45  +
    })
          46  +
}
          47  +
          48  +
#[allow(clippy::unnecessary_wraps)]
          49  +
pub fn ser_duplex_stream_with_initial_messages_http_response(
          50  +
    #[allow(unused_variables)] output: crate::output::DuplexStreamWithInitialMessagesOutput,
          51  +
) -> std::result::Result<
          52  +
    ::aws_smithy_legacy_http_server::response::Response,
          53  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          54  +
> {
          55  +
    Ok({
          56  +
        #[allow(unused_mut)]
          57  +
        let mut builder = ::http::Response::builder();
          58  +
        builder = crate::protocol_serde::shape_duplex_stream_with_initial_messages::ser_duplex_stream_with_initial_messages_headers(&output, builder)?;
          59  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          60  +
            builder,
          61  +
            ::http::header::CONTENT_TYPE,
          62  +
            "application/vnd.amazon.eventstream",
          63  +
        );
          64  +
        let http_status: u16 = 200;
          65  +
        builder = builder.status(http_status);
          66  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          67  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
          68  +
                let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
          69  +
                let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          70  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          71  +
                output
          72  +
                    .stream
          73  +
                    .into_body_stream(marshaller, error_marshaller, signer)
          74  +
            }),
          75  +
        );
          76  +
        builder.body(body)?
          77  +
    })
          78  +
}
          79  +
          80  +
#[allow(clippy::unnecessary_wraps)]
          81  +
pub fn ser_duplex_stream_with_initial_messages_http_error(
          82  +
    error: &crate::error::DuplexStreamWithInitialMessagesError,
          83  +
) -> std::result::Result<
          84  +
    ::aws_smithy_legacy_http_server::response::Response,
          85  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          86  +
> {
          87  +
    Ok({
          88  +
        match error {
          89  +
            crate::error::DuplexStreamWithInitialMessagesError::ServiceUnavailableError(output) => {
          90  +
                let payload = crate::protocol_serde::shape_service_unavailable_error::ser_service_unavailable_error_error(output)?;
          91  +
                #[allow(unused_mut)]
          92  +
                let mut builder = ::http::Response::builder();
          93  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          94  +
                    builder,
          95  +
                    ::http::header::CONTENT_TYPE,
          96  +
                    "application/vnd.amazon.eventstream",
          97  +
                );
          98  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          99  +
                    builder,
         100  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         101  +
                    "ServiceUnavailableError",
         102  +
                );
         103  +
                let content_length = payload.len();
         104  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         105  +
                    builder,
         106  +
                    ::http::header::CONTENT_LENGTH,
         107  +
                    content_length,
         108  +
                );
         109  +
                builder
         110  +
                    .status(500)
         111  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         112  +
            }
         113  +
            crate::error::DuplexStreamWithInitialMessagesError::ValidationException(output) => {
         114  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         115  +
                #[allow(unused_mut)]
         116  +
                let mut builder = ::http::Response::builder();
         117  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         118  +
                    builder,
         119  +
                    ::http::header::CONTENT_TYPE,
         120  +
                    "application/vnd.amazon.eventstream",
         121  +
                );
         122  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         123  +
                    builder,
         124  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         125  +
                    "ValidationException",
         126  +
                );
         127  +
                let content_length = payload.len();
         128  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         129  +
                    builder,
         130  +
                    ::http::header::CONTENT_LENGTH,
         131  +
                    content_length,
         132  +
                );
         133  +
                builder
         134  +
                    .status(400)
         135  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         136  +
            }
         137  +
            crate::error::DuplexStreamWithInitialMessagesError::ErrorEvent(output) => {
         138  +
                let payload =
         139  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         140  +
                #[allow(unused_mut)]
         141  +
                let mut builder = ::http::Response::builder();
         142  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         143  +
                    builder,
         144  +
                    ::http::header::CONTENT_TYPE,
         145  +
                    "application/vnd.amazon.eventstream",
         146  +
                );
         147  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         148  +
                    builder,
         149  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         150  +
                    "ErrorEvent",
         151  +
                );
         152  +
                let content_length = payload.len();
         153  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         154  +
                    builder,
         155  +
                    ::http::header::CONTENT_LENGTH,
         156  +
                    content_length,
         157  +
                );
         158  +
                builder
         159  +
                    .status(400)
         160  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         161  +
            }
         162  +
            crate::error::DuplexStreamWithInitialMessagesError::InternalServerError(output) => {
         163  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         164  +
                #[allow(unused_mut)]
         165  +
                let mut builder = ::http::Response::builder();
         166  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         167  +
                    builder,
         168  +
                    ::http::header::CONTENT_TYPE,
         169  +
                    "application/vnd.amazon.eventstream",
         170  +
                );
         171  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         172  +
                    builder,
         173  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         174  +
                    "InternalServerError",
         175  +
                );
         176  +
                let content_length = payload.len();
         177  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         178  +
                    builder,
         179  +
                    ::http::header::CONTENT_LENGTH,
         180  +
                    content_length,
         181  +
                );
         182  +
                builder
         183  +
                    .status(500)
         184  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         185  +
            }
         186  +
        }
         187  +
    })
         188  +
}
         189  +
         190  +
pub fn ser_duplex_stream_with_initial_messages_headers(
         191  +
    input: &crate::output::DuplexStreamWithInitialMessagesOutput,
         192  +
    mut builder: ::http::response::Builder,
         193  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         194  +
{
         195  +
    {
         196  +
        let formatted_1 = &input.initial_response_member.as_str();
         197  +
        if !formatted_1.is_empty() {
         198  +
            let header_value = formatted_1;
         199  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         200  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         201  +
                    "initial_response_member",
         202  +
                    format!(
         203  +
                        "`{}` cannot be used as a header value: {}",
         204  +
                        &header_value, err
         205  +
                    ),
         206  +
                )
         207  +
            })?;
         208  +
            builder = builder.header("initial-response-member", header_value);
         209  +
        }
         210  +
    }
         211  +
    Ok(builder)
         212  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_duplex_stream_with_initial_messages_input.rs

@@ -0,1 +0,26 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_initial_request_member_header(
           3  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           4  +
) -> ::std::result::Result<
           5  +
    ::std::option::Option<::std::string::String>,
           6  +
    ::aws_smithy_legacy_http::header::ParseError,
           7  +
> {
           8  +
    let headers = header_map.get_all("initial-request-member");
           9  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          10  +
}
          11  +
          12  +
pub fn de_stream_payload(
          13  +
    body: &mut ::aws_smithy_types::body::SdkBody,
          14  +
) -> std::result::Result<
          15  +
    crate::python_event_stream::DuplexStreamWithInitialMessagesInputStreamReceiver,
          16  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          17  +
> {
          18  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
          19  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          20  +
    let receiver =
          21  +
        crate::python_event_stream::DuplexStreamWithInitialMessagesInputStreamReceiver::new(
          22  +
            unmarshaller,
          23  +
            body,
          24  +
        );
          25  +
    Ok(receiver)
          26  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_error_event.rs

@@ -0,1 +0,69 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_error_event_error(
           3  +
    value: &crate::error::ErrorEvent,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_error_event::ser_error_event(&mut object, value)?;
           8  +
    object.finish();
           9  +
    Ok(out)
          10  +
}
          11  +
          12  +
pub fn ser_error_event(
          13  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          14  +
    input: &crate::error::ErrorEvent,
          15  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          16  +
    if let Some(var_1) = &input.message {
          17  +
        object.key("message").string(var_1.as_str());
          18  +
    }
          19  +
    Ok(())
          20  +
}
          21  +
          22  +
pub(crate) fn de_error_event_json_err(
          23  +
    _value: &[u8],
          24  +
    mut builder: crate::error::error_event_internal::Builder,
          25  +
) -> ::std::result::Result<
          26  +
    crate::error::error_event_internal::Builder,
          27  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          28  +
> {
          29  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
          30  +
        crate::protocol_serde::or_empty_doc(_value),
          31  +
    )
          32  +
    .peekable();
          33  +
    let tokens = &mut tokens_owned;
          34  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          35  +
    loop {
          36  +
        match tokens.next().transpose()? {
          37  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          38  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          39  +
                match key.to_unescaped()?.as_ref() {
          40  +
                    "message" => {
          41  +
                        builder = builder.set_message(
          42  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          43  +
                                tokens.next(),
          44  +
                            )?
          45  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          46  +
                            .transpose()?,
          47  +
                        );
          48  +
                    }
          49  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          50  +
                }
          51  +
            }
          52  +
            other => {
          53  +
                return Err(
          54  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          55  +
                        "expected object key or end object, found: {other:?}"
          56  +
                    )),
          57  +
                )
          58  +
            }
          59  +
        }
          60  +
    }
          61  +
    if tokens.next().is_some() {
          62  +
        return Err(
          63  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          64  +
                "found more JSON tokens after completing parsing",
          65  +
            ),
          66  +
        );
          67  +
    }
          68  +
    Ok(builder)
          69  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_headers_and_explicit_payload_event.rs

@@ -0,1 +0,13 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_payload_payload(
           3  +
    input: &crate::model::PayloadStructure,
           4  +
) -> std::result::Result<
           5  +
    ::std::vec::Vec<u8>,
           6  +
    ::aws_smithy_types::error::operation::SerializationError,
           7  +
> {
           8  +
    let mut out = String::new();
           9  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          10  +
    crate::protocol_serde::shape_payload_structure::ser_payload_structure(&mut object, input)?;
          11  +
    object.finish();
          12  +
    Ok(out.into_bytes())
          13  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_headers_and_implicit_payload_event.rs

@@ -0,1 +0,58 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_headers_and_implicit_payload_event_json_err(
           3  +
    _value: &[u8],
           4  +
    mut builder: crate::model::headers_and_implicit_payload_event_internal::Builder,
           5  +
) -> ::std::result::Result<
           6  +
    crate::model::headers_and_implicit_payload_event_internal::Builder,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
          10  +
        crate::protocol_serde::or_empty_doc(_value),
          11  +
    )
          12  +
    .peekable();
          13  +
    let tokens = &mut tokens_owned;
          14  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          15  +
    loop {
          16  +
        match tokens.next().transpose()? {
          17  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          18  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          19  +
                match key.to_unescaped()?.as_ref() {
          20  +
                    "header" => {
          21  +
                        builder = builder.set_header(
          22  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          23  +
                                tokens.next(),
          24  +
                            )?
          25  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          26  +
                            .transpose()?,
          27  +
                        );
          28  +
                    }
          29  +
                    "payload" => {
          30  +
                        builder = builder.set_payload(
          31  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          32  +
                                tokens.next(),
          33  +
                            )?
          34  +
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          35  +
                            .transpose()?,
          36  +
                        );
          37  +
                    }
          38  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          39  +
                }
          40  +
            }
          41  +
            other => {
          42  +
                return Err(
          43  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          44  +
                        "expected object key or end object, found: {other:?}"
          45  +
                    )),
          46  +
                )
          47  +
            }
          48  +
        }
          49  +
    }
          50  +
    if tokens.next().is_some() {
          51  +
        return Err(
          52  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                "found more JSON tokens after completing parsing",
          54  +
            ),
          55  +
        );
          56  +
    }
          57  +
    Ok(builder)
          58  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_http_query_params_only_operation.rs

Renamed from tmp-codegen-diff/codegen-server-test-python/rest_json_extras/rust-server-codegen-python/src/protocol_serde/shape_http_query_params_only_operation.rs

@@ -47,47 +128,103 @@
   67     67   
   68     68   
#[allow(clippy::unnecessary_wraps)]
   69     69   
pub fn ser_http_query_params_only_operation_http_error(
   70     70   
    error: &crate::error::HttpQueryParamsOnlyOperationError,
   71     71   
) -> std::result::Result<
   72     72   
    ::aws_smithy_legacy_http_server::response::Response,
   73     73   
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   74     74   
> {
   75     75   
    Ok({
   76     76   
        match error {
   77         -
            crate::error::HttpQueryParamsOnlyOperationError::ExtraError(output) => {
   78         -
                let payload =
   79         -
                    crate::protocol_serde::shape_extra_error::ser_extra_error_error(output)?;
   80         -
                #[allow(unused_mut)]
   81         -
                let mut builder = ::http::Response::builder();
   82         -
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
   83         -
                    builder,
   84         -
                    ::http::header::CONTENT_TYPE,
   85         -
                    "application/json",
   86         -
                );
   87         -
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
   88         -
                    builder,
   89         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   90         -
                    "ExtraError",
   91         -
                );
   92         -
                let content_length = payload.len();
   93         -
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
   94         -
                    builder,
   95         -
                    ::http::header::CONTENT_LENGTH,
   96         -
                    content_length,
   97         -
                );
   98         -
                builder
   99         -
                    .status(500)
  100         -
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
  101         -
            }
  102     77   
            crate::error::HttpQueryParamsOnlyOperationError::InternalServerError(output) => {
  103     78   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
  104     79   
                #[allow(unused_mut)]
  105     80   
                let mut builder = ::http::Response::builder();
  106     81   
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
  107     82   
                    builder,
  108     83   
                    ::http::header::CONTENT_TYPE,
  109     84   
                    "application/json",
  110     85   
                );
  111     86   
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_input_stream.rs

@@ -0,1 +0,159 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_input_stream_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::InputStreamInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
          12  +
    B::Data: Send,
          13  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          14  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          15  +
{
          16  +
    Ok({
          17  +
        #[allow(unused_mut)]
          18  +
        let mut input = crate::input::input_stream_input_internal::Builder::default();
          19  +
        #[allow(unused_variables)]
          20  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          21  +
            uri, headers, body, ..
          22  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          23  +
        if let Some(value) = {
          24  +
            let mut receiver = crate::protocol_serde::shape_input_stream_input::de_stream_payload(
          25  +
                &mut body.into().into_inner(),
          26  +
            )?;
          27  +
            if let Some(_initial_event) = receiver
          28  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          29  +
                                                .await
          30  +
                                                .map_err(
          31  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          32  +
                                                        #[allow(clippy::useless_conversion)]
          33  +
                                                        format!("{ev_error}").into()
          34  +
                                                    )
          35  +
                                                )? {
          36  +
                                                
          37  +
                                            }
          38  +
            Some(receiver)
          39  +
        } {
          40  +
            input = input.set_stream(value)
          41  +
        }
          42  +
        input.build()?
          43  +
    })
          44  +
}
          45  +
          46  +
#[allow(clippy::unnecessary_wraps)]
          47  +
pub fn ser_input_stream_http_response(
          48  +
    #[allow(unused_variables)] output: crate::output::InputStreamOutput,
          49  +
) -> std::result::Result<
          50  +
    ::aws_smithy_legacy_http_server::response::Response,
          51  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          52  +
> {
          53  +
    Ok({
          54  +
        #[allow(unused_mut)]
          55  +
        let mut builder = ::http::Response::builder();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_TYPE,
          59  +
            "application/json",
          60  +
        );
          61  +
        let http_status: u16 = 200;
          62  +
        builder = builder.status(http_status);
          63  +
        let payload = "";
          64  +
        let content_length = payload.len();
          65  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          66  +
            builder,
          67  +
            ::http::header::CONTENT_LENGTH,
          68  +
            content_length,
          69  +
        );
          70  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          71  +
        builder.body(body)?
          72  +
    })
          73  +
}
          74  +
          75  +
#[allow(clippy::unnecessary_wraps)]
          76  +
pub fn ser_input_stream_http_error(
          77  +
    error: &crate::error::InputStreamError,
          78  +
) -> std::result::Result<
          79  +
    ::aws_smithy_legacy_http_server::response::Response,
          80  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          81  +
> {
          82  +
    Ok({
          83  +
        match error {
          84  +
            crate::error::InputStreamError::ValidationException(output) => {
          85  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          86  +
                #[allow(unused_mut)]
          87  +
                let mut builder = ::http::Response::builder();
          88  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          89  +
                    builder,
          90  +
                    ::http::header::CONTENT_TYPE,
          91  +
                    "application/json",
          92  +
                );
          93  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          94  +
                    builder,
          95  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          96  +
                    "ValidationException",
          97  +
                );
          98  +
                let content_length = payload.len();
          99  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         100  +
                    builder,
         101  +
                    ::http::header::CONTENT_LENGTH,
         102  +
                    content_length,
         103  +
                );
         104  +
                builder
         105  +
                    .status(400)
         106  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         107  +
            }
         108  +
            crate::error::InputStreamError::ErrorEvent(output) => {
         109  +
                let payload =
         110  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         111  +
                #[allow(unused_mut)]
         112  +
                let mut builder = ::http::Response::builder();
         113  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         114  +
                    builder,
         115  +
                    ::http::header::CONTENT_TYPE,
         116  +
                    "application/json",
         117  +
                );
         118  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         119  +
                    builder,
         120  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         121  +
                    "ErrorEvent",
         122  +
                );
         123  +
                let content_length = payload.len();
         124  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         125  +
                    builder,
         126  +
                    ::http::header::CONTENT_LENGTH,
         127  +
                    content_length,
         128  +
                );
         129  +
                builder
         130  +
                    .status(400)
         131  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         132  +
            }
         133  +
            crate::error::InputStreamError::InternalServerError(output) => {
         134  +
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         135  +
                #[allow(unused_mut)]
         136  +
                let mut builder = ::http::Response::builder();
         137  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         138  +
                    builder,
         139  +
                    ::http::header::CONTENT_TYPE,
         140  +
                    "application/json",
         141  +
                );
         142  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         143  +
                    builder,
         144  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         145  +
                    "InternalServerError",
         146  +
                );
         147  +
                let content_length = payload.len();
         148  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         149  +
                    builder,
         150  +
                    ::http::header::CONTENT_LENGTH,
         151  +
                    content_length,
         152  +
                );
         153  +
                builder
         154  +
                    .status(500)
         155  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         156  +
            }
         157  +
        }
         158  +
    })
         159  +
}

tmp-codegen-diff/codegen-server-test-python/rest_json/rust-server-codegen-python/src/protocol_serde/shape_input_stream_input.rs

@@ -0,1 +0,13 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn de_stream_payload(
           3  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           4  +
) -> std::result::Result<
           5  +
    crate::python_event_stream::InputStreamInputStreamReceiver,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
> {
           8  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
           9  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          10  +
    let receiver =
          11  +
        crate::python_event_stream::InputStreamInputStreamReceiver::new(unmarshaller, body);
          12  +
    Ok(receiver)
          13  +
}