Is there a way to validate the response schema against openapi spec schema?
Using Ajv, we can validate the response against schema like this.
var Ajv = require('ajv'),
ajv = new Ajv({logger: console}),
schema = {
"properties": {
"errors": {
"type": "string"
}
}
};
pm.test('Schema is valid', function() {
var error = pm.response.json()['errors'];
pm.expect(ajv.validate(schema, {errors: error})).to.be.true;
});
But instead of manually defining the schema as shown in above example, can we somehow get it from openapi spec.