You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "/workspaces/app/staff_v2/foo.py", line 22, in <module>
@api.get("/")
^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/router.py", line 240, in decorator
self.add_api_operation(
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/router.py", line 289, in add_api_operation
path_view.add_operation(
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/operation.py", line 357, in add_operation
operation = OperationClass(
^^^^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/operation.py", line 69, in __init__
self.signature = ViewSignature(self.path, self.view_func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/signature/details.py", line 87, in __init__
self.models: TModels = self._create_models()
^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/signature/details.py", line 144, in _create_models
flatten_map = self._args_flatten_map(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/signature/details.py", line 181, in _args_flatten_map
for name, path in self._model_flatten_map(arg.annotation, arg.alias):
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/signature/details.py", line 205, in _model_flatten_map
yield from self._model_flatten_map(field.annotation, name) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/signature/details.py", line 205, in _model_flatten_map
yield from self._model_flatten_map(field.annotation, name) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/app/.venv/lib/python3.11/site-packages/ninja/signature/details.py", line 201, in _model_flatten_map
for attr, field in model.model_fields.items():
^^^^^^^^^^^^^^^^^^
AttributeError: 'types.UnionType' object has no attribute 'model_fields'
This makes me think it's not aware of the Json[...] annotation and is still trying to unfurl the model into individual query params.
Versions:
Python version: 3.11.6
Django version: 4.2.10
Django-Ninja version: 1.1.0
Pydantic version: 2.7.1
The text was updated successfully, but these errors were encountered:
Got same error while migrating to pydantic v2 - it seems that it does not support UnionType, or bool | str annotated fields. I just tried to get rid of all field: str | None unions, making them field: str = None instead, and it seems to be working
Describe the bug
I'd like to be able to decode JSON-encoded
pydantic
models from a query param like this:Unfortunately, it crashes out with this error:
This makes me think it's not aware of the
Json[...]
annotation and is still trying to unfurl the model into individual query params.Versions:
The text was updated successfully, but these errors were encountered: