@scalar/nextjs-openapi
v0.3.51
Published
Automatically generate an OpenAPI schema from a Nextjs API
Downloads
3,836
Readme
[PRE-ALPHA] Scalar Next.js API Reference Handler
This plugin automatically generates an OpenAPI schema file based on a Next.js API.
Scalar is an open-source API platform for teams who want beautiful developer interfaces without vendor lock-in.
- API References — Interactive API documentation from OpenAPI and AsyncAPI specs.
- Developer Docs — Write in Markdown/MDX, generate API references, sync with two-way Git.
- SDK Generator — Type-safe SDKs and CLIs in TypeScript, Python, Go, PHP, Java, and Ruby.
- API Client — Open-source, offline-first Postman alternative built on OpenAPI.
20M+ monthly npm installs · 15,500+ GitHub stars · MIT licensed · scalar.com
Installation
npm install @scalar/nextjs-openapiUsage
Currently this plugin is strictly for the app router with typescript. Currently we generate the spec from the Request/Context types as well as the returns in the HTTP method. You can find a simple example in the playground folder.
Also is currently under heavy development, all API's are likely to change. However we are looking for feedback! If you have an open API OR would like to share a private one, let us know so we can test the integration with it.
You just need to drop this file into the app/api/openapi/[[...openapi]] folder. You can rename the openapi folder to whatever you like but the dynamic folder must be catch-all as we will be serving two endpoints.
// app/api/openapi/[[...slug]]/route.ts
import { OpenAPI } from '@scalar/nextjs-openapi'
export const GET = OpenAPI().GET