Package org.mockserver.async.validation
Class AsyncApiSchemaValidator
java.lang.Object
org.mockserver.async.validation.AsyncApiSchemaValidator
Validates JSON payloads against an AsyncAPI channel's JSON Schema definition,
reusing
JsonSchemaValidator from mockserver-core (which uses the
com.networknt:json-schema-validator library under the hood).
Used in two contexts:
- Validating generated example messages before publishing
- Validating consumed/recorded messages from broker subscriptions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResult of a schema validation. -
Constructor Summary
ConstructorsConstructorDescriptionAsyncApiSchemaValidator(MockServerLogger mockServerLogger) Constructor accepting an external logger instance, consistent with the codebase pattern of injecting or per-instance loggers. -
Method Summary
Modifier and TypeMethodDescriptionValidate that the given JSON payload conforms to the given JSON Schema.
-
Constructor Details
-
AsyncApiSchemaValidator
public AsyncApiSchemaValidator() -
AsyncApiSchemaValidator
Constructor accepting an external logger instance, consistent with the codebase pattern of injecting or per-instance loggers.
-
-
Method Details
-
validate
public AsyncApiSchemaValidator.ValidationResult validate(String payload, com.fasterxml.jackson.databind.JsonNode schema) Validate that the given JSON payload conforms to the given JSON Schema.- Parameters:
payload- the JSON payload string to validateschema- the JSON Schema node from the AsyncAPI spec- Returns:
- a validation result; use
AsyncApiSchemaValidator.ValidationResult.isValid()to check
-