Generate OpenAPI Specification
- Find all routes:
grep -rn "router\.\|app\." src/ --include="*.ts" | grep -E "\.(get|post|put|patch|delete)\(" | head -40
- For each route, extract:
- HTTP method and path
- Path parameters (
:id,:slug) - Query parameters (from validation schema)
- Request body schema (from Zod/TypeScript types)
- Response schema
- Auth requirement
- Generate
openapi.yaml:
openapi: 3.0.3
info:
title: API Name
version: 1.0.0
paths:
/users:
get:
summary: List users
security:
- bearerAuth: []
parameters:
- name: page
in: query
schema: { type: integer, default: 1 }
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/UserList'
- Add
components/schemasfor all reusable types.
- Add security schemes (bearerAuth, apiKey, etc.)
- Save to
openapi.yamlordocs/openapi.yaml.
Tip: This file can be used with Swagger UI, Postman, or client SDK generators.