From e7c84cb32bb2605fb8c7f2658ce08c6d3eef825d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Mon, 4 Mar 2019 03:36:02 +0200 Subject: [PATCH] Make `generate_swagger` command work This allows us to statically generate OpenAPI specification documents. --- netbox/netbox/settings.py | 1 + netbox/netbox/urls.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index a85a5d78e..95b52a7ec 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -328,6 +328,7 @@ SWAGGER_SETTINGS = { } }, 'VALIDATOR_URL': None, + 'DEFAULT_INFO': 'netbox.urls.swagger_info', } diff --git a/netbox/netbox/urls.py b/netbox/netbox/urls.py index ab3fcf5c6..efe52061f 100644 --- a/netbox/netbox/urls.py +++ b/netbox/netbox/urls.py @@ -8,16 +8,18 @@ from netbox.views import APIRootView, HomeView, SearchView from users.views import LoginView, LogoutView from .admin import admin_site +swagger_info = openapi.Info( + title="NetBox API", + default_version='v2', + description="API to access NetBox", + terms_of_service="https://github.com/digitalocean/netbox", + contact=openapi.Contact(email="netbox@digitalocean.com"), + license=openapi.License(name="Apache v2 License"), +) + + schema_view = get_schema_view( - openapi.Info( - title="NetBox API", - default_version='v2', - description="API to access NetBox", - terms_of_service="https://github.com/digitalocean/netbox", - contact=openapi.Contact(email="netbox@digitalocean.com"), - license=openapi.License(name="Apache v2 License"), - ), - validators=['flex', 'ssv'], + swagger_info, validators=[], public=True, )