jsonsystems / json-schema

JSONSchema.Net Public Repository
Apache License 2.0
663 stars 64 forks source link

"type": "null" is missing when response JSON any key has null value #74

Closed hitesh010 closed 4 years ago

hitesh010 commented 4 years ago

"type": "null" is missing when response JSON any key has null value.

If a key is null in response, in schema -

  1. type of the key should be there
  2. Initially null can be given i.e. "type": "null"

In your previous implementation, this was there and it used to help when there was an update in value let say from null to String/Integer ,we came to know. I think this needs to be added. Thanks.

jackwootton commented 4 years ago

@hitesh010 Thanks for reporting this. This is a bug.

{
    "foo": null
}

Should yield:


{
    "type": "object",
    "properties": {
        "foo": {
            "type": "null"
        }
    }
}
jackwootton commented 4 years ago

This has been fixed in the next release (not yet deployed):

image

jackwootton commented 4 years ago

I've just released a new version which fixes this.