Skip to content

Commit 49997f1

Browse files
committed
NS feedback
1 parent 87674c1 commit 49997f1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

source/integrations/fastapi-integration.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ StudentCollection Class
278278

279279
The ``StudentCollection`` class is defined to encapsulate a list of
280280
``StudentModel`` instances. The purpose of this endpoint is to provide some
281-
protection from JSON Hijacking. For more information, you can read the `JSON
282-
Hijacking <https://haacked.com/archive/2009/06/25/json-hijacking.aspx/>`__
283-
article on the Haacked website.
281+
protection from JSON Hijacking, where a malicious user attempts to access
282+
sensitive data by exploiting how browsers handle JSON arrays. For more
283+
information, you can read the `JSON Hijacking
284+
<https://haacked.com/archive/2009/06/25/json-hijacking.aspx/>`__ article on the
285+
Haacked website.
284286

285287
You can see the ``StudentCollection`` definition in the following code in the
286288
``app.py`` file:
@@ -359,13 +361,11 @@ You can see the ``create_student`` definition in the following code in the
359361

360362
A unique ``id`` will be created and provided in the response.
361363
"""
362-
new_student = await student_collection.insert_one(
363-
student.model_dump(by_alias=True, exclude=["id"])
364-
)
365-
created_student = await student_collection.find_one(
366-
{"_id": new_student.inserted_id}
367-
)
368-
return created_student
364+
new_student = student.model_dump(by_alias=True, exclude=["id"])
365+
result = await student_collection.insert_one(new_student)
366+
new_student["_id"] = result.inserted_id
367+
368+
return new_student
369369

370370
Read Routes
371371
```````````

0 commit comments

Comments
 (0)