Skip to content

Echo uses param struct tag for path params, not path #40

@overthink

Description

@overthink

Hi there, and first: thanks for this cool project! I am looking forward to using it with a large Echo app I have.

One issue I've found is that spec seems to require the struct tag path to indicate a path param in a route. Echo uses the struct tag param for this purpose, not path. I can work around it by adding both path and param struct tags.

e.g. After fixing the issue in #39 you'll note that the /api/vi/users/:id route doesn't actually bind the ID into the request struct. This can be fixed by adding param:"id" to GetUserRequest here. It's kind of annoying to duplicate this info.

Could we make the name of the struct tag used for path params configurable? Something like option.WithPathParamTag("param").

It's possible there are other struct tag mismatches, but I haven't gone deeper than this one yet.

(I hacked a fix locally that adds a path struct tag to any struct that only has param before handing it off to spec generation, but I'm not sure that's a great approach.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions