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

Allow matching a path variable with a different name: `@httpLabel("foo") bar: String` #2286

Open jjant opened 1 month ago

jjant commented 1 month ago

Hi, I would like the httpLabel to allow matching a path variable with a different name than the input structure field name:

$version: "2"
namespace smithy.example

@readonly
@http(method: "GET", uri: "/{foo}")
operation GetStatus {
    input: GetStatusInput
    output: GetStatusOutput
}

@input
structure GetStatusInput {
    @required
    @httpLabel("foo") // <- New!
    bar: String
}

The reason for this is because we had some paths defined as /{badName} and we wanted the new operations to use /{goodName} (i.e, we want the input structures to have a field named goodName, we don't care about the path variable name).

However, after attempting this (with a Lambda + API Gateway integration), we run into an error like this:

Errors found during import: Unable to create resource at path '/{goodName}/b': A sibling ({badName}) of this resource already has a variable path part -- only one is allowed