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

AvroBaseModel.avro_schema() returns different schemas #254

Closed
vegraux opened this issue Mar 15, 2023 · 2 comments
Closed

AvroBaseModel.avro_schema() returns different schemas #254

vegraux opened this issue Mar 15, 2023 · 2 comments
Assignees

Comments

@vegraux
Copy link

vegraux commented Mar 15, 2023

Describe the bug
I got a AvroBaseModel called MyModel that has another AvroBaseModel called NestedModel as a field. I get different schemas when I call MyModel.avro_schema() twice. The field of the second schema corresponding to NestedModel simply refers to itself as type: {'name': 'nested_model', 'type': 'NestedModel'}

To Reproduce
I am using dataclasses-avroschema==0.37.4 and Python 3.10.6

Code to reproduce the problem:

import json

from dataclasses_avroschema.avrodantic import AvroBaseModel


class NestedModel(AvroBaseModel):
    nesten_hello: str


class MyModel(AvroBaseModel):
    hello: str
    nested_model: NestedModel


schema1 = json.loads(MyModel.avro_schema())

schema2 = json.loads(MyModel.avro_schema())


assert schema1 == schema2, "not equal schemas"

Expected behavior
MyModel.avro_schema() should be idempotent, and return the same schema every time

@vegraux
Copy link
Author

vegraux commented Mar 17, 2023

Quick service, thanks!

@marcosschroh
Copy link
Owner

You're welcom!

@marcosschroh marcosschroh removed bug Something isn't working in progress labels May 19, 2023
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