Skip to content

CommandLine

Rico Suter edited this page May 29, 2016 · 97 revisions

To use the command line tools, either download the latest command line tools or use the NSwag.MSBuild NuGet package.

To see all available command line commands and parameters, start the command line application "NSwag.exe" without parameters and enter "help" as command. All "input" parameter accept file paths, URLs and JSON data.

Swagger Generators

Generate Swagger specification from a Web API controller in a .NET assembly, see WebApiToSwaggerGenerator for more information:

nswag webapi2swagger /assembly:MyWebApiAssembly.dll 
                     /controller:MyNamespace.MyController 
                     /output:MyWebService.json

To generate a single Swagger specification for all controllers in the assembly, just call the command without the controller parameter:

nswag webapi2swagger /assembly:MyWebApiAssembly.dll 
                     /output:MyWebService.json

WebApiToSwaggerCommand.cs

Client Generators

Generate TypeScript client code from a Swagger specifiation, see SwaggerToTypeScriptClientGenerator for more information:

nswag swagger2tsclient /input:MyWebService.json 
                       /output:MyModule.ts

SwaggerToTypeScriptClientCommand.cs

Generate C# client code from a Swagger specifiation, see SwaggerToCSharpClientGenerator:

nswag swagger2csclient /input:MyWebService.json 
                       /classname:MyServiceClient 
                       /namespace:MyNamespace
                       /output:MyServiceClient.cs

SwaggerToCSharpClientCommand.cs

JSON Schema converters

Generate C# classes from a JSON Schema:

nswag jsonschema2csclient /input:JsonSchema.json 
                          /output:MyClasses.cs

JsonSchemaToCSharpCommand.cs

Generate TypeScript interfaces from a JSON Schema:

nswag jsonschema2tsclient /input:JsonSchema.json 
                          /output:MyInterfaces.ts

JsonSchemaToTypeScriptCommand.cs

Clone this wiki locally