Skip to content

Commit

Permalink
docs: /v1/data/topics
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed Oct 25, 2024
1 parent 93e61bf commit 25a9a0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/birdxplorer_api/routers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from birdxplorer_common.storage import Storage

from .openapi_doc import V1DataNotesDocs, V1DataPostsDocs
from .openapi_doc import V1DataNotesDocs, V1DataPostsDocs, V1DataTopicsDocs


class TopicListResponse(BaseModel):
Expand Down Expand Up @@ -67,7 +67,7 @@ def get_user_enrollment_by_participant_id(
raise ValueError(f"participant_id={participant_id} not found")
return res

@router.get("/topics", response_model=TopicListResponse)
@router.get("/topics", description=V1DataTopicsDocs.description, response_model=TopicListResponse)
def get_topics() -> TopicListResponse:
return TopicListResponse(data=list(storage.get_topics()))

Expand Down
6 changes: 6 additions & 0 deletions api/birdxplorer_api/routers/openapi_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,9 @@ class FastAPIEndpointDocs(Generic[_KEY]):
},
)

# 第2引数を空の辞書にすると mypy に怒られる
# が、第2引数が空の辞書でも怒られない実装にすると param 辞書の補完が効かなくなるので、エラーを無視する
V1DataTopicsDocs = FastAPIEndpointDocs(
"自動分類されたコミュニティノートのトピックを取得するエンドポイント",
{}, # type: ignore[var-annotated]
)

0 comments on commit 25a9a0b

Please sign in to comment.