{"action":"created","issue":{"url":"https://api.github.com/repos/natesilva/jayschema/issues/56","labels_url":"https://api.github.com/repos/natesilva/jayschema/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/natesilva/jayschema/issues/56/comments","events_url":"https://api.github.com/repos/natesilva/jayschema/issues/56/events","html_url":"https://github.com/natesilva/jayschema/issues/56","id":88067593,"number":56,"title":"validate hang","user":{"login":"shachr","id":3229512,"avatar_url":"https://avatars.githubusercontent.com/u/3229512?v=3","gravatar_id":"","url":"https://api.github.com/users/shachr","html_url":"https://github.com/shachr","followers_url":"https://api.github.com/users/shachr/followers","following_url":"https://api.github.com/users/shachr/following{/other_user}","gists_url":"https://api.github.com/users/shachr/gists{/gist_id}","starred_url":"https://api.github.com/users/shachr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shachr/subscriptions","organizations_url":"https://api.github.com/users/shachr/orgs","repos_url":"https://api.github.com/users/shachr/repos","events_url":"https://api.github.com/users/shachr/events{/privacy}","received_events_url":"https://api.github.com/users/shachr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-13T21:20:35Z","updated_at":"2015-06-15T21:16:32Z","closed_at":null,"body":"given the following object and schema the validate function hang:\r\n\r\nobject:\r\n```javascript\r\n{\r\n    provider: { name: \"1\" }\r\n}\r\n```\r\nschema:\r\n```javascript\r\n{\r\n        id:\"/api/accounts/register\",\r\n        type: \"object\",\r\n        oneOf: [ { $ref:\"#/definitions/social\" }, { $ref:\"#/definitions/site\" } ],\r\n\r\n\r\n        definitions: {\r\n            social: {\r\n                additionalProperties: false,\r\n                type: 'object',\r\n                properties: {\r\n                    provider: { enum: [ \"facebook\" ], required:true }\r\n                }\r\n            },\r\n            site: {\r\n                additionalProperties: false,\r\n                type: 'object',\r\n                properties: {\r\n                    username: { type: \"string\", required:true },\r\n                    password: { type: \"string\", required:true },\r\n\r\n                    firstname: { type: \"string\" },\r\n                    lastname: { type: \"string\" },\r\n                    email: { type: \"string\" },\r\n                    isSubscribed: { type: \"boolean\" }\r\n                }\r\n            }\r\n        }\r\n    }\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/natesilva/jayschema/issues/comments/112214510","html_url":"https://github.com/natesilva/jayschema/issues/56#issuecomment-112214510","issue_url":"https://api.github.com/repos/natesilva/jayschema/issues/56","id":112214510,"user":{"login":"natesilva","id":160467,"avatar_url":"https://avatars.githubusercontent.com/u/160467?v=3","gravatar_id":"","url":"https://api.github.com/users/natesilva","html_url":"https://github.com/natesilva","followers_url":"https://api.github.com/users/natesilva/followers","following_url":"https://api.github.com/users/natesilva/following{/other_user}","gists_url":"https://api.github.com/users/natesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/natesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natesilva/subscriptions","organizations_url":"https://api.github.com/users/natesilva/orgs","repos_url":"https://api.github.com/users/natesilva/repos","events_url":"https://api.github.com/users/natesilva/events{/privacy}","received_events_url":"https://api.github.com/users/natesilva/received_events","type":"User","site_admin":false},"created_at":"2015-06-15T21:16:32Z","updated_at":"2015-06-15T21:16:32Z","body":"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:\r\n\r\n```javascript\r\nvar schema = {\r\n    id:\"/api/accounts/register\",\r\n    type: \"object\",\r\n    oneOf: [ { $ref:\"#/definitions/social\" }, { $ref:\"#/definitions/site\" } ],\r\n\r\n\r\n    definitions: {\r\n        social: {\r\n            additionalProperties: false,\r\n            type: 'object',\r\n            required: ['provider'],\r\n            properties: {\r\n                provider: { 'enum': [ \"facebook\" ] }\r\n            }\r\n        },\r\n        site: {\r\n            additionalProperties: false,\r\n            type: 'object',\r\n            required: ['username', 'password'],\r\n            properties: {\r\n                username: { type: \"string\" },\r\n                password: { type: \"string\" },\r\n\r\n                firstname: { type: \"string\" },\r\n                lastname: { type: \"string\" },\r\n                email: { type: \"string\" },\r\n                isSubscribed: { type: \"boolean\" }\r\n            }\r\n        }\r\n    }\r\n};\r\n```\r\n\r\nI agree, though, the fact that this hangs is bad and I will take a look preventing that."}}