Skip to content

OpenAPI docs generation fails for root return types with Pydantic v2 #28

Open
@martincpt

Description

@martincpt

Using create_model with __root__ like this:

resp_model = create_model(
    callback.__name__ + "-return",
    __root__=(return_annotation, ...),
)

raises the following error in Pydantic v2:

TypeError: To define root models, use pydantic.RootModel rather than a field called 'root'

Pydantic v2 removed support for defining root models via __root__ in create_model. It now requires using pydantic.RootModel.

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