This package reads your JSDoc-annotated source code on NextJS API route and generates an OpenAPI (Swagger) specification.
Next-swagger-doc is a tool designed to generate Swagger JSON API documentation from NextJS API routes. It simplifies the process of creating and organizing API documentation by reading JSDoc-annotated source code and converting it into an OpenAPI (Swagger) specification. By incorporating next-swagger-doc into your Next.js project, you can easily create a Swagger UI for viewing and interacting with your API documentation.
To install next-swagger-doc with your Next.js project, follow these steps:
Create a Swagger Spec:
npx create-next-app@13
Create Swagger UI Component:
npm install swagger-ui-react
Create API Documentation Page:
touch app/api-doc/page.tsx
Add Swagger Comment to API Route:
// Example Swagger Comment
Navigate to localhost:3000/api-doc to view the Swagger UI.
Next-swagger-doc simplifies the process of creating Swagger API documentation for NextJS projects by automatically generating a Swagger specification from JSDoc-annotated source code in API routes. With its built-in Swagger UI support and compatibility with various validation libraries, next-swagger-doc offers a convenient solution for organizing and visualizing API documentation. The tool’s CLI support and customizable Swagger comments further enhance its usability and flexibility for developers.