C# Configuration Options
This section details the available configuration options for the C# SDK. All configuration is managed in the gen.yaml
file under the csharp
section.
Version and General Configuration
csharp:version: 1.2.3author: "Your Name"packageName: "custom-sdk"dotnetVersion: "net8.0"
Name | Required | Default Value | Description |
---|---|---|---|
version | true | 0.0.1 | The current version of the SDK. |
packageName | true | openapi | The NuGet package ID (opens in a new tab), also used as the root namespace. |
author | true | Speakeasy | The name of the author (opens in a new tab) of the published package. |
dotnetVersion | false | dotnetVersion | The version (opens in a new tab) of .NET to target. net8.0 (default), net6.0 and net5.0 supported. |
Publishing
csharp:packageTags: "openapi sdk rest"includeDebugSymbols: trueenableSourceLink: true
Name | Required | Default Value | Description |
---|---|---|---|
packageTags | false | "" | Space-delimited list of tags and keywords used when searching for packages on NuGet. |
includeDebugSymbols | false | false | Whether to generate .pdb files and publish a .snupkg symbol package to NuGet. |
enableSourceLink | false | false | Whether to produce and publish the package with Source Link. See Source Link (opens in a new tab). |
Additional Dependencies
csharp:additionalDependencies:- "Newtonsoft.Json"- "RestSharp"
Name | Required | Default Value | Description |
---|---|---|---|
additionalDependencies | false | [] | Specify additional dependencies to include in the generated .csproj file. |
Method and Paramater Management
csharp:maxMethodParams: 4
Name | Required | Default Value | Description |
---|---|---|---|
maxMethodParams | false | 4 | Maximum number of parameters before an input object is created. 0 means input objects are always used. |
Security Configuratiaon
csharp:flattenGlobalSecurity: true
Property | Description | Type | Default |
---|---|---|---|
flattenGlobalSecurity | Enables inline security credentials during SDK instantiation. Recommended: true | boolean | true |
Module Management
csharp:sourceDirectory: "src"disableNamespacePascalCasingApr2024: false
Name | Required | Default Value | Description |
---|---|---|---|
sourceDirectory | false | src | The name of the source directory. |
disableNamespacePascalCasingApr2024 | false | false | Whether to disable Pascal Casing sanitization on the packageName when setting the root namespace and NuGet package ID. |
Import Management
csharp:imports:option: "openapi"paths:callbacks: models/callbackserrors: models/errorsoperations: models/operationsshared: models/componentswebhooks: models/webhooks
Field | Required | Default Value | Description |
---|---|---|---|
option | false | "openapi" | Defines the type of import strategy. Typically set to "openapi" , indicating that the structure is based on the OpenAPI document. |
paths | false | {} | Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from. |
Import Paths
Component | Default Value | Description |
---|---|---|
callbacks | models/callbacks | The directory where callback models will be imported from. |
errors | models/errors | The directory where error models will be imported from. |
operations | models/operations | The directory where operation models (i.e., API endpoints) will be imported from. |
shared | models/components | The directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec. |
webhooks | models/webhooks | The directory for webhook models, if your SDK includes support for webhooks. |
Error and Response Handling
csharp:clientServerStatusCodesAsErrors: trueresponseFormat: "envelope-http"
Name | Required | Default Value | Description |
---|---|---|---|
responseFormat | false | envelope-http | Defines how responses are structured. Options: envelope , envelope-http , or flat . |
clientServerStatusCodesAsErrors | false | true | Treats 4XX and 5XX status codes as errors. Set to false to treat them as normal responses. |