Class JsonSchemaValidator
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.validator.jsonschema.JsonSchemaValidator
- Direct Known Subclasses:
JsonSchemaExpectationIdValidator,JsonSchemaExpectationValidator,JsonSchemaHttpRequestAndHttpResponseValidator,JsonSchemaHttpRequestValidator,JsonSchemaHttpResponseValidator,JsonSchemaOpenAPIExpectationValidator,JsonSchemaRequestDefinitionValidator,JsonSchemaVerificationSequenceValidator,JsonSchemaVerificationValidator
public class JsonSchemaValidator
extends ObjectWithReflectiveEqualsHashCodeToString
implements Validator<String>
- Author:
- jamesdbloom
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJsonSchemaValidator(MockServerLogger mockServerLogger, Class<?> type, String routePath, String mainSchemeFile, String... referenceFiles) JsonSchemaValidator(MockServerLogger mockServerLogger, String schema) JsonSchemaValidator(MockServerLogger mockServerLogger, String schema, com.fasterxml.jackson.databind.JsonNode schemaJsonNode) -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonSchemaValidatorcachedJsonSchemaValidator(MockServerLogger mockServerLogger, String schemaJson) Returns aJsonSchemaValidatorforschemaJsonthat reuses a cached one-time compilation of the schema when the same content has been seen before.Methods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
equals, fieldsExcludedFromEqualsAndHashCode, hashCode, toString
-
Field Details
-
OPEN_API_SPECIFICATION_URL
-
JSON_SCHEMA_ALLOW_REMOTE_REFS_PROPERTY
System property opt-in to allow remote$refresolution in JSON schemas.SECURITY: by default MockServer blocks resolution of remote
$refs (http, https, ftp and external file URIs) when matching a request/response body against a JSON Schema, to avoid an SSRF / unexpected-network-fetch risk where a schema could cause the server to fetch arbitrary external resources. Schemas that use only internal references (#/...) and inline definitions are unaffected.Set
-Dmockserver.jsonSchemaAllowRemoteRefs=trueto opt in to remote$refresolution for the rare case where it is genuinely required.- See Also:
-
-
Constructor Details
-
JsonSchemaValidator
-
JsonSchemaValidator
public JsonSchemaValidator(MockServerLogger mockServerLogger, String schema, com.fasterxml.jackson.databind.JsonNode schemaJsonNode) -
JsonSchemaValidator
public JsonSchemaValidator(MockServerLogger mockServerLogger, Class<?> type, String routePath, String mainSchemeFile, String... referenceFiles)
-
-
Method Details
-
cachedJsonSchemaValidator
public static JsonSchemaValidator cachedJsonSchemaValidator(MockServerLogger mockServerLogger, String schemaJson) Returns aJsonSchemaValidatorforschemaJsonthat reuses a cached one-time compilation of the schema when the same content has been seen before. The returned validator is behaviour-identical tonew JsonSchemaValidator(logger, schemaJson)for the same input — same validation outcomes and error messages, the caller's ownlogger, and an independent per-call instance — only the expensiveSchema/SchemaRegistrycompilation is elided on a cache hit. Intended for the per-request OpenAPI validation path. -
getSchema
-
isValid
-
isValid
-