Package io.github.microcks.util.openapi
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 SwaggerSchemaValidator()
-
Method Summary
All Methods Static Methods Concrete Methods 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).
-
-
-
Method Detail
-
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 formessagePathPointer
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 setadditionalProperties
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 nodejsonNode
- The Json object representing actual message as a Jackson nodemessagePathPointer
- 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 formessagePathPointer
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 setadditionalProperties
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 nodejsonNode
- The Json object representing actual message as a Jackson nodemessagePathPointer
- A JSON Pointer for accessing expected message definition within specnamespace
- Namespace definition to resolve relative dependencies in Swagger schema- Returns:
- The list of validation failures. If empty, json object is valid !
-
-