DevOp.Toon.API
0.2.0
dotnet add package DevOp.Toon.API --version 0.2.0
NuGet\Install-Package DevOp.Toon.API -Version 0.2.0
<PackageReference Include="DevOp.Toon.API" Version="0.2.0" />
<PackageVersion Include="DevOp.Toon.API" Version="0.2.0" />
<PackageReference Include="DevOp.Toon.API" />
paket add DevOp.Toon.API --version 0.2.0
#r "nuget: DevOp.Toon.API, 0.2.0"
#:package DevOp.Toon.API@0.2.0
#addin nuget:?package=DevOp.Toon.API&version=0.2.0
#tool nuget:?package=DevOp.Toon.API&version=0.2.0
DevOp.Toon.API
ASP.NET Core MVC input/output formatters for application/toon and text/toon, using the DevOp.Toon runtime. Targets .NET 8 and .NET 10.
Version scope: this guide covers API 0.2.0 with runtime 0.3.0 and Core 0.2.0.
dotnet add package DevOp.Toon.API
using DevOp.Toon.API;
using DevOp.Toon.Core;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers().AddToon(options =>
{
options.Encode.ProtocolVersion = ToonProtocolVersion.V4_4;
});
var app = builder.Build();
app.MapControllers();
app.Run();
Defaults and migration
AddToon() encodes official 4.4 with two-space indentation, comma delimiters, key folding off, and both IgnoreNullOrEmpty and ExcludeEmptyArrays false. Byte sequences use Base64String. Decoding defaults to Auto; ambiguous version-dependent input requires an explicit version hint.
The previous compact custom profile is no longer the default. Select ToonProtocolVersion.CustomLegacy to retain the legacy custom wire format, or CustomV4_4 for the new custom format with nested header groups and row/keyed spills. Both custom profiles default the two omission options to true; set both false when null, empty-string, and empty-array distinctions must be retained. Explicit option values remain effective when changing versions. Custom payloads require compatible readers at both ends.
HTTP version contract
| Header | Meaning |
|---|---|
Request X-Toon-Version: 4.4 |
Version of the request body; selects input decoding. |
Request X-Toon-Option-ProtocolVersion: custom-4.4 |
Requested version of the response; independent of the request body version. |
Response X-Toon-Version: custom-4.4 |
Actual version used for the TOON response body. |
Supported concrete wire names are 3.0, 4.0, 4.1, 4.2, 4.3, 4.4, custom-legacy, and custom-4.4. Auto is a decode policy and cannot be supplied as a wire version or used for encoding.
All supplied X-Toon-Option-* headers and version headers are validated before model binding/body consumption. Malformed, multiple, or conflicting body versions return 400; a well-formed unsupported body version returns 415. A malformed response-version request returns 400; a well-formed unsupported response version returns 406. Version validation errors use application/problem+json. A configured explicit decoder version must agree with the body header.
POST /products
Content-Type: application/toon
Accept: application/toon
X-Toon-Version: 4.4
X-Toon-Option-ProtocolVersion: custom-4.4
X-Toon-Option-Indent: 2
X-Toon-Option-IgnoreNullOrEmpty: false
X-Toon-Option-ExcludeEmptyArrays: false
X-Toon-Option-Indent is an integer number of spaces from 1 through 16; boolean values and values outside this range return 400. This HTTP input limit is separate from trusted direct runtime configuration.
Other X-Toon-Option-* headers apply response encode options only for that request. For example, X-Toon-Option-ByteArrayFormat: NumericArray selects numeric byte arrays. These overlays do not mutate the registered service options.
Compression
AddToon() adds both TOON media types to response compression options. Enable middleware in the host when compression is desired:
builder.Services.AddResponseCompression();
// After builder.Build(), before mapping controllers:
app.UseResponseCompression();
Source and further notes: DevOp.Toon.API repository.
| 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.3.0)
-
net8.0
- DevOp.Toon (>= 0.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Adds protocol-aware ASP.NET Core TOON formatting.
- Adds X-Toon-Version body metadata and independent response-version selection
- Adds pre-body validation with precise malformed, unsupported, and conflicting-version responses
- Breaking: defaults responses to official 4.4 with lossless omission settings and two-space indentation
- Fixes excessive response indentation by accepting HTTP override widths from 1 through 16
- Improves request option reuse while revalidating changed override headers
- Updates the runtime dependency to DevOp.Toon 0.3.0