An open API service indexing awesome lists of open source software.

https://github.com/phaethix/api-doc-generator

AI-powered API documentation generator β€” describe your API in plain English, get OpenAPI specs + beautiful docs. Built with Deno + React.
https://github.com/phaethix/api-doc-generator

ai api-documentation deno llm openapi react swagger typescript

Last synced: 1 day ago
JSON representation

AI-powered API documentation generator β€” describe your API in plain English, get OpenAPI specs + beautiful docs. Built with Deno + React.

Awesome Lists containing this project

README

          

# 🧠 API Doc Generator β€” AI-Powered API Documentation

**Describe your API in plain English. Get beautiful docs in seconds.**

From natural language, OpenAPI specs, or custom definitions β†’ Markdown / HTML / JSON β€” all running locally, no data ever leaves your server.

[![Deno](https://img.shields.io/badge/Deno-2.x-000000?style=flat&logo=deno)](https://deno.land)
[![React](https://img.shields.io/badge/React-18-61DAFB?style=flat&logo=react)](https://react.dev)
[![TypeScript](https://img.shields.io/badge/TypeScript-Strict-3178C6?style=flat&logo=typescript)](https://www.typescriptlang.org)
[![AI](https://img.shields.io/badge/AI-LLM_Structured_Output-8B5CF6?style=flat)](https://platform.openai.com/docs/guides/structured-outputs)
[![License](https://img.shields.io/badge/License-MIT-green?style=flat)](LICENSE)

[δΈ­ζ–‡ζ–‡ζ‘£](docs/README.zh-CN.md)

---

## Why this tool?

Most API doc tools force you to **already have** an OpenAPI spec. You either write it by hand (tedious) or use heavy GUI editors (slow, vendor lock-in). This tool is different:

```mermaid
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#F1F5F9', 'primaryTextColor': '#1E293B', 'primaryBorderColor': '#CBD5E0', 'lineColor': '#94A3B8', 'secondaryColor': '#FFFFFF', 'tertiaryColor': '#F8FAFC'}}}%%
flowchart LR
subgraph Inputs["Input Sources"]
direction TB
NL["πŸ’¬ Natural Language"]
OA["πŸ“‹ OpenAPI 3.0"]
CS["✏️ Custom JSON"]
end

subgraph Pipeline["Unified Pipeline"]
P[Parser] --> G[Generator] --> R[Renderer]
end

subgraph Outputs["Output Formats"]
direction TB
MD["πŸ“„ Markdown"]
HTML["🌐 HTML"]
JSON["πŸ“¦ JSON"]
end

NL --> P
OA --> P
CS --> P
R --> MD
R --> HTML
R --> JSON

style Inputs fill:#F8FAFC,stroke:#CBD5E0,stroke-width:1px,color:#1E293B
style Pipeline fill:#FFFFFF,stroke:#E2E8F0,stroke-width:1px,color:#1E293B
style Outputs fill:#F8FAFC,stroke:#CBD5E0,stroke-width:1px,color:#1E293B
classDef nodeIn fill:#F1F5F9,stroke:#64748B,color:#1E293B,stroke-width:1px
classDef nodePipe fill:#E2E8F0,stroke:#94A3B8,color:#1E293B,stroke-width:1px
classDef nodeOut fill:#F1F5F9,stroke:#64748B,color:#1E293B,stroke-width:1px
class NL,OA,CS nodeIn
class P,G,R nodePipe
class MD,HTML,JSON nodeOut
```

**Three input paths, one pipeline, zero vendor lock-in.** Pick whichever works for you.

### How we compare

| | API Doc Generator | Swagger UI | Redoc | Postman | Stoplight |
|---|---|---|---|---|---|
| **Natural language β†’ docs** | βœ… AI-powered | ❌ | ❌ | ⚠️ AI Agent (cloud) | ❌ |
| **Custom spec format** | βœ… simple JSON | ❌ | ❌ | ❌ | ❌ |
| **Import OpenAPI 3.0** | βœ… | βœ… | βœ… | βœ… | βœ… |
| **Output Markdown** | βœ… | ❌ | ❌ | ❌ | ❌ |
| **Output HTML** | βœ… stylish single-page | βœ… interactive | βœ… beautiful | ⚠️ published portal | βœ… interactive |
| **Output JSON** | βœ… | ❌ | ❌ | ❌ | ❌ |
| **Streaming AI generation** | βœ… SSE | ❌ | ❌ | ❌ | ❌ |
| **Self-hosted** | βœ… docker-compose up | βœ… | βœ… | ⚠️ SaaS, local MCP | ⚠️ Enterprise only |
| **Open source** | βœ… MIT | βœ… Apache 2.0 | βœ… MIT | ❌ | ❌ |
| **Lightweight** | βœ… ~7k LOC | βœ… | βœ… | ❌ | ❌ |

> **Notes:**
> - **Swagger UI** is the open-source renderer. SmartBear (its parent company) launched AI-powered spec generation in 2025, but that's a separate cloud product (SwaggerHub), not Swagger UI itself.
> - **Postman** added Agent Mode (AI) for doc generation, but it consumes AI credits and runs on Postman's cloud. The MCP server is open-source for local bridging, but the core platform is proprietary SaaS.
> - **Redoc** renders Markdown *within* OpenAPI descriptions but does not output standalone `.md` files.
> - **Stoplight** is proprietary SaaS. Self-hosted Git integration requires Enterprise plan (custom pricing).

### ✨ Features

- **🧠 AI-powered generation** β€” Describe your API in plain English, get a valid OpenAPI 3.0 spec. Uses JSON Schema structured output to guarantee correctness, with automatic fallback and local validation.
- **πŸ“‹ OpenAPI import** β€” Already have an OpenAPI spec? Paste it in and get instant docs.
- **✏️ Custom spec format** β€” A lightweight JSON format for when you don't need the full OpenAPI complexity.
- **πŸ“„ Multi-format output** β€” Generate clean Markdown, stylish standalone HTML, or machine-readable JSON.
- **⚑ Streaming AI** β€” Watch the AI generate your API spec in real-time via SSE, with live character count and elapsed time.
- **πŸŒ™ Dark mode** β€” Full light/dark theme support across the entire UI.
- **🐳 One-command deploy** β€” `docker-compose up --build` and you're running.
- **πŸ”’ Data never leaves your server** β€” All processing is local. No cloud, no telemetry, no vendor lock-in.
- **πŸ—οΈ Clean architecture** β€” Deno backend + React frontend + standalone GenAI module. Each layer independently testable.
- **βœ… Production-ready CI** β€” GitHub Actions with fmt β†’ lint β†’ type-check β†’ test β†’ build on every PR.

### πŸ–ΌοΈ Preview





Standard Mode β€” paste a spec, get docs




AI Mode β€” describe in plain English, watch it generate

### πŸ—οΈ Architecture

```mermaid
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#F1F5F9', 'primaryTextColor': '#1E293B', 'primaryBorderColor': '#CBD5E0', 'lineColor': '#94A3B8', 'secondaryColor': '#FFFFFF', 'tertiaryColor': '#F8FAFC'}}}%%
flowchart LR
subgraph FE["React SPA"]
Editor[JsonEditor]
Output[OutputPanel]
AIPanel[AI Panel]
end

subgraph BE["Deno Backend"]
Route{{URLPattern
Router}}
subgraph Pipeline["Core Pipeline"]
P[Parser] --> G[Generator] --> R[Renderer]
end
Adapter[(OpenAPI
Adapter)]
AIHandler[AI
Handlers]
end

subgraph GenAI["GenAI Module"]
Client[LLMClient]
Provider[ChatCompletions
Provider]
Schema[JSON Schemas]
end

FE -->|POST /generate| Route
FE -->|POST /ai/*| Route
Route --> P
Route -.->|/import/openapi| Adapter
Route -.->|/ai/*| AIHandler
Adapter --> G
AIHandler --> Client
Client --> Provider
Provider -->|LLM API| Ext[External
LLM API]
Schema --> Client
R -.->|Response| FE

style FE fill:#F8FAFC,stroke:#CBD5E0,stroke-width:1px,color:#1E293B
style BE fill:#F8FAFC,stroke:#CBD5E0,stroke-width:1px,color:#1E293B
style GenAI fill:#F8FAFC,stroke:#CBD5E0,stroke-width:1px,color:#1E293B
style Pipeline fill:#FFFFFF,stroke:#E2E8F0,stroke-width:1px,color:#1E293B
classDef nodeFe fill:#F1F5F9,stroke:#64748B,color:#1E293B,stroke-width:1px
classDef nodeBe fill:#334155,stroke:#1E293B,color:#F8FAFC,stroke-width:1px
classDef nodePipe fill:#E2E8F0,stroke:#94A3B8,color:#1E293B,stroke-width:1px
classDef nodeGenAI fill:#E2E8F0,stroke:#94A3B8,color:#1E293B,stroke-width:1px
class Editor,Output,AIPanel nodeFe
class Route,AIHandler nodeBe
class P,G,R nodePipe
class Client,Provider,Schema nodeGenAI
```

### πŸš€ Quick Start

#### Prerequisites

- Deno 2.x
- Node.js 18+

#### One-command setup

```bash
./scripts/dev.sh start # Start both frontend & backend
./scripts/dev.sh status # Check status
./scripts/dev.sh stop # Stop services
./scripts/dev.sh restart # Restart
```

Visit **http://localhost:8080**

#### Manual setup

```bash
# Build frontend
cd frontend && npm install && npm run build && cd ..

# Start backend
cd backend && deno task start
```

### πŸ“– API Usage

#### Generate documentation

```bash
POST /generate?format=markdown|html|json

curl -X POST 'http://localhost:8080/generate?format=markdown' \
-H 'Content-Type: application/json' \
-d '{
"info": { "title": "My API", "version": "1.0.0" },
"paths": {
"/users": {
"get": {
"summary": "List users",
"responses": { "200": { "description": "OK" } }
}
}
}
}'
```

#### Import OpenAPI

```bash
POST /import/openapi?format=markdown
# Send OpenAPI 3.0 JSON directly
```

#### AI: Ping (test LLM connection)

```bash
POST /ai/ping
# β†’ { "ok": true, "reply": "...", "model": "...", "usage": {...} }
```

#### AI: Generate OpenAPI from natural language

```bash
POST /ai/generate-openapi
Content-Type: application/json

{
"description": "User management system with list users and get user by ID",
"scope": "document"
}

# β†’ { "ok": true, "openapi": {...}, "scope": "document", "usage": {...}, "format_used": "json_schema" }
```

#### AI: Streaming generation

```bash
POST /ai/generate-openapi-stream
# Server-Sent Events stream of generation progress
```

#### Health check

```bash
GET /health
# β†’ { "status": "ok", "timestamp": "..." }
```

### πŸ§ͺ Testing

```bash
# Backend tests
cd backend && deno test --allow-net --allow-read --allow-env

# GenAI tests
cd genai && deno test --allow-net --allow-read --allow-env
```

### πŸ“¦ Deployment

#### Docker

```bash
docker-compose up --build

# Or build manually
docker build -t api-doc-generator .
docker run -p 8080:8080 api-doc-generator
```

### πŸ”§ Configuration

| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | 8080 | Server port |
| `HOST` | 0.0.0.0 | Server host |
| `OPENAI_API_KEY` | - | LLM API key (required for AI features) |
| `OPENAI_BASE_URL` | `https://apihub.agnes-ai.com/v1` | LLM API base URL |
| `LLM_MODEL` | `agnes-2.0-flash` | LLM model name |
| `LOG_LEVEL` | `info` | Log level |
| `CORS_ALLOWED_ORIGINS` | `http://localhost:5173,...` | CORS allowed origins |

Copy `config/env.example` to `.env` and modify as needed.

### πŸ—ΊοΈ Roadmap

| Status | Feature |
|--------|---------|
| πŸ“‹ | **Multiple LLM providers** β€” OpenAI, Anthropic, Ollama |
| πŸ“‹ | **Swagger 2.0 import** β€” Support legacy specs |
| πŸ“‹ | **OpenAPI file upload** β€” Upload `.json`/`.yaml` in UI |
| πŸ“‹ | **YAML output** β€” Generate docs in YAML |
| πŸ“‹ | **CLI mode** β€” `npx api-doc-gen spec.json -f markdown` |
| πŸ“‹ | **Custom templates** β€” User-defined output templates (Handlebars) |
| πŸ“‹ | **Postman collection export** β€” Export as Postman collection |

See the full [Roadmap](ROADMAP.md) for details and timelines.

### 🀝 Contributing

Contributions are welcome! Whether it's a bug fix, a new LLM provider, or a documentation improvement β€” we'd love your help.

See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding standards, and the PR process.

Look for issues labeled [`good-first-issue`](https://github.com/phaethix/api-doc-generator/labels/good-first-issue) to get started.

### πŸ“„ License

MIT β€” use it, modify it, ship it.

---


Built with Deno + React + TypeScript Β· AI powered Β· Privacy first