Skip to content

feat(http): OpenAPI アノテーションと utoipa-axum 統合#14

Merged
hitalin merged 2 commits into
mainfrom
feat/openapi-annotations
May 14, 2026
Merged

feat(http): OpenAPI アノテーションと utoipa-axum 統合#14
hitalin merged 2 commits into
mainfrom
feat/openapi-annotations

Conversation

@hitalin
Copy link
Copy Markdown
Owner

@hitalin hitalin commented May 14, 2026

なぜ

notecli の HTTP サーバー (build_core_routes) が登録する Misskey コア API 15 本には OpenAPI アノテーションが一切なく、これを埋め込む NoteDeck 側の Scalar API ドキュメントから完全に欠落していた(全 22 本中 7 本しか表示されていなかった)。

何を

utoipa-axumOpenApiRouter + routes! マクロを導入し、ルート登録と OpenAPI spec 生成を 1 操作に統合。ルートを登録すれば必ず spec に載るため、アノテーション付け忘れによるドリフトが構造的に発生しない。

  • 15 ハンドラに #[utoipa::path] を付与(path/method/status/description/security)
  • レスポンスモデル 15 struct に ToSchema を derive(リッチなスキーマ)
  • Query/Body struct に IntoParams / ToSchema を derive
  • build_core_routesOpenApiRouter 化、build_routersplit_for_parts()Router を返す(外部シグネチャ不変)
  • state 非依存の core_openapi() を公開 — ホストアプリ (NoteDeck) が DB/client を構築せずにフル spec を生成できる
  • /api index の手書き endpoints 配列を廃止し、spec から導出(endpoints_from_spec
  • 標準サーバー用に ApiDoc / SecurityAddon を追加(埋め込み時はホストが merge)
  • core_routes_are_all_in_the_spec テストで OpenApiRouter 配線のリグレッションをガード

影響範囲

build_core_routes の戻り値型変更の影響は notecli build_router と NoteDeck serve() の 2 箇所のみ。utoipa / utoipa-axum を通常依存として追加(--no-default-features ビルドも確認済み)。

テスト

  • cargo test 全 142 件 green(http_server の新規 2 件含む)
  • cargo clippy --lib 警告なし(既存の manual_flatten 1 件のみ、本 PR と無関係)
  • cargo check --no-default-features 通過

🤖 Generated with Claude Code

hitalin and others added 2 commits May 14, 2026 16:43
build_core_routes を OpenApiRouter 化し、ルート登録と OpenAPI spec 生成を
routes! マクロで一体化。ルートを追加すれば必ず spec に載るため、
アノテーション付け忘れによるドリフトが構造的に発生しなくなる。

- 15 ハンドラに #[utoipa::path] を付与(path/method/status/description/security)
- レスポンスモデル 15 struct に ToSchema を derive(リッチなスキーマ)
- Query/Body struct に IntoParams / ToSchema を derive
- /api index の手書き endpoints 配列を廃止し、spec から導出(endpoints_from_spec)
- 標準サーバー用に ApiDoc / SecurityAddon を追加(埋め込み時はホストが merge)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ホストアプリ (NoteDeck) が DB/client を構築せずにフル spec を生成できるよう、
ルート登録部を core_openapi_router() に切り出し、state-free な core_openapi() を
公開。/api/openapi.json・Tauri command・コミット済みスナップショットが
同一の spec source を共有できる。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hitalin hitalin self-assigned this May 14, 2026
@hitalin hitalin merged commit 59b39c2 into main May 14, 2026
1 check failed
hitalin added a commit to hitalin/notedeck that referenced this pull request May 14, 2026
PR hitalin/notecli#14 がマージされたため、フィーチャーブランチの commit
から main の マージ commit (59b39c2) に更新。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant