Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update todo.py #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/domain/schemas/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@


class TodoBase(SchemaBase):
"""your code goes here"""
description = str
user_id = int


class TodoCreate(TodoBase):
pass


class Todo(TodoBase):
id: Optional[int] = None
class Config:
orm_mode = True

Expand Down
14 changes: 13 additions & 1 deletion api/host/endpoints/todo_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,16 @@

@cbv(router)
class TodoEndpoints(EndpointsBase[TodoCreate, Todo]):
"""Your code goes here"""
@inject
def __init__(self, handler: TodoHandler = Depends(Provide[ApplicationContainer.handler_container.TodoHandler])):
super().__init__(handler=handler)

@router.post('/todo', status_code=status.HTTP_201_CREATED)
def create(self, dto: TodoCreate) -> TodoResponse:
result = super().create(dto)
return result

@router.get('/todo/{todo_id}')
def get_by_id(self, todo_id: int) -> TodoResponse:
result = super().get_by_id(todo_id)
return result