Add DELETE endpoint for persons and separate update schema - #32
Merged
Conversation
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
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.
What?
Completes the Person CRUD surface by adding a
DELETEendpoint and separating the update schema from the create schema.Files changed (9):
pyfastapi/schemas/person.py— addedPersonUpdateSchemawith optional fieldspyfastapi/schemas/__init__.py— exportedPersonUpdateSchemapyfastapi/services/person.py— addeddelete_person, restoredupdate_or_create_personfor upsert semanticspyfastapi/repositories/person.py— addeddelete_personmethod, keptupdate_or_create_personpyfastapi/controllers/person.py— addedDELETEroute;PUTusesPersonCreateSchemawith upsert semanticstests/unit_tests/services/test_person_service.py— added delete + upsert unit teststests/api_tests/test_persons.py— added delete + upsert integration teststests/api_tests/test_e2e.py— updated e2e test to expect 204 on upsert of non-existent IDhttp/api.http— added DELETE request exampleWhy?
DELETEendpoints exist for any entity, andPUTsemantics are muddled"Personpreviously had noDELETEendpoint andPUTreusedPersonCreateSchemawith unclear upsert behaviorPersonUpdateSchemafromPersonCreateSchemasets up the codebase for futurePATCHsupport if neededHow?
POST /persons— usesPersonCreateSchema(all fields required)PUT /persons/{id}— usesPersonCreateSchema, performs full-replace upsert (SQLiteON CONFLICT DO UPDATE)DELETE /persons/{id}— fetches existing person, deletes if found, otherwise raisesPersonNotFoundError→ 404CountryandContinentremain read-only (no POST/PUT/DELETE added)Testing?
uv run pytest— 65/65 tests passuv run flake8 .— 0 issuesuv run mypy --strict .— 0 errors across 51 source filesScreenshots (optional)
N/A — backend API changes only.
Anything Else?
GET/POSTendpointsAGENTS.mdwere updated to reflect the completed P2 roadmap itemAI Summary (optional)
Completed the Person CRUD surface by adding
DELETE /persons/{id}, separatingPersonUpdateSchemafromPersonCreateSchema, and restoring clear upsert semantics onPUT. Added unit and integration tests for delete and upsert behavior.