Schema Module
Helpers for building explicit schemas and reusing common built-in shapes. This is the main authoring surface for `CodecMapper`. Build a `Schema<'T>` once, then compile it into JSON or XML codecs.
Types
| Type | Description |
|
Represents one explicit case in a tagged-union schema. |
Functions and values
| Function or value |
Description
|
|
|
A schema for `bool`.
|
|
|
|
A schema for `byte`.
|
|
A schema for `char` backed by a single-character string.
|
|
Full Usage:
collection inner
Parameters:
Schema<'T>
Returns: Schema<ICollection<'T>>
Modifiers: inline Type parameters: 'T |
Builds a schema for `ICollection<'T>`. This preserves the normal array wire shape while interoperating with common mutable collection interfaces from .NET APIs.
|
|
|
Full Usage:
create def
Parameters:
SchemaDefinition
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Creates a schema from a raw structural definition. This is public for advanced integrations, but most callers should prefer the higher-level helpers in this module.
|
|
A schema for `DateTimeOffset` using the round-trippable `"O"` string format.
|
A schema for `decimal`.
|
|
Pipeline DSL helpers. The pipeline starts by capturing the curried constructor up front so subsequent field steps only describe the wire layout. We still ask for `'T` explicitly because relying on field-label inference alone becomes brittle as soon as multiple record types share names like `Id` or `Name`. Starts a pipeline schema definition for `'T`.
|
|
|
|
|
|
|
|
Full Usage:
envelope cases
Parameters:
TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds a message envelope using `type` and `data` as the default field names.
|
Full Usage:
envelopeNamed discriminatorName valueName cases
Parameters:
string
valueName : string
cases : TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds a message envelope with custom discriminator and payload field names.
|
|
|
|
|
A schema for `float`.
|
|
Full Usage:
formatFloat value
Parameters:
float
Returns: string
|
Keep the .NET path using round-trip float formatting, but let Fable use the host number string form instead of rejecting the `"R"` specifier.
|
Full Usage:
inlineEnvelope cases
Parameters:
TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds an inline message envelope using `type` as the default discriminator field name.
|
Full Usage:
inlineEnvelopeNamed discriminatorName cases
Parameters:
string
cases : TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds an inline message envelope with a custom discriminator field name.
|
Full Usage:
inlineUnion cases
Parameters:
TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds an explicit tagged-union schema that inlines payload fields next to the discriminator.
|
Full Usage:
inlineUnionNamed discriminatorName cases
Parameters:
string
cases : TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds an explicit tagged-union schema with a custom inline discriminator field name.
|
A schema for `int`.
|
|
A schema for `int16`.
|
|
A schema for `int64`.
|
|
|
|
|
|
Full Usage:
message name value matches
Parameters:
string
value : 'T
matches : 'T -> bool
Returns: TaggedCase<'T>
Modifiers: inline Type parameters: 'T |
Creates a message tag with no payload for envelope-style contracts.
|
Full Usage:
messageWith name project inject schema
Parameters:
string
project : 'T -> 'Field option
inject : 'Field -> 'T
schema : Schema<'Field>
Returns: TaggedCase<'T>
Modifiers: inline Type parameters: 'T, 'Field |
Creates a message tag with a payload for envelope-style contracts.
|
|
|
|
|
|
|
|
Empty strings are often accidental placeholders rather than meaningful values. This helper keeps that validation explicit and reusable.
|
|
|
|
|
|
Positive identifiers and counters are a common wire-level constraint, and `tryMap` keeps that rule opt-in rather than global.
|
Full Usage:
readOnlyList inner
Parameters:
Schema<'T>
Returns: Schema<IReadOnlyList<'T>>
Modifiers: inline Type parameters: 'T |
Builds a schema for `IReadOnlyList<'T>`. Keep the wire form identical to arrays while still allowing .NET-facing APIs to expose read-only collection interfaces.
|
|
|
|
|
A schema for `sbyte`.
|
|
A schema for `string`.
|
|
Full Usage:
stringEnum cases
Parameters:
(string * 'T) list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds a finite string-valued contract for a small set of named cases. This keeps the wire shape explicit as strings while still compiling to strongly typed values and exporting a JSON Schema `enum`.
|
Full Usage:
stringEnumNamed _enumName cases
Parameters:
string
cases : (string * 'T) list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds a finite string-valued contract while keeping a domain-level name available at the call site for readability.
|
Full Usage:
tag name value matches
Parameters:
string
value : 'T
matches : 'T -> bool
Returns: TaggedCase<'T>
Modifiers: inline Type parameters: 'T |
Creates a tag with no payload.
|
Full Usage:
tagWith name project inject schema
Parameters:
string
project : 'T -> 'Field option
inject : 'Field -> 'T
schema : Schema<'Field>
Returns: TaggedCase<'T>
Modifiers: inline Type parameters: 'T, 'Field |
Creates a tag with a payload value.
|
|
Some contracts normalize surrounding whitespace at the boundary rather than making every caller remember to trim before encode and after decode.
|
|
|
A schema for `uint16`.
|
|
A schema for `uint32`.
|
|
A schema for `uint64`.
|
|
Full Usage:
union cases
Parameters:
TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds an explicit tagged-union schema using default wire field names.
|
Full Usage:
unionNamed discriminatorName valueName cases
Parameters:
string
valueName : string
cases : TaggedCase<'T> list
Returns: Schema<'T>
Modifiers: inline Type parameters: 'T |
Builds an explicit tagged-union schema with custom wire field names.
|
CodecMapper