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

Proposal: glue notation in req_url_path(_append) #443

Open
jonthegeek opened this issue Feb 15, 2024 · 1 comment
Open

Proposal: glue notation in req_url_path(_append) #443

jonthegeek opened this issue Feb 15, 2024 · 1 comment
Labels
feature a feature request or enhancement

Comments

@jonthegeek
Copy link
Contributor

req_template() supports glue syntax, but loses the composability of request() |> req_url_path_append(). But paths are often also documented with glue-like syntax. For example, the apis.guru api has a /{provider}.json path, where provider is a path parameter (and the OpenAPI spec specifically allows such path parameters).

At first I thought this would need a new function, but in theory req_url_path() and req_url_path_append() could treat named arguments as path parameters, making these equivalent:

request("https://api.apis.guru/v2") %>% 
  req_url_path_append("googleapis.com.json")
request("https://api.apis.guru/v2") %>% 
  req_url_path_append("{provider}.json", provider = "googleapis.com")

It looks like only dots_to_path would need to be updated, and the tests look robust enough that it could be done safely, I think. I could probably whip up a PR if this sounds reasonable.

@jennybc
Copy link
Member

jennybc commented Feb 16, 2024

gh has some code related to this, which came in r-lib/gh#121.

@hadley hadley added the feature a feature request or enhancement label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants