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.3
author: "Your Name"
packageName: "custom-sdk"
dotnetVersion: "net8.0"

NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
packageNametrueopenapiThe NuGet package ID (opens in a new tab), also used as the root namespace.
authortrueSpeakeasyThe name of the author (opens in a new tab) of the published package.
dotnetVersionfalsedotnetVersionThe 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: true
enableSourceLink: true

NameRequiredDefault ValueDescription
packageTagsfalse""Space-delimited list of tags and keywords used when searching for packages on NuGet.
includeDebugSymbolsfalsefalseWhether to generate .pdb files and publish a .snupkg symbol package to NuGet.
enableSourceLinkfalsefalseWhether to produce and publish the package with Source Link. See Source Link (opens in a new tab).

Additional Dependencies


csharp:
additionalDependencies:
- "Newtonsoft.Json"
- "RestSharp"

NameRequiredDefault ValueDescription
additionalDependenciesfalse[]Specify additional dependencies to include in the generated .csproj file.

Method and Paramater Management


csharp:
maxMethodParams: 4

NameRequiredDefault ValueDescription
maxMethodParamsfalse4Maximum number of parameters before an input object is created. 0 means input objects are always used.

Security Configuratiaon


csharp:
flattenGlobalSecurity: true

PropertyDescriptionTypeDefault
flattenGlobalSecurityEnables inline security credentials during SDK instantiation. Recommended: truebooleantrue

Module Management


csharp:
sourceDirectory: "src"
disableNamespacePascalCasingApr2024: false

NameRequiredDefault ValueDescription
sourceDirectoryfalsesrcThe name of the source directory.
disableNamespacePascalCasingApr2024falsefalseWhether 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/callbacks
errors: models/errors
operations: models/operations
shared: models/components
webhooks: models/webhooks

FieldRequiredDefault ValueDescription
optionfalse"openapi"Defines the type of import strategy. Typically set to "openapi", indicating that the structure is based on the OpenAPI document.
pathsfalse{}Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from.

Import Paths

ComponentDefault ValueDescription
callbacksmodels/callbacksThe directory where callback models will be imported from.
errorsmodels/errorsThe directory where error models will be imported from.
operationsmodels/operationsThe directory where operation models (i.e., API endpoints) will be imported from.
sharedmodels/componentsThe directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec.
webhooksmodels/webhooksThe directory for webhook models, if your SDK includes support for webhooks.

Error and Response Handling


csharp:
clientServerStatusCodesAsErrors: true
responseFormat: "envelope-http"

NameRequiredDefault ValueDescription
responseFormatfalseenvelope-httpDefines how responses are structured. Options: envelope, envelope-http, or flat.
clientServerStatusCodesAsErrorsfalsetrueTreats 4XX and 5XX status codes as errors. Set to false to treat them as normal responses.