55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""
|
|
URL configuration for cremation_backend project.
|
|
|
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
https://docs.djangoproject.com/en/5.2/topics/http/urls/
|
|
Examples:
|
|
Function views
|
|
1. Add an import: from my_app import views
|
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
Class-based views
|
|
1. Add an import: from other_app.views import Home
|
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
Including another URLconf
|
|
1. Import the include() function: from django.urls import include, path
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
"""
|
|
from django.contrib import admin
|
|
from django.urls import path, include
|
|
from rest_framework.routers import DefaultRouter
|
|
|
|
from model_registry.views.ai_model_viewset import AiModelRegistryViewSet
|
|
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView, SpectacularRedocView
|
|
|
|
# 1. กำหนดตัวแปร router ก่อนใช้งาน
|
|
router = DefaultRouter()
|
|
|
|
# 2. ลงทะเบียน API ViewSets (Project-Level Routing)
|
|
# URL: /api/v1/models/
|
|
router.register(
|
|
r'models',
|
|
AiModelRegistryViewSet,
|
|
basename='aimodel' # basename จำเป็นเมื่อ ViewSet ไม่ได้สืบทอดจาก Model
|
|
)
|
|
|
|
# 3. ลงทะเบียน ViewSet อื่น ๆ
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
|
|
# Schema OpenAPI
|
|
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
|
|
|
|
# Swagger UI
|
|
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
|
|
|
# Redoc UI
|
|
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
|
|
|
# Endpoints สำหรับการยืนยันตัวตน (Login, Logout, Register)
|
|
path('api/v1/auth/', include('djoser.urls')), # /users/ (Register/Update/Me), /users/set_password
|
|
path('api/v1/auth/', include('djoser.urls.jwt')), # /jwt/create (Login), /jwt/refresh (Refresh Token)
|
|
|
|
# 3. รวม Router API
|
|
path('api/v1/', include(router.urls)),
|
|
]
|