-
Notifications
You must be signed in to change notification settings - Fork 805
/
Copy pathdev_urls.py
52 lines (45 loc) · 1.39 KB
/
dev_urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from django.http.response import HttpResponseRedirect
from django.urls import include
from django.urls import path
from django.urls import re_path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from kolibri.deployment.default.urls import urlpatterns
def webpack_redirect_view(request):
return HttpResponseRedirect(
"http://127.0.0.1:3000/__open-in-editor?{query}".format(
query=request.GET.urlencode()
)
)
api_info = openapi.Info(
title="Kolibri API",
default_version="v0",
description="Kolibri Swagger API",
license=openapi.License(name="MIT"),
)
schema_view = get_schema_view(
api_info,
public=True,
permission_classes=(permissions.AllowAny,),
)
urlpatterns = urlpatterns + [
re_path(r"^__open-in-editor/", webpack_redirect_view),
re_path(
r"^swagger(?P<format>\.json|\.yaml)$",
schema_view.without_ui(cache_timeout=0),
name="schema-json",
),
re_path(
r"^api_explorer/$",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
),
re_path(
r"^redoc/$",
schema_view.with_ui("redoc", cache_timeout=0),
name="schema-redoc",
),
re_path(r"^api-auth/", include("rest_framework.urls", namespace="rest_framework")),
path("__debug__/", include("debug_toolbar.urls")),
]