Server Test Python

Server Test Python

rev. d838bf488731ae5e751cce0fe13f339a5b9be858 (ignoring whitespace)

Files changed:

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

@@ -15,15 +78,74 @@
   35     35   
///     raise NotImplementedError
   36     36   
///
   37     37   
/// @app.enum_query
   38     38   
/// def enum_query(input: input::EnumQueryInput, ctx: Context) -> output::EnumQueryOutput:
   39     39   
///     raise NotImplementedError
   40     40   
///
   41     41   
/// @app.escaped_string_values
   42     42   
/// def escaped_string_values(input: input::EscapedStringValuesInput, ctx: Context) -> output::EscapedStringValuesOutput:
   43     43   
///     raise NotImplementedError
   44     44   
///
   45         -
/// @app.http_query_params_only_operation
   46         -
/// def http_query_params_only_operation(input: input::HttpQueryParamsOnlyOperationInput, ctx: Context) -> output::HttpQueryParamsOnlyOperationOutput:
   47         -
///     raise NotImplementedError
   48         -
///
   49     45   
/// @app.map_with_enum_key_op
   50     46   
/// def map_with_enum_key_op(input: input::MapWithEnumKeyOpInput, ctx: Context) -> output::MapWithEnumKeyOpOutput:
   51     47   
///     raise NotImplementedError
   52     48   
///
   53     49   
/// @app.null_in_non_sparse
   54     50   
/// def null_in_non_sparse(input: input::NullInNonSparseInput, ctx: Context) -> output::NullInNonSparseOutput:
   55     51   
///     raise NotImplementedError
   56     52   
///
   57     53   
/// @app.primitive_int_header
   58     54   
/// def primitive_int_header(input: input::PrimitiveIntHeaderInput, ctx: Context) -> output::PrimitiveIntHeaderOutput:
@@ -167,163 +242,222 @@
  187    183   
        let builder = builder.escaped_string_values(move |input, state| {
  188    184   
            ::pyo3_asyncio::tokio::scope(
  189    185   
                escaped_string_values_locals.clone(),
  190    186   
                crate::python_operation_adaptor::escaped_string_values(
  191    187   
                    input,
  192    188   
                    state,
  193    189   
                    handler.clone(),
  194    190   
                ),
  195    191   
            )
  196    192   
        });
  197         -
        let http_query_params_only_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  198         -
        let handler = self
  199         -
            .handlers
  200         -
            .get("http_query_params_only_operation")
  201         -
            .expect("Python handler for operation `http_query_params_only_operation` not found")
  202         -
            .clone();
  203         -
        let builder = builder.http_query_params_only_operation(move |input, state| {
  204         -
            ::pyo3_asyncio::tokio::scope(
  205         -
                http_query_params_only_operation_locals.clone(),
  206         -
                crate::python_operation_adaptor::http_query_params_only_operation(
  207         -
                    input,
  208         -
                    state,
  209         -
                    handler.clone(),
  210         -
                ),
  211         -
            )
  212         -
        });
  213    193   
        let map_with_enum_key_op_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  214    194   
        let handler = self
  215    195   
            .handlers
  216    196   
            .get("map_with_enum_key_op")
  217    197   
            .expect("Python handler for operation `map_with_enum_key_op` not found")
  218    198   
            .clone();
  219    199   
        let builder = builder.map_with_enum_key_op(move |input, state| {
  220    200   
            ::pyo3_asyncio::tokio::scope(
  221    201   
                map_with_enum_key_op_locals.clone(),
  222    202   
                crate::python_operation_adaptor::map_with_enum_key_op(
@@ -435,415 +508,474 @@
  455    435   
    /// :rtype None:
  456    436   
    #[pyo3(text_signature = "($self, func)")]
  457    437   
    pub fn escaped_string_values(
  458    438   
        &mut self,
  459    439   
        py: ::pyo3::Python,
  460    440   
        func: ::pyo3::PyObject,
  461    441   
    ) -> ::pyo3::PyResult<()> {
  462    442   
        use ::aws_smithy_http_server_python::PyApp;
  463    443   
        self.register_operation(py, "escaped_string_values", func)
  464    444   
    }
  465         -
    /// Method to register `http_query_params_only_operation` Python implementation inside the handlers map.
  466         -
    /// It can be used as a function decorator in Python.
  467         -
    ///
  468         -
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.HttpQueryParamsOnlyOperationInput, Ctx\], typing.Union\[rest_json_extras.output.HttpQueryParamsOnlyOperationOutput, typing.Awaitable\[rest_json_extras.output.HttpQueryParamsOnlyOperationOutput\]\]\], typing.Callable\[\[rest_json_extras.input.HttpQueryParamsOnlyOperationInput\], typing.Union\[rest_json_extras.output.HttpQueryParamsOnlyOperationOutput, typing.Awaitable\[rest_json_extras.output.HttpQueryParamsOnlyOperationOutput\]\]\]\]:
  469         -
    /// :rtype None:
  470         -
    #[pyo3(text_signature = "($self, func)")]
  471         -
    pub fn http_query_params_only_operation(
  472         -
        &mut self,
  473         -
        py: ::pyo3::Python,
  474         -
        func: ::pyo3::PyObject,
  475         -
    ) -> ::pyo3::PyResult<()> {
  476         -
        use ::aws_smithy_http_server_python::PyApp;
  477         -
        self.register_operation(py, "http_query_params_only_operation", func)
  478         -
    }
  479    445   
    /// Method to register `map_with_enum_key_op` Python implementation inside the handlers map.
  480    446   
    /// It can be used as a function decorator in Python.
  481    447   
    ///
  482    448   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.MapWithEnumKeyOpInput, Ctx\], typing.Union\[rest_json_extras.output.MapWithEnumKeyOpOutput, typing.Awaitable\[rest_json_extras.output.MapWithEnumKeyOpOutput\]\]\], typing.Callable\[\[rest_json_extras.input.MapWithEnumKeyOpInput\], typing.Union\[rest_json_extras.output.MapWithEnumKeyOpOutput, typing.Awaitable\[rest_json_extras.output.MapWithEnumKeyOpOutput\]\]\]\]:
  483    449   
    /// :rtype None:
  484    450   
    #[pyo3(text_signature = "($self, func)")]
  485    451   
    pub fn map_with_enum_key_op(
  486    452   
        &mut self,
  487    453   
        py: ::pyo3::Python,
  488    454   
        func: ::pyo3::PyObject,

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

@@ -1,1 +41,40 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
/// The service builder for [`RestJsonExtras`].
    3      3   
///
    4      4   
/// Constructed via [`RestJsonExtras::builder`].
    5      5   
pub struct RestJsonExtrasBuilder<Body, L, HttpPl, ModelPl> {
    6      6   
    case_insensitive_error_operation: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
    7      7   
    empty_struct_with_content_on_wire_op:
    8      8   
        Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
    9      9   
    enum_query: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   10     10   
    escaped_string_values: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   11         -
    http_query_params_only_operation: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   12     11   
    map_with_enum_key_op: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   13     12   
    null_in_non_sparse: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   14     13   
    primitive_int_header: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   15     14   
    primitive_int_op: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   16     15   
    query_precedence: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   17     16   
    status_response: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   18     17   
    string_payload: Option<::aws_smithy_legacy_http_server::routing::Route<Body>>,
   19     18   
    layer: L,
   20     19   
    http_plugin: HttpPl,
   21     20   
    model_plugin: ModelPl,
@@ -606,605 +818,664 @@
  626    625   
            > + Clone
  627    626   
            + Send
  628    627   
            + 'static,
  629    628   
        S::Future: Send + 'static,
  630    629   
    {
  631    630   
        self.escaped_string_values =
  632    631   
            Some(::aws_smithy_legacy_http_server::routing::Route::new(svc));
  633    632   
        self
  634    633   
    }
  635    634   
  636         -
    /// Sets the [`HttpQueryParamsOnlyOperation`](crate::operation_shape::HttpQueryParamsOnlyOperation) operation.
  637         -
    ///
  638         -
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_legacy_http_server::operation::Handler) trait.
  639         -
    /// See the [operation module documentation](::aws_smithy_legacy_http_server::operation) for more information.
  640         -
    ///
  641         -
    /// # Example
  642         -
    ///
  643         -
    /// ```no_run
  644         -
    /// use rest_json_extras::{RestJsonExtras, RestJsonExtrasConfig};
  645         -
    ///
  646         -
    /// use rest_json_extras::{input, output, error};
  647         -
    ///
  648         -
    /// async fn handler(input: input::HttpQueryParamsOnlyOperationInput) -> Result<output::HttpQueryParamsOnlyOperationOutput, error::HttpQueryParamsOnlyOperationError> {
  649         -
    ///     todo!()
  650         -
    /// }
  651         -
    ///
  652         -
    /// let config = RestJsonExtrasConfig::builder().build();
  653         -
    /// let app = RestJsonExtras::builder(config)
  654         -
    ///     .http_query_params_only_operation(handler)
  655         -
    ///     /* Set other handlers */
  656         -
    ///     .build()
  657         -
    ///     .unwrap();
  658         -
    /// # let app: RestJsonExtras<::aws_smithy_legacy_http_server::routing::RoutingService<::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<::aws_smithy_legacy_http_server::routing::Route>, ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>> = app;
  659         -
    /// ```
  660         -
    ///
  661         -
                    pub fn http_query_params_only_operation<HandlerType, HandlerExtractors, UpgradeExtractors>(self, handler: HandlerType) -> Self
  662         -
                    where
  663         -
                        HandlerType: ::aws_smithy_legacy_http_server::operation::Handler<crate::operation_shape::HttpQueryParamsOnlyOperation, HandlerExtractors>,
  664         -
  665         -
                        ModelPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
  666         -
                            RestJsonExtras<L>,
  667         -
                            crate::operation_shape::HttpQueryParamsOnlyOperation,
  668         -
                            ::aws_smithy_legacy_http_server::operation::IntoService<crate::operation_shape::HttpQueryParamsOnlyOperation, HandlerType>
  669         -
                        >,
  670         -
                        ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_legacy_http_server::plugin::Plugin<
  671         -
                            RestJsonExtras<L>,
  672         -
                            crate::operation_shape::HttpQueryParamsOnlyOperation,
  673         -
                            ModelPl::Output
  674         -
                        >,
  675         -
                        HttpPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
  676         -
                            RestJsonExtras<L>,
  677         -
                            crate::operation_shape::HttpQueryParamsOnlyOperation,
  678         -
                            <
  679         -
                                ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
  680         -
                                as ::aws_smithy_legacy_http_server::plugin::Plugin<
  681         -
                                    RestJsonExtras<L>,
  682         -
                                    crate::operation_shape::HttpQueryParamsOnlyOperation,
  683         -
                                    ModelPl::Output
  684         -
                                >
  685         -
                            >::Output
  686         -
                        >,
  687         -
  688         -
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
  689         -
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
  690         -
  691         -
                    {
  692         -
        use ::aws_smithy_legacy_http_server::operation::OperationShapeExt;
  693         -
        use ::aws_smithy_legacy_http_server::plugin::Plugin;
  694         -
        let svc = crate::operation_shape::HttpQueryParamsOnlyOperation::from_handler(handler);
  695         -
        let svc = self.model_plugin.apply(svc);
  696         -
        let svc =
  697         -
            ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
  698         -
                .apply(svc);
  699         -
        let svc = self.http_plugin.apply(svc);
  700         -
        self.http_query_params_only_operation_custom(svc)
  701         -
    }
  702         -
  703         -
    /// Sets the [`HttpQueryParamsOnlyOperation`](crate::operation_shape::HttpQueryParamsOnlyOperation) operation.
  704         -
    ///
  705         -
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_legacy_http_server::operation::Handler) trait.
  706         -
    /// See the [operation module documentation](::aws_smithy_legacy_http_server::operation) for more information.
  707         -
    ///
  708         -
    /// # Example
  709         -
    ///
  710         -
    /// ```no_run
  711         -
    /// use rest_json_extras::{RestJsonExtras, RestJsonExtrasConfig};
  712         -
    ///
  713         -
    /// use rest_json_extras::{input, output, error};
  714         -
    ///
  715         -
    /// async fn handler(input: input::HttpQueryParamsOnlyOperationInput) -> Result<output::HttpQueryParamsOnlyOperationOutput, error::HttpQueryParamsOnlyOperationError> {
  716         -
    ///     todo!()
  717         -
    /// }
  718         -
    ///
  719         -
    /// let config = RestJsonExtrasConfig::builder().build();
  720         -
    /// let svc = ::tower::util::service_fn(handler);
  721         -
    /// let app = RestJsonExtras::builder(config)
  722         -
    ///     .http_query_params_only_operation_service(svc)
  723         -
    ///     /* Set other handlers */
  724         -
    ///     .build()
  725         -
    ///     .unwrap();
  726         -
    /// # let app: RestJsonExtras<::aws_smithy_legacy_http_server::routing::RoutingService<::aws_smithy_legacy_http_server::protocol::rest::router::RestRouter<::aws_smithy_legacy_http_server::routing::Route>, ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>> = app;
  727         -
    /// ```
  728         -
    ///
  729         -
                    pub fn http_query_params_only_operation_service<S, ServiceExtractors, UpgradeExtractors>(self, service: S) -> Self
  730         -
                    where
  731         -
                        S: ::aws_smithy_legacy_http_server::operation::OperationService<crate::operation_shape::HttpQueryParamsOnlyOperation, ServiceExtractors>,
  732         -
  733         -
                        ModelPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
  734         -
                            RestJsonExtras<L>,
  735         -
                            crate::operation_shape::HttpQueryParamsOnlyOperation,
  736         -
                            ::aws_smithy_legacy_http_server::operation::Normalize<crate::operation_shape::HttpQueryParamsOnlyOperation, S>
  737         -
                        >,
  738         -
                        ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_legacy_http_server::plugin::Plugin<
  739         -
                            RestJsonExtras<L>,
  740         -
                            crate::operation_shape::HttpQueryParamsOnlyOperation,
  741         -
                            ModelPl::Output
  742         -
                        >,
  743         -
                        HttpPl: ::aws_smithy_legacy_http_server::plugin::Plugin<
  744         -
                            RestJsonExtras<L>,
  745         -
                            crate::operation_shape::HttpQueryParamsOnlyOperation,
  746         -
                            <
  747         -
                                ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
  748         -
                                as ::aws_smithy_legacy_http_server::plugin::Plugin<
  749         -
                                    RestJsonExtras<L>,
  750         -
                                    crate::operation_shape::HttpQueryParamsOnlyOperation,
  751         -
                                    ModelPl::Output
  752         -
                                >
  753         -
                            >::Output
  754         -
                        >,
  755         -
  756         -
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
  757         -
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
  758         -
  759         -
                    {
  760         -
        use ::aws_smithy_legacy_http_server::operation::OperationShapeExt;
  761         -
        use ::aws_smithy_legacy_http_server::plugin::Plugin;
  762         -
        let svc = crate::operation_shape::HttpQueryParamsOnlyOperation::from_service(service);
  763         -
        let svc = self.model_plugin.apply(svc);
  764         -
        let svc =
  765         -
            ::aws_smithy_legacy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
  766         -
                .apply(svc);
  767         -
        let svc = self.http_plugin.apply(svc);
  768         -
        self.http_query_params_only_operation_custom(svc)
  769         -
    }
  770         -
  771         -
    /// Sets the [`HttpQueryParamsOnlyOperation`](crate::operation_shape::HttpQueryParamsOnlyOperation) to a custom [`Service`](tower::Service).
  772         -
    /// not constrained by the Smithy contract.
  773         -
    fn http_query_params_only_operation_custom<S>(mut self, svc: S) -> Self
  774         -
    where
  775         -
        S: ::tower::Service<
  776         -
                ::http::Request<Body>,
  777         -
                Response = ::http::Response<::aws_smithy_legacy_http_server::body::BoxBody>,
  778         -
                Error = ::std::convert::Infallible,
  779         -
            > + Clone
  780         -
            + Send
  781         -
            + 'static,
  782         -
        S::Future: Send + 'static,
  783         -
    {
  784         -
        self.http_query_params_only_operation =
  785         -
            Some(::aws_smithy_legacy_http_server::routing::Route::new(svc));
  786         -
        self
  787         -
    }
  788         -
  789    635   
    /// Sets the [`MapWithEnumKeyOp`](crate::operation_shape::MapWithEnumKeyOp) operation.
  790    636   
    ///
  791    637   
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_legacy_http_server::operation::Handler) trait.
  792    638   
    /// See the [operation module documentation](::aws_smithy_legacy_http_server::operation) for more information.
  793    639   
    ///
  794    640   
    /// # Example
  795    641   
    ///
  796    642   
    /// ```no_run
  797    643   
    /// use rest_json_extras::{RestJsonExtras, RestJsonExtrasConfig};
  798    644   
    ///
