Open sikyeong opened 2 years ago
@sikyeong
try giving each NinjaAPI insstnace own urlnamespace ? NinjaAPI(urls_namespace="masters")
Use django-ninja-extra for class based api. It makes easier to implement multiple app's api.
api = NinjaExtraAPI
in project api.py
fileapi.py
file.api.py
fileIt's more efficient structure for big project. because there are many apps in same project.
A general note for people who come here because they run into a namespace resolution problem:
You might have to prefix your API namespace in case you are nesting your Ninja API within an existing app namespace.
api = NinjaAPI(urls_namespace="foo:bar")
Describe the bug A clear and concise description of what the bug is.
I have two APPS in my Django project. And create each api.py in each apps
and my project "urls.py" is like this
from django.contrib import admin from django.urls import path from masters.api import masters #masters = NinjaAPI() from boxs.api import boxs #boxs = NinjaAPI()
urlpatterns = [ path('admin/', admin.site.urls), path('boxs/', boxs.urls), path('masters/', masters.urls), ]
then, i want's open each api docs so try to call like this
but' i can open just one docs of both (the urls response only "/boxs/openapi.json") [18/May/2022 23:42:42] "GET /masters/docs HTTP/1.1" 200 801 [18/May/2022 23:42:42] "GET /boxs/openapi.json HTTP/1.1" 200 298
when i change my project "urls.py" like this
from django.contrib import admin from django.urls import path from masters.api import masters from boxs.api import boxs
urlpatterns = [ path('admin/', admin.site.urls), path('masters/', masters.urls), path('boxs/', boxs.urls),
]
the urls response only "masters/openapi.json" [18/May/2022 23:59:12] "GET /boxs/docs HTTP/1.1" 200 792 [18/May/2022 23:59:12] "GET /masters/openapi.json HTTP/1.1" 200 744
thanks
Versions (please complete the following information):