in chalice/deploy/swagger.py [0:0]
def _add_preflight_request(self, cors, methods, swagger_for_path):
# type: (CORSConfig, List[str], Dict[str, Any]) -> None
methods = methods + ['OPTIONS']
allowed_methods = ','.join(methods)
response_params = {
'Access-Control-Allow-Methods': '%s' % allowed_methods
}
response_params.update(cors.get_access_control_headers())
headers = {k: {'type': 'string'} for k, _ in response_params.items()}
response_params = {'method.response.header.%s' % k: "'%s'" % v for k, v
in response_params.items()}
options_request = {
"consumes": ["application/json"],
"produces": ["application/json"],
"responses": {
"200": {
"description": "200 response",
"schema": {"$ref": "#/definitions/Empty"},
"headers": headers
}
},
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200",
"responseParameters": response_params,
}
},
"requestTemplates": {
"application/json": "{\"statusCode\": 200}"
},
"passthroughBehavior": "when_no_match",
"type": "mock",
"contentHandling": "CONVERT_TO_TEXT"
}
}
swagger_for_path['options'] = options_request