Skip to content

feat: add HTTP QUERY method support#4902

Open
bizprat wants to merge 1 commit into
litestar-org:mainfrom
bizprat:feat/query-method
Open

feat: add HTTP QUERY method support#4902
bizprat wants to merge 1 commit into
litestar-org:mainfrom
bizprat:feat/query-method

Conversation

@bizprat

@bizprat bizprat commented Jul 9, 2026

Copy link
Copy Markdown

Summary

  • add HttpMethod.QUERY and first-class @query route decorator exports
  • add RequestFactory.query() support for tests and request construction
  • treat QUERY as a CSRF safe method by default
  • keep @query excluded from OpenAPI 3.1 schema output by default, leaving OpenAPI 3.2 path item support as a separate follow-up
  • keep OpenAPI TypeScript conversion limited to OpenAPI 3.1 path-item methods so framework-only methods do not break schema tooling

Closes #4626.

Verification

  • uv run --python 3.13 pytest tests/unit/test_openapi/test_typescript_converter/test_converter.py tests/unit/test_cli/test_schema_commands.py
  • uv run --python 3.13 pytest tests/e2e/test_query_method.py tests/e2e/test_router_registration.py tests/e2e/test_option_requests.py tests/unit/test_data_extractors.py tests/unit/test_middleware/test_csrf_middleware.py tests/unit/test_openapi/test_path_item.py
  • uv run --python 3.13 ruff format --check litestar tests/e2e/test_query_method.py tests/unit/test_data_extractors.py tests/unit/test_middleware/test_csrf_middleware.py tests/unit/test_openapi/test_path_item.py tests/unit/test_openapi/test_typescript_converter/test_converter.py tests/unit/test_cli/test_schema_commands.py
  • uv run --python 3.13 ruff check litestar tests/e2e/test_query_method.py tests/unit/test_data_extractors.py tests/unit/test_middleware/test_csrf_middleware.py tests/unit/test_openapi/test_path_item.py tests/unit/test_openapi/test_typescript_converter/test_converter.py tests/unit/test_cli/test_schema_commands.py
  • uv run --python 3.13 pyright litestar/enums.py litestar/types/asgi_types.py litestar/handlers/http_handlers/decorators.py litestar/testing/request_factory.py litestar/_openapi/typescript_converter/converter.py tests/e2e/test_query_method.py tests/unit/test_data_extractors.py tests/unit/test_middleware/test_csrf_middleware.py tests/unit/test_openapi/test_path_item.py tests/unit/test_openapi/test_typescript_converter/test_converter.py tests/unit/test_cli/test_schema_commands.py
  • uv run --python 3.13 mypy litestar/enums.py litestar/types/asgi_types.py litestar/handlers/http_handlers/decorators.py litestar/testing/request_factory.py litestar/_openapi/typescript_converter/converter.py tests/e2e/test_query_method.py tests/unit/test_data_extractors.py tests/unit/test_middleware/test_csrf_middleware.py tests/unit/test_openapi/test_path_item.py tests/unit/test_openapi/test_typescript_converter/test_converter.py tests/unit/test_cli/test_schema_commands.py
  • uv run --python 3.13 pre-commit run --files litestar/__init__.py litestar/config/csrf.py litestar/enums.py litestar/handlers/__init__.py litestar/handlers/http_handlers/__init__.py litestar/handlers/http_handlers/decorators.py litestar/testing/request_factory.py litestar/types/asgi_types.py litestar/_openapi/typescript_converter/converter.py tests/unit/test_data_extractors.py tests/unit/test_middleware/test_csrf_middleware.py tests/unit/test_openapi/test_path_item.py tests/unit/test_openapi/test_typescript_converter/test_converter.py tests/unit/test_cli/test_schema_commands.py tests/e2e/test_query_method.py

📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4902

@bizprat bizprat requested review from a team as code owners July 9, 2026 13:10
@bizprat bizprat force-pushed the feat/query-method branch from 6ed649f to c0a988b Compare July 9, 2026 13:20
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.29%. Comparing base (149a4ae) to head (28e214d).

Files with missing lines Patch % Lines
litestar/handlers/http_handlers/decorators.py 60.00% 2 Missing ⚠️
litestar/enums.py 0.00% 1 Missing ⚠️
litestar/handlers/__init__.py 0.00% 1 Missing ⚠️
litestar/handlers/http_handlers/__init__.py 0.00% 1 Missing ⚠️
litestar/types/asgi_types.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4902   +/-   ##
=======================================
  Coverage   67.28%   67.29%           
=======================================
  Files         293      293           
  Lines       15226    15234    +8     
  Branches     1727     1727           
=======================================
+ Hits        10245    10251    +6     
- Misses       4834     4836    +2     
  Partials      147      147           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bizprat bizprat force-pushed the feat/query-method branch from c0a988b to 4ee6036 Compare July 9, 2026 13:32
Comment thread litestar/_openapi/typescript_converter/converter.py Outdated
Signed-off-by: Prateek Anand <bizprat@gmail.com>
@bizprat bizprat force-pushed the feat/query-method branch from 4ee6036 to 28e214d Compare July 9, 2026 13:36
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.

Enhancement: Support the QUERY HTTP method

2 participants