@scalar/nextjs-openapi
v0.0.27
Published
Automatically generate an OpenAPI schema from a Nextjs API
Downloads
598
Readme
[PRE-ALPHA] Scalar Next.js API Reference Handler
This plugin automatically generates an OpenAPI schema file based on a Next.js API.
Installation
npm install @scalar/nextjs-openapi
Usage
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()