For a project we are working on we are generating an Swagger File automatically. However at this moment we are struggling with the CORS part.
We are using the Amazon API gateway import api functionality. To use this in combination with Swagger and CORS, we have to create an additional action (operation) in our source code which allows CORS(options) for each api method (operation)! eg:
[HttpOptions]
[Route("{id}")]
[ProducesResponseType((int)HttpStatusCode.OK)]
public IActionResult UserOptions()
{
return new OkResult();
}
As you can see this makes the code a lot dirtier. this is a temporary fix, but we can not find another way. Is there any way to generate this in the swagger definition file automatically? Or how can we do this, Amazon API gateway required this (documentation: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html)