This plugin automatically generates an OpenAPI schema file based on a Next.js API.
Installation
1npm 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.
1// app/api/openapi/[[...slug]]/route.ts
2import { OpenAPI } from '@scalar/nextjs-openapi'34export const GET = OpenAPI()