DevOp.Toon.API
0.1.8
dotnet add package DevOp.Toon.API --version 0.1.8
NuGet\Install-Package DevOp.Toon.API -Version 0.1.8
<PackageReference Include="DevOp.Toon.API" Version="0.1.8" />
<PackageVersion Include="DevOp.Toon.API" Version="0.1.8" />
<PackageReference Include="DevOp.Toon.API" />
paket add DevOp.Toon.API --version 0.1.8
#r "nuget: DevOp.Toon.API, 0.1.8"
#:package DevOp.Toon.API@0.1.8
#addin nuget:?package=DevOp.Toon.API&version=0.1.8
#tool nuget:?package=DevOp.Toon.API&version=0.1.8
DevOp.Toon.API
DevOp.Toon.API adds ASP.NET Core MVC formatter support for TOON.
Installation
dotnet add package DevOp.Toon.API
Features
- Registers TOON MVC formatters with
AddToon(...) - Supports
text/toonandapplication/toon - Reuses
DevOp.Toonfor TOON encoding, decoding, and options - Uses
Base64Stringbyte-sequence encoding by default forbyte[],List<byte>, andIEnumerable<byte> - Allows per-request response encode overrides through
X-Toon-Option-*headers - Adds TOON media types to ASP.NET Core response compression options
Basic Usage
using DevOp.Toon.API;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddControllers()
.AddToon();
AddToon() uses the compact columnar encoder profile by default:
- ignores null or empty values
- excludes empty arrays
- uses comma delimiters
- uses one-space indentation
- keeps key folding off
- writes object arrays in columnar layout
Override only the values your API needs to change:
builder.Services
.AddControllers()
.AddToon(options =>
{
options.Encode.Indent = 2;
options.Encode.IgnoreNullOrEmpty = false;
});
Response Compression
AddToon() adds application/toon and text/toon to ASP.NET Core response compression options. The application still controls whether response compression middleware is enabled:
builder.Services.AddResponseCompression();
var app = builder.Build();
app.UseResponseCompression();
app.MapControllers();
Per-Request Response Encode Overrides
Callers can override response encoding behavior for a single request by sending request headers in the format X-Toon-Option-<OptionName>: <value>.
Example:
GET /products
Accept: application/toon
X-Toon-Option-IgnoreNullOrEmpty: true
X-Toon-Option-ExcludeEmptyArrays: true
X-Toon-Option-ObjectArrayLayout: Columnar
X-Toon-Option-ByteArrayFormat: NumericArray
X-Toon-Option-KeyFolding: off
X-Toon-Option-Delimiter: COMMA
This overlay is applied only for the current response and does not change the application's registered ToonServiceOptions.
ByteArrayFormat is useful when a response should keep compact Base64 output by default but allow callers to opt into JSON-like numeric arrays for byte[] members:
GET /files/42
Accept: application/toon
X-Toon-Option-ByteArrayFormat: NumericArray
See Documentation/PerRequestEncodeOptions.md for details.
Package Notes
DevOp.Toon.API depends on DevOp.Toon for the runtime TOON implementation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- DevOp.Toon (>= 0.2.8)
-
net8.0
- DevOp.Toon (>= 0.2.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Improves DevOp.Toon 0.2.8 integration for encode option forwarding and byte sequence handling.
- Adds ByteArrayFormat support to cloned per-request formatter encode options
- Improves ASP.NET Core TOON responses so byte[] defaults follow the DevOp.Toon Base64String behavior
- Fixes X-Toon-Option-ByteArrayFormat overrides so callers can request NumericArray output per response
- Fixes typed TOON request decoding coverage for byte[] payloads encoded as Base64 strings or numeric arrays
- Updates DevOp.Toon runtime dependency to 0.2.8