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

Avro-ts using namespace instead of name to describe wrapped unions #89

Open
puzzledbytheweb opened this issue Jul 9, 2021 · 1 comment

Comments

@puzzledbytheweb
Copy link

Hey!

We are implementing the changes to support the Reader Schema in our code but we're stuck. Comparing the schema that we got from Aiven with the generated types, it looks like the type for the event uses the namespace (instead of the name) to differ between the different branches in the union.

export interface Event {
   event:
     | {
         'namespace.obfuscated.this.is.a.public.package.event.CreatedOrUpdate': NAMESPACE.CreatedOrUpdate;
         'namespace.obfuscated.this.is.a.public.package.event.Deleted'?: never;
       }
     | {
         'namespace.obfuscated.this.is.a.public.package.event.CreatedOrUpdate'?: never;
         'namespace.obfuscated.this.is.a.public.package.event.Deleted': NAMESPACE.Deleted;
       };
 }
{
   "name": "event",
   "type": [
        {
              "type": "record",
              "name": "CreatedOrUpdate",
              "namespace": "different.namespace.obfuscated.this.is.a.public.package.Event",
              "fields": ["MANY_FIELDS"]
        },
        {
              "type": "record",
              "name": "Deleted",
              "namespace": "different.namespace.obfuscated.this.is.a.public.package.Event",
              "fields": ["JUST_AN_ID"]
       }
   ]
}

You can notice that if the generated types used the name, if the namespace changed, everything would be fine. But because it is using the namespace (concatenated with the name), if a message is produced with a different namespace we'll never be able to access the correct branch of the union.

@ivank
Copy link
Contributor

ivank commented Jul 10, 2021

This seems to be a deeper problem from avsc library. Opened an issue there, lets see if they can resolve it first mtth/avsc#361

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