This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
BaseModel with simple __root__ type not allowed in Path and Query params #1437
Comments
Do you think it's a duplicate of #911? |
Partially. In this case, I am trying to extract the enum in the schema definitions. This useful for openapi-generator, otherwise it generates separate enums (e.g. for typescript). |
I have a similar issue. And I try to use request body instead but that raises an error too. For example: class QueryDict(BaseModel):
__root__: dict[str, str]
# some validators here
...
class Query(BaseModel):
query: QueryDict
@app.post('/foo')
def foo(query: Query):
... Request:
In this case I get a validation error:
@tiangolo do you have any thoughts on this? It seems to me this is a pydantic issue.
Also nested |
Pydantic models are not supported for other things apart from bodies. I want to add a way to support them for query parameters and others, but that's not supported yet.
|
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
I want to extract enums from model schema to separate definition, and the solution is:
Output:
But I can't use
HelloEnum
in Query parameters:And I get the error:
To Reproduce
AssertionError: Param: hello_type can only be a request body, using Body(...)
.Expected behavior
Run app successfully, and in openapi schema enum extracted in the separate definition.
Environment
The text was updated successfully, but these errors were encountered: