swt-documentation is a modern, user-friendly API documentation generator, inspired by Swagger. It allows developers to quickly set up beautiful, interactive documentation for their APIs with minimal configuration. Perfect for teams who want a clean, easy-to-use interface for their endpoints.
- Easy to set up using a CLI
- Dynamic rendering of API endpoints, requests, and responses
- Supports success and error responses
- Sidebar navigation with category filtering
- Searchable API categories and requests
- Optional Authorization display
- Fully responsive and mobile-friendly design
- Smooth scrolling to selected API sections
- Internal locked CSS and JS (users can edit
global.css
andendpoints.json
)
Install via npm:
npm install swt-documentation
npx swt-docs
This will create a documentation
folder in your project containing:
global.css
→ editable CSS for customizing stylesendpoints.json
→ editable file for your API endpoints
#!/usr/bin/env node
import express from "express";
import { serveDocs } from "swt-documentation";
const app = express();
// Serve documentation at /docs
serveDocs(app, "/docs");
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Documentation available at http://localhost:${PORT}/docs`);
});
serveDocs(app, "/docs")
serves the documentation at the route/docs
. You can change the route if needed.
This is where you define your API endpoints. Example:
{
"meta": {
"title": "Documentation By SWT",
"header": "Backend API Documentation By SWT",
"description": "AI-native, beautiful API documentation made easy."
},
"endpoints": [
{
"category": "Auth",
"title": "Login",
"path": "/auth/login",
"method": "POST",
"summary": "Login user",
"requestBody": "{ email, password }",
"authorization": false,
"responseSuccess": "{ \"status\": \"success\", \"token\": \"jwt_token_here\" }",
"responseError": [
{ "status": "error", "message": "Invalid email" },
{ "status": "error", "message": "Password is required" }
]
},
{
"category": "User",
"title": "Get Profile",
"path": "/user/profile",
"method": "GET",
"summary": "Get user profile",
"requestBody": "-",
"authorization": true,
"responseSuccess": "{ \"id\": 1, \"name\": \"John Doe\", \"email\": \"john@example.com\" }",
"responseError": [
{ "status": "error", "message": "User not found" }
]
}
]
}
Update this file to reflect your API endpoints.
Edit the global.css
file in the documentation
folder to change styles, colors, or fonts.
Start your Node.js app and open in a browser:
http://localhost:5000/docs
- Sidebar shows categories (filterable)
- Search API requests by title
- Click an endpoint to see details: request, response, and optional authorization
- Popup modal for code examples in Node.js, jQuery, Fetch, XMLHttpRequest, Python, etc.
Each endpoint has a Code button that opens a modal. Users can select from multiple languages:
- Node.js (Axios)
- jQuery AJAX
- JavaScript Fetch
- XMLHttpRequest
- Python (requests)
The popup automatically renders the corresponding code snippet for the selected language.
- Added popup code examples for multiple languages
- Refactored
serveDocs
to fix static file issues - Improved sidebar search for categories and endpoints
- Initial release supporting CLI and
serveDocs
integration
Here’s what your documentation will look like once set up: