Package com.networknt.openapi
Class SchemaValidator
- java.lang.Object
-
- com.networknt.openapi.SchemaValidator
-
public class SchemaValidator extends Object
Validate a value against the schema defined in an OpenAPI specification.Supports validation of properties and request/response bodies, and supports schema references.
- Author:
- Steve Hu
-
-
Constructor Summary
Constructors Constructor Description SchemaValidator()Build a new validator with no API specification.SchemaValidator(com.networknt.oas.model.OpenApi3 api)Build a new validator for the given API specification.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.networknt.status.Statusvalidate(Object value, com.fasterxml.jackson.databind.JsonNode schema)com.networknt.status.Statusvalidate(Object value, com.fasterxml.jackson.databind.JsonNode schema, com.networknt.schema.SchemaValidatorsConfig config)Validate the given value against the given property schema.com.networknt.status.Statusvalidate(Object value, com.fasterxml.jackson.databind.JsonNode schema, com.networknt.schema.SchemaValidatorsConfig config, String at)Validate the given value against the given property schema.com.networknt.status.Statusvalidate(Object value, com.fasterxml.jackson.databind.JsonNode schema, String at)
-
-
-
Constructor Detail
-
SchemaValidator
public SchemaValidator()
Build a new validator with no API specification.This will not perform any validation of $ref references that reference local schemas.
-
SchemaValidator
public SchemaValidator(com.networknt.oas.model.OpenApi3 api)
Build a new validator for the given API specification.- Parameters:
api- The API to build the validator for. If provided, is used to retrieve schemas in components for use in references.
-
-
Method Detail
-
validate
public com.networknt.status.Status validate(Object value, com.fasterxml.jackson.databind.JsonNode schema, com.networknt.schema.SchemaValidatorsConfig config)
Validate the given value against the given property schema.- Parameters:
value- The value to validateschema- The property schema to validate the value againstconfig- The config model for some validator- Returns:
- A status containing error code and description
-
validate
public com.networknt.status.Status validate(Object value, com.fasterxml.jackson.databind.JsonNode schema, com.networknt.schema.SchemaValidatorsConfig config, String at)
Validate the given value against the given property schema.- Parameters:
value- The value to validateschema- The property schema to validate the value againstconfig- The config model for some validatorat- The name of the property being validated- Returns:
- Status object
-
validate
public com.networknt.status.Status validate(Object value, com.fasterxml.jackson.databind.JsonNode schema)
-
-