# Open API 3.0 schema support in PostmanTiny validator

**URL:** <https://community.postman.com/t/open-api-3-0-schema-support-in-postmantiny-validator/7585>\
**Category:** Help Hub\
**Created:** [September 3, 2019, 4:30pm UTC](https://community.postman.com/t/open-api-3-0-schema-support-in-postmantiny-validator/7585 "2019-09-03T16:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjilani](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@rjilani](https://community.postman.com/u/rjilani)\
**Post date:** [September 3, 2019, 4:30pm UTC](https://community.postman.com/t/open-api-3-0-schema-support-in-postmantiny-validator/7585/1 "2019-09-03T16:30:04Z")

</div>

Hi: I am trying to validate the json response against the postman tiny validator but the assertion always returns true no matter what the json response is. I am not sure is it an issue with the tiny validator 4, but if some one has some pointers will really appreciate it. Please find the json response and the schema below

//json response  
{  
“id”: 1,  
“category”: {  
“id”: 2,  
“name”: “Cats”  
},  
“name”: “Cat 1”,  
“photoUrls”: [  
“url1”,  
“url2”  
],  
“tags”: [  
{  
“id”: 1,  
“name”: “tag1”  
},  
{  
“id”: 2,  
“name”: “tag2”  
}  
],  
“status”: “available”  
}

//scheam object  
var schema = {  
“properties”: {  
“Order”: {  
“type”: “object”,  
“properties”: {  
“id”: {  
“type”: “integer”,  
“format”: “int64”  
},  
“petId”: {  
“type”: “integer”,  
“format”: “int64”  
},  
“quantity”: {  
“type”: “integer”,  
“format”: “int32”  
},  
“shipDate”: {  
“type”: “string”,  
“format”: “date-time”  
},  
“status”: {  
“type”: “string”,  
“description”: “Order Status”,  
“enum”: [  
“placed”,  
“approved”,  
“delivered”  
]  
},  
“complete”: {  
“type”: “boolean”,  
“default”: false  
}  
},  
“xml”: {  
“name”: “Order”  
}  
},  
“Category”: {  
“type”: “object”,  
“properties”: {  
“id”: {  
“type”: “integer”,  
“format”: “int64”  
},  
“name”: {  
“type”: “string”  
}  
},  
“xml”: {  
“name”: “Category”  
}  
},  
“User”: {  
“type”: “object”,  
“properties”: {  
“id”: {  
“type”: “integer”,  
“format”: “int64”  
},  
“username”: {  
“type”: “string”  
},  
“firstName”: {  
“type”: “string”  
},  
“lastName”: {  
“type”: “string”  
},  
“email”: {  
“type”: “string”  
},  
“password”: {  
“type”: “string”  
},  
“phone”: {  
“type”: “string”  
},  
“userStatus”: {  
“type”: “integer”,  
“description”: “User Status”,  
“format”: “int32”  
}  
},  
“xml”: {  
“name”: “User”  
}  
},  
“Tag”: {  
“type”: “object”,  
“properties”: {  
“id”: {  
“type”: “integer”,  
“format”: “int64”  
},  
“name”: {  
“type”: “string”  
}  
},  
“xml”: {  
“name”: “Tag”  
}  
},  
“Pet”: {  
“required”: [  
“name”,  
“photoUrls”  
],  
“type”: “object”,  
“properties”: {  
“id”: {  
“type”: “integer”,  
“format”: “int64”  
},  
“category”: {  
“$ref”: “#/components/schemas/Category”  
},  
“name”: {  
“type”: “string”,  
“example”: “doggie”  
},  
“photoUrls”: {  
“type”: “array”,  
“xml”: {  
“name”: “photoUrl”,  
“wrapped”: true  
},  
“items”: {  
“type”: “string”  
}  
},  
“tags”: {  
“type”: “array”,  
“xml”: {  
“name”: “tag”,  
“wrapped”: true  
},  
“items”: {  
“$ref”: “#/components/schemas/Tag”  
}  
},  
“status”: {  
“type”: “string”,  
“description”: “pet status in the store”,  
“enum”: [  
“available”,  
“pending”,  
“sold”  
]  
}  
},  
“xml”: {  
“name”: “Pet”  
}  
},  
“ApiResponse”: {  
“type”: “object”,  
“properties”: {  
“code”: {  
“type”: “integer”,  
“format”: “int32”  
},  
“type”: {  
“type”: “string”  
},  
“message”: {  
“type”: “string”  
}  
}  
}

```
}

```

};

pm.test(‘Schema is valid’, function() {  
pm.expect(tv4.validate(jsonData, schema, true)).to.be.true;

});

---

<div class="post-metadata">

**Author:** ![LiamC](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LiamC](https://community.postman.com/u/LiamC)\
**Post date:** [September 4, 2019, 9:21am UTC](https://community.postman.com/t/open-api-3-0-schema-support-in-postmantiny-validator/7585/2 "2019-09-04T09:21:20Z")

</div>

Hi,

I was wanting to do something similar recently, ended up getting it to work with Ajv validation instead, this topic might be helpful to you:

> [@Testing Properties and Arrays correctly in GET](https://community.postman.com/t/testing-properties-and-arrays-correctly-in-get/7133/13):
>
> I managed to get something to work, after banging my head against a wall for hours. I do agree this schema validation stuff may be a lot more than I can handle at the moment, so I may go back to what I had originally. It’s been a learning experience though! If you’re interested by the way, this is what I found would actually test Passes & fails correctly: const jsonData = pm.response.json(); pm.test('Schema is valid', function() { var Ajv = require('ajv'); ajv = new Ajv(), schem…

@danny-dainton has a more concise example here of Ajv validation if that’s all you’ll need:

> [@Checking a schema with tv4](https://community.postman.com/t/checking-a-schema-with-tv4/7575/2):
>
> Hey @Coxjeffrey, I would recommend using [Ajv](https://github.com/epoberezkin/ajv) over tv4, this also comes as part of the Postman app. You can use this example to check your response against the schema: var Ajv = require('ajv'), ajv = new Ajv({ logger: console, allErrors: true }), schema = { "type":"object", "required":["Id", "Progress", "Status", "Info", "Created", "Ended", "Operation", "Requested"], "properties":{ "Id":{ "$id":"#/properties/I…

I ended up ditching Schema validation and testing it a different way as the API I’m testing has become really complicated and the schema way was just a bit too advanced for me to do for now.

Good luck, hope this helps! 🙂

---

<div class="post-metadata">

**Author:** ![rjilani](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@rjilani](https://community.postman.com/u/rjilani)\
**Post date:** [September 4, 2019, 9:37pm UTC](https://community.postman.com/t/open-api-3-0-schema-support-in-postmantiny-validator/7585/3 "2019-09-04T21:37:59Z")

</div>

Hi: Liam thanks for the reply, I also ended up using Ajv, as recommended by the postman [https://learning.getpostman.com/docs/postman/scripts/postman\_sandbox/](https://learning.getpostman.com/docs/postman/scripts/postman_sandbox/), because tv4 json is deprecated in latest postman releases. Having said that it doesn’t solve my problem, and I guess the reason is both ajv and tiny validator 4 follows the json [http://json-schema.org/](http://json-schema.org/), but open API 3.0 uses an extended subset of the json schema, please see the link [https://swagger.io/docs/specification/data-models/keywords/](https://swagger.io/docs/specification/data-models/keywords/). I am not an expert of Json schema but it looks to me none of the validators are fully compatible with Open API 3.0 schema.
