AI generated prompt for REST API Documentation Generator
**Context**:
The goal is to design a REST API documentation generator that can automatically create high-quality, user-friendly documentation for RESTful APIs. This tool should be able to parse API definitions from various sources such as OpenAPI/Swagger files, API code annotations, or even direct API endpoint scanning. The generated documentation should include detailed information about each endpoint, including HTTP methods, request and response formats, parameters, headers, authentication mechanisms, and example requests and responses.
**Detailed Instructions**:
1. Develop a system that can accept API definitions from multiple sources, including but not limited to OpenAPI/Swagger files (JSON or YAML), API code annotations (e.g., Java, Python, Node.js), and direct API endpoint scanning.
2. Implement a parser that can interpret the API definitions and extract relevant information such as endpoint paths, HTTP methods supported (GET, POST, PUT, DELETE, etc.), request body formats (JSON, XML, form data), response formats, query parameters, path parameters, header parameters, and any authentication or authorization requirements.
3. The system should generate documentation that includes:
- Overview of the API, including its purpose and any general usage guidelines.
- Detailed endpoint documentation, including:
- Endpoint path and supported HTTP methods.
- Description of the endpoint's purpose and any usage notes.
- Request body schema (for methods that require a body).
- Query, path, and header parameters with descriptions and data types.
- Response schema, including possible status codes and response body formats.
- Examples of requests and responses, preferably in a format that can be easily copied and used for testing (e.g., curl commands, HTTPie commands).
- Information on authentication and authorization, including how to obtain tokens, required scopes, and how to pass credentials.
4. The generator should support customization options for the output, including the ability to select the output format (e.g., HTML, Markdown, PDF), the level of detail included, and the inclusion of additional information such as code snippets in various programming languages.
5. Ensure the system is scalable and can handle large APIs with numerous endpoints and complex definitions.
**Output Format**:
The output should be in a format that is easily consumable by both human users and machines. This could include:
- HTML documentation that can be hosted online.
- Markdown files for easy integration into GitHub or other version control systems.
- PDF documents for offline reading.
- Optionally, provide a JSON or YAML output that represents the parsed API definition for further processing or integration with other tools.
**Examples**:
For an API with an endpoint defined as follows in OpenAPI 3.0:
```yaml
paths:
/users:
get:
summary: Retrieve a list of users
description: Returns a list of all users in the system
responses:
'200':
description: A JSON array of user objects
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
'500':
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
User:
type: object
properties:
id:
type: integer
name:
type: string
email:
type: string
Error:
type: object
properties:
code:
type: integer
message:
type: string
```
The generated documentation for the `/users` endpoint might include:
- A brief summary and detailed description.
- HTTP method (GET).
- Request headers and query parameters (if any).
- Response status codes with descriptions and schema (200 with an array of User objects, 500 with an Error object).
- Example request (`curl http://example.com/users`) and example response (`[{"id": 1, "name": "John Doe", "email": "john@example.com"}]`).This coding prompt is designed to help you get better results from AI assistants like ChatGPT, Claude, and Gemini. Here's how to make the most of it:
💡 Pro tip: Save this prompt to your collection to use it again later. Well-crafted prompts can save hours of back-and-forth with AI.
Adjust the prompt to match your specific industry, audience, or use case. Adding relevant context improves output quality.
Specify your desired output length (e.g., "in 200 words" or "in 3 bullet points") to get more targeted responses.
Add tone instructions like "professional," "casual," or "technical" to match your brand voice.
Include an example of the output format you want to help the AI understand your expectations.
This prompt has been tested and optimized for all major AI models. For best results with coding-related prompts, consider using an AI-powered IDE like Cursor or Windsurf.
Learn more about using prompts effectively with our comprehensive guides:
0 people found this prompt helpful
Based on 0 reviews
Be the first to share your experience with this prompt!
This prompt was reviewed and verified to work with current AI models.
Tested with ChatGPT, Claude & Gemini. Reviewed by community users.
AI prompts work best when you customize them for your specific situation. Follow these steps to get the most out of REST API Documentation Generator.