bauweto
bauweto

Reputation: 3

Validate API Manager's payload against JSON Schema

We are working with WSO2 API Manager where we have a bunch of API's defined. I have defined in every API a complete JSON Schema. Does anyone know how to validate payloads against the json schema in the API definition (rather than to make an xsd and so on...)? Furthermore, how can I let APIM validate parameters at all?

Currently, APIM seems to disregard the JSON Schema and parameter constraints (required, datatypes,...). It is only in the swagger.ui part of APIM where it seems to matter. (which is obviously not enough)

Any help is much appreciated

Upvotes: 0

Views: 1657

Answers (1)

sanjeewa.190
sanjeewa.190

Reputation: 360

Currently WSO2 API Manager(which use ESB validate mediator underlying) do not have first class JSON schema validation support . As a workaround, you will have to create an XSD structure as per your JSON payload and then use it in the validate mediator [1]. I have explained it here [2].

But this feature is already implemented for WSO2 ESB(which shares same synapse run time) [3]. So from next release onward we will have native JSON schema validation support.

Also as a workaround you may use filter mediator to achieve this for some extent. But it cannot use to validate complete schema. For more details about filter mediators refer this [4] doc

[1] - https://docs.wso2.com/display/ESB490/Validate+Mediator

[2] - http://sanjeewamalalgoda.blogspot.com/2016/08/how-to-validate-json-request-pay-load_8.html

[3] - https://wso2.org/jira/browse/ESBJAVA-4640

[4] - https://docs.wso2.com/display/ESB480/Filter+Mediator

Upvotes: 1

Related Questions