A worked example, rendered from real sample data. Sign in to run the tool on your own input.
// List every user
app.get('/api/users', (req, res) => {
const limit = req.query.limit;
const cursor = req.query.cursor;
res.status(200).json(page(limit, cursor));
});
// Create a user
app.post('/api/users', requireAuth, (req, res) => {
const { name, email } = req.body;
if (!email) return res.status(422).json({ error: 'email required' });
res.status(201).json(create(name, email));
});
// Fetch one user
app.get('/api/users/:id', (req, res) => {
res.status(200).json(find(req.params.id));
});═══ What this tool did ═══
ℹ Every endpoint below was read out of the code you pasted. This page runs offline and makes no outbound network calls. — no server was called and no route was guessed.
Frameworks recognised: Express / Koa / Fastify
Endpoints found: 3
ℹ Query and body parameters are collected from the lines between one route and the next, so a handler defined far from its route registration may report fewer parameters than it takes.
═══ Methods ═══
GET: 2
POST: 1
═══ Endpoints ═══
─── GET /api/users ───
• List every user
Source: line 2 (Express / Koa / Fastify)
Query params: limit, cursor
Status codes in the handler: 200
─── POST /api/users ───
• Create a user
Source: line 9 (Express / Koa / Fastify)
Body fields: name, email
Status codes in the handler: 201, 422
✓ a handler-level auth guard appears in this route's scope
─── GET /api/users/{id} ───
• Fetch one user
Source: line 16 (Express / Koa / Fastify)
Path params: id
Status codes in the handler: 200
═══ Gaps worth closing ═══
ℹ No server URL is emitted, because the code does not state one. Pass a base URL in the options if you want a servers block.
═══ Next steps ═══
• Switch the output format to OpenAPI to get a spec you can paste into Swagger UI or Redoc.
npx @redocly/cli lint openapi.json
npx openapi-typescript openapi.json -o src/api-types.ts
npx @hey-api/openapi-ts -i openapi.json -o src/client
Extract routes, path/query params, body fields and status codes from pasted Express, NestJS, Flask, Spring, Gin or Rails code into OpenAPI or Markdown. Part of the DevTools Surf developer suite. Browse more tools in the API / Config collection.