{"action":"created","issue":{"url":"https://api.github.com/repos/wikimedia/restbase/issues/387","labels_url":"https://api.github.com/repos/wikimedia/restbase/issues/387/labels{/name}","comments_url":"https://api.github.com/repos/wikimedia/restbase/issues/387/comments","events_url":"https://api.github.com/repos/wikimedia/restbase/issues/387/events","html_url":"https://github.com/wikimedia/restbase/pull/387","id":113348192,"number":387,"title":"More features added to the validator","user":{"login":"Pchelolo","id":814754,"avatar_url":"https://avatars.githubusercontent.com/u/814754?v=3","gravatar_id":"","url":"https://api.github.com/users/Pchelolo","html_url":"https://github.com/Pchelolo","followers_url":"https://api.github.com/users/Pchelolo/followers","following_url":"https://api.github.com/users/Pchelolo/following{/other_user}","gists_url":"https://api.github.com/users/Pchelolo/gists{/gist_id}","starred_url":"https://api.github.com/users/Pchelolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pchelolo/subscriptions","organizations_url":"https://api.github.com/users/Pchelolo/orgs","repos_url":"https://api.github.com/users/Pchelolo/repos","events_url":"https://api.github.com/users/Pchelolo/events{/privacy}","received_events_url":"https://api.github.com/users/Pchelolo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wikimedia/restbase/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-26T12:50:32Z","updated_at":"2015-10-29T13:20:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/wikimedia/restbase/pulls/387","html_url":"https://github.com/wikimedia/restbase/pull/387","diff_url":"https://github.com/wikimedia/restbase/pull/387.diff","patch_url":"https://github.com/wikimedia/restbase/pull/387.patch"},"body":"Added more features:\r\n- Support for type validators. Everything comes in as strings, so we can't use built-in json-schema type validation. Instead, validate with appropriate regex patterns\r\n- Support additional features like `maxLength`, `minLength`, `pattern`, `enum` etc.\r\n- Support for `body` parameters validated against a json-schema\r\n\r\nThe only problem is [weird api for sections transform](https://phabricator.wikimedia.org/T116336) that allows either form-data or application/json types to be passed in. Until we figure out what to do with that issue, we cannot validate `sections` input against a complete schema, so just validate that it has some field named `sections`. We have tests for both types of input, so backwards compatibility is preserved for now.\r\n\r\nBenchmarks show, that, obviously, as more parameters are added and more complex requirements are added, the validator is getting slower, but even with a very complex and long list of params, the overhead is still almost unnoticeable."},"comment":{"url":"https://api.github.com/repos/wikimedia/restbase/issues/comments/152177019","html_url":"https://github.com/wikimedia/restbase/pull/387#issuecomment-152177019","issue_url":"https://api.github.com/repos/wikimedia/restbase/issues/387","id":152177019,"user":{"login":"Pchelolo","id":814754,"avatar_url":"https://avatars.githubusercontent.com/u/814754?v=3","gravatar_id":"","url":"https://api.github.com/users/Pchelolo","html_url":"https://github.com/Pchelolo","followers_url":"https://api.github.com/users/Pchelolo/followers","following_url":"https://api.github.com/users/Pchelolo/following{/other_user}","gists_url":"https://api.github.com/users/Pchelolo/gists{/gist_id}","starred_url":"https://api.github.com/users/Pchelolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pchelolo/subscriptions","organizations_url":"https://api.github.com/users/Pchelolo/orgs","repos_url":"https://api.github.com/users/Pchelolo/repos","events_url":"https://api.github.com/users/Pchelolo/events{/privacy}","received_events_url":"https://api.github.com/users/Pchelolo/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T13:20:58Z","updated_at":"2015-10-29T13:20:58Z","body":"@wikimedia/services I've made a new version with type coercion. This one supports almost everything in swagger specification, and automatically coerces bools/ints/numbers. The problem with `sections` api is still there, because, according to the swagger spec, we can't specify `object` type in `formData` field. But when we deprecate and removed form-data type for this endpoint, all should be fine. \r\n\r\nPerformance is a bit worse then before, but it's expected, we are coercing the types now, but even for very complex validation, with ~10 integer types, we get around 3 million validations per second, so the impact on performance would still be unnoticeable.\r\n\r\nWhen we deploy and stabilise this, as a next step we could remove some validations, made in the handler code. "}}