You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatically map app/api/**/route.ts files to endpoints
Detect supported HTTP methods (GET, POST, etc.) from exports
Infer request/response types and generate static API schema (OpenAPI/Swagger-compatible)
Non-Goals
Introduce runtime decorators or strict typing enforcement
Replace validation libraries like Zod or Yup
Lock users into OpenAPI specifically (should support similar formats too)
Background
With the new App Router and file-based API design, Next.js makes it easier than ever to build fullstack apps. However, there’s no native or community-supported way to generate even basic static API documentation.
While frameworks like NestJS or FastAPI provide OpenAPI generation out of the box, Next.js developers must manually maintain API docs or use external schemas. But much of the structure is already available: file path = route, exported function = method, and TypeScript types = schema.
Proposal
Introduce an optional static CLI or plugin (npx next-api-docs) that scans the app/api folder, collects exported methods, follows TypeScript types, and outputs a JSON/YAML spec consumable by Swagger UI or similar tools.
Would support OpenAPI but remain agnostic to specific standards.
Happy to contribute or collaborate on an initial proof of concept!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
With the new App Router and file-based API design, Next.js makes it easier than ever to build fullstack apps. However, there’s no native or community-supported way to generate even basic static API documentation.
While frameworks like NestJS or FastAPI provide OpenAPI generation out of the box, Next.js developers must manually maintain API docs or use external schemas. But much of the structure is already available: file path = route, exported function = method, and TypeScript types = schema.
Proposal
Introduce an optional static CLI or plugin (npx next-api-docs) that scans the app/api folder, collects exported methods, follows TypeScript types, and outputs a JSON/YAML spec consumable by Swagger UI or similar tools.
Would support OpenAPI but remain agnostic to specific standards.
Happy to contribute or collaborate on an initial proof of concept!
Beta Was this translation helpful? Give feedback.
All reactions