📝 Update ModelRead to ModelPublic documentation and examples (#885)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Esteban Maya 2024-04-08 18:07:48 -05:00 committed by GitHub
parent fa79856a4b
commit 1eb40b1f33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
68 changed files with 427 additions and 427 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -98,7 +98,7 @@ But we also want to have a `HeroCreate` for the data we want to receive when **c
* `secret_name`, required * `secret_name`, required
* `age`, optional * `age`, optional
And we want to have a `HeroRead` with the `id` field, but this time annotated with `id: int`, instead of `id: Optional[int]`, to make it clear that it is required in responses **read** from the clients: And we want to have a `HeroPublic` with the `id` field, but this time annotated with `id: int`, instead of `id: Optional[int]`, to make it clear that it is required in responses **read** from the clients:
* `id`, required * `id`, required
* `name`, required * `name`, required
@ -183,9 +183,9 @@ Here's the important detail, and probably the most important feature of **SQLMod
This means that the class `Hero` represents a **table** in the database. It is both a **Pydantic** model and a **SQLAlchemy** model. This means that the class `Hero` represents a **table** in the database. It is both a **Pydantic** model and a **SQLAlchemy** model.
But `HeroCreate` and `HeroRead` don't have `table = True`. They are only **data models**, they are only **Pydantic** models. They won't be used with the database, but only to declare data schemas for the API (or for other uses). But `HeroCreate` and `HeroPublic` don't have `table = True`. They are only **data models**, they are only **Pydantic** models. They won't be used with the database, but only to declare data schemas for the API (or for other uses).
This also means that `SQLModel.metadata.create_all()` won't create tables in the database for `HeroCreate` and `HeroRead`, because they don't have `table = True`, which is exactly what we want. 🚀 This also means that `SQLModel.metadata.create_all()` won't create tables in the database for `HeroCreate` and `HeroPublic`, because they don't have `table = True`, which is exactly what we want. 🚀
/// tip /// tip
@ -355,7 +355,7 @@ Then we just `add` it to the **session**, `commit`, and `refresh` it, and finall
Because it is just refreshed, it has the `id` field set with a new ID taken from the database. Because it is just refreshed, it has the `id` field set with a new ID taken from the database.
And now that we return it, FastAPI will validate the data with the `response_model`, which is a `HeroRead`: And now that we return it, FastAPI will validate the data with the `response_model`, which is a `HeroPublic`:
//// tab | Python 3.10+ //// tab | Python 3.10+
@ -743,9 +743,9 @@ As an alternative, we could use `HeroBase` directly in the API code instead of `
On top of that, we could easily decide in the future that we want to receive **more data** when creating a new hero apart from the data in `HeroBase` (for example, a password), and now we already have the class to put those extra fields. On top of that, we could easily decide in the future that we want to receive **more data** when creating a new hero apart from the data in `HeroBase` (for example, a password), and now we already have the class to put those extra fields.
### The `HeroRead` **Data Model** ### The `HeroPublic` **Data Model**
Now let's check the `HeroRead` model. Now let's check the `HeroPublic` model.
This one just declares that the `id` field is required when reading a hero from the API, because a hero read from the API will come from the database, and in the database it will always have an ID. This one just declares that the `id` field is required when reading a hero from the API, because a hero read from the API will come from the database, and in the database it will always have an ID.
@ -815,7 +815,7 @@ This one just declares that the `id` field is required when reading a hero from
## Review the Updated Docs UI ## Review the Updated Docs UI
The FastAPI code is still the same as above, we still use `Hero`, `HeroCreate`, and `HeroRead`. But now, we define them in a smarter way with inheritance. The FastAPI code is still the same as above, we still use `Hero`, `HeroCreate`, and `HeroPublic`. But now, we define them in a smarter way with inheritance.
So, we can jump to the docs UI right away and see how they look with the updated data. So, we can jump to the docs UI right away and see how they look with the updated data.

View File

@ -164,7 +164,7 @@ This will let the client know that they probably made a mistake on their side an
Then, if the hero exists, we return it. Then, if the hero exists, we return it.
And because we are using the `response_model` with `HeroRead`, it will be validated, documented, etc. And because we are using the `response_model` with `HeroPublic`, it will be validated, documented, etc.
//// tab | Python 3.10+ //// tab | Python 3.10+

View File

@ -40,9 +40,9 @@ Let's update that. 🤓
First, why is it that we are not getting the related data for each hero and for each team? First, why is it that we are not getting the related data for each hero and for each team?
It's because we declared the `HeroRead` with only the same base fields of the `HeroBase` plus the `id`. But it doesn't include a field `team` for the **relationship attribute**. It's because we declared the `HeroPublic` with only the same base fields of the `HeroBase` plus the `id`. But it doesn't include a field `team` for the **relationship attribute**.
And the same way, we declared the `TeamRead` with only the same base fields of the `TeamBase` plus the `id`. But it doesn't include a field `heroes` for the **relationship attribute**. And the same way, we declared the `TeamPublic` with only the same base fields of the `TeamBase` plus the `id`. But it doesn't include a field `heroes` for the **relationship attribute**.
//// tab | Python 3.10+ //// tab | Python 3.10+
@ -146,7 +146,7 @@ And the same way, we declared the `TeamRead` with only the same base fields of t
Now, remember that <a href="https://fastapi.tiangolo.com/tutorial/response-model/" class="external-link" target="_blank">FastAPI uses the `response_model` to validate and **filter** the response data</a>? Now, remember that <a href="https://fastapi.tiangolo.com/tutorial/response-model/" class="external-link" target="_blank">FastAPI uses the `response_model` to validate and **filter** the response data</a>?
In this case, we used `response_model=TeamRead` and `response_model=HeroRead`, so FastAPI will use them to filter the response data, even if we return a **table model** that includes **relationship attributes**: In this case, we used `response_model=TeamPublic` and `response_model=HeroPublic`, so FastAPI will use them to filter the response data, even if we return a **table model** that includes **relationship attributes**:
//// tab | Python 3.10+ //// tab | Python 3.10+
@ -300,7 +300,7 @@ Let's add a couple more **data models** that declare that data so we can use the
## Models with Relationships ## Models with Relationships
Let's add the models `HeroReadWithTeam` and `TeamReadWithHeroes`. Let's add the models `HeroPublicWithTeam` and `TeamPublicWithHeroes`.
We'll add them **after** the other models so that we can easily reference the previous models. We'll add them **after** the other models so that we can easily reference the previous models.
@ -372,11 +372,11 @@ These two models are very **simple in code**, but there's a lot happening here.
### Inheritance and Type Annotations ### Inheritance and Type Annotations
The `HeroReadWithTeam` **inherits** from `HeroRead`, which means that it will have the **normal fields for reading**, including the required `id` that was declared in `HeroRead`. The `HeroPublicWithTeam` **inherits** from `HeroPublic`, which means that it will have the **normal fields for reading**, including the required `id` that was declared in `HeroPublic`.
And then it adds the **new field** `team`, which could be `None`, and is declared with the type `TeamRead` with the base fields for reading a team. And then it adds the **new field** `team`, which could be `None`, and is declared with the type `TeamPublic` with the base fields for reading a team.
Then we do the same for the `TeamReadWithHeroes`, it **inherits** from `TeamRead`, and declares the **new field** `heroes`, which is a list of `HeroRead`. Then we do the same for the `TeamPublicWithHeroes`, it **inherits** from `TeamPublic`, and declares the **new field** `heroes`, which is a list of `HeroPublic`.
### Data Models Without Relationship Attributes ### Data Models Without Relationship Attributes
@ -386,11 +386,11 @@ Instead, here these are only **data models** that will tell FastAPI **which attr
### Reference to Other Models ### Reference to Other Models
Also, notice that the field `team` is not declared with this new `TeamReadWithHeroes`, because that would again create that infinite recursion of data. Instead, we declare it with the normal `TeamRead` model. Also, notice that the field `team` is not declared with this new `TeamPublicWithHeroes`, because that would again create that infinite recursion of data. Instead, we declare it with the normal `TeamPublic` model.
And the same for `TeamReadWithHeroes`, the model used for the new field `heroes` uses `HeroRead` to get only each hero's data. And the same for `TeamPublicWithHeroes`, the model used for the new field `heroes` uses `HeroPublic` to get only each hero's data.
This also means that, even though we have these two new models, **we still need the previous ones**, `HeroRead` and `TeamRead`, because we need to reference them here (and we are also using them in the rest of the *path operations*). This also means that, even though we have these two new models, **we still need the previous ones**, `HeroPublic` and `TeamPublic`, because we need to reference them here (and we are also using them in the rest of the *path operations*).
## Update the Path Operations ## Update the Path Operations

View File

@ -14,7 +14,7 @@ It's the same process we did for heroes, with a base model, a **table model**, a
We have a `TeamBase` **data model**, and from it, we inherit with a `Team` **table model**. We have a `TeamBase` **data model**, and from it, we inherit with a `Team` **table model**.
Then we also inherit from the `TeamBase` for the `TeamCreate` and `TeamRead` **data models**. Then we also inherit from the `TeamBase` for the `TeamCreate` and `TeamPublic` **data models**.
And we also create a `TeamUpdate` **data model**. And we also create a `TeamUpdate` **data model**.

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -52,7 +52,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -61,7 +61,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -72,7 +72,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -80,7 +80,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -50,7 +50,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -59,7 +59,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -70,7 +70,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -78,7 +78,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -52,7 +52,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -61,7 +61,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -72,7 +72,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -80,7 +80,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -47,7 +47,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -57,14 +57,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -73,7 +73,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -45,7 +45,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -55,14 +55,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -71,7 +71,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -47,7 +47,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -57,14 +57,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -73,7 +73,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,14 +51,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -39,7 +39,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -49,14 +49,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,14 +51,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)

View File

@ -17,7 +17,7 @@ class HeroCreate(SQLModel):
age: Optional[int] = None age: Optional[int] = None
class HeroRead(SQLModel): class HeroPublic(SQLModel):
id: int id: int
name: str name: str
secret_name: str secret_name: str
@ -43,7 +43,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -53,7 +53,7 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()

View File

@ -15,7 +15,7 @@ class HeroCreate(SQLModel):
age: int | None = None age: int | None = None
class HeroRead(SQLModel): class HeroPublic(SQLModel):
id: int id: int
name: str name: str
secret_name: str secret_name: str
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,7 +51,7 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()

View File

@ -17,7 +17,7 @@ class HeroCreate(SQLModel):
age: Optional[int] = None age: Optional[int] = None
class HeroRead(SQLModel): class HeroPublic(SQLModel):
id: int id: int
name: str name: str
secret_name: str secret_name: str
@ -43,7 +43,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -53,7 +53,7 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,7 +51,7 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -39,7 +39,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -49,7 +49,7 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,7 +51,7 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,14 +51,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -39,7 +39,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -49,14 +49,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -41,7 +41,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -51,14 +51,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(): def read_heroes():
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero)).all() heroes = session.exec(select(Hero)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)

View File

@ -19,7 +19,7 @@ class TeamCreate(TeamBase):
pass pass
class TeamRead(TeamBase): class TeamPublic(TeamBase):
id: int id: int
@ -43,7 +43,7 @@ class Hero(HeroBase, table=True):
team: Optional[Team] = Relationship(back_populates="heroes") team: Optional[Team] = Relationship(back_populates="heroes")
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -58,12 +58,12 @@ class HeroUpdate(SQLModel):
team_id: Optional[int] = None team_id: Optional[int] = None
class HeroReadWithTeam(HeroRead): class HeroPublicWithTeam(HeroPublic):
team: Optional[TeamRead] = None team: Optional[TeamPublic] = None
class TeamReadWithHeroes(TeamRead): class TeamPublicWithHeroes(TeamPublic):
heroes: List[HeroRead] = [] heroes: List[HeroPublic] = []
sqlite_file_name = "database.db" sqlite_file_name = "database.db"
@ -90,7 +90,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -99,7 +99,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -110,7 +110,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroReadWithTeam) @app.get("/heroes/{hero_id}", response_model=HeroPublicWithTeam)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -118,7 +118,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):
@ -144,7 +144,7 @@ def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
return {"ok": True} return {"ok": True}
@app.post("/teams/", response_model=TeamRead) @app.post("/teams/", response_model=TeamPublic)
def create_team(*, session: Session = Depends(get_session), team: TeamCreate): def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
db_team = Team.model_validate(team) db_team = Team.model_validate(team)
session.add(db_team) session.add(db_team)
@ -153,7 +153,7 @@ def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
return db_team return db_team
@app.get("/teams/", response_model=List[TeamRead]) @app.get("/teams/", response_model=List[TeamPublic])
def read_teams( def read_teams(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -164,7 +164,7 @@ def read_teams(
return teams return teams
@app.get("/teams/{team_id}", response_model=TeamReadWithHeroes) @app.get("/teams/{team_id}", response_model=TeamPublicWithHeroes)
def read_team(*, team_id: int, session: Session = Depends(get_session)): def read_team(*, team_id: int, session: Session = Depends(get_session)):
team = session.get(Team, team_id) team = session.get(Team, team_id)
if not team: if not team:
@ -172,7 +172,7 @@ def read_team(*, team_id: int, session: Session = Depends(get_session)):
return team return team
@app.patch("/teams/{team_id}", response_model=TeamRead) @app.patch("/teams/{team_id}", response_model=TeamPublic)
def update_team( def update_team(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),

View File

@ -17,7 +17,7 @@ class TeamCreate(TeamBase):
pass pass
class TeamRead(TeamBase): class TeamPublic(TeamBase):
id: int id: int
@ -41,7 +41,7 @@ class Hero(HeroBase, table=True):
team: Team | None = Relationship(back_populates="heroes") team: Team | None = Relationship(back_populates="heroes")
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -56,12 +56,12 @@ class HeroUpdate(SQLModel):
team_id: int | None = None team_id: int | None = None
class HeroReadWithTeam(HeroRead): class HeroPublicWithTeam(HeroPublic):
team: TeamRead | None = None team: TeamPublic | None = None
class TeamReadWithHeroes(TeamRead): class TeamPublicWithHeroes(TeamPublic):
heroes: list[HeroRead] = [] heroes: list[HeroPublic] = []
sqlite_file_name = "database.db" sqlite_file_name = "database.db"
@ -88,7 +88,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -97,7 +97,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -108,7 +108,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroReadWithTeam) @app.get("/heroes/{hero_id}", response_model=HeroPublicWithTeam)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -116,7 +116,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):
@ -142,7 +142,7 @@ def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
return {"ok": True} return {"ok": True}
@app.post("/teams/", response_model=TeamRead) @app.post("/teams/", response_model=TeamPublic)
def create_team(*, session: Session = Depends(get_session), team: TeamCreate): def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
db_team = Team.model_validate(team) db_team = Team.model_validate(team)
session.add(db_team) session.add(db_team)
@ -151,7 +151,7 @@ def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
return db_team return db_team
@app.get("/teams/", response_model=list[TeamRead]) @app.get("/teams/", response_model=list[TeamPublic])
def read_teams( def read_teams(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -162,7 +162,7 @@ def read_teams(
return teams return teams
@app.get("/teams/{team_id}", response_model=TeamReadWithHeroes) @app.get("/teams/{team_id}", response_model=TeamPublicWithHeroes)
def read_team(*, team_id: int, session: Session = Depends(get_session)): def read_team(*, team_id: int, session: Session = Depends(get_session)):
team = session.get(Team, team_id) team = session.get(Team, team_id)
if not team: if not team:
@ -170,7 +170,7 @@ def read_team(*, team_id: int, session: Session = Depends(get_session)):
return team return team
@app.patch("/teams/{team_id}", response_model=TeamRead) @app.patch("/teams/{team_id}", response_model=TeamPublic)
def update_team( def update_team(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),

View File

@ -19,7 +19,7 @@ class TeamCreate(TeamBase):
pass pass
class TeamRead(TeamBase): class TeamPublic(TeamBase):
id: int id: int
@ -43,7 +43,7 @@ class Hero(HeroBase, table=True):
team: Optional[Team] = Relationship(back_populates="heroes") team: Optional[Team] = Relationship(back_populates="heroes")
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -58,12 +58,12 @@ class HeroUpdate(SQLModel):
team_id: Optional[int] = None team_id: Optional[int] = None
class HeroReadWithTeam(HeroRead): class HeroPublicWithTeam(HeroPublic):
team: Optional[TeamRead] = None team: Optional[TeamPublic] = None
class TeamReadWithHeroes(TeamRead): class TeamPublicWithHeroes(TeamPublic):
heroes: list[HeroRead] = [] heroes: list[HeroPublic] = []
sqlite_file_name = "database.db" sqlite_file_name = "database.db"
@ -90,7 +90,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -99,7 +99,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -110,7 +110,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroReadWithTeam) @app.get("/heroes/{hero_id}", response_model=HeroPublicWithTeam)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -118,7 +118,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):
@ -144,7 +144,7 @@ def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
return {"ok": True} return {"ok": True}
@app.post("/teams/", response_model=TeamRead) @app.post("/teams/", response_model=TeamPublic)
def create_team(*, session: Session = Depends(get_session), team: TeamCreate): def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
db_team = Team.model_validate(team) db_team = Team.model_validate(team)
session.add(db_team) session.add(db_team)
@ -153,7 +153,7 @@ def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
return db_team return db_team
@app.get("/teams/", response_model=list[TeamRead]) @app.get("/teams/", response_model=list[TeamPublic])
def read_teams( def read_teams(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -164,7 +164,7 @@ def read_teams(
return teams return teams
@app.get("/teams/{team_id}", response_model=TeamReadWithHeroes) @app.get("/teams/{team_id}", response_model=TeamPublicWithHeroes)
def read_team(*, team_id: int, session: Session = Depends(get_session)): def read_team(*, team_id: int, session: Session = Depends(get_session)):
team = session.get(Team, team_id) team = session.get(Team, team_id)
if not team: if not team:
@ -172,7 +172,7 @@ def read_team(*, team_id: int, session: Session = Depends(get_session)):
return team return team
@app.patch("/teams/{team_id}", response_model=TeamRead) @app.patch("/teams/{team_id}", response_model=TeamPublic)
def update_team( def update_team(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -52,7 +52,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -61,7 +61,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -72,7 +72,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -80,7 +80,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -50,7 +50,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -59,7 +59,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -70,7 +70,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -78,7 +78,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -52,7 +52,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -61,7 +61,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -72,7 +72,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -80,7 +80,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):

View File

@ -19,7 +19,7 @@ class TeamCreate(TeamBase):
pass pass
class TeamRead(TeamBase): class TeamPublic(TeamBase):
id: int id: int
@ -42,7 +42,7 @@ class Hero(HeroBase, table=True):
team: Optional[Team] = Relationship(back_populates="heroes") team: Optional[Team] = Relationship(back_populates="heroes")
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -81,7 +81,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -90,7 +90,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -101,7 +101,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -109,7 +109,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):
@ -135,7 +135,7 @@ def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
return {"ok": True} return {"ok": True}
@app.post("/teams/", response_model=TeamRead) @app.post("/teams/", response_model=TeamPublic)
def create_team(*, session: Session = Depends(get_session), team: TeamCreate): def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
db_team = Team.model_validate(team) db_team = Team.model_validate(team)
session.add(db_team) session.add(db_team)
@ -144,7 +144,7 @@ def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
return db_team return db_team
@app.get("/teams/", response_model=List[TeamRead]) @app.get("/teams/", response_model=List[TeamPublic])
def read_teams( def read_teams(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -155,7 +155,7 @@ def read_teams(
return teams return teams
@app.get("/teams/{team_id}", response_model=TeamRead) @app.get("/teams/{team_id}", response_model=TeamPublic)
def read_team(*, team_id: int, session: Session = Depends(get_session)): def read_team(*, team_id: int, session: Session = Depends(get_session)):
team = session.get(Team, team_id) team = session.get(Team, team_id)
if not team: if not team:
@ -163,7 +163,7 @@ def read_team(*, team_id: int, session: Session = Depends(get_session)):
return team return team
@app.patch("/teams/{team_id}", response_model=TeamRead) @app.patch("/teams/{team_id}", response_model=TeamPublic)
def update_team( def update_team(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),

View File

@ -17,7 +17,7 @@ class TeamCreate(TeamBase):
pass pass
class TeamRead(TeamBase): class TeamPublic(TeamBase):
id: int id: int
@ -40,7 +40,7 @@ class Hero(HeroBase, table=True):
team: Team | None = Relationship(back_populates="heroes") team: Team | None = Relationship(back_populates="heroes")
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -79,7 +79,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -88,7 +88,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -99,7 +99,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -107,7 +107,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):
@ -133,7 +133,7 @@ def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
return {"ok": True} return {"ok": True}
@app.post("/teams/", response_model=TeamRead) @app.post("/teams/", response_model=TeamPublic)
def create_team(*, session: Session = Depends(get_session), team: TeamCreate): def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
db_team = Team.model_validate(team) db_team = Team.model_validate(team)
session.add(db_team) session.add(db_team)
@ -142,7 +142,7 @@ def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
return db_team return db_team
@app.get("/teams/", response_model=list[TeamRead]) @app.get("/teams/", response_model=list[TeamPublic])
def read_teams( def read_teams(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -153,7 +153,7 @@ def read_teams(
return teams return teams
@app.get("/teams/{team_id}", response_model=TeamRead) @app.get("/teams/{team_id}", response_model=TeamPublic)
def read_team(*, team_id: int, session: Session = Depends(get_session)): def read_team(*, team_id: int, session: Session = Depends(get_session)):
team = session.get(Team, team_id) team = session.get(Team, team_id)
if not team: if not team:
@ -161,7 +161,7 @@ def read_team(*, team_id: int, session: Session = Depends(get_session)):
return team return team
@app.patch("/teams/{team_id}", response_model=TeamRead) @app.patch("/teams/{team_id}", response_model=TeamPublic)
def update_team( def update_team(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),

View File

@ -19,7 +19,7 @@ class TeamCreate(TeamBase):
pass pass
class TeamRead(TeamBase): class TeamPublic(TeamBase):
id: int id: int
@ -42,7 +42,7 @@ class Hero(HeroBase, table=True):
team: Optional[Team] = Relationship(back_populates="heroes") team: Optional[Team] = Relationship(back_populates="heroes")
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -81,7 +81,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate): def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
session.add(db_hero) session.add(db_hero)
@ -90,7 +90,7 @@ def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes( def read_heroes(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -101,7 +101,7 @@ def read_heroes(
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(*, session: Session = Depends(get_session), hero_id: int): def read_hero(*, session: Session = Depends(get_session), hero_id: int):
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
if not hero: if not hero:
@ -109,7 +109,7 @@ def read_hero(*, session: Session = Depends(get_session), hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero( def update_hero(
*, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
): ):
@ -135,7 +135,7 @@ def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
return {"ok": True} return {"ok": True}
@app.post("/teams/", response_model=TeamRead) @app.post("/teams/", response_model=TeamPublic)
def create_team(*, session: Session = Depends(get_session), team: TeamCreate): def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
db_team = Team.model_validate(team) db_team = Team.model_validate(team)
session.add(db_team) session.add(db_team)
@ -144,7 +144,7 @@ def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
return db_team return db_team
@app.get("/teams/", response_model=list[TeamRead]) @app.get("/teams/", response_model=list[TeamPublic])
def read_teams( def read_teams(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),
@ -155,7 +155,7 @@ def read_teams(
return teams return teams
@app.get("/teams/{team_id}", response_model=TeamRead) @app.get("/teams/{team_id}", response_model=TeamPublic)
def read_team(*, team_id: int, session: Session = Depends(get_session)): def read_team(*, team_id: int, session: Session = Depends(get_session)):
team = session.get(Team, team_id) team = session.get(Team, team_id)
if not team: if not team:
@ -163,7 +163,7 @@ def read_team(*, team_id: int, session: Session = Depends(get_session)):
return team return team
@app.patch("/teams/{team_id}", response_model=TeamRead) @app.patch("/teams/{team_id}", response_model=TeamPublic)
def update_team( def update_team(
*, *,
session: Session = Depends(get_session), session: Session = Depends(get_session),

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -47,7 +47,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -57,14 +57,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -73,7 +73,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -16,7 +16,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -45,7 +45,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -55,14 +55,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -71,7 +71,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -18,7 +18,7 @@ class HeroCreate(HeroBase):
pass pass
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -47,7 +47,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
with Session(engine) as session: with Session(engine) as session:
db_hero = Hero.model_validate(hero) db_hero = Hero.model_validate(hero)
@ -57,14 +57,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -73,7 +73,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -19,7 +19,7 @@ class HeroCreate(HeroBase):
password: str password: str
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -54,7 +54,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
hashed_password = hash_password(hero.password) hashed_password = hash_password(hero.password)
with Session(engine) as session: with Session(engine) as session:
@ -66,14 +66,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=List[HeroRead]) @app.get("/heroes/", response_model=List[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -82,7 +82,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -17,7 +17,7 @@ class HeroCreate(HeroBase):
password: str password: str
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -52,7 +52,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
hashed_password = hash_password(hero.password) hashed_password = hash_password(hero.password)
with Session(engine) as session: with Session(engine) as session:
@ -64,14 +64,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -80,7 +80,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -19,7 +19,7 @@ class HeroCreate(HeroBase):
password: str password: str
class HeroRead(HeroBase): class HeroPublic(HeroBase):
id: int id: int
@ -54,7 +54,7 @@ def on_startup():
create_db_and_tables() create_db_and_tables()
@app.post("/heroes/", response_model=HeroRead) @app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate): def create_hero(hero: HeroCreate):
hashed_password = hash_password(hero.password) hashed_password = hash_password(hero.password)
with Session(engine) as session: with Session(engine) as session:
@ -66,14 +66,14 @@ def create_hero(hero: HeroCreate):
return db_hero return db_hero
@app.get("/heroes/", response_model=list[HeroRead]) @app.get("/heroes/", response_model=list[HeroPublic])
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)): def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
with Session(engine) as session: with Session(engine) as session:
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all() heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
return heroes return heroes
@app.get("/heroes/{hero_id}", response_model=HeroRead) @app.get("/heroes/{hero_id}", response_model=HeroPublic)
def read_hero(hero_id: int): def read_hero(hero_id: int):
with Session(engine) as session: with Session(engine) as session:
hero = session.get(Hero, hero_id) hero = session.get(Hero, hero_id)
@ -82,7 +82,7 @@ def read_hero(hero_id: int):
return hero return hero
@app.patch("/heroes/{hero_id}", response_model=HeroRead) @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
def update_hero(hero_id: int, hero: HeroUpdate): def update_hero(hero_id: int, hero: HeroUpdate):
with Session(engine) as session: with Session(engine) as session:
db_hero = session.get(Hero, hero_id) db_hero = session.get(Hero, hero_id)

View File

@ -99,7 +99,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -136,7 +136,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -172,7 +172,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -244,7 +244,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -297,8 +297,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -102,7 +102,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -139,7 +139,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -175,7 +175,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -247,7 +247,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -300,8 +300,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -102,7 +102,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -139,7 +139,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -175,7 +175,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -247,7 +247,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -300,8 +300,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -104,7 +104,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -141,7 +141,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -177,7 +177,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -230,8 +230,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -107,7 +107,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -144,7 +144,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -180,7 +180,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -233,8 +233,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -107,7 +107,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -144,7 +144,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -180,7 +180,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -233,8 +233,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -74,7 +74,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -101,7 +101,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -154,8 +154,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["id", "name", "secret_name"], "required": ["id", "name", "secret_name"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -76,7 +76,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -103,7 +103,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -156,8 +156,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["id", "name", "secret_name"], "required": ["id", "name", "secret_name"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -77,7 +77,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -104,7 +104,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -157,8 +157,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["id", "name", "secret_name"], "required": ["id", "name", "secret_name"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -74,7 +74,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -101,7 +101,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -154,8 +154,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -77,7 +77,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -104,7 +104,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -157,8 +157,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -77,7 +77,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -104,7 +104,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -157,8 +157,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -59,7 +59,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -86,7 +86,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -122,7 +122,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -175,8 +175,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -62,7 +62,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -89,7 +89,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -125,7 +125,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -178,8 +178,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -62,7 +62,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -89,7 +89,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -125,7 +125,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -178,8 +178,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -147,7 +147,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -184,7 +184,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -220,7 +220,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroReadWithTeam" "$ref": "#/components/schemas/HeroPublicWithTeam"
} }
} }
}, },
@ -292,7 +292,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -346,7 +346,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Teams Teams Get", "title": "Response Read Teams Teams Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
}, },
} }
} }
@ -383,7 +383,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -419,7 +419,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamReadWithHeroes" "$ref": "#/components/schemas/TeamPublicWithHeroes"
} }
} }
}, },
@ -491,7 +491,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -554,8 +554,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -584,8 +584,8 @@ def test_tutorial(clear_sqlmodel):
"id": {"title": "Id", "type": "integer"}, "id": {"title": "Id", "type": "integer"},
}, },
}, },
"HeroReadWithTeam": { "HeroPublicWithTeam": {
"title": "HeroReadWithTeam", "title": "HeroPublicWithTeam",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -615,14 +615,14 @@ def test_tutorial(clear_sqlmodel):
"team": IsDict( "team": IsDict(
{ {
"anyOf": [ "anyOf": [
{"$ref": "#/components/schemas/TeamRead"}, {"$ref": "#/components/schemas/TeamPublic"},
{"type": "null"}, {"type": "null"},
] ]
} }
) )
| IsDict( | IsDict(
# TODO: remove when deprecating Pydantic v1 # TODO: remove when deprecating Pydantic v1
{"$ref": "#/components/schemas/TeamRead"} {"$ref": "#/components/schemas/TeamPublic"}
), ),
}, },
}, },
@ -681,8 +681,8 @@ def test_tutorial(clear_sqlmodel):
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },
}, },
"TeamRead": { "TeamPublic": {
"title": "TeamRead", "title": "TeamPublic",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -691,8 +691,8 @@ def test_tutorial(clear_sqlmodel):
"id": {"title": "Id", "type": "integer"}, "id": {"title": "Id", "type": "integer"},
}, },
}, },
"TeamReadWithHeroes": { "TeamPublicWithHeroes": {
"title": "TeamReadWithHeroes", "title": "TeamPublicWithHeroes",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -702,7 +702,7 @@ def test_tutorial(clear_sqlmodel):
"heroes": { "heroes": {
"title": "Heroes", "title": "Heroes",
"type": "array", "type": "array",
"items": {"$ref": "#/components/schemas/HeroRead"}, "items": {"$ref": "#/components/schemas/HeroPublic"},
"default": [], "default": [],
}, },
}, },

View File

@ -150,7 +150,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -187,7 +187,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -223,7 +223,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroReadWithTeam" "$ref": "#/components/schemas/HeroPublicWithTeam"
} }
} }
}, },
@ -295,7 +295,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -349,7 +349,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Teams Teams Get", "title": "Response Read Teams Teams Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
}, },
} }
} }
@ -386,7 +386,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -422,7 +422,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamReadWithHeroes" "$ref": "#/components/schemas/TeamPublicWithHeroes"
} }
} }
}, },
@ -494,7 +494,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -557,8 +557,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -587,8 +587,8 @@ def test_tutorial(clear_sqlmodel):
"id": {"title": "Id", "type": "integer"}, "id": {"title": "Id", "type": "integer"},
}, },
}, },
"HeroReadWithTeam": { "HeroPublicWithTeam": {
"title": "HeroReadWithTeam", "title": "HeroPublicWithTeam",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -618,14 +618,14 @@ def test_tutorial(clear_sqlmodel):
"team": IsDict( "team": IsDict(
{ {
"anyOf": [ "anyOf": [
{"$ref": "#/components/schemas/TeamRead"}, {"$ref": "#/components/schemas/TeamPublic"},
{"type": "null"}, {"type": "null"},
] ]
} }
) )
| IsDict( | IsDict(
# TODO: remove when deprecating Pydantic v1 # TODO: remove when deprecating Pydantic v1
{"$ref": "#/components/schemas/TeamRead"} {"$ref": "#/components/schemas/TeamPublic"}
), ),
}, },
}, },
@ -684,8 +684,8 @@ def test_tutorial(clear_sqlmodel):
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },
}, },
"TeamRead": { "TeamPublic": {
"title": "TeamRead", "title": "TeamPublic",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -694,8 +694,8 @@ def test_tutorial(clear_sqlmodel):
"id": {"title": "Id", "type": "integer"}, "id": {"title": "Id", "type": "integer"},
}, },
}, },
"TeamReadWithHeroes": { "TeamPublicWithHeroes": {
"title": "TeamReadWithHeroes", "title": "TeamPublicWithHeroes",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -705,7 +705,7 @@ def test_tutorial(clear_sqlmodel):
"heroes": { "heroes": {
"title": "Heroes", "title": "Heroes",
"type": "array", "type": "array",
"items": {"$ref": "#/components/schemas/HeroRead"}, "items": {"$ref": "#/components/schemas/HeroPublic"},
"default": [], "default": [],
}, },
}, },

View File

@ -150,7 +150,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -187,7 +187,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -223,7 +223,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroReadWithTeam" "$ref": "#/components/schemas/HeroPublicWithTeam"
} }
} }
}, },
@ -295,7 +295,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -349,7 +349,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Teams Teams Get", "title": "Response Read Teams Teams Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
}, },
} }
} }
@ -386,7 +386,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -422,7 +422,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamReadWithHeroes" "$ref": "#/components/schemas/TeamPublicWithHeroes"
} }
} }
}, },
@ -494,7 +494,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -557,8 +557,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -587,8 +587,8 @@ def test_tutorial(clear_sqlmodel):
"id": {"title": "Id", "type": "integer"}, "id": {"title": "Id", "type": "integer"},
}, },
}, },
"HeroReadWithTeam": { "HeroPublicWithTeam": {
"title": "HeroReadWithTeam", "title": "HeroPublicWithTeam",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -618,14 +618,14 @@ def test_tutorial(clear_sqlmodel):
"team": IsDict( "team": IsDict(
{ {
"anyOf": [ "anyOf": [
{"$ref": "#/components/schemas/TeamRead"}, {"$ref": "#/components/schemas/TeamPublic"},
{"type": "null"}, {"type": "null"},
] ]
} }
) )
| IsDict( | IsDict(
# TODO: remove when deprecating Pydantic v1 # TODO: remove when deprecating Pydantic v1
{"$ref": "#/components/schemas/TeamRead"} {"$ref": "#/components/schemas/TeamPublic"}
), ),
}, },
}, },
@ -684,8 +684,8 @@ def test_tutorial(clear_sqlmodel):
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },
}, },
"TeamRead": { "TeamPublic": {
"title": "TeamRead", "title": "TeamPublic",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -694,8 +694,8 @@ def test_tutorial(clear_sqlmodel):
"id": {"title": "Id", "type": "integer"}, "id": {"title": "Id", "type": "integer"},
}, },
}, },
"TeamReadWithHeroes": { "TeamPublicWithHeroes": {
"title": "TeamReadWithHeroes", "title": "TeamPublicWithHeroes",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -705,7 +705,7 @@ def test_tutorial(clear_sqlmodel):
"heroes": { "heroes": {
"title": "Heroes", "title": "Heroes",
"type": "array", "type": "array",
"items": {"$ref": "#/components/schemas/HeroRead"}, "items": {"$ref": "#/components/schemas/HeroPublic"},
"default": [], "default": [],
}, },
}, },

View File

@ -99,7 +99,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -136,7 +136,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -172,7 +172,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -244,7 +244,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -297,8 +297,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -104,7 +104,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -141,7 +141,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -177,7 +177,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -249,7 +249,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -302,8 +302,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -104,7 +104,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -141,7 +141,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -177,7 +177,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -249,7 +249,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -302,8 +302,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -134,7 +134,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -171,7 +171,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -207,7 +207,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -279,7 +279,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -333,7 +333,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Teams Teams Get", "title": "Response Read Teams Teams Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
}, },
} }
} }
@ -370,7 +370,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -406,7 +406,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -478,7 +478,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -541,8 +541,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -626,8 +626,8 @@ def test_tutorial(clear_sqlmodel):
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },
}, },
"TeamRead": { "TeamPublic": {
"title": "TeamRead", "title": "TeamPublic",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -137,7 +137,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -174,7 +174,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -210,7 +210,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -282,7 +282,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -336,7 +336,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Teams Teams Get", "title": "Response Read Teams Teams Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
}, },
} }
} }
@ -373,7 +373,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -409,7 +409,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -481,7 +481,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -544,8 +544,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -629,8 +629,8 @@ def test_tutorial(clear_sqlmodel):
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },
}, },
"TeamRead": { "TeamPublic": {
"title": "TeamRead", "title": "TeamPublic",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -137,7 +137,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -174,7 +174,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -210,7 +210,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -282,7 +282,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -336,7 +336,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Teams Teams Get", "title": "Response Read Teams Teams Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
}, },
} }
} }
@ -373,7 +373,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -409,7 +409,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -481,7 +481,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/TeamRead" "$ref": "#/components/schemas/TeamPublic"
} }
} }
}, },
@ -544,8 +544,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {
@ -629,8 +629,8 @@ def test_tutorial(clear_sqlmodel):
"headquarters": {"title": "Headquarters", "type": "string"}, "headquarters": {"title": "Headquarters", "type": "string"},
}, },
}, },
"TeamRead": { "TeamPublic": {
"title": "TeamRead", "title": "TeamPublic",
"required": ["name", "headquarters", "id"], "required": ["name", "headquarters", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -106,7 +106,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -143,7 +143,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -179,7 +179,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -223,7 +223,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -276,8 +276,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -109,7 +109,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -146,7 +146,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -182,7 +182,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -226,7 +226,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -279,8 +279,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -109,7 +109,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -146,7 +146,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -182,7 +182,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -226,7 +226,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -279,8 +279,8 @@ def test_tutorial(clear_sqlmodel):
), ),
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -169,7 +169,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -206,7 +206,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -242,7 +242,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -286,7 +286,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -340,8 +340,8 @@ def test_tutorial(clear_sqlmodel):
"password": {"type": "string", "title": "Password"}, "password": {"type": "string", "title": "Password"},
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -172,7 +172,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -209,7 +209,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -245,7 +245,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -289,7 +289,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -343,8 +343,8 @@ def test_tutorial(clear_sqlmodel):
"password": {"type": "string", "title": "Password"}, "password": {"type": "string", "title": "Password"},
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -172,7 +172,7 @@ def test_tutorial(clear_sqlmodel):
"title": "Response Read Heroes Heroes Get", "title": "Response Read Heroes Heroes Get",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
}, },
} }
} }
@ -209,7 +209,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -245,7 +245,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -289,7 +289,7 @@ def test_tutorial(clear_sqlmodel):
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/HeroRead" "$ref": "#/components/schemas/HeroPublic"
} }
} }
}, },
@ -343,8 +343,8 @@ def test_tutorial(clear_sqlmodel):
"password": {"type": "string", "title": "Password"}, "password": {"type": "string", "title": "Password"},
}, },
}, },
"HeroRead": { "HeroPublic": {
"title": "HeroRead", "title": "HeroPublic",
"required": ["name", "secret_name", "id"], "required": ["name", "secret_name", "id"],
"type": "object", "type": "object",
"properties": { "properties": {