DiscriminatorBuilder
Builder for Discriminator.
Configures a discriminator for efficient polymorphic type resolution. The discriminator identifies which schema applies based on a property value.
This class is part of the JSON Schema DSL and cannot be instantiated directly. Use within OneOfPropertyBuilder.discriminator context.
Example with references
oneOf {
discriminator("type") {
"dog" mappedTo "#/definitions/Dog"
"cat" mappedTo "#/definitions/Cat"
}
// References are added automatically
}Content copied to clipboard
Example with inline schemas
oneOf {
discriminator("paymentType") {
"credit_card" mappedTo {
property("type") { string { constValue = "credit_card" } }
property("cardNumber") { string() }
}
"paypal" mappedTo {
property("type") { string { constValue = "paypal" } }
property("email") { string { format = "email" } }
}
}
}Content copied to clipboard