Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Document and try your endpoints with OpenAPI and Swagger UI.
API Docs with Swagger is easiest to learn by reading the example, changing it, and observing the result.
// npm install swagger-ui-express
import express from 'express';
import swaggerUi from 'swagger-ui-express';
const openApi = {
openapi: '3.0.0',
info: { title: 'Lessons API', version: '1.0.0' },
paths: { '/api/lessons': { get: { responses: { '200': { description: 'OK' } } } } }
};
const app = express();
app.use('/docs', swaggerUi.serve, swaggerUi.setup(openApi));
app.listen(3000);Practice the API Docs with Swagger example in a small scratch file, then explain what changed and why.