Skip to content

Commit

Permalink
feat: updates to swagger and redoc
Browse files Browse the repository at this point in the history
  • Loading branch information
yokwejuste committed Aug 19, 2024
1 parent 43c9ad9 commit 7f17b6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
29 changes: 18 additions & 11 deletions templates/docs/redoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Documentation</title>
<link href="https://cdn.jsdelivr.net/npm/@redocly/try-it-out@0.1.0-beta.0/dist/try-it-out.min.css" rel="stylesheet">
<title>Django Cameroon API</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<redoc
spec-url="{% url 'schema' %}"
try-it-out="true"
hide-hostname="true"
path-in-middle-panel="true"
expand-responses="all">
</redoc>
<script src="https://cdn.jsdelivr.net/npm/@redocly/try-it-out@0.1.0-beta.0/dist/try-it-out.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
<div id="redoc-container"></div>
<script src="https://cdn.jsdelivr.net/npm/redoc@2.1.5/bundles/redoc.standalone.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/redoc-try-it-out/dist/try-it-out.min.js"></script>
<script>
RedocTryItOut.init(
"{% url 'schema' %}",
{title: "Pet Store"},
document.getElementById("redoc_container")
)
</script>
</body>
</html>
7 changes: 4 additions & 3 deletions website_api/routes/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
SpectacularSwaggerView,
SpectacularRedocView,
)

from django.views.generic import TemplateView
from apps.users.views.index import index

if settings.ENVIRONMENT == "development":
urlpatterns = [
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
re_path(r'$swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
re_path(r'$', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
re_path(r'^$', TemplateView.as_view(template_name='docs/redoc.html'), name='index'),
# re_path(r'$swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
# re_path(r'$', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
]
elif settings.ENVIRONMENT == "production":
urlpatterns = [
Expand Down

0 comments on commit 7f17b6a

Please sign in to comment.