In the rapidly evolving landscape of API development, clear and comprehensive documentation serves as the foundation for successful implementation and adoption. One of the most significant challenges developers face is understanding how to structure request bodies for different scenarios. Apidog addresses this challenge through its robust support for multiple request body examples, a feature that aligns perfectly with OpenAPI specifications while enhancing the overall developer experience.
Multiple request body examples provide developers with concrete representations of how API requests should be structured across various business scenarios. Rather than relying on a single generic example, API consumers can now access tailored examples that demonstrate specific use cases, error conditions, or data variations. This capability is particularly valuable when working with complex APIs that handle diverse data structures or when onboarding new team members who need clear guidance on API usage.
The implementation of multiple request body examples in Apidog offers several key advantages:
- Enhanced clarity for API consumers through contextual examples that demonstrate different business scenarios
- Improved testing efficiency by allowing quick switching between predefined request examples during debugging
- Stronger OpenAPI compliance with proper export of example objects following OAS 3.0/3.1 specifications
- Reduced documentation effort through streamlined example management within a single interface
For API providers, this feature eliminates the need to document various request scenarios in separate locations, centralizing all examples within the API documentation itself. This approach not only saves time but also ensures that examples remain synchronized with the API specification as it evolves.
How to Configure Request Body Examples in Apidog for OpenAPI Compatibility
Apidog's implementation of request body examples has been designed with OpenAPI specifications in mind, ensuring that all configured examples can be properly exported and consumed by other tools in the API ecosystem. The configuration process is straightforward yet powerful, allowing for detailed customization of each example.
To begin working with multiple request body examples in Apidog, users must ensure they are using version 2.7.0 or higher. The feature supports configuring examples for request bodies of JSON, XML, Raw, and MsgPack types, covering the most common data formats used in modern API development.
The configuration process follows these steps:
- Navigate to the endpoint documentation that requires multiple request body examples
- Locate the Request Body section within the
Edit
page - Click the "+ Add" button to create a new request body example
- Configure the example details, including:
- Example Name: A descriptive label (defaults to "Example 1", "Example 2", etc. if left blank)
- Example Value: The actual JSON, XML, or other formatted data
- Description: Markdown-supported explanation of the example's purpose or scenario
- OAS Key: The identifier used when exporting to OpenAPI specifications
- OAS Extensions: Custom fields that will be preserved during export
Each of these configuration options plays a specific role in ensuring that examples are both useful for human readers and properly structured for machine consumption through OpenAPI specifications.
The OAS Key deserves special attention as it controls how examples are identified in exported specifications. When provided, this key becomes the field name within the examples object. If left blank, Apidog automatically assigns sequential numbers as identifiers. This flexibility allows for both human-readable example names and compliance with OpenAPI naming conventions.
Similarly, OAS Extensions enable the addition of custom metadata to examples, which can be valuable for tools that consume OpenAPI specifications and need additional context about each example. These extensions are preserved during export, ensuring that no information is lost when sharing specifications with other systems.
Step-by-Step Guide to Adding Multiple Request Body Examples with Apidog
The process of adding and managing multiple request body examples in Apidog follows a logical workflow designed to minimize friction while maximizing flexibility. This step-by-step guide walks through the entire process from creation to usage.
Step 1: Creating Your First Request Body Example
- Open Apidog and navigate to the API project containing the endpoint you wish to enhance
- Select the specific endpoint and click on the "Edit" tab to access the documentation editor
- Scroll to the "Request Body" section where you'll configure your examples
- Click the "+ Add" button to create your first example

5. In the dialog that appears, provide the following information:

