garycourt/JSV — Issue #32: Reusing extended schemas
Author: pospi
Created: 2012-02-27 06:20:29+00:00
State: open

It appears that JSV's implementation of schema extension is buggy when reusing extended schemas. I'm not sure what is happening internally, but it manifests when adding required properties to multiple extensions of a single schema. It appears that all additional constraints from the extending schemas are merged into a single base one, resulting in every instance failing due to the absence of different required properties.

Code to reproduce follows.

Main schema:

```
{
"id"	: "http://example.com/schemas/extendTest",
"$schema"	: "http://json-schema.org/draft-03/schema",
"description"	: "Testing extending the same schema multiple times",

"type" : "object",
"properties" : {
"set1" : {
"type" : "array",
"items" : {
"extends" : {"$ref" : "http://example.com/schemas/extendTest/subrecord"},
"properties" : {
"newVar1" : {
"type" : "string",
"required" : true
}
},
"additionalProperties" : false
},
"additionalItems" : false
},
"set2" : {
"type" : "array",
"items" : {
"extends" : {"$ref" : "http://example.com/schemas/extendTest/subrecord"},
"properties" : {
"newVar2" : {
"type" : "string",
"required" : true
}
},
"additionalProperties" : false
},
"additionalItems" : false
}
},
"additionalProperties" : false
}
```

Child schema:

```
{
"id" : "http://example.com/schemas/extendTest/subrecord",
"$schema"	: "http://json-schema.org/draft-03/schema",
"type" : "object",
"properties" : {
"someVar" : {
"type" : "string"
}
}
}
```

I feel like this should be working, but perhaps I am implementing the inheritance incorrectly.
Cheers!