Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Why JSON Schema support is needed?

APEX PDP uses AVRO library to perform JSON encoding and decoding to serialize/deserialize the data it consumes. When doing so, it attempts to ensure that the JSON data conforms to the AVRO Schema provided.
In an event that triggers a policy, there could be some fields that are optional, the fields which are not always present depending on the use case.
Avro fails to handle this, and there is no way in APEX-PDP to handle events with optional fields today.

Avro has the concept of union and default, but this doesn't work while decoding a JSON event when the field is missing.
There is an open bug/missing feature in the Avro JSON Decoder library which cannot apply defaults to missing fields, it enforces it instead: https://issues.apache.org/jira/browse/AVRO-2890.

Hence, adding JSON Schema support in addition to Avro support in APEX-PDP can be beneficial.
In addition to the support for optional fields, JSON Schema support can help in writing the schema and using the fields in the logic itself much more simple and straightforward.


What are the potential solutions?

The JSON Schema validators available today are listed here: https://json-schema.org/implementations.html#validator-java

Medeia-validator seems to be the sensible choice to be used for the JSON Schema support. Medeia-validator is already part of the policy-common/policy-models modules.
medeia-validator-gson supports GSON under the hood making it the right choice. The performance of this library also seems to be better comparitively as per the analysis here https://github.com/worldturner/medeia-validator#performance


What are the expected changes?



  • No labels