OpenAPI Documentation
Automatic OpenAPI 3.0 specification generation from Zod schemas with interactive Swagger UI documentation.
OpenAPI Documentation
Automatic OpenAPI specs from Zod schemas. Interactive Swagger UI. Zero configuration needed.
On this page
Documentation That Just Works
Generate OpenAPI specs automatically from your Zod schemas.
Interactive Swagger UI included. Zero configuration.
It's This Simple
Enable documentation with one call
typescript
Why OpenAPI Documentation Matters
Without automatic documentation, you're manually writing specs that get out of sync. With MoroJS, your docs are always up to date.
Traditional OpenAPI setup requires manual spec writing and constant updates. We generate it automatically from your code.
Without Auto-Docs
- •Manual spec writing
- •Docs get out of sync
- •No interactive UI
- •Time-consuming maintenance
With MoroJS
- •Automatic spec generation
- •Always in sync with code
- •Interactive Swagger UI
- •Zero maintenance
It's This Easy
Add descriptions and tags to routes. Documentation updates automatically.
Add descriptions and tags
typescript
Why It Makes Sense
Automatic
OpenAPI specs generated automatically from Zod schemas
Interactive
Built-in Swagger UI with Try It Out functionality
Type Safe
Full TypeScript inference from schemas to docs
Standards
OpenAPI 3.0 specification with JSON/YAML export
How It Works
MoroJS automatically generates OpenAPI specifications from your Zod schemas and route definitions. When you define routes with validation, descriptions, and tags, the OpenAPI spec is built automatically. The interactive Swagger UI is available at the configured base path.
Configuration Options
Full Configuration Example
typescript
Automatic Schema Documentation
typescript
Query Parameters Documentation
typescript
Advanced Features
Path Parameters Documentation
typescript
Headers Documentation
typescript
Complex Nested Schemas
typescript
Programmatic Access to OpenAPI Spec
typescript
Complete Example
Full API with Automatic Documentation
typescript
Accessing Documentation
Interactive UI
Swagger UI at /docs
JSON Export
OpenAPI JSON spec
YAML Export
OpenAPI YAML spec
Available Methods
app.getOpenAPISpec()Returns the OpenAPI specification as a JavaScript object
app.getDocsJSON()Returns the OpenAPI specification as a JSON string
app.getDocsYAML()Returns the OpenAPI specification as a YAML string
Installation
OpenAPI documentation requires the swagger-ui-dist package:
Install Dependencies
bash
The swagger-ui-dist dependency is optional and only needed if you want to enable interactive documentation.