Skip to content

[REQ][ELIXIR] Use Tesla.Middleware.PathParams instead of string interpolation for path parameters #23339

@marcowindt

Description

@marcowindt

Is your feature request related to a problem? Please describe.

The Elixir generator interpolates path parameters directly into the URL string ("/companies/#{company_id}"). This means Tesla.Middleware.PathParams is a no-op even when configured, and middleware that depends on it — like opentelemetry_tesla — can't see the original path template.

In practice, this breaks OpenTelemetry span naming: since opts[:path_params] is never set, all spans fall back to just the HTTP method (GET, POST), making traces useless for distinguishing routes.

Describe the solution you'd like

Use the original OpenAPI path with {param} placeholders and pass parameters via opts[:path_params], so PathParams middleware actually does the substitution.

Example

Before:

|> url("/companies/#{company_id}")

After:

|> url("/companies/{companyId}")
|> add_path_params([{"companyId", company_id}])

Describe alternatives you've considered

Using custom templates via -t, which works but requires maintaining a couple of custom templates.

Happy to submit a PR for this.

Additional context

Only works when used with Tesla.Middleware.PathParams only, so that would be added to connection.ex.mustache.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions