I have an ASP.NET Core Web API site, with Swagger generation and UI enabled. In order for Swagger to work (at least work automatically), the return value from the controller method must be typed. For example,
public async Task<Employee> LoadEmployee(string id)
However, I need to return custom HTTP status codes and content from this action. All the examples I've seen use the StatusCode method, or return some other object. The problem with this is then Swagger doesn't know what the return type of the action is, and so can't generate the API spec.
Is there some way (Exception, methods on controller, etc) to return the custom code/content, while keeping the signature? I've seen solutions using custom middleware, but it seems like a common enough scenario that there should be something built it.