JsonSchemaConfig

open class JsonSchemaConfig(val respectDefaultPresence: Boolean = true, val requireNullableFields: Boolean = false, val useUnionTypes: Boolean = true, val useNullableField: Boolean = false, val includePolymorphicDiscriminator: Boolean = true, val includeOpenAPIPolymorphicDiscriminator: Boolean = false)(source)

Configuration for JSON Schema transformers.

Controls schema generation behavior with individual flags for nullable handling and required field handling. Use the Strict preset for full JSON Schema Draft 2020-12 compliance.

Configuration Flags

Required Field Behavior

respectDefaultPresencerequireNullableFieldsBehavior
truefalseFields without defaults required; nullable fields with defaults optional
truetrueFields without defaults required; nullable fields always required
falsetrueAll fields required (including nullables)
falsefalseOnly non-nullable fields required

Nullable Type Representation

useUnionTypesuseNullableFieldOutput
truefalse{"type": ["string", "null"]} (JSON Schema Draft 2020-12)
falsetrue{"type": "string", "nullable": true} (legacy OpenAPI)
falsefalse{"type": "string"} (no nullable indication)

Author

Konstantin Pavlov

See also

Inheritors

Constructors

Link copied to clipboard
constructor(respectDefaultPresence: Boolean = true, requireNullableFields: Boolean = false, useUnionTypes: Boolean = true, useNullableField: Boolean = false, includePolymorphicDiscriminator: Boolean = true, includeOpenAPIPolymorphicDiscriminator: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Whether to include discriminator in polymorphic schemas.

Link copied to clipboard

Whether to include a type discriminator field in polymorphic schemas.

Link copied to clipboard

Whether nullable fields must be present in JSON.

Link copied to clipboard

Whether to use hasDefaultValue from introspector to determine required fields.

Link copied to clipboard

Whether to emit the nullable field for nullable types.

Link copied to clipboard

Whether to use union types for nullable fields.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String