Skip to content

Commit bf2e99b

Browse files
committed
chore: add details to swagger docs
1 parent a6bce2c commit bf2e99b

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ async def lifespan(app: FastAPI):
1414
FastAPICache.init(InMemoryBackend())
1515
yield
1616

17-
app = FastAPI(lifespan=lifespan)
17+
app = FastAPI(lifespan=lifespan,
18+
title="python-samples-fastapi-restful",
19+
description="🧪 Proof of Concept for a RESTful API made with Python 3 and FastAPI",
20+
version="1.0.0",)
21+
1822
app.include_router(player_route.api_router)

routes/player_route.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def get_orm_session():
3737
@api_router.post(
3838
"/players/",
3939
status_code=status.HTTP_201_CREATED,
40-
summary="Creates a new Player"
40+
summary="Creates a new Player",
41+
tags=["Players"]
4142
)
4243
def post(
4344
player_model: PlayerModel = Body(...),
@@ -69,7 +70,8 @@ def post(
6970
"/players/",
7071
response_model=List[PlayerModel],
7172
status_code=status.HTTP_200_OK,
72-
summary="Retrieves a collection of Players"
73+
summary="Retrieves a collection of Players",
74+
tags=["Players"]
7375
)
7476
@cache(expire=CACHING_TIME_IN_SECONDS)
7577
def get_all(
@@ -93,7 +95,8 @@ def get_all(
9395
"/players/{player_id}",
9496
response_model=PlayerModel,
9597
status_code=status.HTTP_200_OK,
96-
summary="Retrieves a Player by its Id"
98+
summary="Retrieves a Player by its Id",
99+
tags=["Players"]
97100
)
98101
@cache(expire=CACHING_TIME_IN_SECONDS)
99102
def get_by_id(
@@ -125,7 +128,8 @@ def get_by_id(
125128
"/players/squadnumber/{squad_number}",
126129
response_model=PlayerModel,
127130
status_code=status.HTTP_200_OK,
128-
summary="Retrieves a Player by its Squad Number"
131+
summary="Retrieves a Player by its Squad Number",
132+
tags=["Players"]
129133
)
130134
@cache(expire=CACHING_TIME_IN_SECONDS)
131135
def get_by_squad_number(
@@ -158,7 +162,8 @@ def get_by_squad_number(
158162
@api_router.put(
159163
"/players/{player_id}",
160164
status_code=status.HTTP_204_NO_CONTENT,
161-
summary="Updates an existing Player"
165+
summary="Updates an existing Player",
166+
tags=["Players"]
162167
)
163168
def put(
164169
player_id: int = Path(..., title="The ID of the Player"),
@@ -191,7 +196,8 @@ def put(
191196
@api_router.delete(
192197
"/players/{player_id}",
193198
status_code=status.HTTP_204_NO_CONTENT,
194-
summary="Deletes an existing Player"
199+
summary="Deletes an existing Player",
200+
tags=["Players"]
195201
)
196202
def delete(
197203
player_id: int = Path(..., title="The ID of the Player"),

0 commit comments

Comments
 (0)