{"action":"created","issue":{"url":"https://api.github.com/repos/json-schema-faker/json-schema-faker/issues/106","repository_url":"https://api.github.com/repos/json-schema-faker/json-schema-faker","labels_url":"https://api.github.com/repos/json-schema-faker/json-schema-faker/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/json-schema-faker/json-schema-faker/issues/106/comments","events_url":"https://api.github.com/repos/json-schema-faker/json-schema-faker/issues/106/events","html_url":"https://github.com/json-schema-faker/json-schema-faker/issues/106","id":133457627,"number":106,"title":"Bug - generates occasional unexpected empty objects when using $ref","user":{"login":"tauren","id":282084,"avatar_url":"https://avatars.githubusercontent.com/u/282084?v=3","gravatar_id":"","url":"https://api.github.com/users/tauren","html_url":"https://github.com/tauren","followers_url":"https://api.github.com/users/tauren/followers","following_url":"https://api.github.com/users/tauren/following{/other_user}","gists_url":"https://api.github.com/users/tauren/gists{/gist_id}","starred_url":"https://api.github.com/users/tauren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tauren/subscriptions","organizations_url":"https://api.github.com/users/tauren/orgs","repos_url":"https://api.github.com/users/tauren/repos","events_url":"https://api.github.com/users/tauren/events{/privacy}","received_events_url":"https://api.github.com/users/tauren/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"pateketrueke","id":206371,"avatar_url":"https://avatars.githubusercontent.com/u/206371?v=3","gravatar_id":"","url":"https://api.github.com/users/pateketrueke","html_url":"https://github.com/pateketrueke","followers_url":"https://api.github.com/users/pateketrueke/followers","following_url":"https://api.github.com/users/pateketrueke/following{/other_user}","gists_url":"https://api.github.com/users/pateketrueke/gists{/gist_id}","starred_url":"https://api.github.com/users/pateketrueke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pateketrueke/subscriptions","organizations_url":"https://api.github.com/users/pateketrueke/orgs","repos_url":"https://api.github.com/users/pateketrueke/repos","events_url":"https://api.github.com/users/pateketrueke/events{/privacy}","received_events_url":"https://api.github.com/users/pateketrueke/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-02-13T18:42:11Z","updated_at":"2016-02-14T19:31:12Z","closed_at":null,"body":"I believe there is a bug in `json-schema-faker` that causes random invalid empty objects to be generated. The problem is inconsistent, with proper data being generated much of the time and invalid data on occasion. I think it may happen only when using `$ref` references, but have not done much testing without `$ref`.\r\n\r\nThe problem can be seen with [this schema in the json-schema-faker web app](http://json-schema-faker.js.org/#%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22id%22%3A%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Fid%22%7D%2C%22group%22%3A%7B%22oneOf%22%3A%5B%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Fid%22%7D%2C%7B%22type%22%3A%22null%22%7D%5D%7D%2C%22type%22%3A%7B%22oneOf%22%3A%5B%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Ftype%22%7D%2C%7B%22type%22%3A%22null%22%7D%5D%7D%7D%2C%22required%22%3A%5B%22id%22%2C%22group%22%2C%22type%22%5D%2C%22additionalProperties%22%3Afalse%2C%22definitions%22%3A%7B%22id%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22integer%22%2C%22minimum%22%3A%221%22%7D%2C%22type%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22string%22%2C%22enum%22%3A%5B%22apple%22%2C%22orange%22%2C%22banana%22%2C%22pear%22%2C%22peach%22%5D%7D%7D%7D). It uses a simplistic schema with references. You may need to generate samples multiple times to see it. \r\n\r\nSomething like the following is expected to be generated:\r\n\r\n```\r\n{\r\n  \"id\": 35312220,\r\n  \"group\": 41758652,\r\n  \"type\": \"peach\"\r\n}\r\n```\r\n\r\nHowever, on occasion, the following is generated with an empty object for a property value where an empty object is not allowed by the schema:\r\n\r\n```\r\n{\r\n  \"id\": 91206752,\r\n  \"group\": {},\r\n  \"type\": null\r\n}\r\n```\r\n\r\nAt first I thought this may have something to do with using `oneOf`, but this [more complex schema](http://json-schema-faker.js.org/#%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22id%22%3A%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Fid%22%7D%2C%22name%22%3A%7B%22type%22%3A%22string%22%7D%2C%22group%22%3A%7B%22oneOf%22%3A%5B%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Fid%22%7D%2C%7B%22type%22%3A%22null%22%7D%5D%7D%2C%22type%22%3A%7B%22oneOf%22%3A%5B%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Ftype%22%7D%2C%7B%22type%22%3A%22null%22%7D%5D%7D%2C%22groups%22%3A%7B%22type%22%3A%22array%22%2C%22items%22%3A%7B%22%24ref%22%3A%22%23%2Fdefinitions%2FgroupObj%22%7D%7D%2C%22types%22%3A%7B%22type%22%3A%22array%22%2C%22items%22%3A%7B%22%24ref%22%3A%22%23%2Fdefinitions%2FtypeObj%22%7D%7D%7D%2C%22required%22%3A%5B%22id%22%2C%22name%22%2C%22group%22%2C%22type%22%2C%22groups%22%2C%22types%22%5D%2C%22additionalProperties%22%3Afalse%2C%22definitions%22%3A%7B%22id%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22integer%22%2C%22minimum%22%3A%221%22%7D%2C%22type%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22string%22%2C%22enum%22%3A%5B%22apple%22%2C%22orange%22%2C%22banana%22%2C%22pear%22%2C%22peach%22%5D%7D%2C%22groupObj%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22label%22%3A%7B%22type%22%3A%22string%22%7D%2C%22value%22%3A%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Fid%22%7D%7D%2C%22required%22%3A%5B%22label%22%2C%22value%22%5D%2C%22additionalProperties%22%3Afalse%7D%2C%22typeObj%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22label%22%3A%7B%22type%22%3A%22string%22%7D%2C%22value%22%3A%7B%22%24ref%22%3A%22%23%2Fdefinitions%2Ftype%22%7D%7D%2C%22required%22%3A%5B%22label%22%2C%22value%22%5D%2C%22additionalProperties%22%3Afalse%7D%2C%22name%22%3A%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema%23%22%2C%22title%22%3A%22The%20name%20property%22%2C%22type%22%3A%22string%22%2C%22minLength%22%3A1%7D%7D%7D) illustrates the problem at places where `oneOf` is not used. It also shows the problem at a higher frequency.\r\n\r\nHere is an example of a bad result. All empty objects `{}` are not expected. Also I find it interesting that whenever the failure happens in an array of objects, the failure happens for every element of that array.\r\n\r\n```\r\n{\r\n  \"id\": 70505479,\r\n  \"name\": \"officia qui ipsum exercitation\",\r\n  \"group\": {},\r\n  \"type\": {},\r\n  \"groups\": [\r\n    {\r\n      \"label\": \"enim\",\r\n      \"value\": {}\r\n    },\r\n    {\r\n      \"label\": \"adipisicing\",\r\n      \"value\": {}\r\n    },\r\n    {\r\n      \"label\": \"laborum tempor sint\",\r\n      \"value\": {}\r\n    },\r\n    {\r\n      \"label\": \"ea aliqua te\",\r\n      \"value\": {}\r\n    }\r\n  ],\r\n  \"types\": [\r\n    {\r\n      \"label\": \"aute ut fugiat proident\",\r\n      \"value\": \"orange\"\r\n    },\r\n    {\r\n      \"label\": \"laboris occaecat\",\r\n      \"value\": \"apple\"\r\n    },\r\n    {\r\n      \"label\": \"laborum aliq\",\r\n      \"value\": \"apple\"\r\n    }\r\n  ]\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/json-schema-faker/json-schema-faker/issues/comments/183961626","html_url":"https://github.com/json-schema-faker/json-schema-faker/issues/106#issuecomment-183961626","issue_url":"https://api.github.com/repos/json-schema-faker/json-schema-faker/issues/106","id":183961626,"user":{"login":"johntimothybailey","id":641367,"avatar_url":"https://avatars.githubusercontent.com/u/641367?v=3","gravatar_id":"","url":"https://api.github.com/users/johntimothybailey","html_url":"https://github.com/johntimothybailey","followers_url":"https://api.github.com/users/johntimothybailey/followers","following_url":"https://api.github.com/users/johntimothybailey/following{/other_user}","gists_url":"https://api.github.com/users/johntimothybailey/gists{/gist_id}","starred_url":"https://api.github.com/users/johntimothybailey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johntimothybailey/subscriptions","organizations_url":"https://api.github.com/users/johntimothybailey/orgs","repos_url":"https://api.github.com/users/johntimothybailey/repos","events_url":"https://api.github.com/users/johntimothybailey/events{/privacy}","received_events_url":"https://api.github.com/users/johntimothybailey/received_events","type":"User","site_admin":false},"created_at":"2016-02-14T19:31:12Z","updated_at":"2016-02-14T19:31:12Z","body":"@pateketrueke Impacted by the same problem. Do you need/want any help this week on getting a resolution?"}}