Repository navigation
[FEAT] Add domain layout support to addroute - #83
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thanks for this. The direction is right and the code is clean. I pulled the branch, ran the full suite and the runtime tests with FastAPI installed, and generated a project end-to-end. All green locally. Status: one blocker, one design question, then merge. 🔴 Blocker:
|
shipped items domain |
generated domain | |
|---|---|---|
| storage | db.memory.InMemoryStore |
own dict + Lock |
reset() |
yes (used by autouse fixture in conftest.py) |
no |
__init__.py |
re-exports submodules | empty |
So in a domain-starter project the new domain is not reset between tests and does not match what the tutorial teaches.
Pick one:
- Use
InMemoryStorewhendb/memory.pyexists; keep the self-contained store as the fallback. - Keep the self-contained store, but add
reset()and the__init__.pyre-exports.
🟡 Smaller fixes
- Existing registration with a different prefix is silently kept. Right call, but print an info line so a re-run does not end in a bare "success".
include_router(router=...)(keyword-only) is not detected. It gets inserted twice.ast.parseinroute_wiring.pyis unguarded. A syntax error in the aggregator writes the domain files first, then raises. Fall back to text insertion likeinsert_import_linedoes.- Codecov patch: 90.4% vs. 95.4% target. Uncovered: alias-collision and empty-aggregator branches.
- Optional:
route_generators.pyuses private helpers frombackend.mainand avoids the cycle with a lazy import. Mergeable as is; moving classic generation into the generator module would remove the cycle.
✅ Not on you
- The red
inspect-changed-templatescheck is our workflow. Inspection passed; only the PR-comment step got a 403 from the fork's read-only token. - Moving
prefix/tagson the items router is fine. It goes into the release notes. - Non-English docs are regenerated with
make translate, so editingdocs/enonly is correct.
Next: land the template fallback and tell me which repository option you prefer. Then I merge.
|
Addressed in d371fee. The template fallback now uses the registered domain-starter base template when I chose option 2: keep the self-contained repository, add Also fixed keyword-form router registration, added an info message when preserving custom registration options, and added the syntax-error fallback and coverage for alias collisions and empty aggregators. Validation: 227 relevant tests passed locally, with three unrelated path tests excluded; Black/isort and full-source mypy targeting Linux pass. Added executable lines are locally covered at 100% (170/170). The new GitHub CI/Codecov results are pending. The optional classic-generator refactor and the fork workflow issue were left unchanged. |
|
Thanks for the quick follow-up. I re-checked d371fee: full suite, lint/mypy, and a fresh The red Approving and merging. Thank you very much for the contribution. It will ship in the next FastAPI-fastkit release, with credit to you in the changelog. |
fastkit addroutealways generatedapi/routes,crud, andschemasmodules, including in domain-starter projects. This adds--layout=classic-layer|domain; without an override, domain-starter selects domain generation and other presets retain classic generation. When preset metadata is absent, the recorded template determines the fallback, covering startdemo and interactive init projects.The domain layout generates models, schemas, repository, service, and router files with names derived from the route (for example,
HealthChecksService). It provides a typed CRUD example backed by process-local memory, with reset support and package re-exports. The starter test fixture resets generated domains between tests. Both layouts set the domain prefix and tags when registering the router in the shared API router; the shipped items domain follows the same convention.Existing files and router registrations are preserved on repeat runs, including keyword-form include_router calls. Custom registration options are retained with an info message. Invalid aggregator syntax falls back to text insertion. Import aliases allow same-named modules in different layouts to coexist. HTTP path conflicts and migration of existing modules remain the application developer's responsibility. English CLI and domain documentation is updated.
Validation
--platform linux).The initial PR revision passed the complete upstream test workflow on Ubuntu with Python 3.12, 3.13, and 3.14. CI for the review fixes is pending. The complete local Windows suite is not confirmed green; the baseline contains existing Windows/environment failures.