Checking Json schema with Ajv, returning invalid schema error

This is the sample json schema
{

"body": ERROR: NOT FOUND: Valid,

"meta": {

    "status": "success",

    "message": "Valid"
}

}

I’m using the following codes and getting the error, can any one help me on this issue

var jsonData = JSON.response;

var Ajv = require(‘ajv’),

ajv = new Ajv({

    logger: console,

    allErrors: true

}),

schema = {

    "type": "Object",

    "required": [

        "body",

        "meta"

    ],

    "properties": {

        "body": {

            "$body": "#/properties/body",

            "type": "string"

        },

        "meta": {

            "$body": "#/properties/meta",

            "type": "array",

            "status": {

                "$body": "#/properties/meta/status",

                "type": "string",

            },

            "message": {

                "$body": "#/properties/meta/message",

                "type": "string"

            }

        }

    }

}

pm.test(‘Schema is valid’, function() {

pm.expect(ajv.validate(schema, jsonData), JSON.stringify(ajv.errors)).to.be.true;

});

Error Message–
Error: schema is invalid: data.type should be equal to one of the allowed values, data.type should be array, data.type should match some schema in anyOf

Reply