{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-spec/issues/333","labels_url":"https://api.github.com/repos/swagger-api/swagger-spec/issues/333/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-spec/issues/333/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-spec/issues/333/events","html_url":"https://github.com/swagger-api/swagger-spec/issues/333","id":69303319,"number":333,"title":"Make schema object compatible with JSON Schema draft4","user":{"login":"IvanGoncharov","id":8336157,"avatar_url":"https://avatars.githubusercontent.com/u/8336157?v=3","gravatar_id":"","url":"https://api.github.com/users/IvanGoncharov","html_url":"https://github.com/IvanGoncharov","followers_url":"https://api.github.com/users/IvanGoncharov/followers","following_url":"https://api.github.com/users/IvanGoncharov/following{/other_user}","gists_url":"https://api.github.com/users/IvanGoncharov/gists{/gist_id}","starred_url":"https://api.github.com/users/IvanGoncharov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IvanGoncharov/subscriptions","organizations_url":"https://api.github.com/users/IvanGoncharov/orgs","repos_url":"https://api.github.com/users/IvanGoncharov/repos","events_url":"https://api.github.com/users/IvanGoncharov/events{/privacy}","received_events_url":"https://api.github.com/users/IvanGoncharov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/swagger-api/swagger-spec/labels/Swagger.Next%20Proposal","name":"Swagger.Next Proposal","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-04-18T12:05:56Z","updated_at":"2015-07-23T12:20:42Z","closed_at":null,"body":"According to [spec](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#schema-object) swagger inside **schema object** support only **limited subset** of JSON Schema draft4 and extend it with **custom keywords**.\r\n\r\nThis isssue was hidden, before 68c6777dc5eba98dc1eb791983693f089e9d3366 commit any swagger model with arbitrary JSON schema was valid(against Swagger  [schema](https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json)).\r\n\r\nThese create a problem, because in reality most of tools use standard JSON schema validators(for e.g. swagger-tools use z-schema, swagger-express-middleware use tv4). And I didn't found any true Swagger 2.0 validator in the wild.\r\n\r\nAnother problem is  that you can't reference existing schemes inside your swagger files.\r\nIt became real problem, if you want to use some standard scheme or simply reuse your existing validation scheme. For example if you make API that return swagger definitions and want to reuse existing [schema](https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json), you can't simply use '$ref' or even copy-paste it.\r\n\r\nFinally it brake compatibility with all tooling around JSON Schema not only validators but also documentation generators, UI form generators, etc.\r\n\r\nOn technical side, this is list of Draft4 keywords doesn't supported by Swagger: **id, $schema, additionalItems, definitions, patternProperties, dependencies, anyOf, oneOf, not**.\r\n\r\nAlso there are \"discriminator\" and \"readOnly\" Swagger specific keywords that don't supported by JSON Schema validators. \"discriminator\" could be safely substitute with \"oneOf\" construction, as for \"readOnly\" same behaviour could be achieved by  using \"allOf\" with \"write part\" and \"read-only part\".\r\nMy proposal it either to remove these keywords or make them optional to support.\r\n\r\nAlso there are \"safe\" custom keywords namely \"example\" and \"externalDocs\", they shouldn't cause any serious trouble, but should be submitted as requests for [Draft5](https://github.com/json-schema/json-schema/wiki/v5-Proposals) to ensure future compatibility.\r\n\r\nLast keyword is \"xml\", I didn't make any research about it, so I can't say if it used in any Swagger related project or if it brake JSON schema compatibility."},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-spec/issues/comments/124079171","html_url":"https://github.com/swagger-api/swagger-spec/issues/333#issuecomment-124079171","issue_url":"https://api.github.com/repos/swagger-api/swagger-spec/issues/333","id":124079171,"user":{"login":"glen-84","id":261509,"avatar_url":"https://avatars.githubusercontent.com/u/261509?v=3","gravatar_id":"","url":"https://api.github.com/users/glen-84","html_url":"https://github.com/glen-84","followers_url":"https://api.github.com/users/glen-84/followers","following_url":"https://api.github.com/users/glen-84/following{/other_user}","gists_url":"https://api.github.com/users/glen-84/gists{/gist_id}","starred_url":"https://api.github.com/users/glen-84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glen-84/subscriptions","organizations_url":"https://api.github.com/users/glen-84/orgs","repos_url":"https://api.github.com/users/glen-84/repos","events_url":"https://api.github.com/users/glen-84/events{/privacy}","received_events_url":"https://api.github.com/users/glen-84/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T12:20:42Z","updated_at":"2015-07-23T12:20:42Z","body":"@IvanGoncharov That's interesting (thanks for the link), but I'd prefer to use something with existing client- and server-side implementations if possible."}}