# Validating a schema has all the right properties and nothing more

**URL:** <https://community.postman.com/t/validating-a-schema-has-all-the-right-properties-and-nothing-more/36685>\
**Category:** Help Hub\
**Tags:** tests, schema\
**Created:** [June 29, 2022, 10:06am UTC](https://community.postman.com/t/validating-a-schema-has-all-the-right-properties-and-nothing-more/36685 "2022-06-29T10:06:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thingmie](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@thingmie](https://community.postman.com/u/thingmie)\
**Post date:** [June 29, 2022, 10:06am UTC](https://community.postman.com/t/validating-a-schema-has-all-the-right-properties-and-nothing-more/36685/1 "2022-06-29T10:06:38Z")

</div>

Hi, my schema:

```auto
{
    "data": {
        "me": {
            "firstName": "David",
            "lastName": "Robert",
            "myNumber": "ZZ",
            "myBranch": {
                "cCode": "GB",
                "eNumber": "3089800"
            },
            "myAccount": {
                "contactId": "000AAA111"
            }
        }
    }
}

```

I’ve previously written the test for others schemas like so:

```auto
// schema
const schema = {
    "type": "object",
    "properties": {
        "id": { "type": "string" },
        "tel":{ "type":"number" },
        "position":{ "type":"string" }
        },
        "required": [
            "id",
            "tel",
            "position",
        ],
        "additionalProperties":false,
}

pm.test("Schema should be valid", () => {
    pm.response.to.have.jsonSchema(schema);
});

```

But I’ve tried various ways but I can’t seem to modify the test I’ve written previously to suit the new schema objects and properties that are at different levels?! what’s the best way to do it? various levels?!

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 30, 2022, 10:35pm UTC](https://community.postman.com/t/validating-a-schema-has-all-the-right-properties-and-nothing-more/36685/2 "2022-06-30T22:35:38Z")

</div>

Hi @thingmie

You could try this online JSON to JSON Schema tool, to try and create a JSON Schema that matches your example;

> **[Free Online JSON to JSON Schema Converter](https://www.liquid-technologies.com/online-json-to-schema-converter)**
>
> Uses the sample JSON document to infer a JSON schema

---

<div class="post-metadata">

**Author:** ![thingmie](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@thingmie](https://community.postman.com/u/thingmie)\
**Post date:** [July 1, 2022, 11:13am UTC](https://community.postman.com/t/validating-a-schema-has-all-the-right-properties-and-nothing-more/36685/3 "2022-07-01T11:13:32Z")

</div>

Perfect, thanks a lot.
