Closed ticofab closed 9 months ago
Hi Fabio, thanks for the report
That org.apache.avro.SchemaParseException
error is indeed coming from avro, not avrohugger. And it's trying to say that there's some nonsense in the schema.
Hard to tell, by eye. Luckily this test popped up, using GitHub search: https://github.com/julianpeeters/sbt-avrohugger/blob/122b9d5faea05542f1b4280a51d0e8c5436e7e55/src/test/resources/dependencies/ArrayRef.avsc#L13
So you may like to try redefining your schema, to match the format in that example
"fields" : [
{
"name": "ancestors",
"type": {
"type": "array",
"items": "common.Z"
}
}
]
Wow @julianpeeters, thank you for the pointer. I revised the schema definition and it worked. I am very thankful for your time and support 🙏
This issue might be related to the underlying Apache library rather than sbt-avrohugger (or avrohugger), I'm not sure.
Problem
I can't generate case classes for schemas that contains arrays of referenced schemas.
Reproduction steps
Using Scala 3.3.1 and sbt-avrohugger 2.8.2, and the following objects:
Package.avsc
Two other schemas reference this object:
and
The generation of case classes fails with
Notes
The generation works if the referenced object Package is a single object instead of an array, like this:
So the problem seems to lie in the generation of array of referenced objects. I am basically trying to achieve what this SO answer achieves. Tried with previous version of sbt-avrohugger and met the same problem.
Thank you for the work, the attention and the support.