Adapters
Adapters overview
One adapter per framework — same docs UI, same OpenAPI export, same schemas, in Node.js, Python, and PHP.
DocTreen ships an adapter for each supported framework. They all:
- Accept the same config object
- Serve the docs UI at
docsPath(default/docs) — the same zero-dependency UI in every language (the Python and PHP packages ship the exact assets the npm package builds) - Expose OpenAPI 3.1 at
<docsPath>/openapi.json— held identical across languages by a shared conformance suite - Support runtime validation and drift detection
Node.js
| Adapter | Import | Mount order | Schemas read from |
|---|---|---|---|
| Express | doctreen/express | After routes | defineRoute → JSDoc → runtime inference |
| Fastify | doctreen/fastify | Before routes | defineRoute → Fastify native JSON Schema → JSDoc |
| Hono | doctreen/hono | Either order | defineRoute → JSDoc |
| Koa | doctreen/koa | Either order | defineRoute → JSDoc |
| NestJS | doctreen/nest | After NestFactory.create(), before listen() | @DocRoute / @Doc* decorators |
Python
| Adapter | Import | Mount order | Schemas read from |
|---|---|---|---|
| Flask | doctreen.adapters.flask | Either order (introspection runs on first docs request) | @define_route (Pydantic or s.*) → Flask URL converters |
| FastAPI | doctreen.adapters.fastapi | mount_doctreen(app, …) any time | The app's own app.openapi() spec (drift-focused; mounts at /doctreen) |
| Django / DRF | doctreen.adapters.django | *doctreen_urls(…) in urlpatterns (+ middleware for drift) | DRF serializers → URLconf path() converters |
PHP
| Adapter | Install | Mount order | Schemas read from |
|---|---|---|---|
| Laravel | auto-discovered service provider | Automatic | ->doc() route macro (S:: builder) |
Planned
Symfony and PSR-15 adapters are on the PHP roadmap.