Open shachr opened 9 years ago
In JSON Schema v4, the required
attribute must be an array, and it is a property of the object definition. This was one of the main things that changed from v3. Try this:
var schema = {
id:"/api/accounts/register",
type: "object",
oneOf: [ { $ref:"#/definitions/social" }, { $ref:"#/definitions/site" } ],
definitions: {
social: {
additionalProperties: false,
type: 'object',
required: ['provider'],
properties: {
provider: { 'enum': [ "facebook" ] }
}
},
site: {
additionalProperties: false,
type: 'object',
required: ['username', 'password'],
properties: {
username: { type: "string" },
password: { type: "string" },
firstname: { type: "string" },
lastname: { type: "string" },
email: { type: "string" },
isSubscribed: { type: "boolean" }
}
}
}
};
I agree, though, the fact that this hangs is bad and I will take a look preventing that.
given the following object and schema the validate function hang:
object:
schema: