Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
martincpt opened this issue Apr 19, 2025 · 0 comments · May be fixed by #29
Open

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

martincpt opened this issue Apr 19, 2025 · 0 comments · May be fixed by #29

Comments

@martincpt
Copy link

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.

@martincpt martincpt linked a pull request Apr 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant