Feature Request
It would be nice to be able construct models by composition, instead of just static descriptions and inheritance-based extension. What I mean by "composition", is being able to define a partial, parameterized model, which can yield new, complete models/validators by combining with other models/validators. This could be done by exploiting something like typing.Generic, e.g.:
import typing
import pydantic
T = typing.TypeVar("T")
class Response(pydantic.GenericModel[T]):
data: T = ...
total_count: int = None
and then, one could use Response[MyModel] or Response[List[MyModel]] as validators.
I think support for generic is mentioned in #380.
Feature Request
It would be nice to be able construct models by composition, instead of just static descriptions and inheritance-based extension. What I mean by "composition", is being able to define a partial, parameterized model, which can yield new, complete models/validators by combining with other models/validators. This could be done by exploiting something like
typing.Generic, e.g.:and then, one could use
Response[MyModel]orResponse[List[MyModel]]as validators.I think support for generic is mentioned in #380.