JsonSchemaConfig

open class JsonSchemaConfig(val respectDefaultPresence: Boolean = false, val requireNullableFields: Boolean = true, val useUnionTypes: Boolean = true, val useNullableField: Boolean = false, val includeDiscriminator: 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
trueignoredUse introspector's DefaultPresence (fields with defaults are optional)
falsetrueAll fields required (including nullables) - strict mode
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 = false, requireNullableFields: Boolean = true, useUnionTypes: Boolean = true, useNullableField: Boolean = false, includeDiscriminator: 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 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.