Write API Documentation (OpenAPI / Swagger)
Generate OpenAPI 3.0 spec or human-readable API docs from your endpoint descriptions or code.
The Prompt
Generate API documentation for the following endpoints. Output as:
1. OpenAPI 3.0 YAML specification
2. Human-readable summary table (endpoint, method, description, auth required)
3. Example request and response for each endpoint
4. Error response reference
Endpoints to document:
[LIST YOUR ENDPOINTS — e.g.:
GET /api/users — returns paginated list of users
POST /api/users — creates a new user, requires {email, password, name}
DELETE /api/users/:id — soft-deletes a user, requires admin role]
Authentication: [JWT Bearer / API Key / OAuth2 — specify]
Base URL: [YOUR API BASE URL]Example Output
Generated a complete OpenAPI 3.0 spec with components/schemas for User, PaginatedResponse, and ErrorResponse, security scheme definitions for JWT Bearer auth, and working curl examples for each endpoint including error scenarios.
FAQ
Which AI model is best for Write API Documentation (OpenAPI / Swagger)?
GPT-4o or Claude Sonnet 4 for OpenAPI specs. Claude tends to produce more thorough examples.
How do I use the Write API Documentation (OpenAPI / Swagger) prompt?
Copy the prompt, replace the [BRACKETED] placeholders with your specific information, and paste into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.). Generated a complete OpenAPI 3.0 spec with components/schemas for User, PaginatedResponse, and ErrorResponse, security scheme definitions for JWT Bearer auth, and working curl examples for each endpoint including error scenarios.
Model Recommendation
GPT-4o or Claude Sonnet 4 for OpenAPI specs. Claude tends to produce more thorough examples.