ResponseField
Document API response fields and parameters
Basic ResponseField
Document a simple field:
Unique identifier for the user
<ResponseField field_name="user_id" type="string">
Unique identifier for the user
</ResponseField>
Required Fields
Mark fields as required:
User's email address (must be unique)
<ResponseField field_name="email" type="string" required={true}>
User's email address (must be unique)
</ResponseField>
Fields with Default Values
Show default values:
User's role in the system
<ResponseField field_name="role" type="string" default="user">
User's role in the system
</ResponseField>
Deprecated Fields
Mark deprecated fields:
Old identifier format (use user_id instead)
<ResponseField field_name="legacy_id" type="number" deprecated={true}>
Old identifier format (use `user_id` instead)
</ResponseField>
Complete API Response
Document an entire API response:
User Object
Unique user identifier in UUID format
User's email address (must be unique across all users)
User's full name
User role: user, admin, or moderator
URL to the user's profile image (optional)
ISO 8601 timestamp of when the user was created
ISO 8601 timestamp of last update
Whether the user's email has been verified
<ResponseField field_name="id" type="string" required={true}>
Unique user identifier in UUID format
</ResponseField>
<ResponseField field_name="email" type="string" required={true}>
User's email address (must be unique across all users)
</ResponseField>
<ResponseField field_name="name" type="string" required={true}>
User's full name
</ResponseField>
<ResponseField field_name="role" type="string" default="user">
User role: `user`, `admin`, or `moderator`
</ResponseField>
Request Parameters
Document API request parameters:
Create User Request
User's email address (must be valid and unique)
Password (minimum 8 characters, must include uppercase, lowercase, and number)
User's full name (2-100 characters)
User role (defaults to user if not specified)
Optional metadata object with custom key-value pairs
Complex Types
Document nested objects and arrays:
Order Response
Unique order identifier
Array of order items. Each item contains:
product_id(string): Product identifierquantity(number): Number of itemsprice(number): Price per item
Total order amount in cents
Shipping address object with:
street(string): Street addresscity(string): City namestate(string): State/province codezip(string): Postal codecountry(string): Country code (ISO 3166-1 alpha-2)
Order status: pending, processing, shipped, delivered, or cancelled
Data Types
Common data types to use:
Primitives
stringnumberbooleannull
Complex
objectarrayany
Specific
UUIDISO8601URLEmail
Available Options
The name of the field or parameter
Data type (e.g., "string", "number", "boolean", "object", "array")
Whether the field is required
Default value if not provided
Whether the field is deprecated
Best Practices
Be specific with types
Be specific with types
Use specific types when possible:
Instead of
string, useUUID,Email,URL, orISO8601Instead of
number, specifyintegerorfloatFor enums, list the possible values
Include validation details
Include validation details
Document validation rules in the description:
Minimum/maximum lengths
Format requirements
Allowed values
Pattern constraints
Group related fields
Group related fields
Use headings to group related fields:
### User Fields
<ResponseField ...>
### Metadata Fields
<ResponseField ...>
Document nested structures
Document nested structures
For complex objects, either:
Describe nested fields inline in the description
Create a separate section with its own ResponseFields
Link to a detailed schema definition
Common Patterns
Pagination Response
Array of result objects
Current page number (1-indexed)
Number of items per page
Total number of items across all pages
Total number of pages
Whether there is a next page available
Whether there is a previous page available
Error Response
Error object containing details about the failure
Machine-readable error code (e.g., INVALID_INPUT, NOT_FOUND)
Human-readable error message
Array of detailed error objects for validation failures
Unique request identifier for debugging
ResponseField components are perfect for API documentation. Combine them with code examples showing actual request/response JSON.