-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug on Actions returning void #113
Comments
Hi @cbordeman, I don't think one should use ResponseType with void. Rather use concrete types. |
I've also encountered this issue. The auto generated Web API controller methods for PUT actions are decorated with [ResponseType(typeof(void))] by default when you create them based on an EF model. How should the below (auto generated) method be changed to resolve this?
|
As Del says, Visual Studio populates void in automatically generated webapi controllers. Del, I suppose you could create a public class Void {} and use that instead. I'd much rather see the T4 adjusted though. Del, you may want to check out NSwagStudio if this doesn't work. |
I see. In this case it make sense for the T4 logic to be updated. Technically this should return an |
When an action in the REST service returns void ([ResponseType(typeof(void))] on the action), the C# T4 template CSharpProxyTemplate.tt generates the line:
return result.Content.ReadAsAsync<void>().Result;
...in the generated proxy C# source. Obviously, that doesn't compile!
Essentially the T4 template variable "concreteReturnType" needs to be checked for void and a) the method return type and b) the return statement modified. I haven't inspected the entire template.
Chris Bordeman
The text was updated successfully, but these errors were encountered: