Pydantic V2 removes support for __root__ in models. The Pre-release blog post provides 2 different ways to create models with "root" fields.
The easiest replacement seems to be AnalyzedType. This uses the new Pydantic V2 type that allows for creating arbitrary types from generic annotations.
Another, more complicated approach, if custom behavior is required, is to provide custom model validators and serializers, as demonstrated in the Pydantic test suite. This seems to provide more flexibility, but adds a lot of boilerplate code and it's unclear if we actually need this flexibility.
Pydantic V2 removes support for
__root__in models. The Pre-release blog post provides 2 different ways to create models with "root" fields.The easiest replacement seems to be
AnalyzedType. This uses the new Pydantic V2 type that allows for creating arbitrary types from generic annotations.Another, more complicated approach, if custom behavior is required, is to provide custom model validators and serializers, as demonstrated in the Pydantic test suite. This seems to provide more flexibility, but adds a lot of boilerplate code and it's unclear if we actually need this flexibility.