Does the name of the properties matter in a schema validation?

Hi,

I am testing the body response of my request and noticed that if the properties names are different between the response and the schema I try to compare it to, no error message appears

Here a part of my response body:

{
    "timestamp": "2021-12-28T09:47:51+0100",
    "parks": [
        {
            "id": "xx",
            "gisTypeId": "x",
            "type": "xx",
            "operatorId": "x"
.....

Here a part of my schema:

const schema ={ 

    "type": "object",

    "properties": {

        "timestamp": {

            "$id": "#root/timestamp", 

            "title": "Timestamp", 

            "type": "string",

            "default": "",

            "pattern": "^.*$"

        },

        "Cars": {

            "$id": "#root/cars", 

            "title": "Cars", 

            "type": "array",

            "default": [],

            "items":{

When I run the request the test pass without any errors. Is that normal? Wehn we test a schema the properties name are not tested?

Many thanks,

Nawel

Hi @nawelmele

@vdespa explains schema validation really well. He also explains when and how schema validation can cause false positives. Check him out he has a couple of videos about it;

(6 minutes 50 seconds in, he discusses required properties which I think is what you are talking about).

1 Like