Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDL not exporting types for array of union #243

Open
johnykov opened this issue Jun 19, 2023 · 1 comment
Open

IDL not exporting types for array of union #243

johnykov opened this issue Jun 19, 2023 · 1 comment

Comments

@johnykov
Copy link

Hi, I appreciate your hard work on this library and find it helpful! Great job, thank you.
I don't know if this is on purpose or just lacking functionality but when converting IDL to Avro Json notation I've noticed that I'm missing some types. They get lost somewhere along the way.
For example, having IDL Avro file:

@namespace("com.org.domain.fixtures")
protocol ImportProto {
	record Single {
		string foo;
	}

	record Double {
		string bar;
	}

	record Import {
		array<union{Double, Single}> imports;
	}
}

I get following Avro Schema in the result:

{
  "namespace": "com.org.domain.fixtures",
  "type": "record",
  "name": "Import",
  "fields": [
    {
      "type": {
        "type": "array",
        "items": [
          "Double",
          "Single"
        ]
      },
      "name": "imports"
    }
  ]
}

which obviously is not a valid Avro Schema as any tool reading it throws an error of unrecognized types "Double" and "Single".

I would expect to get valid Avro schema which is:

{
  "namespace": "com.org.domain.fixtures",
  "type": "record",
  "name": "Import",
  "fields": [
    {
      "type": {
        "type": "array",
        "items": [        {
          "type": "record",
          "name": "Single",
          "fields": [
            {
              "type": "string",
              "name": "foo"
            }
          ]
        },{
          "type": "record",
          "name": "Double",
          "fields": [
            {
              "type": "string",
              "name": "bar"
            }
          ]
        }]
      },
      "name": "imports"
    }
  ]
}

code

import path from 'path'
import { avdlToAVSCAsync } from '@kafkajs/confluent-schema-registry'
;(async () => {
  const avroSchema = await avdlToAVSCAsync(
    path.join(__dirname, 'schema/import.avdl')
  )

  console.log(JSON.stringify(avroSchema, null, 2))
  
})()
@khy-tawk-to
Copy link

Encountering the same issue also, any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants