Skip to content

CSharpControllerGenerator

Scott Kaye edited this page Nov 25, 2020 · 2 revisions

Generates Web API/ASP.NET Core controllers from a Swagger/OpenAPI specification.

ASP.NET Core

To generate ASP.NET Core controllers set:

ControllerTarget = CSharpControllerTarget.AspNetCore
ControllerBaseClass = "Microsoft.AspNetCore.Mvc.Controller"

CLI example

dotnet "/.../dotnet-nswag.dll" openapi2cscontroller /input:https://somewhere.com/swagger.yaml /classname:MyResource /namespace:Com.Example.MyResource /output:Controllers/ResourceController.cs /UseLiquidTemplates:true /AspNetNamespace:"Microsoft.AspNetCore.Mvc" /ControllerBaseClass:"Microsoft.AspNetCore.Mvc.Controller"