smithy-rs/codegen-client-test
Russell Cohen 23cdff1d8f
Allow 'null' variants in unions (#3481)
## Motivation and Context
- https://github.com/awslabs/aws-sdk-rust/issues/1095

## Description
Update the JSON parser generator to allow for `null` to be set in
unions. Servers can send unions like this:
```json
{
  "AmazonElasticsearchParameters": null,
  "AmazonOpenSearchParameters": null,
  "AppFlowParameters": null,
  "AthenaParameters": null,
  "AuroraParameters": null,
  "AuroraPostgreSqlParameters": null,
  "AwsIotAnalyticsParameters": null,
  "BigQueryParameters": null,
  "DatabricksParameters": null,
  "Db2Parameters": null,
  "DenodoParameters": null,
  "DocumentDBParameters": null,
  "DremioParameters": null,
  "ExasolParameters": null,
  "GoogleAnalyticsParameters": null,
  "JiraParameters": null,
  "MariaDbParameters": null,
  "MongoAtlasParameters": null,
  "MongoDBParameters": null,
  "MySqlParameters": null,
  "OracleParameters": null,
  "PostgreSqlParameters": null,
  "PrestoParameters": null,
  "RdsParameters": null,
  "RedshiftParameters": null,
  "S3Parameters": {
    "IsUploaded": false,
    "ManifestFileLocation": {
      "Bucket": "deided-bucket.prod.us-east-1",
      "Key": "sales/manifest.json"
    },
    "RoleArn": null
  },
  "SalesforceParameters": null,
  "SapHanaParameters": null,
  "ServiceNowParameters": null,
  "SnowflakeParameters": null,
  "SparkParameters": null,
  "SqlServerParameters": null,
  "StarburstParameters": null,
  "TeradataParameters": null,
  "TrinoParameters": null,
  "TwitterParameters": null
}
```

This caused our parser to fail.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
- [x] New unit test
- [x] Dry run against new [smithy protocol
test](https://github.com/smithy-lang/smithy/pull/2180)

## 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._
2024-03-15 22:36:42 +00:00
..
model Upgrade Smithy to 1.45 (#3470) 2024-03-08 13:16:02 -08:00
.gitignore Establish the `codegen-core` module (#1697) 2022-09-07 09:31:46 -07:00
README.md Break up `RustCodegenDecorator` (#2099) 2022-12-14 13:26:55 -08:00
build.gradle.kts Allow 'null' variants in unions (#3481) 2024-03-15 22:36:42 +00:00

README.md

Codegen Integration Tests

This module defines integration tests of the code generation machinery. ./build.gradle.kts will generate a smithy-build.json file as part of the build. The rust-client-codegen Smithy build plugin then invokes our codegen machinery and generates Rust crates, one for each of the integration test services defined under model/.

Usage

These commands are all meant to be run from the repository root.

To run all protocol tests of all the integration test services:

./gradlew codegen-client-test:build

To run only a subset of the integration test services (refer to ./build.gradle.kts for a full list):

./gradlew codegen-client-test:build -P modules='simple,rest_json'

The Gradle task will run cargo check, cargo test, cargo docs and cargo clippy by default on all the generated Rust crates. You can also specify a subset of these commands. For instance, if you're working on documentation and want to check that the crates also compile, you can run:

./gradlew codegen-client-test:build -P cargoCommands='check,docs'

For fast development iteration cycles on protocol tests, we recommend you write a codegen unit test with a minimal service definition and only run that unit test. Alternatively, you can write a minimal integration test service definition in model/simple.smithy and run:

./gradlew codegen-client-test:build -P cargoCommands='test' -P modules='simple'