Create test response from json OR directly access jsonSchema()

Hello @jdeasonphilz, Welcome to the Community :wave:

Yes you can do that using ajv. Please check here for more details.

You can save your sample response and the sample schema as two different variables, and can validate them.

var resp = pm.response.json();

var samplesubsetschema = 
{
..//define your schema
}

var sampleresp = //save the subset response against this;

pm.test('Schema validation using Ajv', function(){
    var Ajv = require('ajv');
    ajv = new Ajv({logger: console});
     pm.expect(ajv.validate(samplesubsetschema,sampleresp));
});

I hope this helps, I have just provided the rough scripts. If you still have any issues, kindly share the response and detailed screenshots :slight_smile:

2 Likes