Skip to content

Inspect URL object with openapi-fetch #1953

Closed
@musjj

Description

@musjj

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestopenapi-fetchRelevant to the openapi-fetch library

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions