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

field ordering issue causing invalid python models #401

Closed
robbertvanwaveren opened this issue Aug 30, 2023 · 0 comments · Fixed by #403
Closed

field ordering issue causing invalid python models #401

robbertvanwaveren opened this issue Aug 30, 2023 · 0 comments · Fixed by #403

Comments

@robbertvanwaveren
Copy link

Describe the bug
Whenever there is a field with some additional metadata like "aliases" or "doc" it causes the generated python field to look like this:

    fieldwithdefault: str = "some default value"
    someotherfield: int = dataclasses.field(metadata={'aliases': ['oldname']})

However these get ordered behind (original order?) fields with a default value which is not valid python. Without aliases or doc these fields do correctly get shifted before fields with defaults.

To Reproduce

{
  "type": "record",
  "name": "Message",
  "fields": [
    {
      "name": "fieldwithdefault",
      "type": "string",
      "default": "some default value"
    },
    {
      "name": "someotherfield",
      "type": "long",
      "aliases": ["oldname"],
      "doc": "test"
    }
  ]
}

Expected behavior
fields get ordered with default values last

    someotherfield: int = dataclasses.field(metadata={'aliases': ['oldname']})
    fieldwithdefault: str = "some default value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant