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

Bug fixes / features #13

Open
ikstewa opened this issue Jun 2, 2024 · 4 comments
Open

Bug fixes / features #13

ikstewa opened this issue Jun 2, 2024 · 4 comments

Comments

@ikstewa
Copy link
Contributor

ikstewa commented Jun 2, 2024

Hey @dorner !

I have a collection of new features and a few bug fixes we needed to add in order to leverage this for our use case. A lot of these are based of the goal of having the avro schemas match the similar behavior described in the proto json mapping.

Let me know if you wanted to merge any of these in!

Features

Bug Fixes

@ikstewa
Copy link
Contributor Author

ikstewa commented Jun 2, 2024

Here's one regarding the enums I am struggling with if you have any input.

Here's a sample WIP: ikstewa#8

When referencing an enum from another message, the Ref ends up not aligning with the definition of the type:

message BleepEnum {
  enum Bleep {
    UNKOWN = 0;
    BLEEP_ME = 1;
    BLEEP_YOU = 2;
  }
}

message Foobar {
  ...
  BleepEnum.Bleep bleep = 18;
  BleepEnum.Bleep bleep_again = 19;
}
...
    {
      "name": "bleep",
      "type": {
        "type": "enum",
        "name": "Bleep",
        "symbols": [
          "UNKOWN",
          "BLEEP_ME",
          "BLEEP_YOU"
        ],
        "default": "UNKOWN"
      },
      "default": "UNKOWN"
    },
    {
      "name": "bleepAgain",
      "type": "testdata.BleepEnum.Bleep"
    }
...

Note: The type names don't match up as the Bleep type is name namespaced under BleepEnum

@dorner
Copy link
Member

dorner commented Jun 3, 2024

Hey @ikstewa - I'm more than happy to accept PRs with both features and bug fixes. Right now this tool is pretty niche, so I'm good to configure it as deeply as needed to get your use cases going.

What assistance do you need with the WIP?

@ikstewa
Copy link
Contributor Author

ikstewa commented Jun 3, 2024

What assistance do you need with the WIP?

I'm having a hard time figuring out how to best update the code to handle the naming of the type. The example from the WIP results in invalid avro as the type testdata.BleepEnum.Bleep is not found. When nesting the type initially the in the record it needs to either have "name": "BleepEnum.Bleep" or needs to be referenced as "type": "testdata.Bleep" instead.

I'm not certain how to best do that, as when toJSON is called on the enum object it doesn't have reference to the namespace where it's being written so it's not able to respect relative type namings.

@dorner
Copy link
Member

dorner commented Jun 7, 2024

Oof... it's been a while since I've had to dive into this. I wonder if there's a way to store the current nesting somewhere in the typeRepo so you can access it as you go into it?

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