Skip to content

Commit b0fa7a0

Browse files
committed
doc: documenting api
1 parent 80cad4a commit b0fa7a0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/app/components/todos/router.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ async def lifespan(_: FastAPI) -> AsyncIterator[Never]:
3030

3131
@router.get("/", tags=["todos"])
3232
async def all() -> Todos:
33+
"""Gets all todos"""
3334
todos = get_todos()
3435
return await todos.all()
3536

3637

3738
@router.get("/search", tags=["todos"])
3839
async def search(name: str | None = None, status: TodoStatus | None = None) -> Todos:
40+
"""Searches for todos by name and/or status"""
3941
todos = get_todos()
4042
return await todos.search(name, status)
4143

4244

4345
@router.get("/{id}", tags=["todos"])
4446
async def one(id: str) -> Todo:
47+
"""Gets a todo by id"""
4548
todos = get_todos()
4649
return await todos.one(id)
4750

@@ -53,6 +56,7 @@ class CreateTodo(BaseModel):
5356

5457
@router.post("/", tags=["todos"])
5558
async def create(todo: CreateTodo) -> TodoDocument:
59+
"""Creates a todo"""
5660
todos = get_todos()
5761
return await todos.create(todo.id, todo.name)
5862

@@ -63,11 +67,13 @@ class UpdateTodo(BaseModel):
6367

6468
@router.patch("/{id}", tags=["todos"])
6569
async def update(id: str, todo: UpdateTodo) -> Todo:
70+
"""Updates a todo's status"""
6671
todos = get_todos()
6772
return await todos.update(id, todo.status)
6873

6974

7075
@router.delete("/{id}", tags=["todos"])
7176
async def delete(id: str) -> None:
77+
"""Deletes a todo"""
7278
todos = get_todos()
7379
return await todos.delete(id)

src/app/components/todos/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ async def create(self, id: Optional[str], name: Optional[str]) -> TodoDocument:
255255

256256
async def update(self, id: str, status: TodoStatus) -> Todo:
257257
"""
258-
Updates a todo
258+
Updates a todo's status
259259
"""
260260
dt = datetime.now(UTC)
261261

0 commit comments

Comments
 (0)