Replies: 5 comments
-
Do you think it's a duplicate of #911? |
Beta Was this translation helpful? Give feedback.
-
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). |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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.
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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
Beta Was this translation helpful? Give feedback.
All reactions