Skip to content

Serialization Configuration using Pydantic Models #99

@insightindustry

Description

@insightindustry

It would be helpful if it were possible to create a serialization configuration set automatically based on a Pydantic model (schema).

The specific intended use would be streamline development in a FastAPI context, and to eliminate the need to maintain parallel serialization/deserialization schemas when using SQLAthanor in an application that is also using Pydantic models (read: the vast majority of FastAPI implementations).

The syntax envisioned for this would be something along the lines of:

  • add Pydantic model and iterable of Pydantic model as an additional supported type for the config argument passed to validate_serialization_config()
  • enable the BaseModel.set_attribute_serialization_config() and BaseModel.configure_serialization() methods to accept Pydantic models as their config sets
  • add an AttributeConfiguration.from_pydantic() class method that will generate an attribute configuration based on a Pydantic model

Note that the solution developed will need support the application of multiple config_set settings, where each config_set will be built off of a separate Pydantic model.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions