.NET Configuration

You can customize the behavior of the C#/.NET SDK generator in generators.yml:

generators.yml
1groups:
2 csharp-sdk:
3 generators:
4 - name: fernapi/fern-csharp-sdk
5 version: 2.1.15
6 config:
7 client_class_name: YourApiClient

SDK configuration options

additional-properties
boolean

When enabled, allows handling of additional properties not explicitly defined in the API specification. This provides flexibility for APIs that may include extra fields in responses.

base-api-exception-class-name
string

Customizes the name of the base API exception class that all API-specific exceptions will inherit from. This allows you to define a custom base exception class name for better integration with your existing error handling patterns.

base-exception-class-name
string

Specifies the name of the base exception class that all generated exceptions will inherit from. This provides a common parent class for all SDK exceptions, enabling consistent exception handling patterns.

client-class-name
string

Sets the name of the generated API client class. This determines the primary client type name that users will interact with in the generated .NET SDK.

custom-pager-name
string

Customizes the name of the pagination helper class used for handling paginated API responses. This allows you to specify a custom name that fits your naming conventions.

enable-forward-compatible-enums
boolean

When enabled, generates enum types that can handle unknown values gracefully. This allows the SDK to process new enum values that may be added to the API without breaking existing client code, improving forward compatibility.

environment-class-name
string

Specifies the name of the environment configuration class used for managing different API environments (e.g., development, staging, production).

explicit-namespaces
boolean

When enabled, generates code with explicit namespace declarations throughout the SDK. This can help avoid naming conflicts and improve code clarity in larger projects.

exported-client-class-name
string

Sets the name of the exported client class that will be used in code examples and documentation. This is useful for customizing how the client appears in generated documentation.

generate-error-types
boolean

When enabled, generates specific error type classes for different API errors. This provides strongly-typed error handling instead of using generic exception types.

generate-mock-server-tests
boolean

When enabled, generates mock server tests alongside the SDK code. This helps with testing and validation of the SDK functionality during development.

include-exception-handler
boolean

When enabled, includes built-in exception handling utilities in the generated SDK. This provides convenience methods for common error handling scenarios.

inline-path-parameters
boolean

When enabled, path parameters are included as properties in the request object instead of being passed as separate method parameters. This creates a more unified request structure where all parameters are grouped together.

namespace
string

Specifies the root namespace for all generated .NET code. This determines the namespace hierarchy that users will import when using the SDK.

package-name
string

Sets the NuGet package identifier for the generated SDK. This is used when publishing the SDK to NuGet or other package repositories.

read-only-memory-types
List<string>

Specifies a list of types that should be generated using ReadOnlyMemory<T> instead of regular arrays or collections. This can improve performance for large data transfers by reducing memory allocations.

root-client-class-access
'public' | 'internal'

Controls the access modifier for the root client class. Use ‘public’ to make the client accessible from other assemblies, or ‘internal’ to restrict access within the same assembly.

root-namespace-for-core-classes
boolean

When enabled, places core SDK classes (like base client classes and utilities) in the root namespace instead of nested namespaces. This can simplify imports for commonly used types.

use-discriminated-unions
boolean

When enabled, generates discriminated union types for API responses that can contain multiple different object types. This provides type-safe handling of polymorphic responses.