@@ -1870,1716 +1935,1775 @@
 1890   1736   
            if self.enum_query.is_none() {
 1891   1737   
                missing_operation_names
 1892   1738   
                    .insert(crate::operation_shape::EnumQuery::ID, ".enum_query()");
 1893   1739   
            }
 1894   1740   
            if self.escaped_string_values.is_none() {
 1895   1741   
                missing_operation_names.insert(
 1896   1742   
                    crate::operation_shape::EscapedStringValues::ID,
 1897   1743   
                    ".escaped_string_values()",
 1898   1744   
                );
 1899   1745   
            }
 1900         -
            if self.http_query_params_only_operation.is_none() {
 1901         -
                missing_operation_names.insert(
 1902         -
                    crate::operation_shape::HttpQueryParamsOnlyOperation::ID,
 1903         -
                    ".http_query_params_only_operation()",
 1904         -
                );
 1905         -
            }
 1906   1746   
            if self.map_with_enum_key_op.is_none() {
 1907   1747   
                missing_operation_names.insert(
 1908   1748   
                    crate::operation_shape::MapWithEnumKeyOp::ID,
 1909   1749   
                    ".map_with_enum_key_op()",
 1910   1750   
                );
 1911   1751   
            }
 1912   1752   
            if self.null_in_non_sparse.is_none() {
 1913   1753   
                missing_operation_names.insert(
 1914   1754   
                    crate::operation_shape::NullInNonSparse::ID,
 1915   1755   
                    ".null_in_non_sparse()",
@@ -1944,1784 +2008,1843 @@
 1964   1804   
                        .expect(unexpected_error_msg),
 1965   1805   
                ),
 1966   1806   
                (
 1967   1807   
                    request_specs::enum_query(),
 1968   1808   
                    self.enum_query.expect(unexpected_error_msg),
 1969   1809   
                ),
 1970   1810   
                (
 1971   1811   
                    request_specs::escaped_string_values(),
 1972   1812   
                    self.escaped_string_values.expect(unexpected_error_msg),
 1973   1813   
                ),
 1974         -
                (
 1975         -
                    request_specs::http_query_params_only_operation(),
 1976         -
                    self.http_query_params_only_operation
 1977         -
                        .expect(unexpected_error_msg),
 1978         -
                ),
 1979   1814   
                (
 1980   1815   
                    request_specs::map_with_enum_key_op(),
 1981   1816   
                    self.map_with_enum_key_op.expect(unexpected_error_msg),
 1982   1817   
                ),
 1983   1818   
                (
 1984   1819   
                    request_specs::null_in_non_sparse(),
 1985   1820   
                    self.null_in_non_sparse.expect(unexpected_error_msg),
 1986   1821   
                ),
 1987   1822   
                (
 1988   1823   
                    request_specs::primitive_int_header(),
@@ -2040,1875 +2108,1934 @@
 2060   1895   
                ),
 2061   1896   
                (
 2062   1897   
                    request_specs::escaped_string_values(),
 2063   1898   
                    self.escaped_string_values.unwrap_or_else(|| {
 2064   1899   
                        let svc = ::aws_smithy_legacy_http_server::operation::MissingFailure::<
 2065   1900   
                            ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
 2066   1901   
                        >::default();
 2067   1902   
                        ::aws_smithy_legacy_http_server::routing::Route::new(svc)
 2068   1903   
                    }),
 2069   1904   
                ),
 2070         -
                (
 2071         -
                    request_specs::http_query_params_only_operation(),
 2072         -
                    self.http_query_params_only_operation.unwrap_or_else(|| {
 2073         -
                        let svc = ::aws_smithy_legacy_http_server::operation::MissingFailure::<
 2074         -
                            ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
 2075         -
                        >::default();
 2076         -
                        ::aws_smithy_legacy_http_server::routing::Route::new(svc)
 2077         -
                    }),
 2078         -
                ),
 2079   1905   
                (
 2080   1906   
                    request_specs::map_with_enum_key_op(),
 2081   1907   
                    self.map_with_enum_key_op.unwrap_or_else(|| {
 2082   1908   
                        let svc = ::aws_smithy_legacy_http_server::operation::MissingFailure::<
 2083   1909   
                            ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
 2084   1910   
                        >::default();
 2085   1911   
                        ::aws_smithy_legacy_http_server::routing::Route::new(svc)
 2086   1912   
                    }),
 2087   1913   
                ),
 2088   1914   
                (
@@ -2206,2032 +2280,2091 @@
 2226   2052   
    pub(super) fn escaped_string_values(
 2227   2053   
    ) -> ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec {
 2228   2054   
        ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec::new(
 2229   2055   
                    ::http::Method::POST,
 2230   2056   
                    ::aws_smithy_legacy_http_server::routing::request_spec::UriSpec::new(
 2231   2057   
                        ::aws_smithy_legacy_http_server::routing::request_spec::PathAndQuerySpec::new(
 2232   2058   
                            ::aws_smithy_legacy_http_server::routing::request_spec::PathSpec::from_vector_unchecked(vec![
 2233   2059   
    ::aws_smithy_legacy_http_server::routing::request_spec::PathSegment::Literal(String::from("escaped-string-values")),
 2234   2060   
]),
 2235   2061   
                            ::aws_smithy_legacy_http_server::routing::request_spec::QuerySpec::from_vector_unchecked(vec![
 2236         -
])
 2237         -
                        )
 2238         -
                    ),
 2239         -
                )
 2240         -
    }
 2241         -
    pub(super) fn http_query_params_only_operation(
 2242         -
    ) -> ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec {
 2243         -
        ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec::new(
 2244         -
                    ::http::Method::GET,
 2245         -
                    ::aws_smithy_legacy_http_server::routing::request_spec::UriSpec::new(
 2246         -
                        ::aws_smithy_legacy_http_server::routing::request_spec::PathAndQuerySpec::new(
 2247         -
                            ::aws_smithy_legacy_http_server::routing::request_spec::PathSpec::from_vector_unchecked(vec![
 2248         -
    ::aws_smithy_legacy_http_server::routing::request_spec::PathSegment::Literal(String::from("http-query-params-only")),
 2249         -
]),
 2250         -
                            ::aws_smithy_legacy_http_server::routing::request_spec::QuerySpec::from_vector_unchecked(vec![
 2251   2062   
])
 2252   2063   
                        )
 2253   2064   
                    ),
 2254   2065   
                )
 2255   2066   
    }
 2256   2067   
    pub(super) fn map_with_enum_key_op(
 2257   2068   
    ) -> ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec {
 2258   2069   
        ::aws_smithy_legacy_http_server::routing::request_spec::RequestSpec::new(
 2259   2070   
                    ::http::Method::POST,
 2260   2071   
                    ::aws_smithy_legacy_http_server::routing::request_spec::UriSpec::new(
@@ -2367,2178 +2466,2275 @@
 2387   2198   
        HttpPl: ::aws_smithy_legacy_http_server::plugin::HttpMarker,
 2388   2199   
        ModelPl: ::aws_smithy_legacy_http_server::plugin::ModelMarker,
 2389   2200   
    >(
 2390   2201   
        config: RestJsonExtrasConfig<L, HttpPl, ModelPl>,
 2391   2202   
    ) -> RestJsonExtrasBuilder<Body, L, HttpPl, ModelPl> {
 2392   2203   
        RestJsonExtrasBuilder {
 2393   2204   
            case_insensitive_error_operation: None,
 2394   2205   
            empty_struct_with_content_on_wire_op: None,
 2395   2206   
            enum_query: None,
 2396   2207   
            escaped_string_values: None,
 2397         -
            http_query_params_only_operation: None,
 2398   2208   
            map_with_enum_key_op: None,
 2399   2209   
            null_in_non_sparse: None,
 2400   2210   
            primitive_int_header: None,
 2401   2211   
            primitive_int_op: None,
 2402   2212   
            query_precedence: None,
 2403   2213   
            status_response: None,
 2404   2214   
            string_payload: None,
 2405   2215   
            layer: config.layers,
 2406   2216   
            http_plugin: config.http_plugins,
 2407   2217   
            model_plugin: config.model_plugins,
 2408   2218   
        }
 2409   2219   
    }
 2410   2220   
 2411   2221   
    /// Constructs a builder for [`RestJsonExtras`].
 2412   2222   
    /// You must specify what plugins should be applied to the operations in this service.
 2413   2223   
    ///
 2414   2224   
    /// Use [`RestJsonExtras::builder_without_plugins`] if you don't need to apply plugins.
 2415   2225   
    ///
 2416   2226   
    /// Check out [`HttpPlugins`](::aws_smithy_legacy_http_server::plugin::HttpPlugins) and
 2417   2227   
    /// [`ModelPlugins`](::aws_smithy_legacy_http_server::plugin::ModelPlugins) if you need to apply
 2418   2228   
    /// multiple plugins.
 2419   2229   
    #[deprecated(
 2420   2230   
        since = "0.57.0",
 2421   2231   
        note = "please use the `builder` constructor and register plugins on the `RestJsonExtrasConfig` object instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
 2422   2232   
    )]
 2423   2233   
    pub fn builder_with_plugins<
 2424   2234   
        Body,
 2425   2235   
        HttpPl: ::aws_smithy_legacy_http_server::plugin::HttpMarker,
 2426   2236   
        ModelPl: ::aws_smithy_legacy_http_server::plugin::ModelMarker,
 2427   2237   
    >(
 2428   2238   
        http_plugin: HttpPl,
 2429   2239   
        model_plugin: ModelPl,
 2430   2240   
    ) -> RestJsonExtrasBuilder<Body, ::tower::layer::util::Identity, HttpPl, ModelPl> {
 2431   2241   
        RestJsonExtrasBuilder {
 2432   2242   
            case_insensitive_error_operation: None,
 2433   2243   
            empty_struct_with_content_on_wire_op: None,
 2434   2244   
            enum_query: None,
 2435   2245   
            escaped_string_values: None,
 2436         -
            http_query_params_only_operation: None,
 2437   2246   
            map_with_enum_key_op: None,
 2438   2247   
            null_in_non_sparse: None,
 2439   2248   
            primitive_int_header: None,
 2440   2249   
            primitive_int_op: None,
 2441   2250   
            query_precedence: None,
 2442   2251   
            status_response: None,
 2443   2252   
            string_payload: None,
 2444   2253   
            layer: ::tower::layer::util::Identity::new(),
 2445   2254   
            http_plugin,
 2446   2255   
            model_plugin,
@@ -2542,2351 +2648,2449 @@
 2562   2371   
}
 2563   2372   
 2564   2373   
/// An enumeration of all [operations](https://smithy.io/2.0/spec/service-types.html#operation) in RestJsonExtras.
 2565   2374   
#[allow(clippy::enum_variant_names)]
 2566   2375   
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
 2567   2376   
pub enum Operation {
 2568   2377   
    CaseInsensitiveErrorOperation,
 2569   2378   
    EmptyStructWithContentOnWireOp,
 2570   2379   
    EnumQuery,
 2571   2380   
    EscapedStringValues,
 2572         -
    HttpQueryParamsOnlyOperation,
 2573   2381   
    MapWithEnumKeyOp,
 2574   2382   
    NullInNonSparse,
 2575   2383   
    PrimitiveIntHeader,
 2576   2384   
    PrimitiveIntOp,
 2577   2385   
    QueryPrecedence,
 2578   2386   
    StatusResponse,
 2579   2387   
    StringPayload,
 2580   2388   
}
 2581   2389   
 2582   2390   
impl Operation {
 2583   2391   
    /// Returns the [operations](https://smithy.io/2.0/spec/service-types.html#operation) [`ShapeId`](::aws_smithy_legacy_http_server::shape_id::ShapeId).
 2584   2392   
    pub fn shape_id(&self) -> ::aws_smithy_legacy_http_server::shape_id::ShapeId {
 2585   2393   
        match self {
 2586   2394   
            Operation::CaseInsensitiveErrorOperation => {
 2587   2395   
                ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2588   2396   
                    "aws.protocoltests.restjson#CaseInsensitiveErrorOperation",
 2589   2397   
                    "aws.protocoltests.restjson",
 2590   2398   
                    "CaseInsensitiveErrorOperation",
 2591   2399   
                )
 2592   2400   
            }
 2593   2401   
            Operation::EmptyStructWithContentOnWireOp => {
 2594   2402   
                ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2595   2403   
                    "aws.protocoltests.restjson#EmptyStructWithContentOnWireOp",
 2596   2404   
                    "aws.protocoltests.restjson",
 2597   2405   
                    "EmptyStructWithContentOnWireOp",
 2598   2406   
                )
 2599   2407   
            }
 2600   2408   
            Operation::EnumQuery => ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2601   2409   
                "aws.protocoltests.restjson#EnumQuery",
 2602   2410   
                "aws.protocoltests.restjson",
 2603   2411   
                "EnumQuery",
 2604   2412   
            ),
 2605   2413   
            Operation::EscapedStringValues => {
 2606   2414   
                ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2607   2415   
                    "aws.protocoltests.restjson#EscapedStringValues",
 2608   2416   
                    "aws.protocoltests.restjson",
 2609   2417   
                    "EscapedStringValues",
 2610   2418   
                )
 2611   2419   
            }
 2612         -
            Operation::HttpQueryParamsOnlyOperation => {
 2613         -
                ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2614         -
                    "aws.protocoltests.restjson#HttpQueryParamsOnlyOperation",
 2615         -
                    "aws.protocoltests.restjson",
 2616         -
                    "HttpQueryParamsOnlyOperation",
 2617         -
                )
 2618         -
            }
 2619   2420   
            Operation::MapWithEnumKeyOp => ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2620   2421   
                "aws.protocoltests.restjson#MapWithEnumKeyOp",
 2621   2422   
                "aws.protocoltests.restjson",
 2622   2423   
                "MapWithEnumKeyOp",
 2623   2424   
            ),
 2624   2425   
            Operation::NullInNonSparse => ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
 2625   2426   
                "aws.protocoltests.restjson#NullInNonSparse",
 2626   2427   
                "aws.protocoltests.restjson",
 2627   2428   
                "NullInNonSparse",
 2628   2429   
            ),
@@ -2656,2457 +2722,2516 @@
 2676   2477   
{
 2677   2478   
    const VALUE: Operation = Operation::EnumQuery;
 2678   2479   
}
 2679   2480   
impl<L>
 2680   2481   
    ::aws_smithy_legacy_http_server::service::ContainsOperation<
 2681   2482   
        crate::operation_shape::EscapedStringValues,
 2682   2483   
    > for RestJsonExtras<L>
 2683   2484   
{
 2684   2485   
    const VALUE: Operation = Operation::EscapedStringValues;
 2685   2486   
}
 2686         -
impl<L>
 2687         -
    ::aws_smithy_legacy_http_server::service::ContainsOperation<
 2688         -
        crate::operation_shape::HttpQueryParamsOnlyOperation,
 2689         -
    > for RestJsonExtras<L>
 2690         -
{
 2691         -
    const VALUE: Operation = Operation::HttpQueryParamsOnlyOperation;
 2692         -
}
 2693   2487   
impl<L>
 2694   2488   
    ::aws_smithy_legacy_http_server::service::ContainsOperation<
 2695   2489   
        crate::operation_shape::MapWithEnumKeyOp,
 2696   2490   
    > for RestJsonExtras<L>
 2697   2491   
{
 2698   2492   
    const VALUE: Operation = Operation::MapWithEnumKeyOp;
 2699   2493   
}
 2700   2494   
impl<L>
 2701   2495   
    ::aws_smithy_legacy_http_server::service::ContainsOperation<
 2702   2496   
        crate::operation_shape::NullInNonSparse,
@@ -2937,2731 +3005,2790 @@
 2957   2751   
 2958   2752   
                        // EscapedStringValues match found, pop from both `member` and `not_member`
 2959   2753   
                        (@ $ name: ident, $ contains: ident (EscapedStringValues $($ member: ident)*) ($($ temp: ident)*) (EscapedStringValues $($ not_member: ident)*)) => {
 2960   2754   
                            scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
 2961   2755   
                        };
 2962   2756   
                        // EscapedStringValues match not found, pop from `not_member` into `temp` stack
 2963   2757   
                        (@ $ name: ident, $ contains: ident (EscapedStringValues $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
 2964   2758   
                            scope! { @ $ name, $ contains (EscapedStringValues $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
 2965   2759   
                        };
 2966   2760   
 2967         -
                        // HttpQueryParamsOnlyOperation match found, pop from both `member` and `not_member`
 2968         -
                        (@ $ name: ident, $ contains: ident (HttpQueryParamsOnlyOperation $($ member: ident)*) ($($ temp: ident)*) (HttpQueryParamsOnlyOperation $($ not_member: ident)*)) => {
 2969         -
                            scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
 2970         -
                        };
 2971         -
                        // HttpQueryParamsOnlyOperation match not found, pop from `not_member` into `temp` stack
 2972         -
                        (@ $ name: ident, $ contains: ident (HttpQueryParamsOnlyOperation $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
 2973         -
                            scope! { @ $ name, $ contains (HttpQueryParamsOnlyOperation $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
 2974         -
                        };
 2975         -
 2976   2761   
                        // MapWithEnumKeyOp match found, pop from both `member` and `not_member`
 2977   2762   
                        (@ $ name: ident, $ contains: ident (MapWithEnumKeyOp $($ member: ident)*) ($($ temp: ident)*) (MapWithEnumKeyOp $($ not_member: ident)*)) => {
 2978   2763   
                            scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
 2979   2764   
                        };
 2980   2765   
                        // MapWithEnumKeyOp match not found, pop from `not_member` into `temp` stack
 2981   2766   
                        (@ $ name: ident, $ contains: ident (MapWithEnumKeyOp $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
 2982   2767   
                            scope! { @ $ name, $ contains (MapWithEnumKeyOp $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
 2983   2768   
                        };
 2984   2769   
 2985   2770   
                        // NullInNonSparse match found, pop from both `member` and `not_member`
@@ -3023,2808 +3072,2857 @@
 3043   2828   
                        }
 3044   2829   
                    ) => {
 3045   2830   
                        use $ crate::operation_shape::*;
 3046   2831   
                        $ crate::server::scope! {
 3047   2832   
                            $(#[$ attrs])*
 3048   2833   
                            $ vis struct $ name {
 3049   2834   
                                includes: [$($ include),*],
 3050   2835   
                                excludes: []
 3051   2836   
                            }
 3052   2837   
                        }
 3053         -
                        scope! { @ $ name, False ($($ include)*) () (CaseInsensitiveErrorOperation EmptyStructWithContentOnWireOp EnumQuery EscapedStringValues HttpQueryParamsOnlyOperation MapWithEnumKeyOp NullInNonSparse PrimitiveIntHeader PrimitiveIntOp QueryPrecedence StatusResponse StringPayload) }
        2838  +
                        scope! { @ $ name, False ($($ include)*) () (CaseInsensitiveErrorOperation EmptyStructWithContentOnWireOp EnumQuery EscapedStringValues MapWithEnumKeyOp NullInNonSparse PrimitiveIntHeader PrimitiveIntOp QueryPrecedence StatusResponse StringPayload) }
 3054   2839   
                    };
 3055   2840   
                    (
 3056   2841   
                        $(#[$ attrs:meta])*
 3057   2842   
                        $ vis:vis struct $ name:ident {
 3058   2843   
                            excludes: [$($ exclude:ident),*]
 3059   2844   
                        }
 3060   2845   
                    ) => {
 3061   2846   
                        use $ crate::operation_shape::*;
 3062   2847   
 3063   2848   
                        $ crate::server::scope! {
 3064   2849   
                            $(#[$ attrs])*
 3065   2850   
                            $ vis struct $ name {
 3066   2851   
                                includes: [],
 3067   2852   
                                excludes: [$($ exclude),*]
 3068   2853   
                            }
 3069   2854   
                        }
 3070         -
                        scope! { @ $ name, True ($($ exclude)*) () (CaseInsensitiveErrorOperation EmptyStructWithContentOnWireOp EnumQuery EscapedStringValues HttpQueryParamsOnlyOperation MapWithEnumKeyOp NullInNonSparse PrimitiveIntHeader PrimitiveIntOp QueryPrecedence StatusResponse StringPayload) }
        2855  +
                        scope! { @ $ name, True ($($ exclude)*) () (CaseInsensitiveErrorOperation EmptyStructWithContentOnWireOp EnumQuery EscapedStringValues MapWithEnumKeyOp NullInNonSparse PrimitiveIntHeader PrimitiveIntOp QueryPrecedence StatusResponse StringPayload) }
 3071   2856   
                    };
 3072   2857   
                }

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

@@ -1,1 +44,45 @@
    5      5   
#![allow(clippy::large_enum_variant)]
    6      6   
#![allow(clippy::wrong_self_convention)]
    7      7   
#![allow(clippy::should_implement_trait)]
    8      8   
#![allow(clippy::disallowed_names)]
    9      9   
#![allow(clippy::vec_init_then_push)]
   10     10   
#![allow(clippy::type_complexity)]
   11     11   
#![allow(clippy::needless_return)]
   12     12   
#![allow(clippy::derive_partial_eq_without_eq)]
   13     13   
#![allow(clippy::result_large_err)]
   14     14   
#![allow(clippy::unnecessary_map_on_constructor)]
          15  +
#![allow(clippy::useless_conversion)]
   15     16   
#![allow(clippy::deprecated_semver)]
   16     17   
#![allow(clippy::uninlined_format_args)]
   17     18   
#![allow(rustdoc::bare_urls)]
   18     19   
#![allow(rustdoc::redundant_explicit_links)]
   19     20   
#![allow(rustdoc::broken_intra_doc_links)]
   20     21   
#![allow(rustdoc::invalid_html_tags)]
   21     22   
#![forbid(unsafe_code)]
   22     23   
#![cfg_attr(docsrs, feature(doc_cfg))]
   23     24   
//! simple
   24     25   

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

@@ -1,1 +40,40 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
#[::pyo3::pymodule]
    3      3   
#[pyo3(name = "simple")]
    4      4   
pub fn python_library(py: ::pyo3::Python<'_>, m: &::pyo3::types::PyModule) -> ::pyo3::PyResult<()> {
    5      5   
    let input = ::pyo3::types::PyModule::new(py, "input")?;
    6      6   
    let output = ::pyo3::types::PyModule::new(py, "output")?;
    7      7   
    let error = ::pyo3::types::PyModule::new(py, "error")?;
    8         -
    error.add_class::<crate::error::InternalServerError>()?;
    9         -
    output.add_class::<crate::output::OperationOutput>()?;
   10      8   
    input.add_class::<crate::input::OperationInput>()?;
           9  +
    output.add_class::<crate::output::OperationOutput>()?;
          10  +
    error.add_class::<crate::error::InternalServerError>()?;
   11     11   
    ::pyo3::py_run!(py, input, "import sys; sys.modules['simple.input'] = input");
   12     12   
    m.add_submodule(input)?;
   13     13   
    ::pyo3::py_run!(
   14     14   
        py,
   15     15   
        output,
   16     16   
        "import sys; sys.modules['simple.output'] = output"
   17     17   
    );
   18     18   
    m.add_submodule(output)?;
   19     19   
    ::pyo3::py_run!(py, error, "import sys; sys.modules['simple.error'] = error");
   20     20   
    m.add_submodule(error)?;

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

@@ -46,46 +316,316 @@
   66     66   
            crate::error::InternalServerError {
   67     67   
                message: error.to_string(),
   68     68   
            }
   69     69   
            .into()
   70     70   
        })
   71     71   
    }
   72     72   
}
   73     73   
   74     74   
#[::pyo3::pyclass(extends = ::pyo3::exceptions::PyException)]
   75     75   
/// :param message str:
          76  +
/// :param field_list typing.Optional\[typing.List\[unique_items.model.ValidationExceptionField\]\]:
   76     77   
/// :rtype None:
   77         -
#[allow(missing_docs)] // documentation missing in model
          78  +
/// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
   78     79   
#[derive(
   79     80   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   80     81   
)]
   81         -
pub struct InternalServerError {
          82  +
pub struct ValidationException {
   82     83   
    #[pyo3(get, set)]
   83     84   
    /// :type str:
   84         -
    #[allow(missing_docs)] // documentation missing in model
          85  +
    /// A summary of the validation failure.
   85     86   
    pub message: ::std::string::String,
          87  +
    #[pyo3(get, set)]
          88  +
    /// :type typing.Optional\[typing.List\[unique_items.model.ValidationExceptionField\]\]:
          89  +
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
          90  +
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
          91  +
}
          92  +
impl ValidationException {
          93  +
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
          94  +
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
          95  +
        self.field_list.as_deref()
          96  +
    }
   86     97   
}
   87     98   
#[allow(clippy::new_without_default)]
   88     99   
#[allow(clippy::too_many_arguments)]
   89    100   
#[::pyo3::pymethods]
   90         -
impl InternalServerError {
         101  +
impl ValidationException {
   91    102   
    #[new]
   92         -
    pub fn new(message: ::std::string::String) -> Self {
   93         -
        Self { message }
         103  +
    pub fn new(
         104  +
        message: ::std::string::String,
         105  +
        field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         106  +
    ) -> Self {
         107  +
        Self {
         108  +
            message,
         109  +
            field_list,
         110  +
        }
   94    111   
    }
   95    112   
    fn __repr__(&self) -> String {
   96    113   
        format!("{self:?}")
   97    114   
    }
   98    115   
    fn __str__(&self) -> String {
   99    116   
        format!("{self:?}")
  100    117   
    }
  101    118   
}
  102         -
impl InternalServerError {
         119  +
impl ValidationException {
  103    120   
    /// Returns the error message.
  104    121   
    pub fn message(&self) -> &str {
  105    122   
        &self.message
  106    123   
    }
  107    124   
    #[doc(hidden)]
  108    125   
    /// Returns the error name.
  109    126   
    pub fn name(&self) -> &'static str {
  110         -
        "InternalServerError"
         127  +
        "ValidationException"
  111    128   
    }
  112    129   
}
  113         -
impl ::std::fmt::Display for InternalServerError {
         130  +
impl ::std::fmt::Display for ValidationException {
  114    131   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  115         -
        ::std::write!(f, "InternalServerError")?;
         132  +
        ::std::write!(f, "ValidationException")?;
  116    133   
        {
  117    134   
            ::std::write!(f, ": {}", &self.message)?;
  118    135   
        }
  119    136   
        Ok(())
  120    137   
    }
  121    138   
}
  122         -
impl ::std::error::Error for InternalServerError {}
  123         -
impl InternalServerError {
  124         -
    /// Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
  125         -
    pub fn builder() -> crate::error::internal_server_error::Builder {
  126         -
        crate::error::internal_server_error::Builder::default()
         139  +
impl ::std::error::Error for ValidationException {}
         140  +
impl ValidationException {
         141  +
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
         142  +
    pub fn builder() -> crate::error::validation_exception::Builder {
         143  +
        crate::error::validation_exception::Builder::default()
  127    144   
    }
  128    145   
}
  129    146   
  130    147   
#[::pyo3::pyclass(extends = ::pyo3::exceptions::PyException)]
  131    148   
/// :param message str:
  132         -
/// :param field_list typing.Optional\[typing.List\[unique_items.model.ValidationExceptionField\]\]:
  133    149   
/// :rtype None:
  134         -
/// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
         150  +
#[allow(missing_docs)] // documentation missing in model
  135    151   
#[derive(
  136    152   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  137    153   
)]
  138         -
pub struct ValidationException {
         154  +
pub struct InternalServerError {
  139    155   
    #[pyo3(get, set)]
  140    156   
    /// :type str:
  141         -
    /// A summary of the validation failure.
         157  +
    #[allow(missing_docs)] // documentation missing in model
  142    158   
    pub message: ::std::string::String,
  143         -
    #[pyo3(get, set)]
  144         -
    /// :type typing.Optional\[typing.List\[unique_items.model.ValidationExceptionField\]\]:
  145         -
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
  146         -
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  147         -
}
  148         -
impl ValidationException {
  149         -
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
  150         -
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
  151         -
        self.field_list.as_deref()
  152         -
    }
  153    159   
}
  154    160   
#[allow(clippy::new_without_default)]
  155    161   
#[allow(clippy::too_many_arguments)]
  156    162   
#[::pyo3::pymethods]
  157         -
impl ValidationException {
         163  +
impl InternalServerError {
  158    164   
    #[new]
  159         -
    pub fn new(
  160         -
        message: ::std::string::String,
  161         -
        field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  162         -
    ) -> Self {
  163         -
        Self {
  164         -
            message,
  165         -
            field_list,
  166         -
        }
         165  +
    pub fn new(message: ::std::string::String) -> Self {
         166  +
        Self { message }
  167    167   
    }
  168    168   
    fn __repr__(&self) -> String {
  169    169   
        format!("{self:?}")
  170    170   
    }
  171    171   
    fn __str__(&self) -> String {
  172    172   
        format!("{self:?}")
  173    173   
    }
  174    174   
}
  175         -
impl ValidationException {
         175  +
impl InternalServerError {
  176    176   
    /// Returns the error message.
  177    177   
    pub fn message(&self) -> &str {
  178    178   
        &self.message
  179    179   
    }
  180    180   
    #[doc(hidden)]
  181    181   
    /// Returns the error name.
  182    182   
    pub fn name(&self) -> &'static str {
  183         -
        "ValidationException"
         183  +
        "InternalServerError"
  184    184   
    }
  185    185   
}
  186         -
impl ::std::fmt::Display for ValidationException {
         186  +
impl ::std::fmt::Display for InternalServerError {
  187    187   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  188         -
        ::std::write!(f, "ValidationException")?;
         188  +
        ::std::write!(f, "InternalServerError")?;
  189    189   
        {
  190    190   
            ::std::write!(f, ": {}", &self.message)?;
  191    191   
        }
  192    192   
        Ok(())
  193    193   
    }
  194    194   
}
  195         -
impl ::std::error::Error for ValidationException {}
  196         -
impl ValidationException {
  197         -
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
  198         -
    pub fn builder() -> crate::error::validation_exception::Builder {
  199         -
        crate::error::validation_exception::Builder::default()
         195  +
impl ::std::error::Error for InternalServerError {}
         196  +
impl InternalServerError {
         197  +
    /// Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         198  +
    pub fn builder() -> crate::error::internal_server_error::Builder {
         199  +
        crate::error::internal_server_error::Builder::default()
  200    200   
    }
  201    201   
}
  202         -
/// See [`InternalServerError`](crate::error::InternalServerError).
  203         -
pub mod internal_server_error {
         202  +
/// See [`ValidationException`](crate::error::ValidationException).
         203  +
pub mod validation_exception {
  204    204   
  205    205   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  206    206   
    /// Holds one variant for each of the ways the builder can fail.
  207    207   
    #[allow(clippy::enum_variant_names)]
  208    208   
    pub enum ConstraintViolation {
  209         -
        /// `message` was not provided but it is required when building `InternalServerError`.
         209  +
        /// `message` was not provided but it is required when building `ValidationException`.
  210    210   
        MissingMessage,
  211    211   
    }
  212    212   
    impl ::std::fmt::Display for ConstraintViolation {
  213    213   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  214    214   
            match self {
  215         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
         215  +
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationException`"),
  216    216   
            }
  217    217   
        }
  218    218   
    }
  219    219   
    impl ::std::error::Error for ConstraintViolation {}
  220         -
    impl ::std::convert::TryFrom<Builder> for crate::error::InternalServerError {
         220  +
    impl ::std::convert::TryFrom<Builder> for crate::error::ValidationException {
  221    221   
        type Error = ConstraintViolation;
  222    222   
  223    223   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  224    224   
            builder.build()
  225    225   
        }
  226    226   
    }
  227         -
    /// A builder for [`InternalServerError`](crate::error::InternalServerError).
         227  +
    /// A builder for [`ValidationException`](crate::error::ValidationException).
  228    228   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  229    229   
    pub struct Builder {
  230    230   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         231  +
        pub(crate) field_list:
         232  +
            ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  231    233   
    }
  232    234   
    impl Builder {
  233         -
        #[allow(missing_docs)] // documentation missing in model
         235  +
        /// A summary of the validation failure.
  234    236   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  235    237   
            self.message = Some(input);
  236    238   
            self
  237    239   
        }
  238         -
        /// Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
         240  +
        /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         241  +
        pub fn field_list(
         242  +
            mut self,
         243  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         244  +
        ) -> Self {
         245  +
            self.field_list = input;
         246  +
            self
         247  +
        }
         248  +
        /// Consumes the builder and constructs a [`ValidationException`](crate::error::ValidationException).
  239    249   
        ///
  240         -
        /// The builder fails to construct a [`InternalServerError`](crate::error::InternalServerError) if you do not provide a value for all non-`Option`al members.
         250  +
        /// The builder fails to construct a [`ValidationException`](crate::error::ValidationException) if you do not provide a value for all non-`Option`al members.
  241    251   
        ///
  242         -
        pub fn build(self) -> Result<crate::error::InternalServerError, ConstraintViolation> {
         252  +
        pub fn build(self) -> Result<crate::error::ValidationException, ConstraintViolation> {
  243    253   
            self.build_enforcing_required_and_enum_traits()
  244    254   
        }
  245    255   
        fn build_enforcing_required_and_enum_traits(
  246    256   
            self,
  247         -
        ) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  248         -
            Ok(crate::error::InternalServerError {
         257  +
        ) -> Result<crate::error::ValidationException, ConstraintViolation> {
         258  +
            Ok(crate::error::ValidationException {
  249    259   
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
         260  +
                field_list: self.field_list,
  250    261   
            })
  251    262   
        }
  252    263   
    }
  253    264   
}
  254         -
/// See [`ValidationException`](crate::error::ValidationException).
  255         -
pub mod validation_exception {
         265  +
/// See [`InternalServerError`](crate::error::InternalServerError).
         266  +
pub mod internal_server_error {
  256    267   
  257    268   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  258    269   
    /// Holds one variant for each of the ways the builder can fail.
  259    270   
    #[allow(clippy::enum_variant_names)]
  260    271   
    pub enum ConstraintViolation {
  261         -
        /// `message` was not provided but it is required when building `ValidationException`.
         272  +
        /// `message` was not provided but it is required when building `InternalServerError`.
  262    273   
        MissingMessage,
  263    274   
    }
  264    275   
    impl ::std::fmt::Display for ConstraintViolation {
  265    276   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  266    277   
            match self {
  267         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationException`"),
         278  +
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
  268    279   
            }
  269    280   
        }
  270    281   
    }
  271    282   
    impl ::std::error::Error for ConstraintViolation {}
  272         -
    impl ::std::convert::TryFrom<Builder> for crate::error::ValidationException {
         283  +
    impl ::std::convert::TryFrom<Builder> for crate::error::InternalServerError {
  273    284   
        type Error = ConstraintViolation;
  274    285   
  275    286   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  276    287   
            builder.build()
  277    288   
        }
  278    289   
    }
  279         -
    /// A builder for [`ValidationException`](crate::error::ValidationException).
         290  +
    /// A builder for [`InternalServerError`](crate::error::InternalServerError).
  280    291   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  281    292   
    pub struct Builder {
  282    293   
        pub(crate) message: ::std::option::Option<::std::string::String>,
  283         -
        pub(crate) field_list:
  284         -
            ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  285    294   
    }
  286    295   
    impl Builder {
  287         -
        /// A summary of the validation failure.
         296  +
        #[allow(missing_docs)] // documentation missing in model
  288    297   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  289    298   
            self.message = Some(input);
  290    299   
            self
  291    300   
        }
  292         -
        /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
  293         -
        pub fn field_list(
  294         -
            mut self,
  295         -
            input: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  296         -
        ) -> Self {
  297         -
            self.field_list = input;
  298         -
            self
  299         -
        }
  300         -
        /// Consumes the builder and constructs a [`ValidationException`](crate::error::ValidationException).
         301  +
        /// Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
  301    302   
        ///
  302         -
        /// The builder fails to construct a [`ValidationException`](crate::error::ValidationException) if you do not provide a value for all non-`Option`al members.
         303  +
        /// The builder fails to construct a [`InternalServerError`](crate::error::InternalServerError) if you do not provide a value for all non-`Option`al members.
  303    304   
        ///
  304         -
        pub fn build(self) -> Result<crate::error::ValidationException, ConstraintViolation> {
         305  +
        pub fn build(self) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  305    306   
            self.build_enforcing_required_and_enum_traits()
  306    307   
        }
  307    308   
        fn build_enforcing_required_and_enum_traits(
  308    309   
            self,
  309         -
        ) -> Result<crate::error::ValidationException, ConstraintViolation> {
  310         -
            Ok(crate::error::ValidationException {
         310  +
        ) -> Result<crate::error::InternalServerError, ConstraintViolation> {
         311  +
            Ok(crate::error::InternalServerError {
  311    312   
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  312         -
                field_list: self.field_list,
  313    313   
            })
  314    314   
        }
  315    315   
    }
  316    316   
}

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

@@ -1,1 +44,45 @@
    5      5   
#![allow(clippy::large_enum_variant)]
    6      6   
#![allow(clippy::wrong_self_convention)]
    7      7   
#![allow(clippy::should_implement_trait)]
    8      8   
#![allow(clippy::disallowed_names)]
    9      9   
#![allow(clippy::vec_init_then_push)]
   10     10   
#![allow(clippy::type_complexity)]
   11     11   
#![allow(clippy::needless_return)]
   12     12   
#![allow(clippy::derive_partial_eq_without_eq)]
   13     13   
#![allow(clippy::result_large_err)]
   14     14   
#![allow(clippy::unnecessary_map_on_constructor)]
          15  +
#![allow(clippy::useless_conversion)]
   15     16   
#![allow(clippy::deprecated_semver)]
   16     17   
#![allow(clippy::uninlined_format_args)]
   17     18   
#![allow(rustdoc::bare_urls)]
   18     19   
#![allow(rustdoc::redundant_explicit_links)]
   19     20   
#![allow(rustdoc::broken_intra_doc_links)]
   20     21   
#![allow(rustdoc::invalid_html_tags)]
   21     22   
#![forbid(unsafe_code)]
   22     23   
#![cfg_attr(docsrs, feature(doc_cfg))]
   23     24   
//! unique_items
   24     25   

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

@@ -1,1 +93,104 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
#[::pyo3::pyclass]
    3         -
/// :param path str:
    4         -
/// :param message str:
    5         -
/// :rtype None:
    6         -
/// Describes one specific validation failure for an input member.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
///
           4  +
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
           5  +
/// [constraint traits]. Use [`SimpleSet::try_from`] to construct values of this type.
           6  +
///
           7  +
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
           8  +
///
    7      9   
#[derive(
    8     10   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    9     11   
)]
   10         -
pub struct ValidationExceptionField {
   11         -
    #[pyo3(get, set)]
   12         -
    /// :type str:
   13         -
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
   14         -
    pub path: ::std::string::String,
   15         -
    #[pyo3(get, set)]
   16         -
    /// :type str:
   17         -
    /// A detailed description of the validation failure.
   18         -
    pub message: ::std::string::String,
   19         -
}
   20         -
impl ValidationExceptionField {
   21         -
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
   22         -
    pub fn path(&self) -> &str {
   23         -
        use std::ops::Deref;
   24         -
        self.path.deref()
          12  +
pub(crate) struct SimpleSet(pub(crate) ::std::vec::Vec<::std::string::String>);
          13  +
impl SimpleSet {
          14  +
    /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::string::String>`].
          15  +
    pub fn into_inner(self) -> ::std::vec::Vec<::std::string::String> {
          16  +
        self.0
   25     17   
    }
   26         -
    /// A detailed description of the validation failure.
   27         -
    pub fn message(&self) -> &str {
   28         -
        use std::ops::Deref;
   29         -
        self.message.deref()
          18  +
          19  +
    fn check_unique_items(
          20  +
        items: ::std::vec::Vec<::std::string::String>,
          21  +
    ) -> ::std::result::Result<
          22  +
        ::std::vec::Vec<::std::string::String>,
          23  +
        crate::model::simple_set_internal::ConstraintViolation,
          24  +
    > {
          25  +
        let mut seen = ::std::collections::HashMap::new();
          26  +
        let mut duplicate_indices = ::std::vec::Vec::new();
          27  +
        for (idx, item) in items.iter().enumerate() {
          28  +
            if let Some(prev_idx) = seen.insert(item, idx) {
          29  +
                duplicate_indices.push(prev_idx);
   30     30   
            }
   31         -
}
   32         -
#[allow(clippy::new_without_default)]
   33         -
#[allow(clippy::too_many_arguments)]
   34         -
#[::pyo3::pymethods]
   35         -
impl ValidationExceptionField {
   36         -
    #[new]
   37         -
    pub fn new(path: ::std::string::String, message: ::std::string::String) -> Self {
   38         -
        Self { path, message }
   39     31   
        }
   40         -
    fn __repr__(&self) -> String {
   41         -
        format!("{self:?}")
          32  +
          33  +
        let mut last_duplicate_indices = ::std::vec::Vec::new();
          34  +
        for idx in &duplicate_indices {
          35  +
            if let Some(prev_idx) = seen.remove(&items[*idx]) {
          36  +
                last_duplicate_indices.push(prev_idx);
   42     37   
            }
   43         -
    fn __str__(&self) -> String {
   44         -
        format!("{self:?}")
   45     38   
        }
   46         -
}
   47         -
impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ValidationExceptionField> {
   48         -
    fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
   49         -
        ob.extract::<ValidationExceptionField>().map(Box::new)
          39  +
        duplicate_indices.extend(last_duplicate_indices);
          40  +
          41  +
        if !duplicate_indices.is_empty() {
          42  +
            debug_assert!(duplicate_indices.len() >= 2);
          43  +
            Err(
          44  +
                crate::model::simple_set_internal::ConstraintViolation::UniqueItems {
          45  +
                    duplicate_indices,
          46  +
                    original: items,
          47  +
                },
          48  +
            )
          49  +
        } else {
          50  +
            Ok(items)
          51  +
        }
   50     52   
    }
   51     53   
}
          54  +
impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for SimpleSet {
          55  +
    type Error = crate::model::simple_set_internal::ConstraintViolation;
   52     56   
   53         -
impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ValidationExceptionField> {
   54         -
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
   55         -
        (*self).into_py(py)
          57  +
    /// Constructs a `SimpleSet` from an [`::std::vec::Vec<::std::string::String>`], failing when the provided value does not satisfy the modeled constraints.
          58  +
    fn try_from(
          59  +
        value: ::std::vec::Vec<::std::string::String>,
          60  +
    ) -> ::std::result::Result<Self, Self::Error> {
          61  +
        let value = Self::check_unique_items(value)?;
          62  +
          63  +
        Ok(Self(value))
   56     64   
    }
   57     65   
}
   58         -
impl ValidationExceptionField {
   59         -
    /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
   60         -
    pub fn builder() -> crate::model::validation_exception_field::Builder {
   61         -
        crate::model::validation_exception_field::Builder::default()
          66  +
          67  +
impl ::std::convert::From<SimpleSet> for ::std::vec::Vec<::std::string::String> {
          68  +
    fn from(value: SimpleSet) -> Self {
          69  +
        value.into_inner()
   62     70   
    }
   63     71   
}
          72  +
impl crate::constrained::Constrained for SimpleSet {
          73  +
    type Unconstrained = crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained;
          74  +
}
   64     75   
   65     76   
#[allow(missing_docs)] // documentation missing in model
   66     77   
///
   67     78   
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
   68     79   
/// [constraint traits]. Use [`ComplexSet::try_from`] to construct values of this type.
   69     80   
///
   70     81   
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
   71     82   
///
   72     83   
#[derive(
   73     84   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
@@ -176,187 +368,349 @@
  196    207   
impl crate::constrained::Constrained for crate::model::ComplexSetStruct {
  197    208   
    type Unconstrained = crate::model::complex_set_struct_internal::Builder;
  198    209   
}
  199    210   
impl ComplexSetStruct {
  200    211   
    /// Creates a new builder-style object to manufacture [`ComplexSetStruct`](crate::model::ComplexSetStruct).
  201    212   
    pub fn builder() -> crate::model::complex_set_struct::Builder {
  202    213   
        crate::model::complex_set_struct::Builder::default()
  203    214   
    }
  204    215   
}
  205    216   
  206         -
#[allow(missing_docs)] // documentation missing in model
  207         -
///
  208         -
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
  209         -
/// [constraint traits]. Use [`SimpleSet::try_from`] to construct values of this type.
  210         -
///
  211         -
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
  212         -
///
         217  +
#[::pyo3::pyclass]
         218  +
/// :param path str:
         219  +
/// :param message str:
         220  +
/// :rtype None:
         221  +
/// Describes one specific validation failure for an input member.
  213    222   
#[derive(
  214    223   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  215    224   
)]
  216         -
pub(crate) struct SimpleSet(pub(crate) ::std::vec::Vec<::std::string::String>);
  217         -
impl SimpleSet {
  218         -
    /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::string::String>`].
  219         -
    pub fn into_inner(self) -> ::std::vec::Vec<::std::string::String> {
  220         -
        self.0
  221         -
    }
  222         -
  223         -
    fn check_unique_items(
  224         -
        items: ::std::vec::Vec<::std::string::String>,
  225         -
    ) -> ::std::result::Result<
  226         -
        ::std::vec::Vec<::std::string::String>,
  227         -
        crate::model::simple_set_internal::ConstraintViolation,
  228         -
    > {
  229         -
        let mut seen = ::std::collections::HashMap::new();
  230         -
        let mut duplicate_indices = ::std::vec::Vec::new();
  231         -
        for (idx, item) in items.iter().enumerate() {
  232         -
            if let Some(prev_idx) = seen.insert(item, idx) {
  233         -
                duplicate_indices.push(prev_idx);
  234         -
            }
         225  +
pub struct ValidationExceptionField {
         226  +
    #[pyo3(get, set)]
         227  +
    /// :type str:
         228  +
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         229  +
    pub path: ::std::string::String,
         230  +
    #[pyo3(get, set)]
         231  +
    /// :type str:
         232  +
    /// A detailed description of the validation failure.
         233  +
    pub message: ::std::string::String,
         234  +
}
         235  +
impl ValidationExceptionField {
         236  +
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         237  +
    pub fn path(&self) -> &str {
         238  +
        use std::ops::Deref;
         239  +
        self.path.deref()
  235    240   
    }
  236         -
  237         -
        let mut last_duplicate_indices = ::std::vec::Vec::new();
  238         -
        for idx in &duplicate_indices {
  239         -
            if let Some(prev_idx) = seen.remove(&items[*idx]) {
  240         -
                last_duplicate_indices.push(prev_idx);
         241  +
    /// A detailed description of the validation failure.
         242  +
    pub fn message(&self) -> &str {
         243  +
        use std::ops::Deref;
         244  +
        self.message.deref()
  241    245   
    }
         246  +
}
         247  +
#[allow(clippy::new_without_default)]
         248  +
#[allow(clippy::too_many_arguments)]
         249  +
#[::pyo3::pymethods]
         250  +
impl ValidationExceptionField {
         251  +
    #[new]
         252  +
    pub fn new(path: ::std::string::String, message: ::std::string::String) -> Self {
         253  +
        Self { path, message }
  242    254   
    }
  243         -
        duplicate_indices.extend(last_duplicate_indices);
  244         -
  245         -
        if !duplicate_indices.is_empty() {
  246         -
            debug_assert!(duplicate_indices.len() >= 2);
  247         -
            Err(
  248         -
                crate::model::simple_set_internal::ConstraintViolation::UniqueItems {
  249         -
                    duplicate_indices,
  250         -
                    original: items,
  251         -
                },
  252         -
            )
  253         -
        } else {
  254         -
            Ok(items)
         255  +
    fn __repr__(&self) -> String {
         256  +
        format!("{self:?}")
  255    257   
    }
         258  +
    fn __str__(&self) -> String {
         259  +
        format!("{self:?}")
  256    260   
    }
  257    261   
}
  258         -
impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for SimpleSet {
  259         -
    type Error = crate::model::simple_set_internal::ConstraintViolation;
  260         -
  261         -
    /// Constructs a `SimpleSet` from an [`::std::vec::Vec<::std::string::String>`], failing when the provided value does not satisfy the modeled constraints.
  262         -
    fn try_from(
  263         -
        value: ::std::vec::Vec<::std::string::String>,
  264         -
    ) -> ::std::result::Result<Self, Self::Error> {
  265         -
        let value = Self::check_unique_items(value)?;
  266         -
  267         -
        Ok(Self(value))
         262  +
impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<ValidationExceptionField> {
         263  +
    fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
         264  +
        ob.extract::<ValidationExceptionField>().map(Box::new)
  268    265   
    }
  269    266   
}
  270    267   
  271         -
impl ::std::convert::From<SimpleSet> for ::std::vec::Vec<::std::string::String> {
  272         -
    fn from(value: SimpleSet) -> Self {
  273         -
        value.into_inner()
         268  +
impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<ValidationExceptionField> {
         269  +
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
         270  +
        (*self).into_py(py)
  274    271   
    }
  275    272   
}
  276         -
impl crate::constrained::Constrained for SimpleSet {
  277         -
    type Unconstrained = crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained;
         273  +
impl ValidationExceptionField {
         274  +
    /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         275  +
    pub fn builder() -> crate::model::validation_exception_field::Builder {
         276  +
        crate::model::validation_exception_field::Builder::default()
         277  +
    }
  278    278   
}
         279  +
pub(crate) mod simple_set_internal {
  279    280   
  280         -
/// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
  281         -
pub mod validation_exception_field {
  282         -
  283         -
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  284         -
    /// Holds one variant for each of the ways the builder can fail.
  285    281   
    #[allow(clippy::enum_variant_names)]
  286         -
    pub enum ConstraintViolation {
  287         -
        /// `path` was not provided but it is required when building `ValidationExceptionField`.
  288         -
        MissingPath,
  289         -
        /// `message` was not provided but it is required when building `ValidationExceptionField`.
  290         -
        MissingMessage,
         282  +
    #[derive(Debug, PartialEq)]
         283  +
    pub(crate) enum ConstraintViolation {
         284  +
        /// Constraint violation error when the list does not contain unique items
         285  +
        UniqueItems {
         286  +
            /// A vector of indices into `original` pointing to all duplicate items. This vector has
         287  +
            /// at least two elements.
         288  +
            /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
         289  +
            /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
         290  +
            /// Nothing is guaranteed about the order of the indices.
         291  +
            duplicate_indices: ::std::vec::Vec<usize>,
         292  +
            /// The original vector, that contains duplicate items.
         293  +
            original: ::std::vec::Vec<::std::string::String>,
         294  +
        },
  291    295   
    }
         296  +
  292    297   
    impl ::std::fmt::Display for ConstraintViolation {
  293    298   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  294         -
            match self {
  295         -
                ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
  296         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
  297         -
            }
         299  +
            let message = match self {
         300  +
                                Self::UniqueItems { duplicate_indices, .. } =>
         301  +
                            format!("Value with repeated values at indices {:?} provided for 'com.amazonaws.constraints#SimpleSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
         302  +
                            };
         303  +
            write!(f, "{message}")
  298    304   
        }
  299    305   
    }
  300         -
    impl ::std::error::Error for ConstraintViolation {}
  301         -
    impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
  302         -
        type Error = ConstraintViolation;
  303    306   
  304         -
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  305         -
            builder.build()
  306         -
        }
  307         -
    }
  308         -
    /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
  309         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
  310         -
    pub struct Builder {
  311         -
        pub(crate) path: ::std::option::Option<::std::string::String>,
  312         -
        pub(crate) message: ::std::option::Option<::std::string::String>,
  313         -
    }
  314         -
    impl Builder {
  315         -
        /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
  316         -
        pub fn path(mut self, input: ::std::string::String) -> Self {
  317         -
            self.path = Some(input);
  318         -
            self
  319         -
        }
  320         -
        /// A detailed description of the validation failure.
  321         -
        pub fn message(mut self, input: ::std::string::String) -> Self {
  322         -
            self.message = Some(input);
  323         -
            self
  324         -
        }
  325         -
        /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
  326         -
        ///
  327         -
        /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if you do not provide a value for all non-`Option`al members.
  328         -
        ///
  329         -
        pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
  330         -
            self.build_enforcing_required_and_enum_traits()
  331         -
        }
  332         -
        fn build_enforcing_required_and_enum_traits(
         307  +
    impl ::std::error::Error for ConstraintViolation {}
         308  +
    impl ConstraintViolation {
         309  +
        pub(crate) fn as_validation_exception_field(
  333    310   
            self,
  334         -
        ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
  335         -
            Ok(crate::model::ValidationExceptionField {
  336         -
                path: self.path.ok_or(ConstraintViolation::MissingPath)?,
  337         -
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  338         -
            })
         311  +
            path: ::std::string::String,
         312  +
        ) -> crate::model::ValidationExceptionField {
         313  +
            match self {
         314  +
                        Self::UniqueItems { duplicate_indices, .. } =>
         315  +
                                crate::model::ValidationExceptionField {
         316  +
                                    message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
         317  +
                                    path,
         318  +
                                },
         319  +
                    }
  339    320   
        }
  340    321   
    }
  341    322   
}
  342    323   
pub(crate) mod complex_set_internal {
  343    324   
  344    325   
    #[allow(clippy::enum_variant_names)]
  345    326   
    #[derive(Debug, PartialEq)]
  346    327   
    pub(crate) enum ConstraintViolation {
  347    328   
        /// Constraint violation error when the list does not contain unique items
  348    329   
        UniqueItems {
@@ -436,417 +509,508 @@
  456    437   
            self.build_enforcing_required_and_enum_traits()
  457    438   
        }
  458    439   
        fn build_enforcing_required_and_enum_traits(self) -> crate::model::ComplexSetStruct {
  459    440   
            crate::model::ComplexSetStruct {
  460    441   
                foo: self.foo,
  461    442   
                blob: self.blob,
  462    443   
            }
  463    444   
        }
  464    445   
    }
  465    446   
}
  466         -
pub(crate) mod simple_set_internal {
         447  +
/// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         448  +
pub mod validation_exception_field {
  467    449   
         450  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         451  +
    /// Holds one variant for each of the ways the builder can fail.
  468    452   
    #[allow(clippy::enum_variant_names)]
  469         -
    #[derive(Debug, PartialEq)]
  470         -
    pub(crate) enum ConstraintViolation {
  471         -
        /// Constraint violation error when the list does not contain unique items
  472         -
        UniqueItems {
  473         -
            /// A vector of indices into `original` pointing to all duplicate items. This vector has
  474         -
            /// at least two elements.
  475         -
            /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
  476         -
            /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
  477         -
            /// Nothing is guaranteed about the order of the indices.
  478         -
            duplicate_indices: ::std::vec::Vec<usize>,
  479         -
            /// The original vector, that contains duplicate items.
  480         -
            original: ::std::vec::Vec<::std::string::String>,
  481         -
        },
         453  +
    pub enum ConstraintViolation {
         454  +
        /// `path` was not provided but it is required when building `ValidationExceptionField`.
         455  +
        MissingPath,
         456  +
        /// `message` was not provided but it is required when building `ValidationExceptionField`.
         457  +
        MissingMessage,
  482    458   
    }
  483         -
  484    459   
    impl ::std::fmt::Display for ConstraintViolation {
  485    460   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  486         -
            let message = match self {
  487         -
                                Self::UniqueItems { duplicate_indices, .. } =>
  488         -
                            format!("Value with repeated values at indices {:?} provided for 'com.amazonaws.constraints#SimpleSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
  489         -
                            };
  490         -
            write!(f, "{message}")
         461  +
            match self {
         462  +
                ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
         463  +
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
         464  +
            }
  491    465   
        }
  492    466   
    }
  493         -
  494    467   
    impl ::std::error::Error for ConstraintViolation {}
  495         -
    impl ConstraintViolation {
  496         -
        pub(crate) fn as_validation_exception_field(
  497         -
            self,
  498         -
            path: ::std::string::String,
  499         -
        ) -> crate::model::ValidationExceptionField {
  500         -
            match self {
  501         -
                        Self::UniqueItems { duplicate_indices, .. } =>
  502         -
                                crate::model::ValidationExceptionField {
  503         -
                                    message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
  504         -
                                    path,
  505         -
                                },
         468  +
    impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
         469  +
        type Error = ConstraintViolation;
         470  +
         471  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         472  +
            builder.build()
         473  +
        }
         474  +
    }
         475  +
    /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         476  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         477  +
    pub struct Builder {
         478  +
        pub(crate) path: ::std::option::Option<::std::string::String>,
         479  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         480  +
    }
         481  +
    impl Builder {
         482  +
        /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         483  +
        pub fn path(mut self, input: ::std::string::String) -> Self {
         484  +
            self.path = Some(input);
         485  +
            self
         486  +
        }
         487  +
        /// A detailed description of the validation failure.
         488  +
        pub fn message(mut self, input: ::std::string::String) -> Self {
         489  +
            self.message = Some(input);
         490  +
            self
  506    491   
        }
         492  +
        /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         493  +
        ///
         494  +
        /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if you do not provide a value for all non-`Option`al members.
         495  +
        ///
         496  +
        pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
         497  +
            self.build_enforcing_required_and_enum_traits()
         498  +
        }
         499  +
        fn build_enforcing_required_and_enum_traits(
         500  +
            self,
         501  +
        ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
         502  +
            Ok(crate::model::ValidationExceptionField {
         503  +
                path: self.path.ok_or(ConstraintViolation::MissingPath)?,
         504  +
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
         505  +
            })
  507    506   
        }
  508    507   
    }
  509    508   
}

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

@@ -1,1 +44,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
#[::pyo3::pymodule]
    3      3   
#[pyo3(name = "unique_items")]
    4      4   
pub fn python_library(py: ::pyo3::Python<'_>, m: &::pyo3::types::PyModule) -> ::pyo3::PyResult<()> {
    5      5   
    let input = ::pyo3::types::PyModule::new(py, "input")?;
    6      6   
    let output = ::pyo3::types::PyModule::new(py, "output")?;
    7      7   
    let error = ::pyo3::types::PyModule::new(py, "error")?;
    8         -
    error.add_class::<crate::error::InternalServerError>()?;
           8  +
    input.add_class::<crate::input::MalformedUniqueItemsInput>()?;
           9  +
    output.add_class::<crate::output::MalformedUniqueItemsOutput>()?;
    9     10   
    error.add_class::<crate::error::ValidationException>()?;
          11  +
    error.add_class::<crate::error::InternalServerError>()?;
   10     12   
    let model = ::pyo3::types::PyModule::new(py, "model")?;
   11         -
    model.add_class::<crate::model::ValidationExceptionField>()?;
   12         -
    output.add_class::<crate::output::MalformedUniqueItemsOutput>()?;
   13         -
    input.add_class::<crate::input::MalformedUniqueItemsInput>()?;
   14     13   
    model.add_class::<crate::model::ComplexSetStruct>()?;
          14  +
    model.add_class::<crate::model::ValidationExceptionField>()?;
   15     15   
    ::pyo3::py_run!(
   16     16   
        py,
   17     17   
        input,
   18     18   
        "import sys; sys.modules['unique_items.input'] = input"
   19     19   
    );
   20     20   
    m.add_submodule(input)?;
   21     21   
    ::pyo3::py_run!(
   22     22   
        py,
   23     23   
        output,
   24     24   
        "import sys; sys.modules['unique_items.output'] = output"

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

@@ -1,1 +44,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
    3         -
pub(crate) mod complex_set_unconstrained {
           3  +
pub(crate) mod simple_set_unconstrained {
    4      4   
    5      5   
    #[derive(Debug, Clone)]
    6         -
    pub(crate) struct ComplexSetUnconstrained(
    7         -
        pub(crate) std::vec::Vec<crate::model::ComplexSetStruct>,
    8         -
    );
           6  +
    pub(crate) struct SimpleSetUnconstrained(pub(crate) std::vec::Vec<::std::string::String>);
    9      7   
   10         -
    impl From<ComplexSetUnconstrained>
   11         -
        for crate::constrained::MaybeConstrained<crate::model::ComplexSet>
           8  +
    impl From<SimpleSetUnconstrained>
           9  +
        for crate::constrained::MaybeConstrained<crate::model::SimpleSet>
   12     10   
    {
   13         -
        fn from(value: ComplexSetUnconstrained) -> Self {
          11  +
        fn from(value: SimpleSetUnconstrained) -> Self {
   14     12   
            Self::Unconstrained(value)
   15     13   
        }
   16     14   
    }
   17         -
    impl std::convert::TryFrom<ComplexSetUnconstrained> for crate::model::ComplexSet {
   18         -
        type Error = crate::model::complex_set_internal::ConstraintViolation;
   19         -
        fn try_from(value: ComplexSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          15  +
    impl std::convert::TryFrom<SimpleSetUnconstrained> for crate::model::SimpleSet {
          16  +
        type Error = crate::model::simple_set_internal::ConstraintViolation;
          17  +
        fn try_from(value: SimpleSetUnconstrained) -> std::result::Result<Self, Self::Error> {
   20     18   
            let inner = value.0;
   21     19   
            Self::try_from(inner)
   22     20   
        }
   23     21   
    }
   24     22   
}
   25         -
pub(crate) mod simple_set_unconstrained {
          23  +
pub(crate) mod complex_set_unconstrained {
   26     24   
   27     25   
    #[derive(Debug, Clone)]
   28         -
    pub(crate) struct SimpleSetUnconstrained(pub(crate) std::vec::Vec<::std::string::String>);
          26  +
    pub(crate) struct ComplexSetUnconstrained(
          27  +
        pub(crate) std::vec::Vec<crate::model::ComplexSetStruct>,
          28  +
    );
   29     29   
   30         -
    impl From<SimpleSetUnconstrained>
   31         -
        for crate::constrained::MaybeConstrained<crate::model::SimpleSet>
          30  +
    impl From<ComplexSetUnconstrained>
          31  +
        for crate::constrained::MaybeConstrained<crate::model::ComplexSet>
   32     32   
    {
   33         -
        fn from(value: SimpleSetUnconstrained) -> Self {
          33  +
        fn from(value: ComplexSetUnconstrained) -> Self {
   34     34   
            Self::Unconstrained(value)
   35     35   
        }
   36     36   
    }
   37         -
    impl std::convert::TryFrom<SimpleSetUnconstrained> for crate::model::SimpleSet {
   38         -
        type Error = crate::model::simple_set_internal::ConstraintViolation;
   39         -
        fn try_from(value: SimpleSetUnconstrained) -> std::result::Result<Self, Self::Error> {
          37  +
    impl std::convert::TryFrom<ComplexSetUnconstrained> for crate::model::ComplexSet {
          38  +
        type Error = crate::model::complex_set_internal::ConstraintViolation;
          39  +
        fn try_from(value: ComplexSetUnconstrained) -> std::result::Result<Self, Self::Error> {
   40     40   
            let inner = value.0;
   41     41   
            Self::try_from(inner)
   42     42   
        }
   43     43   
    }
   44     44   
}