@dilligentech/swagger-ui-cdn
v1.0.5
Published
Lightweight Swagger UI library using CDN for microservices
Maintainers
Readme
@dilligentech/swagger-ui-cdn
Lightweight Swagger UI library using CDN for microservices.
Features
- 🚀 Lightweight - No bundled assets, uses CDN
- ⚡ Fast - Minimal setup, quick loading
- 🎯 Simple - Just pass your swagger.json path
- 🔧 Flexible - Configurable endpoints
Installation
npm install @dilligentech/swagger-ui-cdnUsage
const express = require('express');
const { setupSwagger } = require('@dilligentech/swagger-ui-cdn');
const router = express.Router();
// Setup Swagger UI
setupSwagger(router, './path/to/swagger.json', '/api-docs');
// Your API will be available at:
// http://localhost:3000/api-docs - Swagger UI
// http://localhost:3000/api-docs/swagger.json - Raw JSONAPI
setupSwagger(router, swaggerJsonPath, [path])
- router - Express router instance
- swaggerJsonPath - Path to your swagger.json file
- path - (Optional) Base path for Swagger UI (default: '/api-docs')
Example
const express = require('express');
const { setupSwagger } = require('@dilligentech/swagger-ui-cdn');
const app = express();
const router = express.Router();
// Setup Swagger
setupSwagger(router, './swagger/swagger.json', '/docs');
app.use('/', router);
app.listen(3000);
// Access at: http://localhost:3000/docs