Schema Validation failure

I am getting Assertion error when I run the tv4 or Ajv validators —

AssertionError: [
{“keyword”:“type”,“dataPath”:".SystemVariables[18].Value",“schemaPath”:"#/properties/SystemVariables/items/anyOf/0/properties/Value/type",“params”:{“type”:“string”},“message”:“should be string”},
{“keyword”:“type”,“dataPath”:".SystemVariables[18].DefaultValue",“schemaPath”:"#/properties/SystemVariables/items/anyOf/0/properties/DefaultValue/type",“params”:{“type”:“string”},“message”:“should be string”},
{“keyword”:“anyOf”,“dataPath”:".SystemVariables[18]",“schemaPath”:"#/properties/SystemVariables/items/anyOf",“params”:{},“message”:“should match some schema in anyOf”},

Code for the AJV
var Ajv = require(‘ajv’), ajv = new Ajv({ logger: console, allErrors: true }), schema = {…MASSIVE SCHEMA…}

pm.test(‘Schema is valid from AJV’, function() {
pm.expect(ajv.validate(schema, pm.response.json()), JSON.stringify(ajv.errors)).to.be.true; });

Code for the tv4
var schema_valid = {…massive schema…}
pm.test(“Validate schema”, () => {pm.response.to.have.jsonSchema(schema_valid);});

const responseData = pm.response.json()
pm.test("Schema is valid", function(){
let validation = tv4.validate(responseData, schema_valid);
if (validation !== true) {
    console.log(tv4.error);
    }
pm.expect(validation).to.be.true;

});

The issue areas mentioned in the Assertion error from the schema(I used a tool to generate schema) –

  1. This is the Schema >> Schemepath which is being mentioned in the error–

                         "Value": {
                             "$id": "#/properties/SystemVariables/items/anyOf/0/properties/Value",
                             "type": "string",
                             "title": "The Value schema",
                             "description": "An explanation about the purpose of this instance.",
                             "default": "",
                             "examples": [
                                 "0"
                             ]
                         },
                         "DefaultValue": {
                             "$id": "#/properties/SystemVariables/items/anyOf/0/properties/DefaultValue",
                             "type": "string",
                             "title": "The DefaultValue schema",
                             "description": "An explanation about the purpose of this instance.",
                             "default": "",
                             "examples": [
                                 "0"
                             ]
    
  2. This is the datapath from the Schema which is being mentioned in the error

    {
    “ID”: 18,
    “Name”: “HL7A19Timeout”,
    “Description”: “Site defined time in seconds that client app waits whilst retrieving demographics”,
    “VarType”: “system”,
    “Value”: “40”,
    “DefaultValue”: “40”
    }

CAn some please throw some light as to what is wrong with the schema

Hi @Anumundada,

Welcome to the community! :clap:

While you have provided quite a bit of information, would you be able to add screenshots as well for more context?

Personally, I read through what you wrote, and while it seems exhaustive, I’m not certain where the issue is.

It looks like you have the right type in your schema for the values. However, in your actual, it looks like you have numbers set to those variables, though, they look like “string” numbers and not actual numbers (or integer types for that matter).

With that, it looks like what you have is correct. Screenshots may help get more information to resolve your issue.

Other than that, it’s been awhile since I have done schema validation, so I can’t immediately see anything wrong with what you’ve provided.

Best,
Orest