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

Swagger UI 上のドキュメントを整備する #126

Merged
merged 19 commits into from
Nov 2, 2024

Conversation

sushichan044
Copy link
Collaborator

@sushichan044 sushichan044 commented Oct 25, 2024

Outline

#122
Swagger UI / openapi.json で確認できる API 仕様をより分かりやすいものにする。

  • クエリパラメータ

    • FastAPI の Path()Query() に対して引数でドキュメントを渡すことで自動的に整備できる。
  • レスポンス

    • AnnotatedField(description="", examples=[]) を使って Type Hint でドキュメントを付与
    • 2箇所に分けて書く
    • Model のフィールドごとの説明: common 側の Pydantic Model 内でフィールドごとに付与
      • examples は指定しない
    • Reponse Object の examples: api 側の Response Model に付与

詳細

Docs

  • /posts
    • description
    • param
    • response
  • /notes
    • description
    • param
    • response
  • /topics
    • description
  • /user-enrollments
    • description
    • param

ある程度 Docs 書けたら

  • 各種ドキュメントの examples に指定した ID について、確実にデータが見つかるものに変更する

@sushichan044 sushichan044 self-assigned this Oct 25, 2024
@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from 0191a3a to 3fc71c3 Compare October 25, 2024 09:13
@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from 3fc71c3 to c793b24 Compare October 25, 2024 10:52
@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from 41d8d13 to 34e53b2 Compare October 25, 2024 12:29
@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from 34e53b2 to 20f0874 Compare October 25, 2024 12:33
@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from 20f0874 to 25a9a0b Compare October 25, 2024 12:43
@sushichan044 sushichan044 requested a review from yu23ki14 October 31, 2024 05:57
@sushichan044 sushichan044 marked this pull request as ready for review October 31, 2024 05:57
@sushichan044
Copy link
Collaborator Author

sushichan044 commented Oct 31, 2024

Note

PR description へ転記済

note: レスポンスへの documentation は二箇所に分ける

  • フィールドごとの説明: common の Pydantic Model 内でフィールドごとに付与
    • examples は指定しない
  • Reponse Object の Example: 自動的に lowerCamelCase になる api 側の都合を common に出したくないので api 側の Response Model に付与

@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from d0f9f95 to df69636 Compare October 31, 2024 11:41
Add docs to properties of Topic, Note, Post, PaginationMeta

Post.link のcomputed_field と property の順序が逆だった
これを正しくしたところ Post.link の doctest が壊れた
純粋な文字列合成なのでテストを消しても問題ないと判断して削除
@sushichan044 sushichan044 force-pushed the issue-122-swagger-docs branch from df69636 to 259e19a Compare October 31, 2024 12:26
@yu23ki14 yu23ki14 merged commit c4f0d07 into main Nov 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants