smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.7k stars 201 forks source link

HTTP binding traits mistakenly allowed in RPC protocols #2326

Open david-perez opened 2 weeks ago

david-perez commented 2 weeks ago

In RPC protocols like AWS JSON and RPC v2 CBOR, HTTP binding traits are currently allowed. For example, this model builds fine:

@rpcv2Cbor
service RpcV2Service {
    operations: [
        SimpleStructOperation,
    ]
}

// `@http` trait has no effect
@http(uri: "/simple-struct-operation", method: "POST")
operation SimpleStructOperation {
    input: SimpleStruct
    output: SimpleStruct
}

I think Smithy should disallow these traits if in all the protocols the service supports they are meaningless.

JordonPhillips commented 1 week ago

Services can have multiple protocols, each of which may or may not respect certain traits, so we can't reasonably fail a build in those cases.

david-perez commented 1 week ago

I know, but can't we fail the build/emit a warning in the case where in all the protocols the service supports the traits are meaningless, like in the example I provided?

mtdowling commented 1 week ago

I think that would be confusing for cases where a shared definition of an operation is used by an RPC based service. The shared operation definition (e.g., TagResource) might define HTTP bindings in order to make it just work if the service uses HTTP bindings, and services that don't would ignore the bindings.