nitro
nitro copied to clipboard
swagger API
expose swagger compatible API from dev server based on handler defenitions.
~~Not a periority~~ (reopened following up https://github.com/unjs/nitro/discussions/170)
Related:
- https://github.com/nuxt/framework/discussions/4582
Quoting from https://github.com/nuxt/framework/discussions/4582:
[..] swagger UI is a great feature for newcomers, product managers and smoke-testing (:
So would really love to see this - with the correct pointers I'd even try myself on it, but am unsure if this is a good first issue.
Is the whole /server/api
of Nuxt 3 mostly handled by nuxt or nitro? ...if nitro only has access to the routes and url arguments but not the return type or similar it would make little sense to implement it inside nitro.
Or generally: Is there any access to the route definitions and types during runtime in either nitro or nuxt? I would think so as nuxt generates .d.ts
file on the fly based on my understanding so far but I might be wrong. If that is the case than that could be used to generate them and potentially expose them on a special endpoint, kinda like FastAPI does.
Is there any more work being done on this? Could it be possible to export a json schema or zod type to reflect what the endpoint is returning in the OpenAPI spec?
Currently it is exposed via experimental flag as /_nitro/openapi.json
. So you can use it already.
It is in our roadmap after introducing route meta support to improve this feature and iterate.
how can you modify the tags?
is there any way to support nested route. Api need to be grouped in most case.
@chenyuncai feel free to open new individual issue for it 👍🏼 (or any other idea related to openapi)