After researching, I found that CsvSchema should be written like this, specifying the model we are converting and also defining the line and column separators:
private <T> List<T> parseData(String csvData, Class<?> modelClass) {
try {
CsvMapper csvMapper = CsvMapper.builder()
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
CsvSchema schema = csvMapper.schemaFor(modelClass).withHeader().withLineSeparator("\n").withColumnSeparator(',');
return (List<T>) csvMapper
.readerFor(modelClass)
.with(schema)
.readValues(csvData)
.readAll();
} catch (IOException e) {
throw new RuntimeException("Failed to parse CSV data", e);
}
}