How about?

{
  "namespace": "avrò.test",
  "type": "record",
  "name": "TopObj",
  "fields": [
    {
      "name": "inner1",
      "type": {
        "name": "Inner1",
        "type": "record",
        "fields": [
          {
            "name": "value1",
            "type": "string"
          },
          {
            "name": "value2",
            "type": "string"
          }
        ]
      }
    },
    {
      "name": "inner2",
      "type": [
        {
          "type": "record",
          "name": "Inner2",
          "fields": [
            {
              "name": "value3",
              "type": "string"
            },
            {
              "name": "value4",
              "type": "string"
            }
          ]
        },
        "null"
      ]
    }
  ]
}


On Fri, Aug 21, 2015 at 3:00 PM, Teemu Kanstrén <[email protected]> wrote:

> Hello all,
>
>  I am using the Maven Avro compiler to generate Java code for my Avro
> schemas. Problem. If I have a nested record which is optional, everything
> generates OK. If the type is not optional, the generated reference is set
> to generic Object type and I cannot use it. What might I be doing wrong?
>
>  Example schema:
>
> {
>   "namespace": "avro.test",
>   "type": "record",
>   "name": "TopObj",
>   "fields": [
>     {"name": "inner1", "type": [
>       {"type": "record", "name": "Inner1",
>         "fields": [
>           {"name": "value1", "type": "string"},
>           {"name": "value2", "type": "string"}
>         ]
>       }]
>     },
>     {"name": "inner2", "type": [
>       {"type": "record", "name": "Inner2",
>         "fields": [
>           {"name": "value3", "type": "string"},
>           {"name": "value4", "type": "string"}
>          ]
>       }, "null"]
>     }
>   ]
> }
>
> Running the Avro Java code generator for this produces three classes as 
> expected: TopObj, Inner1 and Inner2. However, in TopObject, the definitions 
> are as:
>
> @Deprecated public java.lang.Object inner1;
> @Deprecated public avro.test.Inner2 inner2;
>
> If I set inner1 as optional (add the , "null" to it) the type also becomes 
> Inner1 in TopObj, which is as I would expect. But I do not want it to be 
> optional.
>
> How do I get inner1 to generate as type Inner1 in TopObj?
>
> Cheers & thanks,
>
> Teemu
>
>


-- 
--
Cheers,
Praj

Reply via email to