docs: how-to のレスポンス返却を #539 後に更新(陳腐化修正)(#757) - #758
Merged
Conversation
how-to 全28本を監査。ドリフトは2本に集中していた(response_model= と JSONResponse 直接返却の同居=#539 以前のパターン)。 - response-patterns.md: §1 を「既定=レスポンスモデルのインスタンスを返す (FastAPI が検証+直列化)」に書き直し。JSONResponse はカスタム status/ヘッダ/ ストリーミング/成功エラー混在など特別用途のエスケープハッチで内容は検証されない 旨を明記。§2 の手動 dict 変換例もモデル返却に更新。§3〜6 は正当なので維持。 - soft-delete.md: get_article を success パス付き・response_model 付きに修正 (list_articles は既に正しいモデル返却だった)。 他10本の JSONResponse は streaming/DI例/webhook 署名など正当な用途で変更不要。 現在の example handler・CLAUDE.md ポリシーと整合。 Closes #757 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
「how-to が古くなっていないか/資産として育てたい」を受けて全28本を監査。大半は妥当だが、ドリフトが2本に集中していた——
response_model=とJSONResponse直接返却が同居し、#539(response_model 統一)以前のパターンを教えていた。監査結果
response-patterns.mdsoft-delete.mdget_articleが success パス欠落で-> JSONResponselist_articlesは既に正しかった)§3〜6(problem_details 混在・
mode="json"・204+response_model のアサーション等)は正当な FastAPI 落とし穴集なので維持。整合
現在の
src/example/*/handler.py(全てreturn XxxResponse(...))・CLAUDE.md「response_model 明示・Any 返却禁止」と一致。npm run docs:build→ exit 0。Closes #757
🤖 Generated with Claude Code