Commit Graph

126 Commits

Author SHA1 Message Date
John DiSanti 358d13a09a
Enable the crate reorganization for generic clients (#2448) 2023-03-13 19:00:11 -07:00
John DiSanti 4835af9d6b
Make `RustReservedWordsSymbolProvider` configurable (#2382)
* Remove `toEnumVariantName` from `RustSymbolProvider`

The `toEnumVariantName` function existed on symbol provider to work
around enum definitions not being shapes. In the future when we refactor
to use `EnumShape` instead of `EnumTrait`, there will be `MemberShape`s
for each enum member. This change incrementally moves us to that future
by creating fake `MemberShape`s in the enum generator from the enum
definition.

* Fix escaping of `Self` in symbol providers

* Clean up an old hack

* Make `RustReservedWordsSymbolProvider` configurable

* Update changelog

* Incorporate feedback
2023-03-13 19:15:55 +00:00
John DiSanti 2f60a5e090
Update top level docs for crate reorganization (#2432) 2023-03-10 10:49:25 -08:00
John DiSanti 51df47576b
Make module docs customizable and update mod docs for crate reorg (#2418) 2023-03-09 19:10:03 +00:00
ysaito1001 7f4152cc93
Add more client re-exports (#2437)
* Add more client re-exports

This commit adds more client re-exports proposed in
https://github.com/awslabs/smithy-rs/issues/1759.
Specifically, it re-exports the following types:
- `aws_smithy_http::body::SdkBody`
- `aws_smithy_http::byte_stream::error::Error`
- `aws_smithy_http::operation::{Request, Response}`

* Update CHANGELOG.next.toml

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-03-09 17:13:03 +00:00
John DiSanti 9d31b6c4a7
Split generated code into multiple files (#2425)
* Split fluent client functions across multiple files

* Add (commented) test for large generated files to CI

* Split serialization/deserialization generated code across multiple files

* Remove extraneous newline from fluent client doc comments

* Add doc comments to `ProtocolFunctions`

* Simplify some doc comment generation

* Improve some function names
2023-03-08 18:21:58 +00:00
Nate McMaster (AWS) fdec05b693
Add hook for CodegenDecorators to insert a custom symbol provider (#2434)
* Add hook for CodegenDecorators to insert a custom symbol provider

* rename {extraS=>s}ymbolProvider

* fix rebase conflict that led to invalid code

* Remove model parameter from CoreCodegenDecorator::symbolProvider

---------

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-03-08 15:37:40 +00:00
Burak 26cb37afb0
Python: Add tests and fix the issues with `Timestamp` and `ByteStream` (#2431)
* Add `timestamp` type test and fix the conversion error

* Add some tests for `ByteStream` and fix async issues

* Use `__anext__` method instead of `anext`

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-03-07 10:04:56 +00:00
Julian Antonielli c3ae6f7eaf
Refactor event stream tests with `{client,server}IntegrationTest`s (#2342)
* Refactor `ClientEventStreamUnmarshallerGeneratorTest` to use `clientIntegrationTest` (WIP)

* Refactor `ClientEventStreamUnmarshallerGeneratorTest` with `clientIntegrationTest`

* Refactor `ClientEventStreamUnmarshallerGeneratorTest` to use generic test cases

* Start refactoring `ServerEventStreamUnmarshallerGeneratorTest`

* Make `ServerEventStreamUnmarshallerGeneratorTest` tests work

* Uncomment other test models

* Allow unused on `parse_generic_error`

* Rename `ServerEventStreamUnmarshallerGeneratorTest`

* Make `EventStreamUnmarshallTestCases` codegenTarget-agnostic

* Refactor `ClientEventStreamMarshallerGeneratorTest`: Tests run but fail

* Refactor `ServerEventStreamMarshallerGeneratorTest`

* Move `.into()` calls to `conditionalBuilderInput`

* Add "context" to TODO

* Fix client unmarshall tests

* Fix clippy lint

* Fix more clippy lints

* Add docs for `event_stream_serde` module

* Fix client tests

* Remove `#[allow(missing_docs)]` from event stream module

* Remove unused `EventStreamTestTools`

* Add `smithy-validation-model` test dep to `codegen-client`

* Temporarily add docs to make tests compile

* Undo change in model

* Make event stream unmarshaller tests a unit test

* Remove unused code

* Make `ServerEventStreamUnmarshallerGeneratorTest` a unit test

* Make `ServerEventStreamMarshallerGeneratorTest` a unit test

* Make `ServerEventStreamMarshallerGeneratorTest` pass

* Make remaining tests non-integration tests

* Make event stream serde module private again

* Remove unnecessary clippy allowances

* Remove clippy allowance

* Remove docs for `event_stream_serde` module

* Remove docs for `$unmarshallerTypeName::new`

* Remove more unnecessary docs

* Remove more superfluous docs

* Undo unnecessary diffs

* Uncomment last test

* Make `conditionalBuilderInput` internal
2023-02-28 20:26:20 +00:00
John DiSanti 5183ccbd6c
Split the `types` and `builders` modules into per-shape private modules (#2415) 2023-02-24 19:53:09 +00:00
david-perez 4c7684732c
Enclose missing Rust template parameters in backticks in the exception message (#1492)
* Enclose missing Rust template parameters in backticks in the exception message

* appease ktlint

* ./gradlew ktlintFormat
2023-02-24 12:22:51 +00:00
John DiSanti 322124680f Reorganize the types/models/primitives modules 2023-02-23 13:55:47 -08:00
John DiSanti 14bd80920c
Add builder symbol/module resolution to symbol providers (#2395)
* Add builder symbol/module resolution to symbol providers

* Back out breaking changes

* Reduce codegen diff

* Fix server example clippy lints

* Associate #2396 with TODO comments

* Improve doc comment

* Revert doc hidden change
2023-02-23 17:19:27 +00:00
John DiSanti 76582ba07c
Move `AppName` and `PKG_VERSION` (#2389)
* Move `AppName` and `PKG_VERSION`

* Fix merge issue
2023-02-23 00:03:54 +00:00
John DiSanti 08c16d31cb
Fix escaping of `Self` in symbol providers (#2381)
* Fix escaping of `Self` in symbol providers

* Clean up an old hack
2023-02-22 23:37:32 +00:00
John DiSanti 6dd7bc7671
Reorganize more modules and re-exports (#2400)
* Conditionally re-export the Smithy Client Builder in clients
* Reorganize error type re-export
* Reorganize the `paginator` module
* Flatten the `presigning` module
* Hide the `http_body_checksum` module
2023-02-22 15:38:03 -08:00
John DiSanti 7cffe14549
Remove `toEnumVariantName` from `RustSymbolProvider` (#2377)
The `toEnumVariantName` function existed on symbol provider to work
around enum definitions not being shapes. In the future when we refactor
to use `EnumShape` instead of `EnumTrait`, there will be `MemberShape`s
for each enum member. This change incrementally moves us to that future
by creating fake `MemberShape`s in the enum generator from the enum
definition.
2023-02-22 21:20:43 +00:00
ysaito1001 da264056eb
Add support for the awsQueryCompatible trait (#2398)
* Add support for the awsQueryCompatible trait

This commit adds support for the awsQueryCompatible trait. This allows
services already supporting custom error codes through the AWS Query
protocol with the awsQueryError trait to continue supporting them after
the services switch to the AWS JSON 1.0 protocol.

* Add copyright header

* Fix clippy warning for clippy::manual-map

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

* Update CHANGELOG.next.toml

* Remove unused variables from `errorScope`

This commit addresses https://github.com/awslabs/smithy-rs/pull/2398#discussion_r1114763528

* Reorder arguments for test verification

This commit addresses https://github.com/awslabs/smithy-rs/pull/2398#discussion_r1114766817

---------

Co-authored-by: Yuki Saito <awsaito@amazon.com>
2023-02-22 21:04:48 +00:00
John DiSanti 85d2ace0d6
Upgrade Kotlin and Ktlint (#2392)
* Upgrade Kotlin to 1.7.21

* Upgrade Ktlint to 0.48.2

* Run `pre-commit run --all-files` to fix broken Ktlints

* Fix string comparison broken by code formatting
2023-02-22 18:21:06 +00:00
John DiSanti a40dbfcc94
Reorganize credentials, endpoints, region, and op customization (#2393)
* Move `Endpoint` re-export into `config`

* Move `Credentials` and `Region`

* Move `customize` into `crate::client`

* Clean up `RustModule`
2023-02-17 21:20:11 +00:00
John DiSanti 86bddca689
Move inputs, outputs, and op errors into operation modules (#2394) 2023-02-17 13:19:45 -08:00
John DiSanti afb1f16c9c
Move `RustSymbolProvider` and related types out of `SymbolVisitor` (#2380)
* Move base `RustSymbolProvider` types out of `SymbolVisitor`
* Rename `SymbolVisitorConfig` to `RustSymbolProviderConfig`
2023-02-17 12:17:59 -08:00
Fahad Zubair 3d007674b9
Constraint member types are refactored as standalone shapes. (#2256)
* Constraint member types are refactored as standalone shapes.

* ModelModule to ServerRustModule.model

* Constraints are written to the correct module

* Code generates for non-public constrained types.

* Removed a comment

* Using ConcurrentHashmap just to be on the safe side

* Clippy warnings removed on constraints, k.into() if gated

* Wordings for some of the checks changed

* Test need to call rustCrate.renderInlineMemoryModules

* ktlintFormat related changes

* RustCrate need to be passed for server builder

* Param renamed in getParentAndInlineModuleForConstrainedMember

* pubCrate to publicConstrainedType rename

* PythonServer symbol builder needed to pass publicConstrainedTypes

* @required still remains on the member shape after transformation

* ConcurrentLinkedQueue used for root RustWriters

* runTestCase does not run the tests but just sets them up, hence has been renamed

* CHANGELOG added

---------

Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
2023-02-17 19:21:01 +00:00
Eduardo de Moura Rodrigues 2473c5ca68
feat(codegen): support for api key auth trait (#2154)
* feat(codegen): support for api key auth trait

* chore: update to new codegen decorator interface

* chore: include basic test

* chore: set api key into rest xml extras model

* chore: update test

* chore: refactor api key definition map

* feat(codegen): add api key decorator by default

* chore: add smithy-http-auth to runtime type

* chore: reference new smithy-http-auth crate

* Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Revert "chore: set api key into rest xml extras model"

This reverts commit 93b99c8703.

* chore: moved api key re-export to extras customization

* chore: include test for auth in query and header

* chore: fix linting

* Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/ApiKeyAuthDecorator.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ApiKeyAuthDecoratorTest.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* Update codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/ApiKeyAuthDecoratorTest.kt

Co-authored-by: John DiSanti <johndisanti@gmail.com>

* chore: add doc hidden to re-export

* chore: ensure extras are added only if it applies

* Revert "chore: add doc hidden to re-export"

This reverts commit 8a49e2b47b.

---------

Co-authored-by: Eduardo Rodrigues <eduardomourar@users.noreply.github.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: John DiSanti <johndisanti@gmail.com>
2023-02-16 01:15:40 +00:00
david-perez f9fb9e69d7
Fix recursive constraint violations with paths over list and map shapes (#2371)
* Fix recursive constraint violations with paths over list and map shapes

There is a widespread assumption throughout the generation of constraint
violations that does not hold true all the time, namely, that a
recursive constraint violation graph has the same requirements with
regards to boxing as the regular shape graph.

Some types corresponding to recursive shapes are boxed to introduce
indirection and thus not generate an infinitely recursive type. The
algorithm however does not superfluously introduce boxes when the cycle
goes through a list shape or a map shape. Why list shapes and map
shapes? List shapes and map shapes get rendered in Rust as `Vec<T>` and
`HashMap<K, V>`, respectively, they're the only Smithy shapes that
"organically" introduce indirection (via a pointer to the heap) in the
recursive path. For other recursive paths, we thus have to introduce the
indirection artificially ourselves using `Box`. This is done in the
`RecursiveShapeBoxer` model transform.

However, the constraint violation graph needs to box types in recursive
paths more often. Since we don't collect constraint violations
(yet, see #2040), the constraint violation graph never holds
`Vec<T>`s or `HashMap<K, V>`s, only simple types. Indeed, the following simple
recursive model:

```smithy
union Recursive {
    list: List
}

@length(min: 69)
list List {
    member: Recursive
}
```

has a cycle that goes through a list shape, so no shapes in it need
boxing in the regular shape graph. However, the constraint violation
graph is infinitely recursive if we don't introduce boxing somewhere:

```rust
pub mod model {
    pub mod list {
        pub enum ConstraintViolation {
            Length(usize),
            Member(
                usize,
                crate::model::recursive::ConstraintViolation,
            ),
        }
    }

    pub mod recursive {
        pub enum ConstraintViolation {
            List(crate::model::list::ConstraintViolation),
        }
    }
}
```

This commit fixes things by making the `RecursiveShapeBoxer` model
transform configurable so that the "cycles through lists and maps
introduce indirection" assumption can be lifted. This allows a server
model transform, `RecursiveConstraintViolationBoxer`, to tag member
shapes along recursive paths with a new trait,
`ConstraintViolationRustBoxTrait`, that the constraint violation type
generation then utilizes to ensure that no infinitely recursive
constraint violation types get generated.

For example, for the above model, the generated Rust code would now look
like:

```rust
pub mod model {
    pub mod list {
        pub enum ConstraintViolation {
            Length(usize),
            Member(
                usize,
                std::boxed::Box(crate::model::recursive::ConstraintViolation),
            ),
        }
    }

    pub mod recursive {
        pub enum ConstraintViolation {
            List(crate::model::list::ConstraintViolation),
        }
    }
}
```

Likewise, places where constraint violations are handled (like where
unconstrained types are converted to constrained types) have been
updated to account for the scenario where they now are or need to be
boxed.

Parametrized tests have been added to exhaustively test combinations of
models exercising recursive paths going through (sparse and non-sparse)
list and map shapes, as well as union and structure shapes
(`RecursiveConstraintViolationsTest`). These tests even assert that the
specific member shapes along the cycles are tagged as expected
(`RecursiveConstraintViolationBoxerTest`).

* Address comments
2023-02-15 22:09:37 +00:00
John DiSanti 6cade905f1
Move symbol extension functions into `SymbolExt` (#2378) 2023-02-15 21:36:09 +00:00
Eduardo de Moura Rodrigues 1d1e68aeba
feat(smithy-http-auth): add api key auth types (#2153)
* feat(aws-types): add api key to configuration

* chore: set package version to 0.52.0

* feat(aws-smithy-types): create auth types

* chore: use auth from smithy types

* chore: fix return self type

* chore: create http auth definition type

* chore: add constructor for http auth definition

* chore: ensure properties are not moved

* chore: create convenience constructors

* chore: add some todo comments

* feat: move query writer to aws-smithy-http crate

* chore(codegen): expose smithy http tower dependency

* chore: remove setters for auth definition

* chore: fix logical error for scheme not allowed

* chore: add constructor for basic and digest auth

* chore: allow equality comparision for api key

* Revert "chore: set package version to 0.52.0"

This reverts commit da660fcf16.

* chore: fix additional references to querywriter

* chore: implement from string for api key struct

* chore: disallow none api key in sdk config

* chore: fix formatting

* chore: add unit tests for auth types

* chore: add auth api key to external types

* chore: make query writer doc hidden

* feat: create aws-smithy-http-auth crate

* chore: use zeroing for auth api key

* chore: use builder pattern for auth definition

* chore: restructure http auth package

* chore: define default lint warning

* chore: include http auth in runtime common list

* chore: define setter for optional scheme

* chore: should panic while building auth definition

* chore: return missing required field error

* chore: make few code simplications for api key

* Revert "chore: add auth api key to external types"

This reverts commit b2318b0230.

* chore: revert api key from sdk config

* chore: panic on missing required field

* Opt out of `clippy::derive_partial_eq_without_eq`

---------

Co-authored-by: Eduardo Rodrigues <eduardomourar@users.noreply.github.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-02-13 23:07:06 +00:00
Harry Barber 9ecd7f0a30
Fix consistent service naming and add test coverage (#2349)
* Make service name casing consistent

* Add naming-obstacle-course-casing.smithy

* Add missing import

* Relax obstacle course even further

* Better TODO

* Add CHANGELOG.next.toml
2023-02-13 18:25:56 +00:00
david-perez e63f3ee693
Simplify `simple.smithy` (#2339)
`simple.smithy` is currently not that simple. Besides, it serves no
effective purpose: everything that the model exercises is already
exercised in a clearer and more orderly manner in other integration
tests.

This PR makes the model minimal, so that it recovers its purpose as a
simple smoke test. Contributors can also use the model as a scratchpad
for features or bugfixs they're working on.
2023-02-13 11:41:43 +00:00
John DiSanti d48878ee01
Implement request ID access for SDK clients RFC (#2129)
* Add `RequestId` trait
* Implement `RequestId` for generated AWS client errors
* Move `RustWriter.implBlock` out of `StructureGenerator`
* Create structure/builder customization hooks
* Customize `_request_id` into AWS outputs
* Set request ID on outputs
* Refactor SDK service decorators
* Refactor S3's extended request ID implementation
* Combine `Error` and `ErrorKind`
* Add test for service error conversion
* Move error generators into `codegen-client` and fix tests
* Re-export `ErrorMetadata`
* Add request IDs to trace logs
* Simplify some error trait handling
* Rename `ClientContextParamDecorator` to `ClientContextConfigCustomization`
* Add deprecated alias to guide customers through upgrading
* Rename the `ErrorMetadata` trait to `ProvideErrorMetadata`
* Rename `aws_smithy_types::Error` to `ErrorMetadata`
2023-02-10 17:36:48 -08:00
John DiSanti cdc710ddd1
Make modules in `codegen-core` configurable (#2336)
* Refactor modules to be configurable in `codegen-core`
* Remove panicking default test symbol provider
* Remove as many references to Error/Types as possible
* Rename module constants
2023-02-10 22:21:16 +00:00
Nugine de186678ee
Bump Rust MSRV to 1.63.0 (#2222)
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
2023-02-10 12:59:31 -08:00
Burak e84ef6c7e2
Python: Type-stub generation for SSDKs (#2149)
* Initial Python stub generation

* Handle default values correctly

* Only generate `__init__` for classes that have constructor signatures

* Preserve doc comments

* Make context class generic

* Put type hint into a string to fix runtime error

* Run `mypy` on CI

* Use `make` to build Python SSDKs while generating diffs

* Escape Python types in Rust comments

* Only mark class methods with

* Sort imports to minimize diffs

* Add type annotations for `PySocket`

* Dont extend classes from `object` as every class already implicitly extended from `object`

* Use `vars` instead of `inspect.getmembers` to skip inherited members of a class

* Fix linting issues

* Add some tests for stubgen and refactor it

* Add type annotations to `PyMiddlewareException`

* Fix tests on Python 3.7

Python 3.7 doesn't support reading signatures from `__text_signature__`
for non-builtin functions (i.e. C/Rust functions). For testing we're using
regular Python syntax for defining signature.

* Provide default values for `typing.Optional[T]` types in type-stubs

* Update `is_fn_like` to cover more cases

* Remove `tools/smithy-rs-tool-common/`

* Make `DECORATORS` an array instead of a list

* Ignore missing type stub errors for `aiohttp`
2023-02-10 14:00:53 +00:00
John DiSanti 086d9654a4
Refactor client/server logic out of `EnumGenerator` (#2334)
* Refactor client/server enum generation logic into new `EnumType`
* Move client enum logic into `codegen-client`
2023-02-09 12:10:31 -08:00
david-perez a3075ea527
Move converters from constraint violations into `ValidationException` to decorators (#2302)
This allows "easily" converting to other custom validation exception
shapes by implementing a decorator.

As a simple example, this PR adds a
`CustomValidationExceptionWithReasonDecorator` decorator that is able to
convert into a shape that is very similar to
`smithy.framework#ValidationException`, but that has an additional
`reason` field. The decorator can be enabled via the newly added
`experimentalCustomValidationExceptionWithReasonPleaseDoNotUse` codegen
config flag.

This effectively provides a way for users to use custom validation
exceptions without having to wait for the full implementation of #2053,
provided they're interested enough to write a decorator in a JVM
language. This mechanism is _experimental_ and will be removed once full
support for custom validation exceptions as described in #2053 lands,
hence why the configuration key is strongly worded in this respect.

This commit also ports the mechanism to run codegen integration tests
within Kotlin unit tests for client SDKs to the server. See #1956 for
details. The custom validation exception decorator is tested this way.
2023-02-08 22:14:31 +00:00
david-perez 0226446121
Rename Rust server codegen plugins (#2306)
Rename `RustCodegenServerPlugin` to `RustServerCodegenPlugin`, for
consistency with `RustClientCodegenPlugin`. This is a better name, since
the plugin is named `rust-server-codegen`.

This commit also renames `PythonCodegenServerPlugin` to
`RustServerCodegenPythonPlugin` for the same reasons.

This commit also contains other drive-by improvements made while working
on #2302.
2023-02-06 18:16:43 +00:00
Russell Cohen c9275fbf60
Prevent test dependencies from leaking into production (#2264)
* Prevent test dependencies from leaking into production

* refactor & fix tests

* fix tests take two

* fix more tests

* Fix missed called to mergeDependencyFeatures

* Add test

* fix glacier compilation

* fix more tests

* fix one more test
2023-02-06 10:12:17 -05:00
david-perez 7bf92516d5
Remove usage of always empty writable in `JsonParserGenerator` (#2192)
The writable calculates a string that it never writes.

This was added in #2131.
2023-02-03 19:53:08 +00:00
John DiSanti afa9edbe97
Simplify `AdHocSection` (#2272)
Co-authored-by: Russell Cohen <rcoh@amazon.com>
2023-02-02 22:35:09 +00:00
82marbag cfd1627f27
Must set a member in unions (#2241)
* Must set a member in unions

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-02-02 04:23:04 +00:00
david-perez 52cb0fc8e8
Add support for `@uniqueItems` (#2232)
This commit adds support for the `@uniqueItems` trait on `list` shapes
in server SDKs. Requests with duplicate values for `list` shapes
constrained with `@uniqueItems` will be rejected by servers.
2023-02-01 12:43:12 +00:00
Russell Cohen 41ca31b85b
Add CI action to test aws-sdk-services (#2251)
* run cargo test --all-features instead

* Add check-only option, change check to test

* Support nested APIs in operation input tests
2023-01-25 15:55:05 -05:00
82marbag 48ce90d3a3
Dense lists cannot deserialize null (#2240)
* Dense lists cannot deserialize null

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-01-23 23:16:16 +00:00
82marbag 2f4bc33718
Dense maps cannot deserialize null values (#2239)
* Dense maps cannot deserialize null values

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-01-23 18:29:02 +00:00
Zelda Hessler a559048ad8
formatting: run pre-commit on all files (#2236)
* formatting: run pre-commit on all files

* fix: test broken by string indent
2023-01-20 16:02:26 +00:00
82marbag c05e904d53
AwsJson1.0 `@streaming` unique in payload (#2230)
* AwsJson1.0 `@streaming` unique in payload

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-01-20 08:03:32 +00:00
david-perez adf30a8eee
Derive `Eq` and `Hash` wherever possible (#2223)
In server SDKs, these traits can be implemented by any shape _except_ if
the shape's closure contains:

1. A `float`, `double`, or `document` shape: floating point types in
   Rust do not implement `Eq`. Similarly, [`document` shapes] may
   contain arbitrary JSON-like data containing floating point values.
2. A [@streaming] shape: all the streaming data would need to be
   buffered first to compare it.

Additionally, the `Hash` trait cannot be implemented by shapes whose
closure contains:

1. A `map` shape: we render `map` shapes as `std::collections::HashMap`,
   which _do not_ implement `Hash`. See
   https://github.com/awslabs/smithy/issues/1567.

In **client SDKs, these traits cannot be derived on any code-generated
Rust types corresponding to Smithy shapes**, since e.g. adding new
optional members to a structure [is a backwards-compatible change], and
doing so alters the semantics of these traits.

However, this commit does implement these traits for the
`aws_smithy_types::date_time::DateTime` and `aws_smithy_types::Blob`
runtime types.

This change is necessary to efficiently implement the `@uniqueItems`
constraint trait in server SDKs.

[`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
[`Hash`]: https://doc.rust-lang.org/std/hash/trait.Hash.html
[`document` shapes]: https://smithy.io/2.0/spec/simple-types.html#document
[@streaming]: https://smithy.io/2.0/spec/streaming.html
[is a backwards-compatible change]: https://smithy.io/2.0/guides/evolving-models.html#updating-structures
2023-01-19 13:25:00 +01:00
Russell Cohen 95dc365db9
Endpoint operation input tests (#2204)
* Add support for operationInput tests

* More unfication, fix tests, docs

* Set endpoint_url only when endpoint_url is used

* Fix test-util feature

* CR feedback

* fix missing path
2023-01-18 14:12:48 -05:00
david-perez 8013166c9b
Don't use `#[allow(unused)]` in generated code (#2211)
Most usages are in the server constrained types generators, where
`#[allow(dead_code)]` suffices and makes the intent clearer.

See https://stackoverflow.com/a/64556868
2023-01-18 14:00:17 +00:00
david-perez 9f905179cd
Support `@sparse` constrained map shapes and list shapes (#2213)
Turns out we've never supported them, neither directly constrained nor
with constrained members, because of a lack of tests. Yet another data
point to prioritize working on code-generating `constraints.smithy` (see
https://github.com/awslabs/smithy-rs/issues/2101).

The implementation is simple: we just need to call the symbol provider
on the member symbols instead of on the target symbols so we get
`Option<T>` list members / map values if applicable, and handle the
wrapper when converting between unconstrained and constrained types with
help from `match` and `Option<T>::map`.
2023-01-17 14:58:42 +00:00