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

fails to convert schemas with field with names matching reserved words #32

Open
jonykalavera opened this issue Apr 8, 2022 · 2 comments

Comments

@jonykalavera
Copy link

example:

{
    "name": "payload",
    "doc": "Payload of the message.",
    "type": {
        "name": "payload",
        "type": "record",
        "fields": [
            {
                "name": "from",
                "type": "int"
            },
            {
                "name": "import",
                "type": "int"
            }
        ]
    }
} 

would generate:

class payload(BaseModel):
    from: int
    import: int
@jonykalavera
Copy link
Author

maybe it could do something like

class payload(BaseModel):
    from_: int = Field(alias="from")
    import_: int = Field(alias="import")

@jonykalavera
Copy link
Author

jonykalavera commented Apr 8, 2022

solution should cover all reserved keywords https://www.w3schools.com/python/python_ref_keywords.asp

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

1 participant