Skip to content

Instantly share code, notes, and snippets.

@nordinrahman
Created May 31, 2017 15:42
Show Gist options
  • Select an option

  • Save nordinrahman/51eeecba2d0463d2194d41f4d612f92e to your computer and use it in GitHub Desktop.

Select an option

Save nordinrahman/51eeecba2d0463d2194d41f4d612f92e to your computer and use it in GitHub Desktop.
Command line for nswag
NSwag command line tool for .NET 4.6+, toolchain v10.6.6324.28497 (NJsonSchema v8.33.6323.36213) (x64)
Visit http://NSwag.org for more information.
NSwag bin directory: C:\@App\NSwag
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: types2swagger
Arguments:
Assembly
The path to the Web API .NET assembly.
ClassNames
The class names.
AssemblyConfig
The path to the assembly App.config or Web.config (optional).
ReferencePaths
The paths to search for referenced assembly files.
DefaultPropertyNameHandling
The default property name handling ('Default' or 'CamelCase').
DefaultEnumHandling
The default enum handling ('String' or 'Integer'), default: Integer.
FlattenInheritanceHierarchy
Flatten the inheritance hierarchy instead of using allOf to describe inheritance (default: false).
GenerateKnownTypes
Generate schemas for types in KnownTypeAttribute attributes (default: true).
GenerateXmlObjects
Generate xmlObject representation for definitions (default: false).
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: webapi2swagger
Generates a Swagger specification for a controller or controlles contained in a .NET Web API assembly.
Arguments:
Assembly
The path or paths to the Web API .NET assemblies (comma separated).
AssemblyConfig
The path to the assembly App.config or Web.config (optional).
ReferencePaths
The paths to search for referenced assembly files (comma separated).
AspNetCore
Specifies whether the controllers are hosted by ASP.NET Core.
Controller
The Web API controller full class name or empty to load all controllers from the assembly.
Controllers
The Web API controller full class names or empty to load all controllers from the assembly (comma separated).
DefaultUrlTemplate
The Web API default URL template (default: 'api/{controller}/{id}').
DefaultPropertyNameHandling
The default property name handling ('Default' or 'CamelCase').
DefaultEnumHandling
The default enum handling ('String' or 'Integer'), default: Integer.
FlattenInheritanceHierarchy
Flatten the inheritance hierarchy instead of using allOf to describe inheritance (default: false).
GenerateKnownTypes
Generate schemas for types in KnownTypeAttribute attributes (default: true).
GenerateXmlObjects
Generate xmlObject representation for definitions (default: false).
AddMissingPathParameters
Specifies whether to add path parameters which are missing in the action method (default: true).
ServiceHost
Overrides the service host of the web service (optional, use '.' to remove the hostname).
ServiceBasePath
The basePath of the Swagger specification (optional).
ServiceSchemes
Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
InfoTitle
Specify the title of the Swagger specification.
InfoDescription
Specify the description of the Swagger specification.
InfoVersion
Specify the version of the Swagger specification (default: 1.0.0).
DocumentTemplate
Specifies the Swagger document template (may be a path or JSON, default: none).
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: new
Creates a new nswag.json file in the current directory.
Arguments:
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: run
Executes an .nswag file. If 'input' is not specified then all *.nswag files and the nswag.json file is executed.
Arguments:
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: jsonschema2csclient
Generates CSharp classes from a JSON Schema.
Arguments:
Name
The class name of the root schema.
Namespace
The namespace of the generated classes.
RequiredPropertiesMustBeDefined
Specifies whether a required property must be defined in JSON (sets Required.Always when the property is required).
DateTimeType
The date time .NET type (default: 'DateTime').
ArrayType
The generic array .NET type (default: 'ObservableCollection').
DictionaryType
The generic dictionary .NET type (default: 'Dictionary').
Input
A file path or URL to the data or the JSON data itself.
ServiceHost
Overrides the service host of the web document (optional, use '.' to remove the hostname).
ServiceSchemes
Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: jsonschema2tsclient
Generates TypeScript interfaces from a JSON Schema.
Arguments:
Name
The type name of the root schema.
Input
A file path or URL to the data or the JSON data itself.
ServiceHost
Overrides the service host of the web document (optional, use '.' to remove the hostname).
ServiceSchemes
Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: swagger2csclient
Generates CSharp client code from a Swagger specification.
Arguments:
ClientBaseClass
The client base class (empty for no base class).
ConfigurationClass
The configuration class. The setting ClientBaseClass must be set. (empty for no configuration class).
GenerateClientClasses
Specifies whether generate client classes.
GenerateClientInterfaces
Specifies whether generate interfaces for the client classes.
GenerateDtoTypes
Specifies whether to generate DTO classes.
InjectHttpClient
Specifies whether an HttpClient instance is injected.
DisposeHttpClient
Specifies whether to dispose the HttpClient (injected HttpClient is never disposed).
ProtectedMethods
List of methods with a protected access modifier ('classname.methodname').
GenerateExceptionClasses
Specifies whether to generate exception classes (default: true).
ExceptionClass
The exception class (default 'SwaggerException', may use '{controller}' placeholder).
WrapDtoExceptions
Specifies whether DTO exceptions are wrapped in a SwaggerException instance (default: true).
UseHttpClientCreationMethod
Specifies whether to call CreateHttpClientAsync on the base class to create a new HttpClient.
HttpClientType
Specifies the HttpClient type. By default the 'System.Net.Http.HttpClient' is used.
UseHttpRequestMessageCreationMethod
Specifies whether to call CreateHttpRequestMessageAsync on the base class to create a new HttpRequestMethod.
UseBaseUrl
Specifies whether to use and expose the base URL (default: true).
GenerateSyncMethods
Specifies whether to generate synchronous methods (not recommended, default: false).
JsonConverters
Specifies the custom Json.NET converter types (optional, comma separated).
ClientClassAccessModifier
The client class access modifier (default: public).
GenerateContractsOutput
Specifies whether to generate contracts output (interface and models in a separate file set with the ContractsOutput parameter).
ContractsNamespace
The contracts .NET namespace.
ContractsOutput
The contracts output file path (optional, if no path is set then a single file with the implementation and contracts is generated).
ClassName
The class name of the generated client.
Namespace
The namespace of the generated classes.
AdditionalNamespaceUsages
The additional namespace usages.
GenerateOptionalParameters
Specifies whether to reorder parameters (required first, optional at the end) and generate optional parameters (default: false).
RequiredPropertiesMustBeDefined
Specifies whether a required property must be defined in JSON (sets Required.Always when the property is required).
DateType
The date .NET type (default: 'DateTime').
DateTimeType
The date time .NET type (default: 'DateTime').
TimeType
The time .NET type (default: 'TimeSpan').
TimeSpanType
The time span .NET type (default: 'TimeSpan').
ArrayType
The generic array .NET type (default: 'ObservableCollection').
DictionaryType
The generic dictionary .NET type (default: 'Dictionary').
ClassStyle
The CSharp class style, 'Poco' or 'Inpc' (default: 'Inpc').
OperationGenerationMode
The operation generation mode ('SingleClientFromOperationId' or 'MultipleClientsFromPathSegments').
GenerateDefaultValues
Specifies whether to generate default values for properties (may generate CSharp 6 code, default: true).
GenerateDataAnnotations
Specifies whether to generate data annotation attributes on DTO classes (default: true).
ExcludedTypeNames
The excluded DTO type names (must be defined in an import or other namespace).
WrapResponses
Specifies whether to wrap success responses to allow full response access (experimental).
GenerateResponseClasses
Specifies whether to generate response classes (default: true).
ResponseClass
The response class (default 'SwaggerResponse', may use '{controller}' placeholder).
HandleReferences
Use preserve references handling (All) in the JSON serializer (default: false).
GenerateImmutableArrayProperties
Specifies whether to remove the setter for non-nullable array properties (default: false).
GenerateImmutableDictionaryProperties
Specifies whether to remove the setter for non-nullable dictionary properties (default: false).
Input
A file path or URL to the data or the JSON data itself.
ServiceHost
Overrides the service host of the web document (optional, use '.' to remove the hostname).
ServiceSchemes
Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: swagger2cscontroller
Generates CSharp Web API controller code from a Swagger specification.
Arguments:
ControllerBaseClass
The controller base class (empty for 'ApiController').
ClassName
The class name of the generated client.
Namespace
The namespace of the generated classes.
AdditionalNamespaceUsages
The additional namespace usages.
GenerateOptionalParameters
Specifies whether to reorder parameters (required first, optional at the end) and generate optional parameters (default: false).
RequiredPropertiesMustBeDefined
Specifies whether a required property must be defined in JSON (sets Required.Always when the property is required).
DateType
The date .NET type (default: 'DateTime').
DateTimeType
The date time .NET type (default: 'DateTime').
TimeType
The time .NET type (default: 'TimeSpan').
TimeSpanType
The time span .NET type (default: 'TimeSpan').
ArrayType
The generic array .NET type (default: 'ObservableCollection').
DictionaryType
The generic dictionary .NET type (default: 'Dictionary').
ClassStyle
The CSharp class style, 'Poco' or 'Inpc' (default: 'Inpc').
OperationGenerationMode
The operation generation mode ('SingleClientFromOperationId' or 'MultipleClientsFromPathSegments').
GenerateDefaultValues
Specifies whether to generate default values for properties (may generate CSharp 6 code, default: true).
GenerateDataAnnotations
Specifies whether to generate data annotation attributes on DTO classes (default: true).
ExcludedTypeNames
The excluded DTO type names (must be defined in an import or other namespace).
WrapResponses
Specifies whether to wrap success responses to allow full response access (experimental).
GenerateResponseClasses
Specifies whether to generate response classes (default: true).
ResponseClass
The response class (default 'SwaggerResponse', may use '{controller}' placeholder).
HandleReferences
Use preserve references handling (All) in the JSON serializer (default: false).
GenerateImmutableArrayProperties
Specifies whether to remove the setter for non-nullable array properties (default: false).
GenerateImmutableDictionaryProperties
Specifies whether to remove the setter for non-nullable dictionary properties (default: false).
Input
A file path or URL to the data or the JSON data itself.
ServiceHost
Overrides the service host of the web document (optional, use '.' to remove the hostname).
ServiceSchemes
Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: swagger2tsclient
Generates TypeScript client code from a Swagger specification.
Arguments:
ClassName
The class name of the generated client.
ModuleName
The TypeScript module name (default: '', no module).
Namespace
The TypeScript namespace (default: '', no namespace).
TypeScriptVersion
The target TypeScript version (default: 1.8).
Template
The type of the asynchronism handling ('JQueryCallbacks', 'JQueryPromises', 'AngularJS', 'Angular', 'Fetch', 'Aurelia').
PromiseType
The promise type ('Promise' or 'QPromise').
DateTimeType
The date time type ('Date', 'MomentJS', 'string').
NullValue
The null value used in object initializers (default 'Undefined', 'Null').
GenerateClientClasses
Specifies whether generate client classes.
GenerateClientInterfaces
Specifies whether generate interfaces for the client classes (default: false).
GenerateOptionalParameters
Specifies whether to reorder parameters (required first, optional at the end) and generate optional parameters (default: false).
WrapDtoExceptions
Specifies whether DTO exceptions are wrapped in a SwaggerException instance (default: false).
ClientBaseClass
The base class of the generated client classes (optional, must be imported or implemented in the extension code).
ProtectedMethods
List of methods with a protected access modifier ('classname.methodname').
ConfigurationClass
The configuration class. The setting ClientBaseClass must be set. (empty for no configuration class).
UseTransformOptionsMethod
Call 'transformOptions' on the base class or extension class (default: false).
UseTransformResultMethod
Call 'transformResult' on the base class or extension class (default: false).
GenerateDtoTypes
Specifies whether to generate DTO classes.
OperationGenerationMode
The operation generation mode ('SingleClientFromOperationId' or 'MultipleClientsFromPathSegments').
MarkOptionalProperties
Specifies whether to mark optional properties with ? (default: false).
GenerateCloneMethod
Specifies whether a clone() method should be generated in the DTO classes (default: false).
TypeStyle
The type style (default: Class).
ClassTypes
The type names which always generate plain TypeScript classes.
ExtendedClasses
The list of extended classes.
ExtensionCode
The extension code (string or file path).
GenerateDefaultValues
Specifies whether to generate default values for properties (default: true).
ExcludedTypeNames
The excluded DTO type names (must be defined in an import or other namespace).
HandleReferences
Handle JSON references (default: false).
GenerateConstructorInterface
Generate an class interface which is used in the constructor to initialize the class (default: true).
ImportRequiredTypes
Specifies whether required types should be imported (default: true).
BaseUrlTokenName
The token name for injecting the API base URL string (used in the Angular template, default: 'API_BASE_URL').
Input
A file path or URL to the data or the JSON data itself.
ServiceHost
Overrides the service host of the web document (optional, use '.' to remove the hostname).
ServiceSchemes
Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').
Output
The output file path (optional).
Press <enter> key for next command...
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
==================
Command: version
Prints the tool chain version.
Arguments:
Press <enter> key for next command...
Duration: 00:00:05.3669735
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment