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

Fix broken OpenAPI documentation #37

Merged
merged 3 commits into from
Jan 25, 2025
Merged
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
9 changes: 5 additions & 4 deletions server/routes/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def edit_event(
request: RouteRequest,
id: uuid.UUID,
req: Union[ModifiedEvent, ModifiedEventWithDatetime],
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> EventsWithID:
"""Updates the specified event"""
query = """
Expand Down Expand Up @@ -159,7 +159,7 @@ class DeleteResponse(BaseModel, frozen=True):
async def delete_event(
request: RouteRequest,
id: uuid.UUID,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> DeleteResponse:
"""Deletes the specified event"""
query = """
Expand All @@ -179,7 +179,7 @@ async def delete_event(
async def create_events(
request: RouteRequest,
req: EventsWithCreatorID,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> EventsWithAllID:
"""Creates a new event given the provided data"""
query = """
Expand All @@ -197,5 +197,6 @@ async def create_events(
# Depends on auth
@router.post("/events/join")
async def join_event(
request: RouteRequest, session: SessionContainer = Depends(verify_session)
request: RouteRequest,
session: Annotated[SessionContainer, Depends(verify_session())],
): ...
19 changes: 9 additions & 10 deletions server/routes/projects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import datetime
import uuid
from typing import Annotated, Literal, Optional
Expand Down Expand Up @@ -162,7 +160,7 @@ async def edit_project(
request: RouteRequest,
id: uuid.UUID,
req: ModifiedProject,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
):
"""Updates the specified project"""

Expand Down Expand Up @@ -209,7 +207,7 @@ async def edit_project(
async def delete_project(
request: RouteRequest,
id: uuid.UUID,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
):
"""Deletes the specified project"""
query = """
Expand Down Expand Up @@ -249,7 +247,7 @@ class CreateProject(BaseModel):
async def create_project(
request: RouteRequest,
req: CreateProject,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> PartialProjects:
"""Creates a new project given the provided data"""
query = """
Expand Down Expand Up @@ -306,7 +304,7 @@ class JoinResponse(BaseModel):
async def join_project(
request: RouteRequest,
id: uuid.UUID,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> JoinResponse:
# The member is authenticated already, aka meaning that there is an existing member in our database
query = """
Expand Down Expand Up @@ -353,7 +351,7 @@ async def bulk_join_project(
request: RouteRequest,
id: uuid.UUID,
req: list[BulkJoinMember],
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> JoinResponse:
if len(req) > 10:
raise BadRequestException("Must be less than 10 members")
Expand Down Expand Up @@ -393,7 +391,7 @@ async def bulk_join_project(
async def leave_project(
request: RouteRequest,
id: uuid.UUID,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> DeleteResponse:
query = """
DELETE FROM project_members
Expand Down Expand Up @@ -428,7 +426,7 @@ async def modify_member(
request: RouteRequest,
id: uuid.UUID,
req: UpgradeMemberRole,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
):
"""Undocumented route to just upgrade/demote member role in projects"""
query = """
Expand All @@ -450,7 +448,8 @@ async def modify_member(
@router.get("/projects/me", responses={200: {"model": PartialProjects}})
@router.limiter.limit("15/minute")
async def get_my_projects(
request: RouteRequest, session: SessionContainer = Depends(verify_session)
request: RouteRequest,
session: Annotated[SessionContainer, Depends(verify_session())],
) -> list[PartialProjects]:
"""Get all projects associated with the authenticated user"""
query = """
Expand Down
12 changes: 3 additions & 9 deletions server/routes/tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

from typing import Annotated, Optional

from fastapi import Depends, Query
Expand All @@ -23,10 +21,6 @@ class Tags(BaseModel):
description: str


class PartialTags(BaseModel):
title: str


@router.get("/tags")
async def get_tags(
request: RouteRequest,
Expand Down Expand Up @@ -104,7 +98,7 @@ async def edit_tag(request: RouteRequest, id: int, req: ModifiedTag) -> Tags:
async def delete_tag(
request: RouteRequest,
id: int,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> DeleteResponse:
"""Remove specified tag"""
query = """
Expand All @@ -123,7 +117,7 @@ async def delete_tag(
async def create_tags(
request: RouteRequest,
req: ModifiedTag,
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> Tags:
"""Create tag"""
query = """
Expand All @@ -140,7 +134,7 @@ async def create_tags(
async def bulk_create_tags(
request: RouteRequest,
req: list[ModifiedTag],
session: SessionContainer = Depends(verify_session),
session: Annotated[SessionContainer, Depends(verify_session())],
) -> list[Tags]:
"""Bulk-create tags"""
query = """
Expand Down
4 changes: 1 addition & 3 deletions server/utils/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ class PartialConfig(BaseModel, frozen=True):


class KanaeRouter(APIRouter):
limiter: Limiter

def __init__(self, **kwargs):
super().__init__(**kwargs)

# This isn't my favorite implementation, but will do for now - Noelle
self._config = self._load_config()
self.limiter = Limiter(
self.limiter: Limiter = Limiter(
key_func=get_remote_address,
storage_uri=self._config.redis_uri,
default_limits=self._config.ratelimits, # type: ignore
Expand Down