{"action":"created","issue":{"url":"https://api.github.com/repos/aws/chalice/issues/913","repository_url":"https://api.github.com/repos/aws/chalice","labels_url":"https://api.github.com/repos/aws/chalice/issues/913/labels{/name}","comments_url":"https://api.github.com/repos/aws/chalice/issues/913/comments","events_url":"https://api.github.com/repos/aws/chalice/issues/913/events","html_url":"https://github.com/aws/chalice/issues/913","id":344692628,"node_id":"MDU6SXNzdWUzNDQ2OTI2Mjg=","number":913,"title":"HTTP status code 200 hardcoded in generated Swagger","user":{"login":"cciotti","id":662561,"node_id":"MDQ6VXNlcjY2MjU2MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/662561?v=4","gravatar_id":"","url":"https://api.github.com/users/cciotti","html_url":"https://github.com/cciotti","followers_url":"https://api.github.com/users/cciotti/followers","following_url":"https://api.github.com/users/cciotti/following{/other_user}","gists_url":"https://api.github.com/users/cciotti/gists{/gist_id}","starred_url":"https://api.github.com/users/cciotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cciotti/subscriptions","organizations_url":"https://api.github.com/users/cciotti/orgs","repos_url":"https://api.github.com/users/cciotti/repos","events_url":"https://api.github.com/users/cciotti/events{/privacy}","received_events_url":"https://api.github.com/users/cciotti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-26T04:40:36Z","updated_at":"2018-08-01T06:10:38Z","closed_at":null,"author_association":"NONE","body":"I have an API Gateway method that returns a 202. Chalice allows for custom responses, so cool. However, the custom HTTP response code is ignored in the API Gateway auto-generated Swagger etc.  \r\n\r\n#### Example\r\n\r\n```python\r\nreturn Response(body=json.loads(foo), \r\n    status_code=202, \r\n    headers={'Content-Type': 'application/json'})\r\n```\r\n\r\nThe generated swagger (from the API Gateway export) has the following instead of the 202 I want there (and yes, it matters).\r\n\r\n```json\r\n\"responses\": {\r\n          \"200\": {\r\n            \"description\": \"200 response\",\r\n            \"schema\": {\r\n              \"$ref\": \"#/definitions/Empty\"\r\n            }\r\n          }\r\n        }\r\n```\r\n\r\nLooking at `_generate_precanned_responses` in [`swagger.py`](https://github.com/aws/chalice/blob/3bfbd3d6800777206198fc58d264eaee1c4f574d/chalice/deploy/swagger.py#L145) I see it's hardcoded. There are other places as well (`_add_preflight_request`, `_generate_apig_integ`).\r\n\r\nIt looks like the `Response` object is not accessible during the package/deploy phase (please let me know if I missed something). Given the custom response is specific to a route/verb combo (it is in my case but that shouldn't matter), I experimented with adding a parameter to the `@app.route`.\r\n\r\n```python\r\n@app.route(API_BASE_PATH + '/tasks', \r\n    methods=['POST'], \r\n    content_types=['application/json'], \r\n    custom_response_code=202)\r\n```\r\n\r\nI have a solution that works for me and if this is useful to the community, I can submit a PR. \r\n\r\nI'm really interested in your thoughts on this and how you might go about dealing with it.\r\n\r\nThank you."},"comment":{"url":"https://api.github.com/repos/aws/chalice/issues/comments/409460576","html_url":"https://github.com/aws/chalice/issues/913#issuecomment-409460576","issue_url":"https://api.github.com/repos/aws/chalice/issues/913","id":409460576,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTQ2MDU3Ng==","user":{"login":"wutachih","id":34287686,"node_id":"MDQ6VXNlcjM0Mjg3Njg2","avatar_url":"https://avatars1.githubusercontent.com/u/34287686?v=4","gravatar_id":"","url":"https://api.github.com/users/wutachih","html_url":"https://github.com/wutachih","followers_url":"https://api.github.com/users/wutachih/followers","following_url":"https://api.github.com/users/wutachih/following{/other_user}","gists_url":"https://api.github.com/users/wutachih/gists{/gist_id}","starred_url":"https://api.github.com/users/wutachih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wutachih/subscriptions","organizations_url":"https://api.github.com/users/wutachih/orgs","repos_url":"https://api.github.com/users/wutachih/repos","events_url":"https://api.github.com/users/wutachih/events{/privacy}","received_events_url":"https://api.github.com/users/wutachih/received_events","type":"User","site_admin":false},"created_at":"2018-08-01T06:10:38Z","updated_at":"2018-08-01T06:10:38Z","author_association":"NONE","body":"Can you share your changes in Chalice code? I would like to support a redirect."}}
{"actor":{"display_login":"wutachih"}}