Class SwaggerSchemaValidator

java.lang.Object
io.github.microcks.util.openapi.SwaggerSchemaValidator

public class SwaggerSchemaValidator extends Object
Helper class for validating Json objects against their Swagger schema. Supported version of Swagger schema is https://swagger.io/specification/v2/.
Author:
laurent
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    validateJsonMessage(com.fasterxml.jackson.databind.JsonNode specificationNode, com.fasterxml.jackson.databind.JsonNode jsonNode, String messagePathPointer)
    Validate a Json object representing a Swagger message (response or request) against a node representing a full OpenAPI specification (and not just a schema node).
    static List<String>
    validateJsonMessage(com.fasterxml.jackson.databind.JsonNode specificationNode, com.fasterxml.jackson.databind.JsonNode jsonNode, String messagePathPointer, String namespace)
    Validate a Json object representing a Swagger message (response or request) against a node representing a full Swagger specification (and not just a schema node).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SwaggerSchemaValidator

      public SwaggerSchemaValidator()
  • Method Details

    • validateJsonMessage

      public static List<String> validateJsonMessage(com.fasterxml.jackson.databind.JsonNode specificationNode, com.fasterxml.jackson.databind.JsonNode jsonNode, String messagePathPointer)
      Validate a Json object representing a Swagger message (response or request) against a node representing a full OpenAPI specification (and not just a schema node). Specify the message by providing a valid JSON pointer for messagePathPointer within specification. Validation is a deep one: its pursue checking children nodes on a failed parent. Validation is respectful of Swagger schema spec semantics regarding additional or unknown attributes: schema must explicitly set additionalProperties to false if you want to consider unknown attributes as validation errors. It returns a list of validation error messages.
      Parameters:
      specificationNode - The Swagger full specification as a Jackson node
      jsonNode - The Json object representing actual message as a Jackson node
      messagePathPointer - A JSON Pointer for accessing expected message definition within spec
      Returns:
      The list of validation failures. If empty, json object is valid !
    • validateJsonMessage

      public static List<String> validateJsonMessage(com.fasterxml.jackson.databind.JsonNode specificationNode, com.fasterxml.jackson.databind.JsonNode jsonNode, String messagePathPointer, String namespace)
      Validate a Json object representing a Swagger message (response or request) against a node representing a full Swagger specification (and not just a schema node). Specify the message by providing a valid JSON pointer for messagePathPointer within specification. Validation is a deep one: its pursue checking children nodes on a failed parent. Validation is respectful of Swagger schema spec semantics regarding additional or unknown attributes: schema must explicitly set additionalProperties to false if you want to consider unknown attributes as validation errors. It returns a list of validation error messages.
      Parameters:
      specificationNode - The Swagger full specification as a Jackson node
      jsonNode - The Json object representing actual message as a Jackson node
      messagePathPointer - A JSON Pointer for accessing expected message definition within spec
      namespace - Namespace definition to resolve relative dependencies in Swagger schema
      Returns:
      The list of validation failures. If empty, json object is valid !