P
🤖AutomatisationIntermediate4 steps

Automatic REST API Documentation Generator Agent

This agent analyzes your source code or API specifications to automatically generate complete and structured technical documentation. It produces endpoint descriptions, data schemas, request/response examples, and documented error handling. The result is ready to integrate into a developer portal or export in OpenAPI format.

documentation techniqueAPI RESTcode cleanautomatisationdéveloppement backend

For who

Backend developers, tech leads, and DevOps teams looking to quickly document their REST APIs without manually writing each endpoint.

Input

Type: text
Format: code source

Code source de l'API (fichiers de routes, contrôleurs, modèles, middleware) ou spécification partielle des endpoints à documenter. Formats acceptés : JavaScript/TypeScript (Express, NestJS), Python (FastAPI, Django), PHP (Laravel), Java (Spring Boot), ou toute description textuelle des endpoints.

steps (4)

1

Source Code Analysis and Endpoint Extraction

prompt

Scans source code to identify and inventory all API endpoints and their characteristics.

2

Description and Data Schema Generation

prompt

Generates detailed descriptions and data schemas for each endpoint.

3

Request and Response Example Creation

prompt

Creates realistic copy-paste ready usage examples for each endpoint.

4

Final Documentation Compilation

prompt

Assembles all elements into polished documentation ready for publication.

Output

Type: text
Format: structuré

Documentation API complète incluant : description de chaque endpoint, schémas JSON Schema des requêtes et réponses, exemples cURL et multi-langages, gestion des erreurs, guide d'authentification et modèles de données. Format Markdown ou OpenAPI selon le choix utilisateur.

Example

Input

// routes/users.js (Express)
router.get('/api/v1/users', authMiddleware, async (req, res) => {
  const { page = 1, limit = 20, role } = req.query;
  const users = await User.find(role ? { role } : {}).skip((page-1)*limit).limit(limit);
  const total = await User.countDocuments(role ? { role } : {});
  res.json({ data: users, pagination: { page, limit, total } });
});

router.post('/api/v1/users', authMiddleware, adminOnly, async (req, res) => {
  const { email, name, role } = req.body;
  if (!email || !name) return res.status(400).json({ error: 'Email and name required' });
  const user = await User.create({ email, name, role: role || 'user' });
  res.status(201).json({ data: user });
});

Output

## Users

### GET /api/v1/users
**Lists users** with pagination and optional role filtering.
- Auth: Bearer token required
- Query params: page (number, default: 1), limit (number, default: 20), role (string, optional)
- Response 200: { data: User[], pagination: { page, limit, total } }

```curl
curl -H 'Authorization: Bearer eyJhb...' 'https://api.example.com/api/v1/users?page=1&limit=20&role=admin'
```

### POST /api/v1/users
**Creates a new user.** Restricted to administrators.
- Auth: Bearer token required + admin role
- Body: { email (string, required), name (string, required), role (string, default: 'user') }
- Response 201: { data: User }
- Error 400: { error: 'Email and name required' }

Customization

ParameterDescriptionDefault
format_sortieFormat du document de documentation final généré par l'agentMarkdown
langLangue de rédaction de la documentation (français, anglais, etc.)français
lang_sdkLangage pour les exemples de code SDK côté clientJavaScript (fetch)

Technical Notes

<p>This agent works optimally with structured source code using popular frameworks (Express, NestJS, FastAPI, Django REST, Spring Boot, Laravel). For less common frameworks, provide comments or annotations in the code to improve endpoint detection.</p><p>The Markdown output format can be converted to OpenAPI 3.0 YAML by adding this instruction in the step 4 prompt. For very large APIs (50+ endpoints), it is recommended to split the code by module and run the agent multiple times, then merge the results.</p><p>Generated examples use realistic fictional data. Always verify validation constraints and error codes against your actual implementation before publishing the documentation.</p>