-
-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Hi!
I'm currently using django-ninja-extra with multiple NinjaExtraAPI instances, each exposed under a different URL namespace — for example:
api_a = NinjaExtraAPI(urls_namespace="...")
api_b = NinjaExtraAPI(urls_namespace="...")
Each API instance is supposed to expose different sets of endpoints, but some controller logic is shared (such as auth endpoints). However, when I try to register the same controller class in both instances:
a.register_controllers(OAuthController)
b.register_controllers(OAuthController)
Only one API ends up exposing the controller routes — the second registration seems to be silently ignored.
Would it be possible to allow the same controller logic to be reused across multiple API instances, ideally with isolation per API?
This would enable use cases like:
- Versioned APIs (/v1/, /v2/) sharing base controllers
- Specialized APIs (e.g., /admin/, /public/) exposing overlapping endpoints
- Mounted APIs in different Django apps or URL namespaces
Allow ControllerBase to register routes separately per API instance (not globally).
Support copying or isolating the router at the time of register_controllers(...).
Add an option to force re-registration, e.g. api.register_controllers(MyController, force=True).
If there's already a supported workaround, I'd love to hear it.
Thanks for the awesome project! I'm happy to contribute a PR if this is something you’d consider supporting.