Package org.mockserver.async
Class MessageExampleGenerator
java.lang.Object
org.mockserver.async.MessageExampleGenerator
Generates example JSON payloads for each channel in an
AsyncApiSpec.
Uses the following precedence for each channel:
- The first explicit example from the spec
- A schema-aware example synthesized from the JSON Schema payload (applies constraints: enum, minimum/maximum, minLength/maxLength, pattern hint, required fields, default values)
- An empty JSON object
{}as a last-resort fallback
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateExample(AsyncApiChannel channel) Generate an example payload for a single channel.generateExample(AsyncApiMessage message) Generate an example payload for a singleAsyncApiMessage.generateExamples(AsyncApiSpec spec) Generate example payloads for all channels in the spec.
-
Constructor Details
-
MessageExampleGenerator
public MessageExampleGenerator()
-
-
Method Details
-
generateExamples
Generate example payloads for all channels in the spec.- Returns:
- a map from channel name to JSON string payload
-
generateExample
Generate an example payload for a single channel. Uses the channel's first message's examples and schema (backward compatible). -
generateExample
Generate an example payload for a singleAsyncApiMessage. Follows the same precedence asgenerateExample(AsyncApiChannel): explicit example first, then schema synthesis, then empty object fallback.
-