Skip to content

Commit

Permalink
#414 Define a schema for project duplicate checks (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Only-bottle authored Dec 4, 2024
1 parent 00403e1 commit dbb9a21
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/api/v1/endpoints/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
ProjectCreate,
ProjectDetailPayload,
ProjectDetailResponse,
ProjectDuplicationCheckResponse,
ProjectDuplicationStatus,
ProjectResponse,
ProjectsResponse,
ProjectSummaryPayload,
Expand All @@ -32,6 +34,17 @@ def create_project(
return ProjectResponse(data=project)


@router.post("/duplicate", response_model=ProjectDuplicationCheckResponse)
def check_project_duplication(
*,
request_body: ProjectCreate,
) -> ProjectDuplicationCheckResponse:

duplication_status = ProjectDuplicationStatus(is_duplicated=False)

return ProjectDuplicationCheckResponse(data=duplication_status)


@router.get("", response_model=ProjectsResponse)
def get_projects(
*,
Expand Down
8 changes: 8 additions & 0 deletions app/api/v1/schemas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def validate_length_of_project_name(cls, project_name: str) -> str:
return project_name


class ProjectDuplicationStatus(BaseModel):
is_duplicated: bool = Field(..., description="Indicates if the project name is duplicated.")


class ProjectSummaryPayload(ProjectCreate):
model_config = ConfigDict(from_attributes=True)

Expand Down Expand Up @@ -44,6 +48,10 @@ class ProjectResponse(ResponseItem):
data: ProjectSummaryPayload


class ProjectDuplicationCheckResponse(ResponseItem):
data: ProjectDuplicationStatus


class ProjectDetailResponse(ResponseItem):
data: ProjectDetailPayload

Expand Down

0 comments on commit dbb9a21

Please sign in to comment.