Commit Graph

24 Commits

Author SHA1 Message Date
Russell Cohen a107c0154a
Add initial implementation of a Serde Decorator (#3753)
## Motivation and Context
Customers want to be able to use `serde` with Smithy models. For
details, see the
[RFC](https://github.com/smithy-lang/smithy-rs/blob/configurable-serde/design/src/rfcs/rfc0045_configurable_serde.md)

## Description
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
Implementation of `serde::Serialize` for smithy-rs code generators. This
takes the approach of a trait, `SerializeConfigured` which _returns_ a
type that implements `Serialize`. This allows customers to control serde
behavior for their use case.

```rust
/// Trait that allows configuring serialization
/// **This trait should not be implemented directly!** Instead, `impl Serialize for ConfigurableSerdeRef<T>`**
pub trait SerializeConfigured {
    /// Return a `Serialize` implementation for this object that owns the object. This is what you want
    /// If you need to pass something that `impl`s serialize elsewhere.
    fn serialize_owned(self, settings: SerializationSettings) -> impl Serialize;

    /// Return a `Serialize` implementation for this object that borrows from the given object
    fn serialize_ref<'a>(&'a self, settings: &'a SerializationSettings) -> impl Serialize + 'a;
}
```

This can be used as follows:
```rust
serde_json::to_string(&my_struct.serialize_ref(&SerializationSettings::redact_sensitive_fields());
```


Currently, this codegen plugin is not used by anything. It can be
enabled by bringing it in scope during code generation & adding the
`@serde` trait to the model for the fields where serialization is
desired. This will allow the SDK (if they choose to) roll it out only
for specific types or services that have customer demand.

There are a number of follow on items required:
- [x] Ensure the generated impls work for `Server` codegen
- [ ] Generate `Deserialize` implementations
- [x] Test the implementation all Smithy protocol test models (ensure it
compiles)


## Testing
Unit test testing serialization with a kitchen-sink model

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: david-perez <d@vidp.dev>
2024-08-12 16:44:32 +00:00
John DiSanti ae52b69572
Upgrade Smithy Gradle Plugin to 0.9 (#3394)
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-02-07 22:18:49 +00:00
Russell Cohen 2c27834f90
Make required context parameters required (#2964)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
When a `@contextParam` is marked as required, we will enforce it on
inputs. Since these fields may influence endpoint, omitting them can
result in a different target being hit.

- #1668 
- aws-sdk-rust#873

## Description
<!--- Describe your changes in detail -->

## Testing
- [x] S3 Integration test

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-08-31 19:26:07 +00:00
John DiSanti cf8df40f18
Merge `sra-test` into the SDK integration tests and fix its tests (#2883)
This PR merges the benchmark and integration tests from `aws/sra-test`
into the SDK integration tests, and updates the tests so that they
compile and pass.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-07-28 17:09:18 +00:00
Matteo Bigoi 3862ca0a37
Initial implementation of Typescript server bindings (#2277)
* A barely working code generation in typescript

* Extract shared socket into feature inside aws-smithy-http-server

* Building a fully functional application, I think

* Add NAPI build.rs

* Refactor all names to use typescript instead of js

* Add (hopefully) the PR bot for TS

* Clippy fixes

* Fix documentation

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* set_reuse_port in socket not on windows

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add example implementation

* Allow the new application to build

* Remove all occurrences of Python

* Simplify README

* Fix issue with the codegen-diff-revision script

* Try to prevent the ci-lint to bother us with TODO at this stage of development

* Remove codegen-client from typescript dependencies

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Add CODEOWNERS and fix some other linting issues

* Add license

* Prevent from running tests on typescript in Windows

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Initial work to remove error from this PR

* Update to call_async

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* types/node in package.json

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Generate app.ts

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Improve makefile

* Adapting code to the latest changes and removing runtime dependency (for now).

* Removing rust-runtime/aws-smithy-http-server-typescript.

* Making CI happy.

* Restoring ServerCodegenDecorator to be like main.

* Adding back the aws-smithy-http-server-typescript crate back.

* Removing index.js file.

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
Co-authored-by: 82marbag <69267416+82marbag@users.noreply.github.com>
Co-authored-by: Alberto Pose <albepose@amazon.com>
2023-04-06 15:27:17 +00:00
John DiSanti 6b21e46ef1
Orchestrator `ResponseDeserializer` codegen and auth (#2494)
* Convert interceptor fns to macro invocations

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Add unmodeled error to ServiceError and bring in EventLog

Co-authored-by: John DiSanti <jdisanti@amazon.com>

* Simplify and test `EventLog`

* Attempt to integrate the event log with the orchestrator

* fix: error type in integration test
update: retry handling in orchestrator

* update: set the runtime plugins to do nothing instead of panic when called on

* Introduce a construct for type erasure

* Eliminate several generics and add phased error handling

* Code generate the `ResponseDeserializer` trait impls

* CI fixes

* Reorganize the new runtime crates

* Create the `Identity` type

* Reorganize orchestrator traits and accessors

* Set up code generated test environment for the new runtime

* Add initial auth orchestration implementation

* Fix clippy lint

* Incorporate feedback

* Fix external types lint

---------

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-03-27 23:15:36 +00:00
Zelda Hessler 445b7fea1e
fix: use idiomatic method of setting smithy gradle plugin version (#1995) 2022-11-16 21:58:04 +00:00
David Oguns 9260781f45
Add mavenLocal repo to allow for local dependency override (#1852) 2022-10-17 14:03:42 -07:00
John DiSanti 96e9f61fee
Establish the `codegen-core` module (#1697)
* Create the `codegen-core` module
* Move the `Version` class into `codegen-core`
* Rename `codegen` to `codegen-client`
* Rename `codegen-test` to `codegen-client-test`
* Move shared test models to common location
* Fix Smithy validation errors in `misc.smithy`
2022-09-07 09:31:46 -07:00
John DiSanti 6e1d1f6c18
Fix adhoc SDK codegen and refactor SDK CI (#1624)
* 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
2022-08-10 09:08:08 -07:00
Russell Cohen edb1394561
Upgrade to Gradle 7 (#1411)
* Upgrade to Gradle 7

* Document the upgrade and update changelogs
2022-06-23 12:27:43 -04:00
Matteo Bigoi 5881feaf8f
[Server] Implement Gradle subprojects and scaffolding for the Python server. (#1366) 2022-05-18 14:26:29 +00:00
John DiSanti a0539e20b0
Fix `SPDX-License-Identifier` in header comments (#1377)
* Fix misc whitespace with pre-commit

* Revise copyright check in `sdk-lints`

* Fix `SPDX-License-Identifier` in header comments
2022-05-09 09:50:46 -05:00
John DiSanti 27acbc6d30
Upgrade Smithy (#1330)
* Upgrade to Smithy 1.16.2

* Remove extra test fixed in Smithy 1.16.2

* Upgrade to Smithy 1.16.3

* Remove extra test fixed in Smithy 1.16.3

* Remove failing expectation from server tests

* Upgrade to Smithy 1.17.0

* Upgrade to Smithy 1.18.1

* Upgrade to Smithy 1.19.0

* Upgrade to Smithy 1.21.0

* Update changelog

* Fix Gradle repositories
2022-04-21 09:22:35 -04:00
John DiSanti c25c24d0f9
Upgrade Smithy to 1.16.1 (#1053) 2022-01-12 15:35:40 -08:00
Matteo Bigoi ada243be64
[POC] Basic server type serde for RestJson1 (#737)
* Initial implementation of RestJson and Http ser/de

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Visitor render operation shapes from server generators

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Use a symlink for the ebs test model

* Revert "Use a symlink for the ebs test model"

This reverts commit 0c2adcbf12.

* Now the model is emitted in different files

* A little more general model generation

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Use a very simple model to try the service generators

* Move serializer in its own folder

* Initial implementation of RestJson and Http ser/de

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Visitor render operation shapes from server generators

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Use a symlink for the ebs test model

* Revert "Use a symlink for the ebs test model"

This reverts commit 0c2adcbf12.

* Now the model is emitted in different files

* A little more general model generation

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>

* Use a very simple model to try the service generators

* Move serializer in its own folder

* Refactor RestJson to accomodate upstream changes

* Refactor a little RestJson1 and add simple RFC doc

* Remove inheritance from Json ser/de and refactor codegen visitor to
directly use the rendering functions

* Make operation.rs module public

* Use the protocol ID instead of its string representation

Signed-off-by: Bigo <1781140+crisidev@users.noreply.github.com>
2021-10-05 13:05:00 -04:00
Russell Cohen f7ba94c16c
Remove jcenter / bintray from gradle (#651)
* Remove jcenter / bintray from gradle

Our build was referencing the old bintray repositories. This would 403 and make the build much slower as at retried 5 times against the broken URL.

* Update CHANGELOG.md

Co-authored-by: John DiSanti <jdisanti@amazon.com>

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2021-08-16 22:02:04 +00:00
Russell Cohen a9b6e6e1a8
Deserialize Extended S3 Errors (#429)
* Add customization for S3 host ID

* Cleanup and fully replace the s3 protocol

* Only generate the customization for S3

* Fix bugs which caused rustfmt to crash

* Add test

* Back out unused change

* Update aws/sdk/integration-tests/s3/Cargo.toml

* CR feedback, add missing test
2021-05-28 12:55:07 -04:00
Russell Cohen 6b605892c7
Add ApiGateway accept header customization (#287)
* Add ApiGateway accept header customization

* Update Java version in CI to match local

* Fix bug in dependency relative paths

* Add path validation
2021-04-01 17:16:13 +00:00
Russell Cohen 88ca4fedd8
[chore] Move AWS codegeneration into its own folder (#166)
This allows us to deliniate AWS runtime vs. Smithy runtime and will make a future separation easier
2021-01-19 15:23:07 -05:00
Russell Cohen 41891fb690
First cut at SPI / AWS Customizations (#101)
* Add SPI capability to codegen

* Logging improvements

* Wire up aws-sdk-codegen for AWS-specific customizations

* Add AWS SDK codegen sources

* Drop dokka from aws-sdk-codegen
2021-01-04 16:49:04 -05:00
Russell Cohen 883fc05795
Generate an AWS-SDK shaped artifact (#92)
* Generate an AWS-SDK shaped artifact

* Fix gradle dependency tree

* Rename artifact to 'sdk'

* Load SdkId from the service shape
2020-12-30 09:48:51 -05:00
Russell Cohen efdca4484c
Add uuidv4 implementation & rust-runtime as JAR (#55)
* Add uuidv4 implementation & rust-runtime as JAR

* Add inlineable crate

* Flesh out dependency test
2020-11-25 18:49:38 -05:00
Russell Cohen 3ba6fe37e7 Add Kotlin codegen 2020-10-28 11:00:49 -04:00