Skip to content

Add option to use original_schema in AvroModel.serialize()  #712

@kamilglod

Description

@kamilglod

Is your feature request related to a problem? Please describe.
I generate dataclass models from AVRO schema that other team provides, and I want to be sure that I'm generating AVRO data using exact same schema. So I'm building python instance and now I want to call .serialize() but it uses only auto-generated schema from model, there is no option to use original_schema

Describe the solution you'd like
It would be nice to have either separate method or flag as an argument of the .serialize() method, something like use_original_schema: bool = False (for me True should be default but it would break backward compatibility)

Describe alternatives you've considered
Creating helper function in my code that would be used alywas to serialize model:

def serialize(model: AvroModel) -> bytes:
    return serialization.serialize(
        model.asdict(standardize_factory=utils.standardize_custom_type),
        model.original_schema,
        serialization_type="avro",
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions