Skip to content

fix: require deck_id on Card response schema - #92

Merged
lesnik512 merged 1 commit into
mainfrom
fix/card-deck-id-required
Oct 17, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
fix/card-deck-id-required

Conversation

@lesnik512

Copy link
Copy Markdown
Member

cards.deck_id is NOT NULL in the model and the database after #91, so Card.deck_id in the API schema should be required instead of PositiveInt | None = None.

Card was also the body type of PUT /api/decks/{deck_id}/cards/, where the deck comes from the path and the repository already dropped any body deck_id. Making the field required would have made every PUT fail validation, so the body now uses a new CardUpdate (front, back, hint, id). Card extends it with the required deck_id and is used for responses only. upsert_cards no longer needs exclude={"deck_id"}.

Tests: a new OpenAPI test asserts deck_id is required on Card. It failed before the change. Ruff, ty and pytest (100% coverage) pass against Postgres 14.

@lesnik512
lesnik512 merged commit 736dca3 into main Oct 17, 2026
3 checks passed
@lesnik512
lesnik512 deleted the fix/card-deck-id-required branch October 17, 2026 07:35
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