Table of Contents

Class JsonSchemaSet

Namespace
RDCore.SDK.Runtime.Hosting
Assembly
RDCore.SDK.dll

The JSON Schemas (draft 2020-12, the dialect of OpenAPI 3.1) of the JSON values the declared types of a program take where a host passes arguments (Arguments) and receives a returned value (Value). Each class of the workspace that a schema reaches has one definition (Definitions), which the schemas refer to.

public sealed class JsonSchemaSet
Inheritance
JsonSchemaSet
Inherited Members

Remarks

A schema states the JSON a value of the type converts to, which is also the JSON to give a parameter of the type:

Declared typeSchema
Booleanboolean.
Byte, Integer, Long, LongLong, LongPtr, an Enum integer, from the type's least value to its greatest (an Enum is a Long, and a LongPtr a LongLong in a 64-bit environment and a Long in a 32-bit one); format int32, or int64.
Single, Doublenumber, format float or double.
Currency, Decimalnumber: every digit converts.
DateA string of ISO 8601 to the second with no offset (no format: date-time has an offset).
String, a fixed-length Stringstring.
VariantAny JSON value: the empty schema.
Object, Scripting.DictionaryAn object of any members, or null.
CollectionAn array of any values, or null.
A class of the workspaceIts definition, or null.
Another classnull: Nothing is the only value that converts.
A dynamic arrayAn array of its elements' schema.
A UDT, a fixed-size array, an array of UDTs, and any other typeNone (SchemaOf(VBType) is null): no JSON value converts to it.

The definition of a class is an object of the members its JSON has (IsWrittenToJson) and those a key gives a value (IsGivenAValueFromJson), named as the class declares them, in that order: readOnly for a member only written, writeOnly for one only given a value. A member whose type has no schema is not one of them. Other keys are allowed, since a host ignores them.

Constructors

JsonSchemaSet(Func<VBClassType, VBClassModuleSymbol?>, string)

The JSON Schemas (draft 2020-12, the dialect of OpenAPI 3.1) of the JSON values the declared types of a program take where a host passes arguments (Arguments) and receives a returned value (Value). Each class of the workspace that a schema reaches has one definition (Definitions), which the schemas refer to.

public JsonSchemaSet(Func<VBClassType, VBClassModuleSymbol?> classModuleOf, string referencePrefix = "#/$defs/")

Parameters

classModuleOf Func<VBClassType, VBClassModuleSymbol>

The class module of the program that declares a class type, with its members as the binding has them; null for a class that no module of the program declares.

referencePrefix string

What a reference to a definition is, before the definition's name: #/$defs/ for a schema whose $defs are Definitions, #/components/schemas/ for an OpenAPI document whose schemas they are.

Remarks

A schema states the JSON a value of the type converts to, which is also the JSON to give a parameter of the type:

Declared typeSchema
Booleanboolean.
Byte, Integer, Long, LongLong, LongPtr, an Enum integer, from the type's least value to its greatest (an Enum is a Long, and a LongPtr a LongLong in a 64-bit environment and a Long in a 32-bit one); format int32, or int64.
Single, Doublenumber, format float or double.
Currency, Decimalnumber: every digit converts.
DateA string of ISO 8601 to the second with no offset (no format: date-time has an offset).
String, a fixed-length Stringstring.
VariantAny JSON value: the empty schema.
Object, Scripting.DictionaryAn object of any members, or null.
CollectionAn array of any values, or null.
A class of the workspaceIts definition, or null.
Another classnull: Nothing is the only value that converts.
A dynamic arrayAn array of its elements' schema.
A UDT, a fixed-size array, an array of UDTs, and any other typeNone (SchemaOf(VBType) is null): no JSON value converts to it.

The definition of a class is an object of the members its JSON has (IsWrittenToJson) and those a key gives a value (IsGivenAValueFromJson), named as the class declares them, in that order: readOnly for a member only written, writeOnly for one only given a value. A member whose type has no schema is not one of them. Other keys are allowed, since a host ignores them.

Properties

Definitions

The definition of each class of the workspace that a schema refers to, by name, in the order the schemas reached them. The name is the class's, each character other than an ASCII letter, a digit, ., - and written (the names OpenAPI allows a component); a name that another class has already is followed by _2, _3, and so on.

public IReadOnlyDictionary<string, JsonObject> Definitions { get; }

Property Value

IReadOnlyDictionary<string, JsonObject>

Methods

SchemaOf(VBType)

The schema of the JSON values of a declared type, a new object at each call; a class it reaches is added to Definitions.

public JsonObject? SchemaOf(VBType declaredType)

Parameters

declaredType VBType

A declared type: a parameter's, a variable's, or what a function returns.

Returns

JsonObject

The schema; null for a type that no JSON value converts to.