redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.06k stars 108 forks source link

redis save gives me error #553

Closed PARKER-X closed 9 months ago

PARKER-X commented 11 months ago

@app.post("/products") def create(product: Product):

return product.save()

raise fastapi.exceptions.FastAPIError(

fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that <class 'inventory.schema.Product'> is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/

PARKER-X commented 10 months ago

Can anyone help me

XChikuX commented 10 months ago

Product.save() returns either none, boolean or some integer value, to indicate it saved correctly on redis.

You probably want to return something after Product.get()

As far as I can tell, is not a redis-om issue.

ggozad commented 9 months ago

@XChikuX This is not irrelevant to redis-om. It's the same issue as in #546 & #539. Basically redis-om is not compatible with Pydantic>2. Works fine with pydantic<2.

PARKER-X commented 9 months ago

@XChikuX Yeah man it's work for pydantic <2 Thanks!