{"action":"closed","issue":{"url":"https://api.github.com/repos/apiaryio/api-blueprint/issues/132","labels_url":"https://api.github.com/repos/apiaryio/api-blueprint/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/apiaryio/api-blueprint/issues/132/comments","events_url":"https://api.github.com/repos/apiaryio/api-blueprint/issues/132/events","html_url":"https://github.com/apiaryio/api-blueprint/issues/132","id":47169159,"number":132,"title":"Multiple requests and responses with same status code and different parameters","user":{"login":"netmilk","id":79609,"avatar_url":"https://avatars.githubusercontent.com/u/79609?v=3","gravatar_id":"","url":"https://api.github.com/users/netmilk","html_url":"https://github.com/netmilk","followers_url":"https://api.github.com/users/netmilk/followers","following_url":"https://api.github.com/users/netmilk/following{/other_user}","gists_url":"https://api.github.com/users/netmilk/gists{/gist_id}","starred_url":"https://api.github.com/users/netmilk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netmilk/subscriptions","organizations_url":"https://api.github.com/users/netmilk/orgs","repos_url":"https://api.github.com/users/netmilk/repos","events_url":"https://api.github.com/users/netmilk/events{/privacy}","received_events_url":"https://api.github.com/users/netmilk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/apiaryio/api-blueprint/labels/feature","name":"feature","color":"3C7ABD"},{"url":"https://api.github.com/repos/apiaryio/api-blueprint/labels/testing","name":"testing","color":"9E6D41"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2014-10-29T16:19:05Z","updated_at":"2015-05-01T18:35:48Z","closed_at":"2015-05-01T18:35:48Z","body":"At this moment API blueprint does not support multiple examples (request and response pairs) for invoking different behavior on same action with same status code for testing and specifying non optimistic or corner API behavior. For full support of this feature in blueprint we need at least one of following blueprint extensions:\r\n\r\n- Possibility to specify parameters for both request and response.\r\n- Multiple named examples under one resource action (explicit pairs?)\r\n- Non-unique status codes for responses (or distinguished by name)\r\n\r\n\r\nExample:\r\n```\r\n# Machine member [/machines{/id}{?fields}]\r\n\r\n+ Parameters\r\n  + id (required, number, `1`) ... Machine identificator\r\n  + fields (optional, string) ... Comma separated list of fields included in response\r\n  + include (optional, stirng) ... Comma separated list of embedded relate objects\r\n\r\n## Retreive a machine [GET]\r\n\r\n+ Response (200)\r\n\r\n    {\r\n      \"name\": \"waldo\",\r\n      \"type\": \"bulldozer\",\r\n      \"createdAt\": \"Wed Oct 27 16:32:27 CET 2014\"\r\n    }\r\n\r\n\r\n+ Response filtered parameters (200)\r\n  + Parameters\r\n    + fields = `name`\r\n\r\n  + Body\r\n        {\r\n          \"name\": \"waldo\"\r\n        }  \r\n\r\n+ Response embedded objects (200)\r\n  + Parameters\r\n    + fields = `name`\r\n    + include = `owner, type`\r\n  \r\n  + Body\r\n        {\r\n          \"name\": \"waldo'\r\n          \"type\": {\r\n            \"name\": \"buldozer\"\r\n          },\r\n          \"owner\": {\r\n            \"nane\": \"Adam Kliment\",\r\n            \"nick\": \"netmilk\"\r\n          }\r\n        }\r\n\r\n+ Response (404)\r\n  + Parameters\r\n    + id = `999`\r\n  \r\n  + Body\r\n            {\r\n              \"message\": \"Document not found\"\r\n            }\r\n```\r\n\r\nAs a workaround in Dredd, I propose to allow user be able to programatically create new named [transaction example](https://github.com/apiaryio/api-blueprint-ast#transaction-example) under same resource action in the AST. Action will be flagged in the AST and it will be highlighted in Dredd results to distinguish between actions is coming from AST and manually created. \r\n\r\n```coffee\r\nast = require 'ast'\r\n\r\nast.newExample \"Machines > Machine > Update a Machine\", \"New example name\", (newExample) ->\r\n    newExample.parameters = \r\n      id: 2000\r\n\r\n    newExample.request =\r\n      headers:\r\n        \"Content-Type\": 'application/json'\r\n      body: \"{ \\\"name\\\": \\\"waldo\\\"}\"\r\n    \r\n    newExample.response =\r\n      status: 400\r\n      headers:\r\n        \"Content-Type\": 'applicaiton/json'\r\n      body: \"{ \\\"message\\\": \\\"Rejected, can't update name\\\"}\"\r\n```\r\n\r\nOr user will can be allowed to load data stored in another blueprint:\r\n\r\n```coffee\r\nast.newExample \"Machines > Machine > Update a Machine\", \"New example name\", (newExample) ->\r\n  ast.newExample = loadFromBlueprint \"./storage/bad_params.md\" \"Machines > Machine > Update a Machine with invalid data\"\r\n```"}}