enzonotario / vitepress-openapi

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

(Custom Slots usage) Allow using custom components in operations #89

Closed ashercoren closed 1 month ago

ashercoren commented 1 month ago

What would you like?

Vitepress has the ability to define custom components which can later on be used across the documentation.

It would be nice if we could use such custom components in the generated api operations.

Why is this needed?

No response

How could it be implemented?

No response

Other information

No response

enzonotario commented 1 month ago

Hi @ashercoren! I don't understand at all what you specifically mean.

  1. If you want to declare an CustomTryButton for example, and that the project uses it instead of the own library OATryButton, it may be possible, maybe just re-declaring Vue Components, but you will have to implement it as expected (just change html/css). I'd avoid this.

  2. If you want to include some custom Vue components inside the rendered OpenAPI Spec. In this case, you can do this by using Custom Slots. You can even replace entire sections and implement them by yourself.

For example: https://stackblitz.com/edit/enzonotario-vitepress-openapi-starter-hrwwfe?file=docs%2Foperations%2F%5BoperationId%5D.md

These slots are not documented yet, you can see available slots in OAPath component. PRs are welcome!

Also, you can use any Markdown/Vue component before/after rendering the OpenAPI (via OAOperation or OASpec), as you can see in ArgentinaDatos. This page includes a Part File that contains Markdown and Vue components

ashercoren commented 1 month ago

Thanks @enzonotario. I'll look into the idea of using slots.

enzonotario commented 1 month ago

Nice! I'll close this issue. Feel free to re-open if needed, or to open other Issues.

Thanks!