More Premium Hugo Themes Premium Nextjs Themes

Next Swagger Doc

This package reads your JSDoc-annotated source code on NextJS API route and generates an OpenAPI (Swagger) specification.

Next Swagger Doc

This package reads your JSDoc-annotated source code on NextJS API route and generates an OpenAPI (Swagger) specification.

Author Avatar Theme by jellydn
Github Stars Github Stars: 499
Last Commit Last Commit: Apr 23, 2025 -
First Commit Created: Aug 27, 2024 -
default image

Overview:

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.

Features:

  • Generate Swagger JSON API: Automatically generate Swagger documentation based on JSDoc-annotated source code in NextJS API routes.
  • Built-in Swagger UI: Provides a user-friendly interface for viewing and interacting with the generated Swagger documentation.
  • Support for Multiple Libraries: Compatible with various validation libraries such as Zod, Yup, Fastest-Validator, and Joi for enhanced functionality.
  • CLI Support: Allows for generating Swagger files from the command line interface.
  • Customizable Swagger Comments: Add Swagger comments to API routes for detailed metadata inclusion in the Swagger spec.

Installation:

To install next-swagger-doc with your Next.js project, follow these steps:

  1. Create a Swagger Spec:

    npx create-next-app@13
    
  2. Create Swagger UI Component:

    npm install swagger-ui-react
    
  3. Create API Documentation Page:

    touch app/api-doc/page.tsx
    
  4. Add Swagger Comment to API Route:

    // Example Swagger Comment
    
  5. Navigate to localhost:3000/api-doc to view the Swagger UI.

Summary:

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.