Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Middleware.PathParams: add OpenAPI params #628

Merged

Commits on Dec 20, 2023

  1. feat: Middleware.PathParams: add OpenAPI params

    Tesla.Middleware.PathParams has been extended to support OpenAPI style
    parameters in addition to the existing Phoenix style parameters.
    
    - Phoenix parameters begin with `:` and a letter (`a-zA-Z`) and continue
      to the next non-word character (not `a-zA-Z0-9_`). Examples include
      `:id`, `:post_id`, `:idPost`.
    
    - OpenAPI parameters are contained in braces (`{}`), must begin with
      a letter (`a-zA-Z`) and may contain word characters and hyphens
      (`-a-zA-Z0-9_`). Examples inlucde `{id}`, `{post_id}`, `{IdPost}`.
    
    Parameter value objects may be provided as maps with atom or string
    keys, keyword lists, or structs. During path resolution, to avoid
    potential atom exhaustion, the parameter value object is transformed to
    a string-keyed map.
    
    Parameter values that are `nil` or that are not present in the value
    object are not replaced; all other values are converted to string (with
    `to_string`) and encoded with `application/x-www-form-urlencoded`
    formatting. If the value does not implement the `String.Chars` protocol,
    it is the caller's responsibility to convert it to a string prior to
    passing it to the Tesla client using this middleware.
    
    Execution time is determined by the number of parameter patterns in the
    path.
    
    Closes: elixir-tesla#566
    halostatue committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    ddb9ec3 View commit details
    Browse the repository at this point in the history