Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Using JSON Schema Validator

712 vues

Publié le

Overview of Mulesoft's JSON Schema Validator.
This presentation also contains information about the things you should consider before using Mulesoft's JSON Schema Validator

Publié dans : Logiciels
  • Soyez le premier à commenter

Using JSON Schema Validator

  1. 1. Using JSON Schema Validator - By Rahul Kumar
  2. 2. Prerequisites JSON Reference : https://tools.ietf.org/html/rfc7159 JSON Schema Reference : http://json-schema.org/documentation.html
  3. 3. JSON Schema Validator JSON schema validator is used to validate JSON data against a JSON schema. The JSON Schema validator evaluates JSON payloads at runtime and verifies that they match a referenced JSON schema. You can match against schemas that exist in a local file or in an external URI. If the validation fails, an exception is raised with feedback about what went wrong and a reference to the original invalid payload. The JSON Schema Validator supports schema drafts of version 4 and older.
  4. 4. Accepted Payload Types java.lang.String, java.io.Reader, InputStream, byte[], com.fasterxml.jackson.databind.JsonNode, org.mule.module.json.JsonData If the payload type is none of the above, then the validator attempts to transform the payload into a usable type, in the following order: org.mule.module.json.JsonData com.fasterxml.jackson.databind.JsonNode java.lang.String
  5. 5. ConfigurationFollowing are the properties on general tab: Display Name – The display name of the connector used for display purposes in Mule flow. Schema Location – Location of the schema. It may be a web URL, file system URL etc. Dereferencing - Draft v4 defines two dereferencing modes, canonical (default) and inline. This attribute is ignored if validating a v3 draft. Schema redirects - Schema Validator supports referencing URIs to external schemas, and because one schema might reference another, the validator also supports URI redirection, so that a reference to another schema doesn’t
  6. 6. Schema Redirects In this example, any links to the external address http://my.site/schemas/fstab.json will redirect to the internal address resource:/org/mule/json/examples/fstab.json.
  7. 7. Validation Behavior If the validation is successful, then control is passed to the next processor in the chain. Otherwise a JsonSchemaValidationException is thrown containing validation feedback on the message. This exception contains a message with a detailed explanation of what went wrong, and a property called invalidJson in which the invalid payload is available on its String representation.
  8. 8. Precaution For performing validation the validator consumes a streaming resource (InputStream, Reader, etc), so the message payload is altered to the fully consumed JSON. So you may pass a payload of type java.io.InputStream or a java.io.Reader but you may get back a String
  9. 9. Flow
  10. 10. Thank You !!