Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a01a055

Browse filesBrowse files
docs: explain the state of doclist in fastapi (#1546)
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
1 parent 0bcc956 commit a01a055
Copy full SHA for a01a055

1 file changed

+13-5Lines changed: 13 additions & 5 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/user_guide/sending/api/fastAPI.md‎

Copy file name to clipboardExpand all lines: docs/user_guide/sending/api/fastAPI.md
+13-5Lines changed: 13 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,21 @@ Image(
9595
) # fails validation because it does not have enough dimensions
9696
```
9797

98+
## Use DocList with FastAPI
9899

99-
Further, you can send and receive lists of documents represented as a `DocList` object:
100+
Further, you can send and receive lists of documents represented as a `DocList` object.
100101

101-
!!! note
102-
Currently, `FastAPI` receives `DocList` objects as lists, so you have to construct a DocList inside the function.
103-
Also, if you want to return a `DocList` object, first you have to convert it to a list.
104-
(Shown in the example below)
102+
To do that, you need to receive a list of documents (`List[TextDoc]`) in your FastAPI function, and then convert it to a `DocList` object.
103+
To return a `DocList` object, similarly, you need to convert it to a list first.
104+
105+
!!! note "Why is there no native support for `DocList`?"
106+
We would love to natively support `DocList` in FastAPI, but it's not possible at the moment due to some behaviour
107+
stemming from Pydantic. This should be resolved once [Pydantic v2](https://docs.pydantic.dev/latest/blog/pydantic-v2/) is released.
108+
109+
If you are curious about the root cause of this, you can check out the following issues:
110+
- [Pydantic issue #1457](https://github.com/pydantic/pydantic/issues/1457)
111+
- [Should be resolved in Pydantic v2 (#4161)](https://github.com/pydantic/pydantic/issues/4161)
112+
- [DocArray needs the above (#1521)](https://github.com/docarray/docarray/issues/1521)
105113

106114
```python
107115
from typing import List

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.