SwaggerToCSharpControllerGenerator: Generate Task<ActionResult<T>> for ASP.NET Core
See original GitHub issuePlease add an ability to generate controller actions that return ActionResult<T>
/Task<ActionResult<T>>
for ASP.NET Core.
Ref: #1386
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Controller action return types in ASP.NET Core web API
This attribute produces more descriptive response details for web API help pages generated by tools like Swagger. [ProducesResponseType] ...
Read more >The Most Complete ASP.NET Core UI Component Library
NET Core UI Component Library. Create modern cross-platform web applications with over 110+ full-featured ASP.NET Core UI components for any scenario.
Read more >Making an ASP.NET Core Website | ASP.NET Core 101 [2 of 13]
Learn more ➡️ https://learn.microsoft.com/training/paths/ aspnet - core -web-app/ Creating a dynamic website is easier than you might thing.
Read more >Build and run an ASP.NET Core app in a container
Develop, build, and debug an ASP.NET Core app in a Docker container, using Visual Studio Code.
Read more >Deploying an ASP.NET core application with Elastic Beanstalk
First, you will use the .NET Core SDK's dotnet command line tool to generate a basic .NET Core command line application, install dependencies,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I actually played around this a bit and came up with this fork: https://github.com/optuuttila/NSwag/commit/cef9ecc1693bde731a636c52173562a832e3ef6a
It results in following kind of generated code: Interface:
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<MyModel>> MyMethodAsync(string param1, string param2);
Controller:
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<MyModel>> MyMethod(string param1, string param2) { return _implementation.MyMethodAsync(param1, param2); }
Obviously the code would need to be finalized (a PR for the NJsonSchema.CodeGeneration.CSharp package), but before doing any of that I just wanted to ask whether this is anything along the lines you would accept as an PR?I believe it’s the same as with
System.Net.Http.HttpResponseMessage
for ASP.NET WebAPI which is allowed right now (https://github.com/RSuter/NSwag/blob/master/src/NSwag.CodeGeneration.CSharp/Templates/Controller.liquid#L94).It gives you a better flexibility around http status codes.