# Create test response from json OR directly access jsonSchema()

**URL:** <https://community.postman.com/t/create-test-response-from-json-or-directly-access-jsonschema/19539>\
**Category:** Help Hub\
**Tags:** tests, response, ajv\
**Created:** [January 25, 2021, 6:42pm UTC](https://community.postman.com/t/create-test-response-from-json-or-directly-access-jsonschema/19539 "2021-01-25T18:42:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [January 26, 2021, 12:37am UTC](https://community.postman.com/t/create-test-response-from-json-or-directly-access-jsonschema/19539/2 "2021-01-26T00:37:22Z")

</div>

Hello @jdeasonphilz, Welcome to the Community 👋

Yes you can do that using ajv. Please check [here](https://community.postman.com/t/is-it-possible-to-have-a-shared-ajv-schema/7275/5) for more details.

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

```auto
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 🙂

---

_[View the full topic](https://community.postman.com/t/create-test-response-from-json-or-directly-access-jsonschema/19539)._
