Aight got it, the crucial missing thing was that you have to provide this part here:
'type' => 'object'
twice; once when declaring the variable’s type, and once again when defining the possibilities. Otherwise, validation fails; so a proper example would be:
'args' => [
'data' => [
'type' => 'object',
'oneOf' => [
[
'title' => 'first_option',
'type' => 'object',
'properties' => [
'first_name' => [
'type' => 'string',
'enum' => [
'first name',
],
'required' => true
],
'last_name' => [
'type' => 'string',
'enum' => [
'last_name'
],
'required' => true
]
],
'additionalProperties' => false
],
[
'title' => 'second_option',
'type' => 'object',
'properties' => [
'age' => [
'type' => 'integer',
'minimum' => 18,
'required' => true
],
'gender' => [
'type' => 'string',
'enum' => [
'm',
'w'
],
'required' => true
],
],
'additionalProperties' => false
],
],
],
'required' => true,
'validate_callback' => 'rest_validate_request_arg',
'sanitize_callback' => 'rest_sanitize_request_arg'
]