What are the supported JSON Schema validators

Not applicable

Hi,

Our need is to validate the JSON request payload before forwarding the request to the back end servers

The below does link provide the steps on using the OpenAPI Spec to validate JSON requests for draft#4

https://community.apigee.com/articles/42993/using-the-openapi-spec-to-validate-json-requests.html.

Can we use other JSON Schema validators like (djv, Ajv etc) for validating Json payloads ?

if so, please let us know the steps to implement the same.

Thanks,

Raju

0 2 2,332
2 REPLIES 2

Yes you can use other validators.

But you'll need to assemble such a solution, yourself.

Hi @Ram Kalidindi,

The article you sited works for TV4 and uses tv4-min.js.

I tried the same approach for ajv and djv, but they do not work with the JavaScript that Edge uses, at least not without modification. Edge uses Rhino JavaScript engine 1.7.7.1

An alternate approach is to use a "hybrid" proxy with 2 targets, one for the real backend and one that uses Node.js to perform the validation. I've tested this for ajv.

The flow is:

  1. API call to the real endpoint (e.g. POST /resources)
  2. Service Callout to a LocalTargetConnection (same proxy with RouteRule) with a "validate" endpoint and passing the "current.flow.name" as a header. Then validate along the same lines as the other article, that is using the current.flow.name === OAS operationId.

Another alternative would be to use a Java Callout which may have better performance.