- A descriptive name for your example (e.g., "Standard Request")
- The actual example value in the appropriate format (JSON, XML, etc.)
- An optional description explaining the purpose or context of this example
- An optional OAS Key if you need specific naming in exported specifications
- Any custom OAS Extensions as JSON key-value pairs
Step 2: Adding Additional Examples for Different Scenarios
After creating your first example, you can add more examples to cover different business scenarios:
- Click the "+ Add" button again to create another example
- Provide a distinct name that clearly identifies the scenario (e.g., "Error Case")
- Enter the example value representing this specific scenario
- Add a detailed description explaining when this example would be used
- Configure the OAS Key and Extensions as needed
- Repeat this process for all relevant scenarios your API might encounter
Step 3: Organizing and Prioritizing Your Examples
Apidog displays examples according to a specific priority order:
- Examples with names are displayed before unnamed examples
- Examples with OAS Keys are prioritized over those without
- Examples without names or OAS Keys are ordered by their serial numbers
To ensure your most important examples appear prominently:
- Assign clear, descriptive names to critical examples
- Provide OAS Keys for examples that need specific identification in exports
- Review the display order in both the documentation and debugging views
Step 4: Extracting Request Parameters as Examples
Apidog also allows you to create examples from actual debugging sessions:
- Navigate to the "Run" page of your endpoint
- Configure the request body with the values you want to save
- Click the
Extract
button and selectExtract to "Request Example"

5. Choose whether to overwrite an existing example or create a new one
6. The current debugging values will be automatically filled into the example

This feature is particularly valuable during API development when you've found a working request structure that you want to preserve for future reference or documentation.
Leveraging Request Body Examples for Efficient API Testing and Debugging
The true power of multiple request body examples becomes apparent during the testing and debugging phases of API development. Apidog's implementation allows developers to quickly switch between different examples without manually reconfiguring request bodies, significantly accelerating the testing process.
When debugging an endpoint with multiple request body examples:
- Navigate to the "Run" page of the endpoint documentation
- Locate the "Auto-generate" section in the request configuration
- Click the dropdown menu to view all available request body examples
- Select the desired example to automatically populate the request body
- Send the request to test the endpoint with the selected example

This workflow eliminates the need to manually copy and paste different request structures during testing, reducing the potential for errors and saving valuable development time. Developers can rapidly cycle through different scenarios, testing how the API responds to various input combinations without leaving the Apidog interface.
For more advanced testing needs, Apidog provides additional options accessible through the dropdown icon next to "Auto-generate":
- EXAMPLES: Select from predefined request body examples
- Generate Each Time: Automatically generate random values based on mock rules
- Auto-generation Preference: Configure more advanced generation settings
These options provide flexibility for different testing approaches, from deterministic testing with predefined examples to randomized testing with generated values. The ability to switch between these approaches within a single interface streamlines the testing process and encourages more thorough API validation.
Ensuring OpenAPI Compliance with Apidog's Request Body Examples
OpenAPI specifications have become the industry standard for describing RESTful APIs, and Apidog's implementation of multiple request body examples is designed to align perfectly with these specifications. When exporting API documentation from Apidog, request body examples are properly formatted according to OAS 3.0/3.1 guidelines.
The export process follows specific rules to ensure compliance:
- Each example is included in the exported specification under the appropriate content type
- Example names are derived from the OAS Key if provided, or from sequential numbers if not
- Example descriptions are preserved and formatted according to OpenAPI conventions
- Any custom OAS Extensions are included in the exported specification
This alignment with OpenAPI specifications ensures that examples created in Apidog can be consumed by any tool that supports the OpenAPI standard, facilitating interoperability across the API development ecosystem.
To maximize compatibility when exporting:
- Provide meaningful OAS Keys for all examples to ensure clear identification
- Use descriptive example names and detailed Markdown descriptions
- Include relevant OAS Extensions to provide additional context
- Review exported specifications to verify that examples are properly formatted
The exported OpenAPI specification will include all examples in a structure similar to:
"examples": {
"example1": {
"value": {
"name": "Blake Keeling",
"id": "165061",
"email": "Blake.Keeling@gmail.com"
},
"summary": "example1",
"description": "This is example 1"
},
"example2": {
"value": {
"name": "Jolie Kutch",
"id": "138164",
"email": "Jolie_Kutch@hotmail.com"
},
"summary": "example 2",
"description": "This is example 2"
}
}
This structure aligns with the OpenAPI specification for request body examples, ensuring that all information is preserved and properly formatted for consumption by other tools.
Best Practices for Managing Multiple Request Body Examples in Apidog
To maximize the value of multiple request body examples in Apidog, consider the following best practices:
1. Create Examples for Common Scenarios
Develop a comprehensive set of examples covering the most common usage scenarios:
- Standard/Happy Path: The typical successful request structure
- Error Cases: Examples that demonstrate how to trigger specific error responses
- Edge Cases: Examples with minimum/maximum values or special characters
- Different Data Types: Examples showing various data types or formats
2. Use Clear Naming Conventions
Establish consistent naming conventions for examples:
- Use descriptive names that clearly indicate the scenario
- Include the purpose or expected outcome in the name
- Consider prefixing names with categories (e.g., "Success-StandardUser", "Error-InvalidInput")
3. Provide Detailed Descriptions
Enhance examples with thorough descriptions:
- Explain the purpose and context of each example
- Document expected responses for each example
- Use Markdown formatting to improve readability
- Include links to related documentation when appropriate
4. Leverage OAS Keys Effectively
Optimize OAS Keys for clarity in exported specifications:
- Use meaningful, descriptive keys instead of generic identifiers
- Maintain consistency in key naming across different endpoints
- Consider using keys that reflect the example's purpose or scenario
5. Regularly Review and Update Examples
Maintain the accuracy and relevance of examples:
- Update examples when API changes occur
- Remove obsolete examples to prevent confusion
- Periodically review examples for completeness and clarity
- Solicit feedback from API consumers about example usefulness
By following these best practices, API providers can create a more valuable and user-friendly documentation experience that accelerates adoption and reduces support requirements.
Frequently Asked Questions About Multiple Request Body Examples
How do I enable multiple request body examples in existing projects?
No manual action is required. When adding a second request body example to an existing endpoint, Apidog automatically upgrades the format to support multiple examples. This seamless transition ensures backward compatibility while enabling the new functionality.
How are multiple request body examples handled when exporting to OpenAPI specifications?
When exporting to OpenAPI specifications, Apidog automatically generates an example object following OAS 3.1 specifications. The system uses the OAS Key as the unique identifier for each example. If no OAS Key is provided, serial numbers (starting from 1) are used instead.
Will the order of request body examples change in the exported OpenAPI specification?
No, the order of examples in the exported specifications will match the order in which they were added in Apidog. This consistency ensures that the most important examples remain prominently positioned in both Apidog and exported documentation.
How can I make exported example names more user-friendly?
To create more descriptive and user-friendly example names in exported specifications, fill in the OAS Key field for each request body example (e.g., "standard_request", "error_case"). These keys will be used as the example identifiers during export, making the documentation more intuitive for consumers.
Can I use multiple request body examples with all content types?
Apidog supports multiple request body examples for JSON, XML, Raw, and MsgPack content types. However, for request bodies of Raw type, only the first example value is displayed during debugging, though all examples are preserved in the documentation and exports.
Conclusion: Elevating API Documentation with Multiple Request Body Examples
Apidog's support for multiple request body examples represents a significant advancement in API documentation capabilities. By allowing developers to create, manage, and utilize various example scenarios within a single interface, this feature streamlines both the documentation and testing processes while ensuring compliance with OpenAPI specifications.
The benefits of implementing multiple request body examples extend beyond mere documentation improvements. This feature enhances the entire API lifecycle by:
- Accelerating development through clear, scenario-specific examples
- Reducing errors by providing concrete request structures for different use cases
- Improving testing efficiency with quick switching between predefined examples
- Ensuring specification compliance through proper OpenAPI formatting
- Enhancing collaboration by creating a shared understanding of API usage patterns
As APIs continue to serve as the foundation for modern software integration, comprehensive and accurate documentation becomes increasingly critical. Apidog's implementation of multiple request body examples addresses this need directly, providing a powerful yet intuitive mechanism for documenting the various ways an API can be used.
By following the step-by-step guide and best practices outlined in this article, API providers can leverage this feature to create more valuable documentation, accelerate development cycles, and ultimately deliver a better experience for API consumers.