ToonOutputFormatter supports request-scoped response encode overrides through HTTP request headers.
This allows a caller to change how one response is encoded without mutating the application-wide ToonServiceOptions.
Use:
X-Toon-Option-<OptionName>: <value>
Example:
GET /products
Accept: application/toon
X-Toon-Option-IgnoreNullOrEmpty: true
X-Toon-Option-ExcludeEmptyArrays: true
X-Toon-Option-ProtocolVersion: custom-4.4
X-Toon-Option-Indent: 2
X-Toon-Option-ObjectArrayLayout: Columnar
X-Toon-Option-ByteArrayFormat: NumericArray
X-Toon-Option-KeyFolding: Off
X-Toon-Option-Delimiter: COMMA
Request X-Toon-Version labels the request body. Request X-Toon-Option-ProtocolVersion independently selects the response format. Response X-Toon-Version labels the actual TOON response. Concrete wire names are 3.0, 4.0 through 4.4, custom-legacy, and custom-4.4.
API 0.2.0 validates version headers and supplied X-Toon-Option-* headers before model binding/body consumption. Malformed, multiple, or conflicting body versions return 400; well-formed unsupported body versions return 415. Malformed response-version requests return 400; well-formed unsupported response versions return 406. Version validation errors use application/problem+json.
X-Toon-Option-Indent takes an integer width from 1 through 16; booleans and out-of-range widths return 400. This HTTP input limit is separate from trusted direct runtime configuration. API indentation defaults to two spaces when no override is supplied.
Client 0.2.0 changes ToonResponseEncodeOverrideOptions.Indent from bool? to int?. Use Indent = 2, or null to omit the override. EncodeOptions.ProtocolVersion controls outbound request bodies; ResponseEncodeOverrides.ProtocolVersion controls response selection. Invalid, unsupported, multiple, or conflicting response-version hints produce ToonClientException. An explicit decoder setting must agree with the response header. Without a header, configured decode options apply, defaulting to Auto.
Any writable public property on ToonEncodeOptions can be overridden per request, including:
ProtocolVersionIndentDelimiterKeyFoldingFlattenDepthObjectArrayLayoutByteArrayFormatIgnoreNullOrEmptyExcludeEmptyArraysByteArrayFormat is useful when the API should keep compact Base64 output by default but allow a caller to opt into numeric arrays for one response:
GET /files/42
Accept: application/toon
X-Toon-Option-ByteArrayFormat: NumericArray
options.Encode.ByteArrayFormat = ToonByteArrayFormat.Base64String; is the default, matching the DevOp.Toon runtime behavior for byte[], List<byte>, and IEnumerable<byte>This is especially useful when:
Source usage reference: DevOp.Toon.API README.