smithy-rs
smithy-rs copied to clipboard
Abort server SDK generation when multiple protocols are specified
Until server-side multi-protocol support lands (see https://github.com/awslabs/smithy-rs/issues/2979), we should abort code generation when we encounter a model where the service
shape is annotated with multiple protocol traits.
$version: "2"
namespace smithy.example
use aws.protocols#restJson1
use aws.protocols#awsJson1_1
@restJson1
@awsJson1_1
service MyService {
version: "2023-09-12"
}
We currently pick the first protocol and ignore the rest. This can lead to user confusion, as they might reasonably expect that if code generation succeeds, the server SDK can honor what they modeled.
One possibility to implement this could be to add a software.amazon.smithy.model.validation.Validator
that only gets loaded when generating servers (see https://github.com/awslabs/smithy-rs/pull/2752 for an example), which I think is preferable, as the error will surface in Smithy's consistent report format. Another is to simply throw a CodegenException
in ServerProtocolLoader
.