scrapy-plugins / scrapy-jsonschema

Scrapy schema validation pipeline and Item builder using JSON Schema
BSD 3-Clause "New" or "Revised" License
44 stars 12 forks source link

schema doesn't check for misspelt/new fields within array of objects #24

Closed ablewalmsley closed 4 years ago

ablewalmsley commented 4 years ago

I noticed a bug for array of objects in JSON schemas, if I accidentally misspell a property, or add a property that is not yet in the schema to my item, it will still pass validation i.e.

{
   "type":"object",
   "properties":{
      "contacts":{
         "type":"array",
         "items":{
            "type":"object",
            "properties":{
               "title":{
                  "type":"string"
               },
               "name":{
                  "type":"string"
               },
               "phone":{
                  "type":"string"
               },
               "email":{
                  "type":"string"
               }
            }
         }
      }
   }

it will validate contacts is there and not misspelt, but if I accidentally put "telephone" instead of "phone" (or a similar mistake), within the array of objects, it will be considered valid.

Please let me know if this is intended, or if there is an available workaround.

ablewalmsley commented 4 years ago

nevermind, looks like thats a schema issue, I can just add "additionalProperties": False to fix that