I found a solution in the SMT
It seams as the AvroConverter is stricter than the JsonSchemaConverter.
In case of null values, the schema provided needs to match the null value and needs to be optional in order to pass the checks in AvroData class.
public R apply(R record) {
Struct origStruct = Requirements.requireStruct(record.value(), "flat");
Schema newSchema;
Struct targetStruct;
if (String.valueOf(origStruct.get(this.checkField)).equals(this.checkContent)) {
targetStruct = null;
newSchema = SchemaBuilder.struct().optional().build();
} else {
targetStruct = origStruct;
newSchema = targetStruct.schema();
}
return record.newRecord(
record.topic(),
record.kafkaPartition(),
record.keySchema(),
record.key(),
newSchema,
targetStruct,
record.timestamp());
}
It seems wrong to me as a final solution - but it works for the moment.