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

Inspect URL object with openapi-fetch #1953

Open
1 task
musjj opened this issue Oct 20, 2024 · 0 comments
Open
1 task

Inspect URL object with openapi-fetch #1953

musjj opened this issue Oct 20, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request openapi-fetch Relevant to the openapi-fetch library

Comments

@musjj
Copy link

musjj commented Oct 20, 2024

Description

Sometimes it can be useful to inspect the constructed URL object from openapi-fetch. For example, when you want to create an <a> element that links to a GET route.

In Hono, you can inspect an API url like this:

let url = client.api.posts.$url()
console.log(url.pathname) // `/api/posts`

url = client.api.posts[':id'].$url({
  param: {
    id: '123',
  },
})
console.log(url.pathname) // `/api/posts/123`

Proposal

It would be nice if you can do this with openapi-fetch. Maybe the syntax can look like:

client.URL("/blogposts/{post_id}", {
  params: { post_id: "my-post" },
  query: { version: 2 },
});

Checklist

@musjj musjj added enhancement New feature or request openapi-fetch Relevant to the openapi-fetch library labels Oct 20, 2024
@drwpow drwpow self-assigned this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request openapi-fetch Relevant to the openapi-fetch library
Projects
Status: No status
Development

No branches or pull requests

2 participants