Class JsonSchemaValidatorSettings

java.lang.Object
io.restassured.module.jsv.JsonSchemaValidatorSettings

public class JsonSchemaValidatorSettings extends Object
Settings for the JsonSchemaValidator
  • Constructor Details

    • JsonSchemaValidatorSettings

      public JsonSchemaValidatorSettings(com.github.fge.jsonschema.main.JsonSchemaFactory jsonSchemaFactory, boolean checkedValidation)
      Initializes JsonSchemaValidatorSettings with a specific JsonSchemaFactory and checked validation. It will also use checked validation and treating uri's and url's as Strings. To change the latter refer to parseUriAndUrlsAsJsonNode(boolean).
    • JsonSchemaValidatorSettings

      public JsonSchemaValidatorSettings(com.github.fge.jsonschema.main.JsonSchemaFactory jsonSchemaFactory)
      Initializes JsonSchemaValidatorSettings with a specific JsonSchemaFactory. The settings will also use checked validation and treating uri's and url's as Strings.
    • JsonSchemaValidatorSettings

      public JsonSchemaValidatorSettings()
      Initializes JsonSchemaValidatorSettings with a default JsonSchemaFactory (generated by JsonSchemaFactory.byDefault()) and using checked validation and treating uri's and url's as Strings.
  • Method Details

    • jsonSchemaFactory

      public com.github.fge.jsonschema.main.JsonSchemaFactory jsonSchemaFactory()
    • shouldParseUriAndUrlsAsJsonNode

      public boolean shouldParseUriAndUrlsAsJsonNode()
    • shouldUseCheckedValidation

      public boolean shouldUseCheckedValidation()
    • checkedValidation

      public JsonSchemaValidatorSettings checkedValidation(boolean shouldUseCheckedValidation)
      Instruct the JsonSchemaValidator to use checked validation or not.
      Parameters:
      shouldUseCheckedValidation - true to use checked validation, false otherwise.
      Returns:
      A new instance of JsonSchemaValidatorSettings
    • parseUriAndUrlsAsJsonNode

      public JsonSchemaValidatorSettings parseUriAndUrlsAsJsonNode(boolean parseUriAndUrlsAsJsonNode)
      Instruct the JsonSchemaValidator to parse URI's and URL's as JsonNode before they are passed to validation. If true then JsonSchemaValidator.matchesJsonSchema(url) handled like this:
       instanceSettings.jsonSchemaFactory().getJsonSchema(JsonLoader.fromURL(url))
       
      If false then JsonSchemaValidator.matchesJsonSchema(url) handled like this:
       instanceSettings.jsonSchemaFactory().getJsonSchema(url)
       
      The latter is good for you need to resolve relative ref in a parent schema because the validator does not know what is the base URI of the parent schema if first having parsed it as a JsonNode.

      Default is false.

      Parameters:
      parseUriAndUrlsAsJsonNode - true to parse URI's and URL's as JsonNode's, false otherwise.
      Returns:
      A new instance of JsonSchemaValidatorSettings
    • jsonSchemaFactory

      public JsonSchemaValidatorSettings jsonSchemaFactory(com.github.fge.jsonschema.main.JsonSchemaFactory jsonSchemaFactory)
      Set a JsonSchemaFactory instance that will be used when creating the validator.
      Parameters:
      jsonSchemaFactory - The JsonSchemaFactory instance to use.
      Returns:
      A new instance of JsonSchemaValidatorSettings
    • and

      Syntactic sugar.
      Returns:
      The same settings instance.
    • with

      Syntactic sugar.
      Returns:
      The same settings instance.
    • settings

      public static JsonSchemaValidatorSettings settings()
      Create a new instance of JsonSchemaValidatorSettings. Same as calling JsonSchemaValidatorSettings().
      Returns:
      A default instance of the JsonSchemaValidatorSettings.