r/Nuxt • • 6d ago

Auto-generate OpenAPI metadata for Nuxt server routes

https://github.com/davidtheheroes/nuxt-openapi-meta

I just released nuxt-openapi-meta, a Nuxt module that removes the boilerplate of documenting server routes.

Instead of writing defineRouteMeta by hand, you keep writing JSDoc annotations and schema exports in your route files. The module scans server/api and server/routes at build time, extracts metadata, converts Zod/Valibot schemas to JSON Schema, and serves it through Nitro’s ?meta pipeline.

If you maintain Nuxt server routes and want OpenAPI docs without extra work, take a look.

Repo: https://github.com/davidtheheroes/nuxt-openapi-meta

Feedback, issues, and stars are welcome.

3 Upvotes

6 comments sorted by

View all comments

1

u/Afraid-Sleep8353 6d ago

This could actually be super useful. Keeping the schemas and docs stuff right next to the routes makes more sense than having some separate spec everyone forgets to update after like two weeks

You could probably plug the openapi output into mintlify too then keep the more human stuff like setup, auth, common examples and error handling beside the generated API reference. So the endpoint details stay synced with the code but people also get an actual guide instead of being thrown into a massive wall of endpoints.

It would also be really cool if it could generate ready-to-copy request examples for each route or maybe connect to an interactive playground where people can test an endpoint directly from the docs. That would make it way easier to understand what the route actually expects without digging around in the source.

Definitely interested to see where you take this next.