Skip to content

anusthan12/Swagger-Autogen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swagger-Autogen

Swagger Implementation in Full-Stack Project (Node.js)

Node.js Swagger JWT

Overview

This repository demonstrates the integration of Swagger for API documentation in a full-stack Node.js project. Swagger enables automatic API documentation generation and provides an intuitive interface for testing APIs, including support for JWT authentication.

Features

  • Automatic API Documentation — Uses swagger-autogen to generate documentation from project structure and code comments
  • JWT Authentication Support — Enhanced middleware for JWT token handling in API documentation
  • Dynamic Configuration — Host and port configuration via environment variables
  • Interactive Swagger UI — Graphical interface at /api-docs for API exploration and testing

Folder Structure

├── swagger.js           # Documentation generation
├── swaggerEnhancer.js   # JWT token handling middleware
└── app.js               # Main server entry point

Installation & Usage

npm i swagger-autogen   # Install
node swagger.js         # Generate Swagger documentation
npm start               # Start the server

Access Swagger UI at http://localhost:8080/api-docs

Files Explanation

File Purpose
swagger.js Configures API title, description, host, schemes, security, and scans routes to generate Swagger JSON
swaggerEnhancer.js Adds Authorization parameter to docs, enables secured API testing, manages JWT token handling
app.js Express server configuration, middleware integration, and Swagger UI setup with generated JSON

Benefits

  • Improved Collaboration — Clear documentation for all team members
  • Efficient Testing — Browser-based API testing interface
  • Automated Documentation — Reduces manual effort and maintains consistency
  • Security Integration — JWT authentication testing without exposing credentials

Implementation Steps

  1. Run node swagger.js to generate documentation
  2. Start server and navigate to /api-docs
  3. Use Swagger UI to explore endpoints and include JWT tokens for secured routes

Author

Built and maintained by Anusthan Singh · © 2025

Releases

No releases published

Packages

 
 
 

Contributors