Skip to content
Discussion options

You must be logged in to vote

You shouldn't use Pydantic or SQLModel models with Depends (this is not supported officially):

async def root(
    model: Annotated[Model, Depends()],  # This is wrong
):

To declare Query parameters using Pydantic\SQLModel model, use the following approach:

async def root(
    model: Annotated[Model, Query()],
):

Note that it's not currently possible to combine multiple models to declare Query parameters (or combine Query model with single Query parameters). As a workaround you can create a model that inherits from multiple models:

class Model(SQLModel):
    field: str = Field('default')

class Model2(SQLModel):
    field2: str = Field('default')

class QueryParametersModel(Model, Model2)…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tommytsim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants