Issue-79 - To be able to Add Examples for Parameters, Schemas ans Request #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Support for External Example Configuration in openapi-maven-plugin
Description
This Pull Request introduces the ability to add Examples to OpenAPI entities, parameters, and operations. The examples can be specified via an external file provided in the Maven plugin configuration. This feature enhances the plugin by allowing developers to maintain and manage examples separately from the codebase.
This is also mentioned in #79 and #50
Key Features:
New Configuration Option:
pom.xml
, allowing the user to specify the path to an external file containing examples.Supported Example Structure:
Code First Approach: This feature aligns with the plugin's philosophy of maintaining documentation through code-first principles, while offering flexibility for managing external examples.
How to Use
pom.xml
:Example
Below are examples of how the configuration can be used for each module: PARAMETER, SCHEMA, REQUESTBODY, and RESPONSE.
1. Parameter Examples
The example below demonstrates how this configuration supports both Path parameters and Header parameters:
2. Schema Examples
In this configuration, ExampleEnum and ExampleRequestBodyDto represent the names of entities. This demonstrates that the feature works for both simple entities (e.g., enums) and complex objects (e.g., DTOs with nested properties)
3. Request Body Examples
For the REQUESTBODY module, the configuration allows both a default example and multiple options that OpenAPI supports. When using multiple options, the JSON should be formatted as an array to allow readers to choose during testing
4. Response Examples
The following example demonstrates how to configure RESPONSE examples.
BOTH Request Body and Response supports Multi Options and referenced examples
To use the $ref the respective information must be informed using Free Fields