Skip to content

Add DELETE endpoint for persons and separate update schema - #32

Merged
heinrich10 merged 2 commits into
mainfrom
feat/fix_api_endpoints
Jun 12, 2026
Merged

Add DELETE endpoint for persons and separate update schema#32
heinrich10 merged 2 commits into
mainfrom
feat/fix_api_endpoints

Conversation

@heinrich10

Copy link
Copy Markdown
Owner

What?

Completes the Person CRUD surface by adding a DELETE endpoint and separating the update schema from the create schema.

Files changed (9):

  • pyfastapi/schemas/person.py — added PersonUpdateSchema with optional fields
  • pyfastapi/schemas/__init__.py — exported PersonUpdateSchema
  • pyfastapi/services/person.py — added delete_person, restored update_or_create_person for upsert semantics
  • pyfastapi/repositories/person.py — added delete_person method, kept update_or_create_person
  • pyfastapi/controllers/person.py — added DELETE route; PUT uses PersonCreateSchema with upsert semantics
  • tests/unit_tests/services/test_person_service.py — added delete + upsert unit tests
  • tests/api_tests/test_persons.py — added delete + upsert integration tests
  • tests/api_tests/test_e2e.py — updated e2e test to expect 204 on upsert of non-existent ID
  • http/api.http — added DELETE request example

Why?

  • The architecture roadmap flagged P2: "Incomplete CRUD surface — No DELETE endpoints exist for any entity, and PUT semantics are muddled"
  • Person previously had no DELETE endpoint and PUT reused PersonCreateSchema with unclear upsert behavior
  • Separating PersonUpdateSchema from PersonCreateSchema sets up the codebase for future PATCH support if needed

How?

  • POST /persons — uses PersonCreateSchema (all fields required)
  • PUT /persons/{id} — uses PersonCreateSchema, performs full-replace upsert (SQLite ON CONFLICT DO UPDATE)
  • DELETE /persons/{id} — fetches existing person, deletes if found, otherwise raises PersonNotFoundError → 404
  • Country and Continent remain read-only (no POST/PUT/DELETE added)

Testing?

  • uv run pytest65/65 tests pass
  • uv run flake8 .0 issues
  • uv run mypy --strict .0 errors across 51 source files

Screenshots (optional)

N/A — backend API changes only.

Anything Else?

  • No behavioral changes to existing GET / POST endpoints
  • AGENTS.md were updated to reflect the completed P2 roadmap item

AI Summary (optional)

Completed the Person CRUD surface by adding DELETE /persons/{id}, separating PersonUpdateSchema from PersonCreateSchema, and restoring clear upsert semantics on PUT. Added unit and integration tests for delete and upsert behavior.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1220 1201 98% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
pyfastapi/controllers/person.py 100% 🟢
pyfastapi/repositories/person.py 100% 🟢
pyfastapi/services/person.py 100% 🟢
tests/api_tests/test_e2e.py 100% 🟢
tests/api_tests/test_persons.py 100% 🟢
tests/unit_tests/services/test_person_service.py 100% 🟢
TOTAL 100% 🟢

updated for commit: 276c914 by action🐍

@heinrich10
heinrich10 merged commit b8a88d0 into main Jun 12, 2026
1 check passed
@heinrich10
heinrich10 deleted the feat/fix_api_endpoints branch June 12, 2026 09:44
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