enzonotario / vitepress-openapi

Generate VitePress API Docs from OpenAPI specifications
https://vitepress-openapi.vercel.app
MIT License
36 stars 8 forks source link

servers url path elements are not respected by the component #7

Closed addshore closed 1 month ago

addshore commented 1 month ago

In my open API spec, I have the following defined, however the /v2 part of the URL is not respected by the component and is missing in renderings

  "servers": [
    {
      "url": "https://api.domain/v2"
    }
  ],

image

enzonotario commented 1 month ago

It's by design, since the URLs could be really long. I will add a setting for toggle this, but also consider that you can extend it by Custom Slots (as you can see in https://dolarapi.com/docs/argentina/operations/get-dolares.html - https://raw.githubusercontent.com/enzonotario/esjs-dolar-api/main/docs/argentina/operations/get-dolares.md).

addshore commented 1 month ago

It's by design

Hmm, but I guess it doesnt matter too much how long the URL is, ultimately at least 1 server url is required to make the code examples meaningful and accurate?

I guess I could also put the /v2/ in the paths within the oapi spec, however per the spec of server object in oapi, I shouldnt do this, and should leave the /v2 in the servers url

enzonotario commented 1 month ago

I mean, it by design removes the Base Url, since it's supposed to have the Base Url mentioned before, like in:

But yes, sometimes we also need to just show the Full Url (as I did in DolarApi.com). So, you could remove the /v2 part of your Base Url, and add it as prefix for every Path; or extend it via Custom Slots (like in DolarApi.com); or make a PR for allows to change it via Settings (with useTheme composable); or wait for me to add this Setting

addshore commented 1 month ago

Aaah right, im less concerened about the top bit (in red) and more concerned about the bit i circled in yellow!

I agree, having the red bit shorter makes sense, and having it just be the path makes sense.

However I think the rendered full url in examples / try it code needs to be correct

image

enzonotario commented 1 month ago

Ahh ok, that's definitely an Issue, will fix that. Thanks!

addshore commented 1 month ago

I actually noticed another interesting thing here today.

With multiple refreshes, by v2 appears to come and go as it pleases, even while the underlying spec and all code is staying the same!

https://github.com/user-attachments/assets/0b092187-6e4c-423d-a57c-2fd9091c5a9c

enzonotario commented 1 month ago

There was some strange reactivity issue, but also a wrong creation of URL, fixed now.