mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
* removed old frameworks from csharp-netcore * removed another reference and build samples * updated readme * deprecated frameworks * fix test csproj file * update doc Co-authored-by: devhl-labs <shawnkanyer@gmail.com>
306 lines
8.5 KiB
Markdown
306 lines
8.5 KiB
Markdown
---
|
|
title: Documentation for the csharp Generator
|
|
---
|
|
|
|
## METADATA
|
|
|
|
| Property | Value | Notes |
|
|
| -------- | ----- | ----- |
|
|
| generator name | csharp | pass this to the generate command after -g |
|
|
| generator stability | STABLE | |
|
|
| generator type | CLIENT | |
|
|
| generator language | C# | |
|
|
| generator default templating engine | mustache | |
|
|
| helpTxt | Generates a CSharp client library. | |
|
|
|
|
## CONFIG OPTIONS
|
|
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
|
|
|
| Option | Description | Values | Default |
|
|
| ------ | ----------- | ------ | ------- |
|
|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|
|
|
|generatePropertyChanged|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |false|
|
|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
|
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
|
|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |PascalCase|
|
|
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|
|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|
|
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|
|
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|
|
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|
|
|packageGuid|The GUID that will be associated with the C# project| |null|
|
|
|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools|
|
|
|packageVersion|C# package version.| |1.0.0|
|
|
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|
|sourceFolder|source folder for generated code| |src|
|
|
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<dl><dt>**v3.5**</dt><dd>.NET Framework 3.5 compatible</dd><dt>**v4.0**</dt><dd>.NET Framework 4.0 compatible</dd><dt>**v4.5**</dt><dd>.NET Framework 4.5 compatible</dd><dt>**v4.5.2**</dt><dd>.NET Framework 4.5.2+ compatible</dd><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3 compatible (DEPRECATED. Please use `csharp-netcore` generator instead)</dd><dt>**uwp**</dt><dd>Universal Windows Platform (DEPRECATED. Please use `csharp-netcore` generator instead)</dd></dl>|v4.5|
|
|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|
|
|useCompareNetObjects|Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.| |false|
|
|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|
|
|validatable|Generates self-validatable models.| |true|
|
|
|
|
## IMPORT MAPPING
|
|
|
|
| Type/Alias | Imports |
|
|
| ---------- | ------- |
|
|
|
|
|
|
## INSTANTIATION TYPES
|
|
|
|
| Type/Alias | Instantiated By |
|
|
| ---------- | --------------- |
|
|
|array|List|
|
|
|list|List|
|
|
|map|Dictionary|
|
|
|
|
|
|
## LANGUAGE PRIMITIVES
|
|
|
|
<ul class="column-ul">
|
|
<li>Boolean</li>
|
|
<li>Collection</li>
|
|
<li>DateTime</li>
|
|
<li>DateTime?</li>
|
|
<li>DateTimeOffset</li>
|
|
<li>DateTimeOffset?</li>
|
|
<li>Decimal</li>
|
|
<li>Dictionary</li>
|
|
<li>Double</li>
|
|
<li>Float</li>
|
|
<li>Guid</li>
|
|
<li>Guid?</li>
|
|
<li>ICollection</li>
|
|
<li>Int32</li>
|
|
<li>Int64</li>
|
|
<li>List</li>
|
|
<li>Object</li>
|
|
<li>String</li>
|
|
<li>System.IO.Stream</li>
|
|
<li>bool</li>
|
|
<li>bool?</li>
|
|
<li>byte[]</li>
|
|
<li>decimal</li>
|
|
<li>decimal?</li>
|
|
<li>double</li>
|
|
<li>double?</li>
|
|
<li>float</li>
|
|
<li>float?</li>
|
|
<li>int</li>
|
|
<li>int?</li>
|
|
<li>long</li>
|
|
<li>long?</li>
|
|
<li>string</li>
|
|
</ul>
|
|
|
|
## RESERVED WORDS
|
|
|
|
<ul class="column-ul">
|
|
<li>Client</li>
|
|
<li>Configuration</li>
|
|
<li>Version</li>
|
|
<li>abstract</li>
|
|
<li>as</li>
|
|
<li>base</li>
|
|
<li>bool</li>
|
|
<li>break</li>
|
|
<li>byte</li>
|
|
<li>case</li>
|
|
<li>catch</li>
|
|
<li>char</li>
|
|
<li>checked</li>
|
|
<li>class</li>
|
|
<li>client</li>
|
|
<li>const</li>
|
|
<li>continue</li>
|
|
<li>decimal</li>
|
|
<li>default</li>
|
|
<li>delegate</li>
|
|
<li>do</li>
|
|
<li>double</li>
|
|
<li>else</li>
|
|
<li>enum</li>
|
|
<li>event</li>
|
|
<li>explicit</li>
|
|
<li>extern</li>
|
|
<li>false</li>
|
|
<li>finally</li>
|
|
<li>fixed</li>
|
|
<li>float</li>
|
|
<li>for</li>
|
|
<li>foreach</li>
|
|
<li>goto</li>
|
|
<li>if</li>
|
|
<li>implicit</li>
|
|
<li>in</li>
|
|
<li>int</li>
|
|
<li>interface</li>
|
|
<li>internal</li>
|
|
<li>is</li>
|
|
<li>localVarFileParams</li>
|
|
<li>localVarFormParams</li>
|
|
<li>localVarHeaderParams</li>
|
|
<li>localVarHttpContentType</li>
|
|
<li>localVarHttpContentTypes</li>
|
|
<li>localVarHttpHeaderAccept</li>
|
|
<li>localVarHttpHeaderAccepts</li>
|
|
<li>localVarPath</li>
|
|
<li>localVarPathParams</li>
|
|
<li>localVarPostBody</li>
|
|
<li>localVarQueryParams</li>
|
|
<li>localVarResponse</li>
|
|
<li>localVarStatusCode</li>
|
|
<li>lock</li>
|
|
<li>long</li>
|
|
<li>namespace</li>
|
|
<li>new</li>
|
|
<li>null</li>
|
|
<li>object</li>
|
|
<li>operator</li>
|
|
<li>out</li>
|
|
<li>override</li>
|
|
<li>parameter</li>
|
|
<li>params</li>
|
|
<li>private</li>
|
|
<li>protected</li>
|
|
<li>public</li>
|
|
<li>readonly</li>
|
|
<li>ref</li>
|
|
<li>return</li>
|
|
<li>sbyte</li>
|
|
<li>sealed</li>
|
|
<li>short</li>
|
|
<li>sizeof</li>
|
|
<li>stackalloc</li>
|
|
<li>static</li>
|
|
<li>string</li>
|
|
<li>struct</li>
|
|
<li>switch</li>
|
|
<li>this</li>
|
|
<li>throw</li>
|
|
<li>true</li>
|
|
<li>try</li>
|
|
<li>typeof</li>
|
|
<li>uint</li>
|
|
<li>ulong</li>
|
|
<li>unchecked</li>
|
|
<li>unsafe</li>
|
|
<li>ushort</li>
|
|
<li>using</li>
|
|
<li>virtual</li>
|
|
<li>void</li>
|
|
<li>volatile</li>
|
|
<li>while</li>
|
|
</ul>
|
|
|
|
## FEATURE SET
|
|
|
|
|
|
### Client Modification Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|BasePath|✓|ToolingExtension
|
|
|Authorizations|✗|ToolingExtension
|
|
|UserAgent|✓|ToolingExtension
|
|
|MockServer|✗|ToolingExtension
|
|
|
|
### Data Type Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|Custom|✗|OAS2,OAS3
|
|
|Int32|✓|OAS2,OAS3
|
|
|Int64|✓|OAS2,OAS3
|
|
|Float|✓|OAS2,OAS3
|
|
|Double|✓|OAS2,OAS3
|
|
|Decimal|✓|ToolingExtension
|
|
|String|✓|OAS2,OAS3
|
|
|Byte|✓|OAS2,OAS3
|
|
|Binary|✓|OAS2,OAS3
|
|
|Boolean|✓|OAS2,OAS3
|
|
|Date|✓|OAS2,OAS3
|
|
|DateTime|✓|OAS2,OAS3
|
|
|Password|✓|OAS2,OAS3
|
|
|File|✓|OAS2
|
|
|Array|✓|OAS2,OAS3
|
|
|Maps|✓|ToolingExtension
|
|
|CollectionFormat|✓|OAS2
|
|
|CollectionFormatMulti|✓|OAS2
|
|
|Enum|✓|OAS2,OAS3
|
|
|ArrayOfEnum|✓|ToolingExtension
|
|
|ArrayOfModel|✓|ToolingExtension
|
|
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
|
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
|
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
|
|MapOfEnum|✓|ToolingExtension
|
|
|MapOfModel|✓|ToolingExtension
|
|
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
|
|MapOfCollectionOfModel|✓|ToolingExtension
|
|
|MapOfCollectionOfEnum|✓|ToolingExtension
|
|
|
|
### Documentation Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|Readme|✓|ToolingExtension
|
|
|Model|✓|ToolingExtension
|
|
|Api|✓|ToolingExtension
|
|
|
|
### Global Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|Host|✓|OAS2,OAS3
|
|
|BasePath|✓|OAS2,OAS3
|
|
|Info|✓|OAS2,OAS3
|
|
|Schemes|✗|OAS2,OAS3
|
|
|PartialSchemes|✓|OAS2,OAS3
|
|
|Consumes|✓|OAS2
|
|
|Produces|✓|OAS2
|
|
|ExternalDocumentation|✓|OAS2,OAS3
|
|
|Examples|✓|OAS2,OAS3
|
|
|XMLStructureDefinitions|✗|OAS2,OAS3
|
|
|MultiServer|✗|OAS3
|
|
|ParameterizedServer|✗|OAS3
|
|
|ParameterStyling|✗|OAS3
|
|
|Callbacks|✗|OAS3
|
|
|LinkObjects|✗|OAS3
|
|
|
|
### Parameter Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|Path|✓|OAS2,OAS3
|
|
|Query|✓|OAS2,OAS3
|
|
|Header|✓|OAS2,OAS3
|
|
|Body|✓|OAS2
|
|
|FormUnencoded|✓|OAS2
|
|
|FormMultipart|✓|OAS2
|
|
|Cookie|✗|OAS3
|
|
|
|
### Schema Support Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|Simple|✓|OAS2,OAS3
|
|
|Composite|✓|OAS2,OAS3
|
|
|Polymorphism|✓|OAS2,OAS3
|
|
|Union|✗|OAS3
|
|
|
|
### Security Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|BasicAuth|✓|OAS2,OAS3
|
|
|ApiKey|✓|OAS2,OAS3
|
|
|OpenIDConnect|✗|OAS3
|
|
|BearerToken|✗|OAS3
|
|
|OAuth2_Implicit|✓|OAS2,OAS3
|
|
|OAuth2_Password|✗|OAS2,OAS3
|
|
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
|
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
|
|
|
### Wire Format Feature
|
|
| Name | Supported | Defined By |
|
|
| ---- | --------- | ---------- |
|
|
|JSON|✓|OAS2,OAS3
|
|
|XML|✓|OAS2,OAS3
|
|
|PROTOBUF|✗|ToolingExtension
|
|
|Custom|✗|OAS2,OAS3
|