{"action":"created","issue":{"url":"https://api.github.com/repos/pipermerriam/flex/issues/58","labels_url":"https://api.github.com/repos/pipermerriam/flex/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/pipermerriam/flex/issues/58/comments","events_url":"https://api.github.com/repos/pipermerriam/flex/issues/58/events","html_url":"https://github.com/pipermerriam/flex/issues/58","id":57705701,"number":58,"title":"Improve api path matching","user":{"login":"pipermerriam","id":824194,"avatar_url":"https://avatars.githubusercontent.com/u/824194?v=3","gravatar_id":"","url":"https://api.github.com/users/pipermerriam","html_url":"https://github.com/pipermerriam","followers_url":"https://api.github.com/users/pipermerriam/followers","following_url":"https://api.github.com/users/pipermerriam/following{/other_user}","gists_url":"https://api.github.com/users/pipermerriam/gists{/gist_id}","starred_url":"https://api.github.com/users/pipermerriam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipermerriam/subscriptions","organizations_url":"https://api.github.com/users/pipermerriam/orgs","repos_url":"https://api.github.com/users/pipermerriam/repos","events_url":"https://api.github.com/users/pipermerriam/events{/privacy}","received_events_url":"https://api.github.com/users/pipermerriam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-14T20:36:43Z","updated_at":"2015-03-20T15:06:39Z","closed_at":null,"body":"The current api path matching leaves room for improvement in the case where multiple matches are found for a target path.  This happens in pretty simple situations like nested resources.\r\n\r\n- `/get/{id}` => `/get/(?P<id>.+)`\r\n- `/get/{id}/nested/{other_id}` => `/get/(?P<id>.+)/nested/(?P<other_id>.+)`\r\n\r\nBoth of these path regexes will match `/get/1234/nested/5678`.\r\n\r\nThe current logic looks at the match with the most matched groups and assumes it is the correct path.  I think this is a bit naive and may have false positives, or potentially pick the wrong path in specialized use cases.\r\n\r\nI don't know that the correct approach is, but I think a start would be to use other factors in the definition of the parameter to generate stricter regexes.  Fox example, path parameters that are of `integer` type could generate `/get/(?P<id>\\d+)` so that it will only match paths that have numeric values in the location of `id`.\r\n\r\nAnother thing to take into account, is that adding this kind matching based on type will turn what *should* be a type error in the actual extracted parameter value into an error matching the path.  I don't know which is the correct error to raise.  Maybe there is a way to do both?\r\n"},"comment":{"url":"https://api.github.com/repos/pipermerriam/flex/issues/comments/84038967","html_url":"https://github.com/pipermerriam/flex/issues/58#issuecomment-84038967","issue_url":"https://api.github.com/repos/pipermerriam/flex/issues/58","id":84038967,"user":{"login":"pipermerriam","id":824194,"avatar_url":"https://avatars.githubusercontent.com/u/824194?v=3","gravatar_id":"","url":"https://api.github.com/users/pipermerriam","html_url":"https://github.com/pipermerriam","followers_url":"https://api.github.com/users/pipermerriam/followers","following_url":"https://api.github.com/users/pipermerriam/following{/other_user}","gists_url":"https://api.github.com/users/pipermerriam/gists{/gist_id}","starred_url":"https://api.github.com/users/pipermerriam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipermerriam/subscriptions","organizations_url":"https://api.github.com/users/pipermerriam/orgs","repos_url":"https://api.github.com/users/pipermerriam/repos","events_url":"https://api.github.com/users/pipermerriam/events{/privacy}","received_events_url":"https://api.github.com/users/pipermerriam/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T15:06:39Z","updated_at":"2015-03-20T15:06:39Z","body":"Out of town on vacation for two more days.  I'll take a look into this when I get back.  Feel free to start up a pull request, even if it only creates a test that shows this failure."}}