📝 Update docs for models for updating, id should not be updatable (#335)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
kurtportelli 2022-08-28 01:43:42 +02:00 committed by GitHub
parent 8ac82e7101
commit a2cda8377f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 12 deletions

View File

@ -55,11 +55,11 @@ And the same way, we declared the `TeamRead` with only the same base fields of t
# Code here omitted 👈 # Code here omitted 👈
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:32-37]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-36]!}
# Code here omitted 👈 # Code here omitted 👈
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:46-47]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:45-46]!}
# Code below omitted 👇 # Code below omitted 👇
``` ```
@ -80,11 +80,11 @@ In this case, we used `response_model=TeamRead` and `response_model=HeroRead`, s
```Python hl_lines="3 8 12 17" ```Python hl_lines="3 8 12 17"
# Code above omitted 👆 # Code above omitted 👆
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:105-110]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:104-109]!}
# Code here omitted 👈 # Code here omitted 👈
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:160-165]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:159-164]!}
# Code below omitted 👇 # Code below omitted 👇
``` ```

View File

@ -18,8 +18,8 @@ Then we also inherit from the `TeamBase` for the `TeamCreate` and `TeamRead` **d
And we also create a `TeamUpdate` **data model**. And we also create a `TeamUpdate` **data model**.
```Python hl_lines="7-9 12-15 18-19 22-23 26-29" ```Python hl_lines="7-9 12-15 18-19 22-23 26-28"
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-29]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-28]!}
# Code below omitted 👇 # Code below omitted 👇
``` ```
@ -42,7 +42,7 @@ Let's now update the `Hero` models too.
```Python hl_lines="3-8 11-15 17-18 21-22 25-29" ```Python hl_lines="3-8 11-15 17-18 21-22 25-29"
# Code above omitted 👆 # Code above omitted 👆
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:32-58]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-57]!}
# Code below omitted 👇 # Code below omitted 👇
``` ```
@ -66,10 +66,10 @@ And even though the `HeroBase` is *not* a **table model**, we can declare `team_
Notice that the **relationship attributes**, the ones with `Relationship()`, are **only** in the **table models**, as those are the ones that are handled by **SQLModel** with SQLAlchemy and that can have the automatic fetching of data from the database when we access them. Notice that the **relationship attributes**, the ones with `Relationship()`, are **only** in the **table models**, as those are the ones that are handled by **SQLModel** with SQLAlchemy and that can have the automatic fetching of data from the database when we access them.
```Python hl_lines="11 39" ```Python hl_lines="11 38"
# Code above omitted 👆 # Code above omitted 👆
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-58]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-57]!}
# Code below omitted 👇 # Code below omitted 👇
``` ```
@ -92,7 +92,7 @@ These are equivalent and very similar to the **path operations** for the **heroe
```Python hl_lines="3-9 12-20 23-28 31-47 50-57" ```Python hl_lines="3-9 12-20 23-28 31-47 50-57"
# Code above omitted 👆 # Code above omitted 👆
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:140-194]!} {!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:139-193]!}
# Code below omitted 👇 # Code below omitted 👇
``` ```

View File

@ -24,7 +24,6 @@ class TeamRead(TeamBase):
class TeamUpdate(SQLModel): class TeamUpdate(SQLModel):
id: Optional[int] = None
name: Optional[str] = None name: Optional[str] = None
headquarters: Optional[str] = None headquarters: Optional[str] = None

View File

@ -442,7 +442,6 @@ openapi_schema = {
"title": "TeamUpdate", "title": "TeamUpdate",
"type": "object", "type": "object",
"properties": { "properties": {
"id": {"title": "Id", "type": "integer"},
"name": {"title": "Name", "type": "string"}, "name": {"title": "Name", "type": "string"},
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },