From 09e16a23c6135bb6827ade5671f20d6828f5c05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Tue, 19 Sep 2023 16:49:30 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20documenta=C3=A7=C3=A3o=20da=20API=20?= =?UTF-8?q?rest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/templates/sigi/api/redoc.html | 21 +++++++++++++++++++ sigi/templates/sigi/api/swagger-ui.html | 28 +++++++++++++++++++++++++ sigi/urls.py | 23 +++++++++++++++++--- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 sigi/templates/sigi/api/redoc.html create mode 100644 sigi/templates/sigi/api/swagger-ui.html diff --git a/sigi/templates/sigi/api/redoc.html b/sigi/templates/sigi/api/redoc.html new file mode 100644 index 0000000..07650ce --- /dev/null +++ b/sigi/templates/sigi/api/redoc.html @@ -0,0 +1,21 @@ + + + + SIGI ReDoc documentation + + + + + + + + + + + + \ No newline at end of file diff --git a/sigi/templates/sigi/api/swagger-ui.html b/sigi/templates/sigi/api/swagger-ui.html new file mode 100644 index 0000000..0d2ab1c --- /dev/null +++ b/sigi/templates/sigi/api/swagger-ui.html @@ -0,0 +1,28 @@ + + + + SIGI Swagger documentation + + + + + +
+ + + + \ No newline at end of file diff --git a/sigi/urls.py b/sigi/urls.py index 843dc04..680498b 100644 --- a/sigi/urls.py +++ b/sigi/urls.py @@ -14,10 +14,11 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from rest_framework.schemas import get_schema_view -from django.contrib import admin -from django.urls import path, include from django.conf import settings from django.conf.urls.static import static +from django.contrib import admin +from django.urls import path, include +from django.views.generic import TemplateView urlpatterns = [ path("casas/", include("sigi.apps.casas.urls")), @@ -30,7 +31,7 @@ urlpatterns = [ path("admin/ocorrencias/", include("sigi.apps.ocorrencias.admin_urls")), path("admin/", admin.site.urls), path( - "api/", + "api/doc/schema.yaml", get_schema_view( title="SIGI Open API Schema", description="API for SIGI opendata", @@ -38,6 +39,22 @@ urlpatterns = [ ), name="openapi-schema", ), + path( + "api/doc/swagger-ui/", + TemplateView.as_view( + template_name="sigi/api/swagger-ui.html", + extra_context={"schema_url": "openapi-schema"}, + ), + name="swagger-ui", + ), + path( + "api/doc/redoc/", + TemplateView.as_view( + template_name="sigi/api/redoc.html", + extra_context={"schema_url": "openapi-schema"}, + ), + name="redoc", + ), path("api/eventos/", include("sigi.apps.eventos.api_urls")), path("tinymce/", include("tinymce.urls")), path("accounts/", include("sigi.apps.home.accounts_urls")),