* Add TLS support to Pokemon server
* Add missing copyright header to TLS module
* Handle connection errors
* Move TLS example to own binary
* Update comments according to reviews
* Move rewrite base url middleware to its own function
* Support granular control of specifying runtime crate versions
**BREAKING**: after this PR, `in smity-build.json` the path
`rust-codegen.runtimeConfig.version` no longer exists. Instead, a new
field `versions` comes in. It's an object mapping a runtime crate name
to a version string. There is also a special key `DEFAULT`, which is
presetted as detected runtime version but open to override. Crates
without version specified would be set as the same version as which
associated to key `DEFAULT`.
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
This commit adds the SDK and server groups to smithy-rs runtime crates,
but only the SDK group on `AwsRuntime` and `AwsSdk` crates.
With this change, the `publisher` tool won't fail when publishing the
`aws-smithy-http-server` crate.
XML deserialization of enums is currently broken.
This commit should have been done as part of #1398, but we only tested
that patch using the restJson1 protocol.
The converter from the unknown enum variant error into
`aws_smithy_json::deserialize::Error` has been removed from
`ServerEnumGenerator`, since it's protocol-specific logic. We instead
use `map_err` in the protocol-specific parsers before bubbling up using
`?`.
Fixes#1477.
* Add codegen version to generated package metadata
* Update `CHANGELOG.next.toml`
* Remove unnecessary try-catch block from `smithyCodegenVersion`
* Add git commit hash to version
* Fix version filename
* Add tests for `Version`
* Store version in "$smithyRsVersion\n$gitCommitHash" format
* Make version parsing more strict
This commit fixes two bugs that were present in the server
implementation:
* We were incorrectly referring to the operation input shape name
instead of using the symbol provider in
`ServerOperationHandlerGenerator.kt` and
`ServerOperationRegistryGenerator.kt`.
* We were not escaping Rust reserved keywords in operation names in
`ServerOperationRegistryGenerator.kt`.
The second bug would have been caught had we been generating server
crates for the two naming obstacle course test suites
(`naming-obstacle-course-ops.smithy` and
`naming-obstacle-course-structs.smithy`) that the client is already
passing. This commit adds these suites to the `codegen-server-test`
subproject, and expands `naming-obstacle-course-ops.smithy` to exercise
the logic that was causing the first bug.
* Rename `cargo-api-linter` to `cargo-check-external-types`
* Run `cargo-check-external-types` on Smithy client/shared runtime crates
* Run `cargo-check-external-types` on SDK runtime crates
* Fix bug in determining crate name
* Run `cargo-check-external-types` on generated SDK crates
* Fix `aws:sdk-codegen-test` build
* Add config for SDK endpoint/readme generation
* Rename `sdk-codegen-test` to `sdk-adhoc-test` and update README
* Add `sdk-adhoc-tests` to CI
* Refactor CI scripts
The `check-rust-runtime-and-tools` script was getting beyond 20
minutes to run, so this commit splits it into `check-aws-config`,
`check-rust-runtimes`, and `check-tools`.
This also enables most of the checks to run before the smoke test SDK is
generated, which should deliver more immediate feedback on PRs.
* Give the canary its own CI step
* Upgrade `cargo-api-linter` to the latest Rust nightly
* Upgrade Rust nightly used by CI
* Handle failure to provide error context better
* Fix `aws-config` external type approval list
* Fix error context pathing issue
* Add `MakeFmt` trait which modifies `Display`/`Debug` implementations.
* Add `http` wrappers which modify the `Debug` and `Display` implementations based on closures marking sensitivity. Each wrapper has an associated `MakeFmt` impl.
* Add `InstrumentOperation` [tower::Service](https://docs.rs/tower/latest/tower/trait.Service.html) which logs requests and responses. Accepts a `MakeFmt` for each potentially sensitive component of the request/response.
* Add [ServerHttpSensitivityGenerator.kt](https://github.com/awslabs/smithy-rs/compare/harryb/add-logging?expand=1#diff-a7ad7f28d152bba6f2a63f3bde498582d91c8f7ab9c2de0c7f4494d6fd1c02ff) which generates marker closures from models.
* Apply `InstrumentationOperation` to the `OperationHandler` using `MakeFmt`s using the marker closures.
Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
The current approach that attempts to downcast never worked; all Rust
decorators were being loaded, and the cast was doing nothing, because
the generic type parameter is erased at runtime.
Attempting to downcast a generic class `C<T>` to `C<U>` where `U: T` is
not possible to do in Kotlin (and presumably all JVM-based languages)
_at runtime_. Not even when using reified type parameters of inline
functions. See https://kotlinlang.org/docs/generics.html#type-erasure
for details.
This commit thus goes for another approach, suggested in the linked
Stack Overflow question [0]: add a method to the loaded classes that
signals at runtime the generic type parameter (`ClientCodegenContext` or
`ServerCodegenContext`) they can work with, in order to filter them.
This commit also simplifies the way the Python server project loads the Python
server-specific decorators, by deleting the combined decorator
`PythonServerCodegenDecorator`, which was being loaded from the classpath, and
instead directly using `CombinedCodegenDecorator` and passing it the Python
server-specific decorators in the `extras` parameter.
[0]: https://stackoverflow.com/questions/5451734/loading-generic-service-implementations-via-java-util-serviceloader
When registering the Cargo commands tasks. The `aws:sdk` is the only
Gradle subproject that depends on the Cargo commands tasks, but that
does not register the `modifyMtime` task.
Partially addresses #1596.
The `Content-Type` check of the incoming request in
`ServerHttpBoundProtocolGenerator` is performed by comparing against the
configured protocol directly within the class.
Delegating to the protocol enables the implementation of protocols in
decorators loaded from the classpath in other projects outside
smithy-rs.
This commit makes the `ServerHttpBoundProtocolGenerator`
protocol-agnostic by looking up the expected incoming request
`Content-Type` header from the protocol implementation directly. To this
end, the macro-generated `check_<protocol>_content_type` functions from
the `aws-smithy-http-server` runtime have been replaced with a single
general `check_content_type` function that takes in the expected mime
type.
* Update `generate-matrix` to return SDK release tags instead of versions
* Upgrade the SDK used in the canary runner
* Move `build-bundle` into `canary-runner` to use `versions.toml`
* Make release tag matrix output singular
* Delete old `build-bundle` and update README
* Add canary projects to standard tool CI checks
* Generate `Cargo.toml` before testing `canary-lambda`
* Add helper for creating deprecated attribute
* `Attribute.Custom.deprecated` is the main logic for building up
`#[deprecated]` attribute
* `RustWriter.deprecatedShape` is the counterpart of `documentShape`,
but we do not going to generalize it as what `documentShape` does.
Deprecated is only for Rust code and probably won't be used in other
output language.
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* Test `@deprecated` trait for RustWriter
* Support `@deprecated` trait for StructureGenerator
* Support `@deprecated` trait for UnionGenerator
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* Support `@deprecated` trait for EnumGenerator
* Support `@deprecated` trait for TopLevelErrorGenerator
* Support `@deprecated` trait for CombinedErrorGenerator
* Support `@deprecated` trait for ServerCombinedErrorGenerator
* Support `@deprecated` trait for FluentClient
* Support `@deprecated` trait for BuilderGenerator
* Cleanup leftover in test
* Use `dq()` helper method instead of escaping by hands
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* Leverage Kotlin null safety well
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* Allow `deprecated` rustc lint rule
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* Allow deprecated in unit tests
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* Leverage kotlin null safety check again
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
* changelog: Support @deprecated trait
Signed-off-by: Weihang Lo <whlo@amazon.co.uk>
Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
* Exclude sigv4 test suite from pre-commit file endings hook
* Upgrade Ktlint
* Make Gradle ktlint target consistent with pre-commit
They were previously running two separate rulesets since pre-commit
pulls in the standard ruleset, and that wasn't pulled into the Gradle
dependencies.
* Fix Gradle Ktlint paths
* Establish editorconfig for Ktlint
* Fix Ktlint lints
* Enable `trailing-commas` rule
* Fix block quote indentation
Rust crate names are allowed to contain hyphens, while Rust identifiers
are not [0]. However, the Rust and Python server projects are currently
broken because we use the user-provided crate name verbatim
(`moduleName` in `settings`) in places where Rust expects valid
identifiers:
* The Rust server's generated operation registry Rust docs use the crate
name verbatim in import statements.
* The Python server uses the crate name verbatim to generate a shared
library, but library target names in `Cargo.toml` cannot contain
hyphens.
We never caught this bug because we don't generate any crates with
hyphens in their names.
This commit:
* fixes the above usages of verbatim crate names where identifiers are
expected by calling `toSnakeCase()`,
* modifies the unit test for the server's operation registry generator
to generate a crate with hyphens in its name,
* changes the Pokémon service server SDK crate names from
`pokemon_service_sdk` to `pokemon-service-server-sdk`, so that we
exercise generation of a crate with hyphens in its name, and to better
convey that the generated SDK is server-specific; and
* changes the Pokémon service client SDK crate name from
`pokemon_service_client` to `pokemon-service-client`, and changes the
Pokémon service crate name itself from `pokemon_service` to
`pokemon-service`, for symmetry.
[0]: https://doc.rust-lang.org/reference/identifiers.html