Back to Scalar

C#

documentation/guides/sdks/configuration/csharp.md

latest4.8 KB
Original Source

C#

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

yml
csharp:
  version: 1.2.3
  author: "Author Name"
  packageName: "custom-sdk"
  dotnetVersion: "net8.0"
NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
packageNametrueopenapiThe NuGet package ID, also used as the root namespace
authortrueSpeakeasyThe name of the author of the published package.
dotnetVersionfalsedotnetVersionThe version of .NET to target. net8.0 (default), net6.0 and net5.0 supported.

Publishing configuration

yml
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.

Additional dependencies

yml
csharp:
  additionalDependencies:
    - package: Newtonsoft.Json
      version: 13.0.3
NameRequiredDefault ValueDescription
additionalDependenciesfalse[]Add additional dependencies to include in the generated .csproj file. Dependencies must be specified as objects with package and version properties.

Method and parameter management

yml
csharp:
  maxMethodParams: 4
NameRequiredDefault ValueDescription
maxMethodParamsfalse4Maximum number of parameters before an input object is created. 0 means input objects are always used.

Security configuration

yml
csharp:
  flattenGlobalSecurity: true
PropertyDescriptionTypeDefault
flattenGlobalSecurityEnables inline security credentials during SDK instantiation. Recommended: truebooleantrue

Module management

yml
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

yml
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, and 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 the SDK includes support for webhooks.

Error and response handling

yml
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.