Skip to content

feat: implement missing FastAPI-parity features#24

Merged
EshwarCVS merged 8 commits intomasterfrom
claude/build-missing-features-abDz7
Apr 18, 2026
Merged

feat: implement missing FastAPI-parity features#24
EshwarCVS merged 8 commits intomasterfrom
claude/build-missing-features-abDz7

Conversation

@EshwarCVS
Copy link
Copy Markdown
Collaborator

@EshwarCVS EshwarCVS commented Apr 17, 2026

Summary

Implements the missing features identified in the codebase audit, bringing FasterAPI to full FastAPI API parity.

New modules

  • security.pyOAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, HTTPBasic/HTTPBasicCredentials, APIKeyHeader, APIKeyQuery, APIKeyCookie
  • templating.pyJinja2Templates with TemplateResponse()
  • staticfiles.pyStaticFiles ASGI app with path-traversal protection

Updated modules

  • response.pyEventSourceResponse (SSE), ORJSONResponse/UJSONResponse aliases, datetime/UUID/Decimal serialization via custom enc_hook
  • dependencies.pyAnnotated[T, Depends()] PEP 593 style, @dataclass body support, callable-instance dependencies (for security schemes), class-based dependencies
  • app.pylifespan= async context manager, response_model/response_model_include/response_model_exclude field filtering, app.mount() for sub-apps, openapi_tags/terms_of_service/contact/license_info constructor params, responses={404:…} per-route, dependencies= on include_router()
  • router.pydependencies=[] on FasterRouter and all route decorators
  • openapi/generator.py — Enum path param schemas, multiple response declarations, all new metadata fields, datetime/UUID/Decimal/@dataclass type schemas
  • testclient.py — Lifespan startup/shutdown support via background thread
  • __init__.py — Exports all new public classes

Test plan

  • 203 existing tests continue to pass
  • 31 new tests covering every new feature
  • 234 total tests passing locally

github-actions Bot and others added 4 commits April 17, 2026 01:50
Security utilities (OAuth2PasswordBearer, OAuth2PasswordRequestForm,
SecurityScopes, HTTPBasic, APIKeyHeader/Query/Cookie), lifespan async
context manager, response_model/include/exclude field filtering,
Annotated[T, Depends()] PEP-593 style injection, sub-application
mounting via app.mount(), EventSourceResponse (SSE), ORJSONResponse/
UJSONResponse aliases, datetime/UUID/Decimal JSON serialization,
multiple response declarations (responses={404:...}), router-level
dependencies, dataclass request body support, enum path param
OpenAPI schemas, openapi_tags/terms_of_service/contact/license_info
in app constructor, and StaticFiles + Jinja2Templates integrations.

TestClient gains lifespan startup/shutdown support via background thread.
31 new tests; 234 total passing.

https://claude.ai/code/session_0175FLYUJtjUuigZeBQnscSB
- app.py: remove unused AsyncGenerator/asynccontextmanager/msgspec imports,
  drop forward-ref quotes on Faster type, use contextlib.suppress for
  StopAsyncIteration
- dependencies.py: use callable() instead of hasattr(__call__),
  use inspect.getattr_static to fetch __call__ for type-hint resolution
- openapi/generator.py: fix import order, rename dict_schema/extra_schema
  to avoid no-redef, remove stale type:ignore comment
- security.py: remove forward-ref quotes on from_request return type,
  add raise-from on HTTPException, explicit str() casts in from_request
- staticfiles.py: remove unused os import
- tests/test_new_features.py: fix import sort, drop unused pytest/StaticFiles

https://claude.ai/code/session_0175FLYUJtjUuigZeBQnscSB
Keep our encode_json/ORJSONResponse/UJSONResponse additions in response.py,
take upstream benchmark numbers in README.

https://claude.ai/code/session_0175FLYUJtjUuigZeBQnscSB
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

Benchmark results

Ubuntu runner, Python 3.13. HTTP table uses the same httpx load against uvicorn (Python) and Fiber (Go). Direct ASGI (below) is Python-only and excludes network I/O.

🟢 Benchmark status: improvement detected.

HTTP throughput (FasterAPI vs FastAPI vs Fiber)

Endpoint FasterAPI FastAPI Fiber (Go) F / Fast
GET /health 474/s 492/s 491/s 0.96x
GET /users/{id} 499/s 510/s 529/s 0.98x
POST /users 450/s 465/s 431/s 0.97x

Direct ASGI (no HTTP; 50,000 iterations)

Endpoint FasterAPI FastAPI Speedup vs README ASGI ratio
GET /health 191,928/s 19,306/s 9.94x +45.1%
GET /users/{id} 167,823/s 13,466/s 12.46x +42.8%
POST /users 100,532/s 10,843/s 9.27x +29.7%

Routing (radix vs regex, 1,500,000 lookups)

Router Ops/s Speedup vs README
Radix 940,605 9.9x +30.3%
Regex 94,994 1.0x
How to read this
  • F / Fast = FasterAPI req/s ÷ FastAPI req/s on the same HTTP harness (higher is better).
  • Fiber uses the Go app in benchmarks/fiber (same routes). Go is often several times faster than Python here; the important guard for regressions is check_regressions.py (ASGI + routing floors), which must pass in this workflow.
  • vs README compares combined speedups to documented reference numbers (local machine); CI absolute req/s differs by hardware.

claude and others added 4 commits April 17, 2026 21:28
…ge cases

Adds 28 new tests to bring total coverage from 82.71% to 85.97%, passing
the 85% CI threshold. Covers StaticFiles path traversal, html mode, error
responses; Jinja2Templates rendering; and security auto_error=False paths.

https://claude.ai/code/session_0175FLYUJtjUuigZeBQnscSB
jinja2 is used in tests/test_coverage_gaps.py to cover Jinja2Templates.
Without it installed in CI, those tests are skipped, dropping total
coverage below the 85% threshold.

https://claude.ai/code/session_0175FLYUJtjUuigZeBQnscSB
… 3.13

On Python 3.13, mypy flags `f.default_factory is not dataclasses.MISSING`
as a [misc] error because the typeshed types for Field.default_factory
don't include _MISSING_TYPE. Using callable() avoids the type comparison
and works correctly since dataclasses.MISSING is not callable.

https://claude.ai/code/session_0175FLYUJtjUuigZeBQnscSB
msgspec's updated typeshed stubs annotate json.encode() as returning
bytes directly, making cast(bytes, ...) redundant. mypy --python-version
3.13 flags this as [redundant-cast]; removing the cast resolves the CI
failure on Python 3.13.

https://claude.ai/code/session_01WD4Xmw8KHWMU6bXFttoTpD
@EshwarCVS EshwarCVS merged commit 7b3a199 into master Apr 18, 2026
6 checks passed
@EshwarCVS EshwarCVS deleted the claude/build-missing-features-abDz7 branch April 18, 2026 06:04
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