What you’ve posted should work, if you remove the "type":"object"
from the definition.
However, a neater, more explicit way to specify alternatives is to use oneOf
. You can keep your "id"
definition untouched, and just use:
"owner":{
"oneOf": [
{"type": "null"},
{"$ref":"#/definitions/id"}
]
}