Repository navigation
Commit 4e59e1c
refactor: split the Deck response contract from its detail view
A single Deck schema served two endpoints with different card-loading
strategies, leaking that difference into a cards: list[Card] | None
field. Worse, list_decks reported cards: [] for every deck regardless
of its real cards, because the relationship is lazy="noload" — the
list contract was lying, and the | None was dead (noload yields []).
Split into Deck (no cards) and DeckWithCards(Deck) (cards: list[Card],
always populated). get_deck returns DeckWithCards; list/create/update
return the light Deck. Each endpoint's type now states exactly what it
loads, and the dead | None is gone.
This is an intentional wire-contract change: the cards key disappears
from list/create/update responses. The two-shape convention is recorded
in CLAUDE.md and in docstrings on the Deck/DeckWithCards schemas.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 250109c commit 4e59e1c
3 files changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
0 commit comments