Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for OperationContextParams #1680

Merged
merged 11 commits into from
Aug 21, 2024

Conversation

sichanyoo
Copy link
Contributor

@sichanyoo sichanyoo commented Aug 15, 2024

Companion PR

Issue #

Description of changes

  • Add support for endpoint parameters that have @operationContextParams trait
  • Update codegen tests

New/existing dependencies impact assessment, if applicable

Conventional Commits

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor Author

@sichanyoo sichanyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments to help reviewers

@@ -154,6 +154,7 @@ func addProtocolTests() {
.init(name: "EventStream", sourcePath: "\(baseDirLocal)/EventStream", buildOnly: true),
.init(name: "RPCEventStream", sourcePath: "\(baseDirLocal)/RPCEventStream", buildOnly: true),
.init(name: "Waiters", sourcePath: "\(baseDirLocal)/Waiters", testPath: "../codegen/protocol-test-codegen-local/Tests"),
.init(name: "StringArrayEndpointParam", sourcePath: "\(baseDirLocal)/StringArrayEndpointParam")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new target for running runtime test that run against generated code

Comment on lines +51 to +53
CodegenTest(
"aws.endpointtests.stringarray#EndpointStringArray",
"StringArrayEndpointParam"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the endpoint string array Smithy model to list of models used by this build script

@@ -0,0 +1,197 @@
$version: "2.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the Smithy model file provided by SEP that has prescribed test cases. Only edits made were putting on @service trait and @restJson1 trait to the service shape, and adding @http traits to each of the operation shape with dummy values. This was done to "plug" this into existing protocol test codegen flow. Building the local protocol test gradle project generates Swift service code for this model, along with the endpoint tests.

@@ -66,7 +66,7 @@ class EndpointTestGenerator(
val value = Value.fromNode(pair.second)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file fixes a bug in endpoint test generator where it was incorrectly & unnecessarily casting array endpoint params to [AnyHashable]. This was never caught before bc we never had test for it & no service has string array endpoint params yet.

@@ -6,26 +6,35 @@
package software.amazon.smithy.aws.swift.codegen.middleware
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file add support for handling the @operationContextParams trait

@@ -30,33 +30,45 @@ public struct EndpointParams {
public let boolBaz: Swift.String?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here on it's just codegen test updates

@sichanyoo sichanyoo merged commit f135974 into main Aug 21, 2024
29 checks passed
@sichanyoo sichanyoo deleted the feat/operation-context-params branch August 21, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants