Class JsonSchemaSet
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 type | Schema |
|---|---|
Boolean | boolean. |
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, Double | number, format float or double. |
Currency, Decimal | number: every digit converts. |
Date | A string of ISO 8601 to the second with no offset (no format: date-time has an offset). |
String, a fixed-length String | string. |
Variant | Any JSON value: the empty schema. |
Object, Scripting.Dictionary | An object of any members, or null. |
Collection | An array of any values, or null. |
| A class of the workspace | Its definition, or null. |
| Another class | null: Nothing is the only value that converts. |
| A dynamic array | An array of its elements' schema. |
| A UDT, a fixed-size array, an array of UDTs, and any other type | None (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
classModuleOfFunc<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.
referencePrefixstringWhat a reference to a definition is, before the definition's name:
#/$defs/for a schema whose$defsare 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 type | Schema |
|---|---|
Boolean | boolean. |
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, Double | number, format float or double. |
Currency, Decimal | number: every digit converts. |
Date | A string of ISO 8601 to the second with no offset (no format: date-time has an offset). |
String, a fixed-length String | string. |
Variant | Any JSON value: the empty schema. |
Object, Scripting.Dictionary | An object of any members, or null. |
Collection | An array of any values, or null. |
| A class of the workspace | Its definition, or null. |
| Another class | null: Nothing is the only value that converts. |
| A dynamic array | An array of its elements' schema. |
| A UDT, a fixed-size array, an array of UDTs, and any other type | None (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
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
declaredTypeVBTypeA 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.