Schema validation ignoring array sub-fields type

Hey @fermani

Welcome to the community :wave:

Not sure what was happening for you locally but the JSON Schema you posted wasn’t valid JSON - It was missing a closing " at the end of the access key.

I’ve used a different Schema validation module that’s built-in to Postman, to help with this question.

It’s very similar to the tv4 module but is actively maintained.

I mocked out the response body from the question and this seems to be working (failing the test due to the wrong data type).

var Ajv = require('ajv'),
    ajv = new Ajv({logger: console}),
    accessSchema = {
        "properties": {
            "access": { 
                "type": "array",
                "items": {
                    "properties": {
                        "id": { "type": "string" },
                        "client": { "type": "string" },
                        "apikey": { "type": "string" },
                        "description": { "type": "integer" }
                      }
                  }
              }
        }
    }

pm.test('Schema is valid', function() {
    pm.expect(ajv.validate(accessSchema, pm.response.json())).to.be.true;
});  

When the schema data types are correct, the test is passing: