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
| respectDefaultPresence | requireNullableFields | Behavior |
|---|---|---|
| true | false | Fields without defaults required; nullable fields with defaults optional |
| true | true | Fields without defaults required; nullable fields always required |
| false | true | All fields required (including nullables) |
| false | false | Only non-nullable fields required |
Nullable Type Representation
| useUnionTypes | useNullableField | Output |
|---|---|---|
| true | false | {"type": ["string", "null"]} (JSON Schema Draft 2020-12) |
| false | true | {"type": "string", "nullable": true} (legacy OpenAPI) |
| false | false | {"type": "string"} (no nullable indication) |
Author
Konstantin Pavlov
See also
Inheritors
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.