Class ValueObjectJsonSchemaGeneratorSettingsExtensions
Namespace: AdCodicem.ValueObjects.NJsonSchema
Assembly: AdCodicem.ValueObjects.NJsonSchema.dll
Wires value object support into the schema settings of NJsonSchema, on which NSwag's OpenAPI documents and Confluent's JSON serdes for the Schema Registry are built.
public static class ValueObjectJsonSchemaGeneratorSettingsExtensions
Inheritance
object ← ValueObjectJsonSchemaGeneratorSettingsExtensions
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Methods
AddValueObjects<TSettings>(TSettings)
Describes every value object as its underlying type, with the rules declared on it, in the schemas these settings generate.
public static TSettings AddValueObjects<TSettings>(this TSettings settings) where TSettings : JsonSchemaGeneratorSettings
Parameters
settings TSettings
The settings, NSwag's SchemaSettings or the ones handed to Confluent's serdes.
Returns
TSettings
The same settings, so calls can be chained.
Type Parameters
TSettings
The type of the settings: the System.Text.Json or the Newtonsoft.Json ones.
Remarks
NJsonSchema describes a value object by its public properties under System.Text.Json settings, and as a bare
string, through its type converter, under Newtonsoft.Json ones. Each value object gets one definition
instead, a component in an OpenAPI document, describing it as its underlying type with the pattern, bounds,
lengths, example and accepted values declared on it, and every use of it refers to that definition.
The schema says what the settings' serializer writes, which the settings are never changed for: the
SerializerOptions of System.Text.Json settings, as they stand when the schema is generated, a value object
they do not convert as a value being left as NJsonSchema describes it; under Newtonsoft.Json settings, the value
ValueObjectConverter writes when the type's or the settings' converter is it, and the text of its type
converter when no converter claims it; a value object written otherwise is left as NJsonSchema describes it. In an
OpenAPI or Swagger document a number is a number, whatever the options let be read from text.
A Swagger 2.0 document, which refers to no schema from a parameter, describes every value object in place. Text a
member or a parameter holds to a value object's rules with [ParsesAs] is described as that value object's
text. A type mapper of the settings keeps the application's description of the forms NJsonSchema hands it: the
value object and its nullable type for a mapper of the value object or of its generic definition, the nullable
type alone for a mapper of that type, which only Newtonsoft.Json settings consult. A member NJsonSchema's
[JsonSchemaType] or [JsonSchema] describes keeps the application's description too.
Called twice, it changes nothing more.
Exceptions
settings is null.