Skip to content

Add explicit status_code to all API route decorators#9

Merged
JuliusScheuerer merged 1 commit into
mainfrom
worktree-add-explicit-status-codes
Mar 25, 2026
Merged

Add explicit status_code to all API route decorators#9
JuliusScheuerer merged 1 commit into
mainfrom
worktree-add-explicit-status-codes

Conversation

@JuliusScheuerer
Copy link
Copy Markdown
Owner

Summary

  • Add status_code=200 to /api/detect, /api/anonymize, and /api/strategies route decorators
  • Ensures OpenAPI schema correctly documents response status codes for client codegen
  • Per FASTAPI-RULES.md §6

Test plan

  • make check passes (275 tests, 95.58% coverage)

Per FASTAPI-RULES.md §6, every route must declare status_code explicitly
so OpenAPI schema consumers get accurate status codes.
@JuliusScheuerer JuliusScheuerer merged commit 3e3090c into main Mar 25, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 25, 2026

Greptile Summary

This PR makes the HTTP 200 response status code explicit on all three API route decorators in router.py. Previously FastAPI inferred 200 as the default, but the explicit declaration ensures the OpenAPI schema correctly documents the response status codes, which is important for accurate client code generation.

  • Adds status_code=200 to POST /api/detect, POST /api/anonymize, and GET /api/strategies
  • No logic, behavior, or response structure changes — purely declarative
  • The chosen status code (200) is semantically correct for all three endpoints: they perform transformations/reads rather than resource creation (which would warrant 201)

Confidence Score: 5/5

  • This PR is safe to merge — it is a purely declarative, zero-risk change.
  • The change adds explicit status_code=200 to three route decorators. FastAPI already defaults to 200 for these endpoints, so this is a no-op at runtime with no behavioral change. All three status codes are semantically correct (processing/read operations, not resource creation). The change is minimal, consistent, and well-scoped.
  • No files require special attention.

Important Files Changed

Filename Overview
src/document_anonymizer/api/router.py Adds explicit status_code=200 to all three route decorators (/detect, /anonymize, /strategies) to make OpenAPI schema status codes explicit for client codegen — no logic changes.

Sequence Diagram

sequenceDiagram
    participant Client
    participant FastAPI as FastAPI Router
    participant Engine as Detection/Anonymization Engine

    Client->>FastAPI: POST /api/detect
    FastAPI->>Engine: detect_pii_in_text()
    Engine-->>FastAPI: List[RecognizerResult]
    FastAPI-->>Client: 200 DetectionResponse

    Client->>FastAPI: POST /api/anonymize
    FastAPI->>Engine: detect_pii_in_text() + anonymize_text()
    Engine-->>FastAPI: anonymized string
    FastAPI-->>Client: 200 AnonymizeResponse

    Client->>FastAPI: GET /api/strategies
    FastAPI-->>Client: 200 StrategiesResponse
Loading

Reviews (1): Last reviewed commit: "Add explicit status_code=200 to all API ..." | Re-trigger Greptile

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