Open dan83g opened 8 months ago
@dan83g
could you provide some use case ?
why dont you just use pydantic's dataclasses ?
from pydantic.dataclasses import dataclass
@dataclass
class User:
id: int
name: str
I would like something like this (SearchRequest)
@pydantic.dataclasses.dataclass(config=pydantic.ConfigDict(arbitrary_types_allowed=True))
class SearchRequest:
q: str
...
@field_validator('q')
def validate_q(cls, v):
return v
@router.api_operation(['GET'], '/search', response=SearchResponseSchema)
def search(request, query_params: Query[SearchRequest]):
...
Note to myself - pydantic.dataclasses should work - probably not detecting it correctly
After updating pydantic, it was no longer possible to use the
__pydantic_model__
attribute (pydantic.dataclasses.dataclass). Is it possible to create schemas dynamically from dataclasses.