{"action":"created","issue":{"url":"https://api.github.com/repos/localmed/api-mock/issues/28","labels_url":"https://api.github.com/repos/localmed/api-mock/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/localmed/api-mock/issues/28/comments","events_url":"https://api.github.com/repos/localmed/api-mock/issues/28/events","html_url":"https://github.com/localmed/api-mock/pull/28","id":58337579,"number":28,"title":"Feature - conditional body mapping & API polymorphism","user":{"login":"srenauld","id":3967363,"avatar_url":"https://avatars.githubusercontent.com/u/3967363?v=3","gravatar_id":"","url":"https://api.github.com/users/srenauld","html_url":"https://github.com/srenauld","followers_url":"https://api.github.com/users/srenauld/followers","following_url":"https://api.github.com/users/srenauld/following{/other_user}","gists_url":"https://api.github.com/users/srenauld/gists{/gist_id}","starred_url":"https://api.github.com/users/srenauld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srenauld/subscriptions","organizations_url":"https://api.github.com/users/srenauld/orgs","repos_url":"https://api.github.com/users/srenauld/repos","events_url":"https://api.github.com/users/srenauld/events{/privacy}","received_events_url":"https://api.github.com/users/srenauld/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-20T11:06:20Z","updated_at":"2015-02-21T17:49:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/localmed/api-mock/pulls/28","html_url":"https://github.com/localmed/api-mock/pull/28","diff_url":"https://github.com/localmed/api-mock/pull/28.diff","patch_url":"https://github.com/localmed/api-mock/pull/28.patch"},"body":"This MR adds the ability to conditionally respond to an API call in a way other than by passing `Prefer` headers. In practice, it enables a developer to use examples described in an API blueprint to create a feature-rich, scenario-based API mock.\r\n\r\nEach request is now conditionally checked for the following:\r\n* If a `Body` is present, this `Body` is compared with the request body (this also takes into account JSON, if headers are set to the right `content-type`)\r\n* If a `Header` is present, this is compared with the request header\r\n\r\nIf a `Request` matches both `Body` and `Header`, api-mock returns the associated response.\r\n\r\nIf nothing matched, by specification, api-mock returns the last defined response.\r\n\r\nIf a `Prefer` header is passed, it is taken into account as usual and the behaviour remains unchanged.\r\n\r\nUnit-tests are updated to reflect this, with a coverage of 100%."},"comment":{"url":"https://api.github.com/repos/localmed/api-mock/issues/comments/75383091","html_url":"https://github.com/localmed/api-mock/pull/28#issuecomment-75383091","issue_url":"https://api.github.com/repos/localmed/api-mock/issues/28","id":75383091,"user":{"login":"ecordell","id":58055,"avatar_url":"https://avatars.githubusercontent.com/u/58055?v=3","gravatar_id":"","url":"https://api.github.com/users/ecordell","html_url":"https://github.com/ecordell","followers_url":"https://api.github.com/users/ecordell/followers","following_url":"https://api.github.com/users/ecordell/following{/other_user}","gists_url":"https://api.github.com/users/ecordell/gists{/gist_id}","starred_url":"https://api.github.com/users/ecordell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ecordell/subscriptions","organizations_url":"https://api.github.com/users/ecordell/orgs","repos_url":"https://api.github.com/users/ecordell/repos","events_url":"https://api.github.com/users/ecordell/events{/privacy}","received_events_url":"https://api.github.com/users/ecordell/received_events","type":"User","site_admin":false},"created_at":"2015-02-21T17:49:35Z","updated_at":"2015-02-21T17:49:35Z","body":"The code looks great and I appreciate the solid tests along with it.\r\n\r\n> If nothing matched, by specification, api-mock returns the last defined response.\r\n\r\nCan you explain the reasoning behind this? I'm not sure why this would be a desirable default behavior (and in particular I'm having trouble seeing how it helps \"create a feature-rich, scenario-based API mock\"). "}}