<PackageReference Include="NJsonSchema" Version="10.4.0" />

JsonSchemaGenerator

public class JsonSchemaGenerator
Generates a JsonSchema object for a given type.

Gets the settings.

Initializes a new instance of the JsonSchemaGenerator class.

public virtual void ApplyDataAnnotations(JsonSchema schema, JsonTypeDescription typeDescription)

Applies the property annotations to the JSON property.

public virtual object ConvertDefaultValue(ContextualType type, object defaultValue)

Gets the actual default value for the given object (e.g. correctly converts enums).

public JsonSchema Generate(Type type)

Generates a JsonSchema object for the given type and adds the mapping to the given resolver.

public JsonSchema Generate(Type type, JsonSchemaResolver schemaResolver)

Generates a JsonSchema object for the given type and adds the mapping to the given resolver.

public TSchemaType Generate<TSchemaType>(Type type, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema

Generates a JsonSchema object for the given type and adds the mapping to the given resolver.

public JsonSchema Generate(ContextualType contextualType, JsonSchemaResolver schemaResolver)

Generates a JsonSchema object for the given type and adds the mapping to the given resolver.

public TSchemaType Generate<TSchemaType>(ContextualType contextualType, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema

Generates a JsonSchema object for the given type and adds the mapping to the given resolver.

public void Generate<TSchemaType>(TSchemaType schema, Type type, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema

Generates into the given JsonSchema object for the given type and adds the mapping to the given resolver.

public virtual void Generate<TSchemaType>(TSchemaType schema, ContextualType contextualType, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema

Generates into the given JsonSchema object for the given type and adds the mapping to the given resolver.

protected virtual void GenerateArray<TSchemaType>(TSchemaType schema, JsonTypeDescription typeDescription, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema

Generates an array in the given schema.

protected virtual void GenerateDictionary<TSchemaType>(TSchemaType schema, JsonTypeDescription typeDescription, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema

Generates an array in the given schema.

protected virtual void GenerateEnum(JsonSchema schema, JsonTypeDescription typeDescription)

Generates an enumeration in the given schema.

public virtual object GenerateExample(ContextualType type)

Generates the example from the type's xml docs.

protected virtual void GenerateObject(JsonSchema schema, JsonTypeDescription typeDescription, JsonSchemaResolver schemaResolver)

Generates the properties for the given type and schema.

public TSchemaType GenerateWithReference<TSchemaType>(ContextualType contextualType, JsonSchemaResolver schemaResolver, Action<TSchemaType, JsonSchema> transformation = null) where TSchemaType : JsonSchema

Generetes a schema directly or referenced for the requested schema type; does NOT change nullability.

public TSchemaType GenerateWithReferenceAndNullability<TSchemaType>(ContextualType contextualType, JsonSchemaResolver schemaResolver, Action<TSchemaType, JsonSchema> transformation = null) where TSchemaType : JsonSchema

Generetes a schema directly or referenced for the requested schema type; also adds nullability if required by looking at the type's JsonTypeDescription.

public virtual TSchemaType GenerateWithReferenceAndNullability<TSchemaType>(ContextualType contextualType, bool isNullable, JsonSchemaResolver schemaResolver, Action<TSchemaType, JsonSchema> transformation = null) where TSchemaType : JsonSchema

Generetes a schema directly or referenced for the requested schema type; also adds nullability if required.

public virtual string GetPropertyName(JsonProperty jsonProperty, ContextualMemberInfo contextualMember)

Gets the converted property name.

protected virtual string[] GetTypeProperties(Type type)

Gets the properties of the given type or null to take all properties.

protected virtual bool IsPropertyIgnored(ContextualMemberInfo property, Type parentType)

Checks whether a property is ignored.