DEV Community

Alex Spinov
Alex Spinov

Posted on

Swagger Has a Free API Documentation Tool — Generate Docs from Your Code

Swagger UI generates interactive API documentation from OpenAPI specs. Test endpoints directly in the browser. Free, open-source, industry standard.

Why API Docs Matter

Your API without documentation is a black box. Developers guess at endpoints, parameters, and response shapes. Support tickets pile up.

Swagger/OpenAPI: your code generates the documentation. Documentation is always in sync.

What You Get for Free

Swagger UI — interactive web page where developers can:

  • Browse all endpoints
  • See request/response schemas
  • Try endpoints with real data
  • Copy cURL commands
  • View authentication requirements

Swagger Editor — write OpenAPI specs with real-time preview
Swagger Codegen — generate client SDKs in 40+ languages from your spec
OpenAPI spec — the industry standard for describing REST APIs

Quick Start (Node.js + Express)

npm i swagger-ui-express swagger-jsdoc
Enter fullscreen mode Exit fullscreen mode
import swaggerUi from 'swagger-ui-express';
import swaggerJsdoc from 'swagger-jsdoc';

const spec = swaggerJsdoc({
  definition: {
    openapi: '3.0.0',
    info: { title: 'My API', version: '1.0.0' },
  },
  apis: ['./routes/*.ts'], // files with JSDoc comments
});

app.use('/docs', swaggerUi.serve, swaggerUi.setup(spec));
Enter fullscreen mode Exit fullscreen mode

Add JSDoc to your routes:

/**
 * @openapi
 * /users/{id}:
 *   get:
 *     summary: Get user by ID
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema: { type: string }
 *     responses:
 *       200:
 *         description: User found
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 id: { type: string }
 *                 name: { type: string }
 */
app.get('/users/:id', getUser);
Enter fullscreen mode Exit fullscreen mode

Visit /docs — interactive API documentation, auto-generated.

Framework Integration

Most modern frameworks generate OpenAPI automatically:

  • Fastify@fastify/swagger from route schemas
  • NestJS@nestjs/swagger from decorators
  • Elysia@elysiajs/swagger from TypeBox schemas
  • FastAPI (Python) — built-in, from type hints

If you have an API without docs — Swagger setup takes 10 minutes and saves hundreds of support hours.


Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.

Custom solution? Email spinov001@gmail.com — quote in 2 hours.

Top comments (0)