Switched to Redoc
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import inspect
|
import inspect
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from ninja import NinjaAPI, Router, Schema
|
from ninja import NinjaAPI, Router, Schema, Redoc
|
||||||
from ninja.security import django_auth
|
from ninja.security import django_auth
|
||||||
|
|
||||||
from .security import JWTAuth
|
from .security import JWTAuth
|
||||||
@@ -15,6 +15,7 @@ from .routers.access import build_router as build_access_router
|
|||||||
from .routers.telemetry import build_router as build_telemetry_router
|
from .routers.telemetry import build_router as build_telemetry_router
|
||||||
from .routers.agent import build_router as build_agent_router
|
from .routers.agent import build_router as build_agent_router
|
||||||
|
|
||||||
|
from django.contrib.admin.views.decorators import staff_member_required
|
||||||
|
|
||||||
def register_routers(target_api: NinjaAPI) -> None:
|
def register_routers(target_api: NinjaAPI) -> None:
|
||||||
target_api.add_router("/system", build_system_router(), tags=["system"])
|
target_api.add_router("/system", build_system_router(), tags=["system"])
|
||||||
@@ -39,6 +40,8 @@ api = build_api(
|
|||||||
version="1.0.0",
|
version="1.0.0",
|
||||||
description="Authenticated API for internal app use and external clients.",
|
description="Authenticated API for internal app use and external clients.",
|
||||||
auth=[django_auth, JWTAuth()],
|
auth=[django_auth, JWTAuth()],
|
||||||
|
docs=Redoc(),
|
||||||
|
docs_decorator=staff_member_required,
|
||||||
)
|
)
|
||||||
register_routers(api)
|
register_routers(api)
|
||||||
|
|
||||||
@@ -48,5 +51,7 @@ api_v1 = build_api(
|
|||||||
description="Authenticated API for internal app use and external clients.",
|
description="Authenticated API for internal app use and external clients.",
|
||||||
auth=[django_auth, JWTAuth()],
|
auth=[django_auth, JWTAuth()],
|
||||||
urls_namespace="api-v1",
|
urls_namespace="api-v1",
|
||||||
|
docs=Redoc(),
|
||||||
|
docs_decorator=staff_member_required,
|
||||||
)
|
)
|
||||||
register_routers(api_v1)
|
register_routers(api_v1)
|
||||||
|
|||||||
32
app/templates/ninja/swagger.html
Normal file
32
app/templates/ninja/swagger.html
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{% load static %}
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>{{ title|default:"Keywarden API" }}</title>
|
||||||
|
<link rel="stylesheet" href="{% static 'ninja/swagger-ui.css' %}">
|
||||||
|
<style>
|
||||||
|
.swagger-ui .opblock-summary {
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
}
|
||||||
|
.swagger-ui .opblock-summary-path {
|
||||||
|
max-width: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
word-break: normal;
|
||||||
|
overflow-wrap: normal;
|
||||||
|
writing-mode: horizontal-tb;
|
||||||
|
}
|
||||||
|
.swagger-ui .opblock-summary-path a {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body data-api-csrf="{{ add_csrf|yesno:'true,false' }}" data-csrf-token="{{ csrf_token }}">
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
<script id="swagger-settings" type="application/json">{{ swagger_settings|safe }}</script>
|
||||||
|
<script src="{% static 'ninja/swagger-ui-bundle.js' %}"></script>
|
||||||
|
<script src="{% static 'ninja/swagger-ui-init.js' %}"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
add_header Content-Security-Policy "default-src 'self'; font-src *;img-src * data:; script-src * 'unsafe-eval'; style-src * 'unsafe-inline'";
|
add_header Content-Security-Policy "default-src 'self'; font-src *;img-src * data:; script-src * 'unsafe-eval' 'unsafe-inline'; style-src * 'unsafe-inline'";
|
||||||
add_header X-Frame-Options "SAMEORIGIN";
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
add_header X-Content-Type-Options nosniff;
|
add_header X-Content-Type-Options nosniff;
|
||||||
add_header Referrer-Policy "strict-origin";
|
add_header Referrer-Policy "strict-origin";
|
||||||
|
|||||||
Reference in New Issue
Block a user