ToonClientOptions is the single configuration point for DevOp.Toon.Client. Pass a configuration callback to AddToonClient(...) to set options at registration time.
builder.Services.AddToonClient(options =>
{
// configure here
});
Options are cloned on registration so external mutations after AddToonClient(...) returns do not affect the running client.
BaseAddressoptions.BaseAddress = new Uri("https://api.example.com/");
Base URI applied to the underlying HttpClient. All relative request URIs resolve against this.
Timeoutoptions.Timeout = TimeSpan.FromSeconds(30);
HTTP client timeout. Must be greater than zero if set.
EnableCompressionoptions.EnableCompression = true; // default
When true (the default), the registered HttpClient automatically decompresses GZip and Deflate responses. On .NET 5 and later, Brotli is also included. This also causes the client to send the appropriate Accept-Encoding request headers automatically — no manual header configuration is needed.
Set to false to opt out entirely, for example when an intermediary proxy handles decompression.
EncodeOptionsoptions.EncodeOptions = new ToonEncodeOptions
{
ObjectArrayLayout = ToonObjectArrayLayout.Columnar,
KeyFolding = ToonKeyFolding.Off
};
Controls how outbound request bodies are TOON-encoded. If not set, the IToonService defaults apply.
DecodeOptionsoptions.DecodeOptions = new ToonDecodeOptions
{
Strict = true
};
Controls how inbound TOON response bodies are decoded.
ResponseEncodeOverridesoptions.ResponseEncodeOverrides = new ToonResponseEncodeOverrideOptions
{
ObjectArrayLayout = ToonObjectArrayLayout.Columnar,
KeyFolding = ToonKeyFolding.Off,
IgnoreNullOrEmpty = true,
ExcludeEmptyArrays = true
};
Sends X-Toon-Option-* headers on every request to instruct the server how to shape its TOON response. Only non-null properties produce a header.
Supported override properties:
IndentDelimiterKeyFoldingFlattenDepthObjectArrayLayoutIgnoreNullOrEmptyExcludeEmptyArraysThis works with any server running DevOp.Toon.API.
JsonSerializerOptionsoptions.JsonSerializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
Used when the response content type is JSON rather than TOON. Defaults to JsonSerializerDefaults.Web (camelCase, case-insensitive).
ToonMediaTypeoptions.ToonMediaType = ToonMediaTypes.Application; // "application/toon"
The media type sent as the request body Content-Type. Defaults to application/toon. Set to text/toon if the server requires it.
ToonClient accepts an optional ILogger<ToonClient> that is resolved automatically from the DI container when using AddToonClient(...). No additional configuration is needed — standard ILoggingBuilder setup (e.g. builder.Logging) controls the output.
Log levels used:
The client sends an Accept header with the following priority chain on every request:
| Media type | Priority |
|---|---|
application/toon |
1.0 |
text/toon |
0.9 |
application/json |
0.8 |
Responses are deserialized based on the actual response Content-Type:
IToonService decodeSystem.Text.Json deserializeToonClientExceptionNon-2xx responses throw ToonClientException regardless of content type.