-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aws_smithy_http_server::*
should be re-exported from generated crat…
…es (#3839) Many customers have reported the need to explicitly depend on the `aws-smithy-http-server` crate in their service handler code. When they re-generate the crate, they often encounter version mismatches between the `aws-smithy-http-server` crate used in the generated code and the one they use in their service handler. This version discrepancy leads to compilation errors, requiring them to manually adjust the crate versions, which adds friction to their development workflow. To resolve this issue, we now re-export all relevant types from `aws-smithy-http-server` within the generated crates. By doing so, customers can use these re-exported types directly, eliminating the need to depend on `aws-smithy-http-server` in their handler code. Additionally, the generated crates no longer have the `aws-lambda` feature flag enabled by default. This prevents the `aws-lambda` feature from being automatically enabled in `aws-smithy-http-server` when the SDK is not intended for AWS Lambda. --------- Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
- Loading branch information
Showing
22 changed files
with
187 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
applies_to: ["server"] | ||
authors: ["drganjoo"] | ||
references: [] | ||
breaking: true | ||
new_feature: false | ||
bug_fix: false | ||
--- | ||
The generated crates no longer have the `aws-lambda` feature flag enabled by default. This prevents the [aws-lambda](https://docs.rs/crate/aws-smithy-http-server/0.63.3/features#aws-lambda) feature from being automatically enabled in [aws-smithy-http-server](https://docs.rs/aws-smithy-http-server/0.63.3/aws_smithy_http_server/) when the SDK is not intended for AWS Lambda. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
applies_to: ["server"] | ||
authors: ["drganjoo"] | ||
references: [] | ||
breaking: false | ||
new_feature: true | ||
bug_fix: false | ||
--- | ||
All relevant types from [aws-smithy-http-server](https://docs.rs/aws-smithy-http-server/0.63.3/aws_smithy_http_server/) are now re-exported within the generated crates. This removes the need to explicitly depend on [aws-smithy-http-server](https://docs.rs/aws-smithy-http-server/0.63.3/aws_smithy_http_server/) in service handler code and prevents compilation errors caused by version mismatches. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
.../test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerTypesReExportTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.rust.codegen.server.smithy | ||
|
||
import org.junit.jupiter.api.Test | ||
import software.amazon.smithy.rust.codegen.core.rustlang.Attribute | ||
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate | ||
import software.amazon.smithy.rust.codegen.core.testutil.IntegrationTestParams | ||
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel | ||
import software.amazon.smithy.rust.codegen.core.testutil.testModule | ||
import software.amazon.smithy.rust.codegen.core.testutil.unitTest | ||
import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverIntegrationTest | ||
|
||
class ServerTypesReExportTest { | ||
private val sampleModel = | ||
""" | ||
namespace amazon | ||
use aws.protocols#restJson1 | ||
@restJson1 | ||
service SampleService { | ||
operations: [SampleOperation] | ||
} | ||
@http(uri: "/sample", method: "GET") | ||
operation SampleOperation { | ||
output := {} | ||
} | ||
""".asSmithyModel(smithyVersion = "2") | ||
|
||
@Test | ||
fun `ensure types are exported from aws-smithy-http-server`() { | ||
serverIntegrationTest(sampleModel, IntegrationTestParams(service = "amazon#SampleService")) { _, rustCrate -> | ||
rustCrate.testModule { | ||
fun Set<String>.generateUseStatements(prefix: String) = | ||
this.joinToString(separator = "\n") { | ||
"#[allow(unused_imports)] use $prefix::$it;" | ||
} | ||
|
||
// Ensure all types that were exported before version 0.64 and used | ||
// under the `{generated_sdk_crate_name}::server` namespace remain available. | ||
// Additionally, include all types requested by customers. | ||
unitTest( | ||
"types_exists_in_server_module", | ||
setOf( | ||
"extension::{OperationExtensionExt, OperationExtension}", | ||
"plugin::Scoped", | ||
"routing::{Route, RoutingService}", | ||
"body::boxed", | ||
"shape_id::ShapeId", | ||
"body::BoxBody", | ||
"operation::OperationShape", | ||
"plugin::HttpPlugins", | ||
"plugin::ModelPlugins", | ||
"plugin::HttpMarker", | ||
"plugin::ModelMarker", | ||
"plugin::Plugin", | ||
"plugin::PluginStack", | ||
"request::{self, FromParts}", | ||
"response::IntoResponse", | ||
"routing::IntoMakeService", | ||
"routing::IntoMakeServiceWithConnectInfo", | ||
"routing::Router", | ||
"instrumentation", | ||
"protocol", | ||
"Extension", | ||
"scope", | ||
).generateUseStatements("crate::server"), | ||
) | ||
|
||
unitTest( | ||
"request_id_reexports", | ||
additionalAttributes = listOf(Attribute.featureGate("request-id")), | ||
) { | ||
rustTemplate( | ||
""" | ||
##[allow(unused_imports)] use crate::server::request::request_id::ServerRequestId; | ||
""", | ||
) | ||
} | ||
|
||
unitTest( | ||
"aws_lambda_reexports", | ||
additionalAttributes = listOf(Attribute.featureGate("aws-lambda")), | ||
) { | ||
rustTemplate( | ||
""" | ||
##[allow(unused_imports)] use crate::server::{request::lambda::Context, routing::LambdaHandler}; | ||
""", | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.