Skip to content

Commit

Permalink
docs: /v1/data/user-enrollments
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed Oct 25, 2024
1 parent 25a9a0b commit 6d90ff5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
17 changes: 13 additions & 4 deletions api/birdxplorer_api/routers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List, Union

from dateutil.parser import parse as dateutil_parse
from fastapi import APIRouter, HTTPException, Query, Request
from fastapi import APIRouter, HTTPException, Path, Query, Request
from pydantic import HttpUrl

from birdxplorer_common.models import (
Expand All @@ -21,7 +21,12 @@
)
from birdxplorer_common.storage import Storage

from .openapi_doc import V1DataNotesDocs, V1DataPostsDocs, V1DataTopicsDocs
from .openapi_doc import (
V1DataNotesDocs,
V1DataPostsDocs,
V1DataTopicsDocs,
V1DataUserEnrollmentsDocs,
)


class TopicListResponse(BaseModel):
Expand Down Expand Up @@ -58,9 +63,13 @@ def ensure_twitter_timestamp(t: Union[str, TwitterTimestamp]) -> TwitterTimestam
def gen_router(storage: Storage) -> APIRouter:
router = APIRouter()

@router.get("/user-enrollments/{participant_id}", response_model=UserEnrollment)
@router.get(
"/user-enrollments/{participant_id}",
description=V1DataUserEnrollmentsDocs.description,
response_model=UserEnrollment,
)
def get_user_enrollment_by_participant_id(
participant_id: ParticipantId,
participant_id: ParticipantId = Path(**V1DataUserEnrollmentsDocs.params["participant_id"]),
) -> UserEnrollment:
res = storage.get_user_enrollment_by_participant_id(participant_id=participant_id)
if res is None:
Expand Down
18 changes: 18 additions & 0 deletions api/birdxplorer_api/routers/openapi_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,21 @@ class FastAPIEndpointDocs(Generic[_KEY]):
"自動分類されたコミュニティノートのトピックを取得するエンドポイント",
{}, # type: ignore[var-annotated]
)


v1_data_user_enrollments_participant_id: FastAPIEndpointParamDocs = {
"description": "取得するコミュニティノート参加ユーザーの ID。",
"openapi_examples": {
"single": {
"summary": "ID: B8B599F50C14003B9520DC8832612831B2D69BFC3B44C8336A800DF725396FBF のユーザーのデータを取得する",
"value": "B8B599F50C14003B9520DC8832612831B2D69BFC3B44C8336A800DF725396FBF",
},
},
}

V1DataUserEnrollmentsDocs = FastAPIEndpointDocs(
"コミュニティノート参加ユーザーのデータを取得するエンドポイント",
{
"participant_id": v1_data_user_enrollments_participant_id,
},
)

0 comments on commit 6d90ff5

Please sign in to comment.