Skip to content

fix: restore LEANN HTTP server OpenAPI and search body parsing - #2

Draft
Paltidor87 wants to merge 1 commit into
mainfrom
cursor/fix-server-openapi-e0ec
Draft

Paltidor87 wants to merge 1 commit into
mainfrom
cursor/fix-server-openapi-e0ec

Conversation

@Paltidor87

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes LEANN HTTP server schema/validation issues that broke both /openapi.json and POST /indexes/{index_name}/search.

Changes

  • Add a regression test module for HTTP server behavior:
    • test_openapi_schema_loads ensures /openapi.json renders successfully.
    • test_search_endpoint_accepts_json_body ensures plain JSON request bodies are accepted by the search route.
  • Update packages/leann-core/src/leann/server.py:
    • Import Body from FastAPI in lazy loader.
    • Change search route signature from typed local model body to body: dict[str, Any] = Body(...).
    • Parse/validate with SearchRequest(**body) inside the route handler.
    • Keep response model + search behavior unchanged.

This removes the unresolved forward-ref/schema generation failure and restores normal request parsing.

Related Issues

Fixes #

Checklist

  • Tests pass (uv run pytest)
  • Code formatted (ruff format and ruff check)
  • Pre-commit hooks pass (pre-commit run --all-files)

Verification performed

  • uv run pytest tests/test_http_server_api.py -q passes.
  • Manual smoke checks against running server:
    • GET /health returns {"status":"ok"}
    • GET /indexes returns indexed entries
    • GET /openapi.json returns valid schema including /indexes/{index_name}/search
    • POST /indexes/env-check/search with JSON body returns search results
Open in Web Open in Cursor 

Co-authored-by: Peggens <iamaltidor@gmail.com>
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.

2 participants