Skip to content
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

bug: don't support pydantic v2 #328

Closed
bekishev04 opened this issue Jul 27, 2023 · 5 comments
Closed

bug: don't support pydantic v2 #328

bekishev04 opened this issue Jul 27, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@bekishev04
Copy link

bekishev04 commented Jul 27, 2023

Describe the bug

When i use pydantic v2:

assert issubclass(model, BaseModel), "invalid `pydantic.BaseModel`"
AssertionError: invalid `pydantic.BaseModel`

code line:
https://github.com/0b01001001/spectree/blob/master/spectree/response.py#L76

To Reproduce

class ResponseMessage(BaseModel):
    """Response Message"""

    message: str


@spec_tree.validate(
        resp=Response("HTTP_401", HTTP_200=schemas.ResponseMessage),
    )
    def get(self):
        pass

Expected behavior

No response

The spectree version

spectree = "^1.2.0"
pydantic = {extras = ["email"], version = "^2.1.1"}

Additional context

You can fix it in this file:

https://github.com/0b01001001/spectree/blob/master/spectree/_pydantic.py

There we use only version 1 of pydantic and dont use the second version

@bekishev04 bekishev04 added the bug Something isn't working label Jul 27, 2023
@kemingy
Copy link
Member

kemingy commented Jul 27, 2023

Currently, you might need to from pydantic.v1 import BaseModel when you're using pydantic v2.

It's tricky to support both v1 and v2.

@kemingy
Copy link
Member

kemingy commented Jul 27, 2023

Ref to #319 (review)

We might need to refactor some parts.

@bekishev04
Copy link
Author

Currently, you might need to from pydantic.v1 import BaseModel when you're using pydantic v2.

It's tricky to support both v1 and v2.

i understand. But when know i want using V2 pydantic. And cant do it with spectree.

I think it would be useful to write in readme that spectree only supports version 1 including the first version from pedantic v2

@bekishev04
Copy link
Author

bekishev04 commented Jul 27, 2023

You can close the issue if you think it is necessary, I have received my answer. I was just counting on full v2 support

@kemingy
Copy link
Member

kemingy commented Jul 27, 2023

Let me create another issue to track the full v2 support.

@kemingy kemingy closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants