2022-08-22 23:26:39 +01:00
|
|
|
from django.urls import include, path, re_path
|
2022-08-23 08:37:00 +01:00
|
|
|
from django.views.generic import RedirectView
|
2022-08-22 23:26:39 +01:00
|
|
|
from drf_yasg import openapi
|
|
|
|
from drf_yasg.views import get_schema_view
|
|
|
|
from rest_framework import permissions
|
|
|
|
|
|
|
|
from . import views
|
|
|
|
|
|
|
|
app_name = "api"
|
|
|
|
|
2022-08-23 09:23:22 +01:00
|
|
|
api_urlpatterns = [
|
|
|
|
path("ping", views.PingAPIView.as_view(), name="ping"),
|
|
|
|
path("page-links", views.PageLinksAPIView.as_view(), name="page-links"),
|
2022-08-23 14:56:05 +01:00
|
|
|
path("lmotfy", views.LMOTFYAPIView.as_view(), name="lmotfy"),
|
2022-08-23 09:23:22 +01:00
|
|
|
]
|
2022-08-22 23:26:39 +01:00
|
|
|
|
|
|
|
schema_view = get_schema_view(
|
|
|
|
openapi.Info(
|
|
|
|
title="Website API",
|
|
|
|
default_version="v1",
|
|
|
|
description="Random API endpoints for cool things",
|
|
|
|
),
|
|
|
|
public=True,
|
|
|
|
permission_classes=[permissions.AllowAny],
|
|
|
|
patterns=[
|
|
|
|
# HACK: Ensure the created URLs are fully-formed
|
|
|
|
path("api/", include(api_urlpatterns))
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
urlpatterns = [
|
|
|
|
re_path(
|
|
|
|
r"^swagger(?P<format>\.json|\.yaml)$",
|
2022-08-23 08:39:38 +01:00
|
|
|
schema_view.without_ui(cache_timeout=60 * 60),
|
2022-08-22 23:26:39 +01:00
|
|
|
name="schema-json",
|
|
|
|
),
|
2022-08-23 08:39:38 +01:00
|
|
|
path(
|
|
|
|
"swagger/",
|
|
|
|
schema_view.with_ui("swagger", cache_timeout=60 * 60),
|
2022-08-22 23:26:39 +01:00
|
|
|
name="schema-swagger-ui",
|
|
|
|
),
|
2022-10-02 19:20:40 +01:00
|
|
|
path("", RedirectView.as_view(pattern_name="api:schema-swagger-ui"), name="index"),
|
2022-08-22 23:26:39 +01:00
|
|
|
] + api_urlpatterns
|