Hi There,
Our requirement is to validate the JSON request payload before forwarding the request to the back end servers, could you pls refer me to the appropriate article for it. Thanks
Thanks for the info.Bit unlcear with the steps, do i need to import both java script TV4 and uses tv4-min.js in to my proxy?
One more question,Isn't that APIGEE developer team planning to build any builtin policy for this schema validation,since it quite tedious to manage this code
Yes - Apigee is doing some work on an OpenAPI Spec validator.
You can also try this Java version:
https://github.com/DinoChiesa/ApigeeEdge-Java-Validate-JSON-Schema
@Popleys you can use json-schema draft v4 to validate simple values and complex objects using a rich validation vocabulary: https://github.com/geraintluff/tv4
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="JS-Subscriber-ParamsValidation"> <DisplayName>JS-ParamsValidation</DisplayName> <Properties/> <ResourceURL>jsc://JS-ParamsValidation.js</ResourceURL> <IncludeURL>jsc://tv4.js</IncludeURL> </Javascript>
if(tv4.validate(requestPayload, apiSchema)){ context.setVariable("validRequest" ,true); }else{ context.setVariable("validRequest" ,false); context.setVariable("tv4ErrorCode" ,tv4.error.code); context.setVariable("tv4ErrorDataPath" ,tv4.error.dataPath); context.setVariable("tv4ErrorSchemaPath" ,tv4.error.schemaPath); context.setVariable("ERRORMSG" ,tv4.error.message); }
<Step> <Name>RF-ParamsValidation</Name> <Condition>validRequest=false</Condition> </Step>
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |