Browse Source

Adiciona documentação da API rest

pull/166/head
Sesóstris Vieira 1 year ago
parent
commit
09e16a23c6
  1. 21
      sigi/templates/sigi/api/redoc.html
  2. 28
      sigi/templates/sigi/api/swagger-ui.html
  3. 23
      sigi/urls.py

21
sigi/templates/sigi/api/redoc.html

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>SIGI ReDoc documentation</title>
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
<!-- ReDoc doesn't change outer page styles -->
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<redoc spec-url='{% url schema_url %}'></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>
</html>

28
sigi/templates/sigi/api/swagger-ui.html

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title>SIGI Swagger documentation</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<script>
const ui = SwaggerUIBundle({
url: "{% url schema_url %}",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
layout: "BaseLayout",
requestInterceptor: (request) => {
request.headers['X-CSRFToken'] = "{{ csrf_token }}"
return request;
}
})
</script>
</body>
</html>

23
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")),

Loading…
Cancel
Save