Response models can now properly return expansions as well
This commit is contained in:
parent
a7f9b63556
commit
c73d7b31ce
1 changed files with 4 additions and 2 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
|
|
@ -23,13 +25,13 @@ def get_boardgame_by_id(boardgame_id: int):
|
|||
requested_boardgame: boardgame_classes.BoardGame = data_connection.get_boardgame(boardgame_id)
|
||||
return requested_boardgame
|
||||
|
||||
@app.get("/owned", response_model=list[boardgame_classes.OwnedBoardGame])
|
||||
@app.get("/owned", response_model=Union[list[boardgame_classes.OwnedBoardGame], list[boardgame_classes.OwnedBoardGameExpansion]])
|
||||
def get_owned_collection():
|
||||
requested_collection: list[boardgame_classes.OwnedBoardGame] = data_connection.get_user_owned_collection()
|
||||
return requested_collection
|
||||
|
||||
|
||||
@app.get("/wishlist", response_model=list[boardgame_classes.WishlistBoardGame])
|
||||
@app.get("/wishlist", response_model=Union[list[boardgame_classes.WishlistBoardGame], list[boardgame_classes.WishlistBoardGameExpansion]])
|
||||
def get_wishlist_collection():
|
||||
requested_collection: list[boardgame_classes.WishlistBoardGame] = data_connection.get_user_wishlist_collection()
|
||||
return requested_collection
|
||||
|
|
|
|||
Loading…
Reference in a new issue