From 257c0afdb5b62c7ea84159d2b46d53ce5a43f3a3 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 1 Oct 2021 12:02:04 -0400 Subject: [PATCH] Closes #6423: Cache rendered REST API specifications --- docs/release-notes/version-3.0.md | 1 + netbox/netbox/urls.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index 16d3b8d18..277a37692 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -4,6 +4,7 @@ ### Enhancements +* [#6423](https://github.com/netbox-community/netbox/issues/6423) - Cache rendered REST API specifications * [#7387](https://github.com/netbox-community/netbox/issues/7387) - Enable arbitrary ordering of custom scripts ### Bug Fixes diff --git a/netbox/netbox/urls.py b/netbox/netbox/urls.py index 53e20351c..3d4c60c93 100644 --- a/netbox/netbox/urls.py +++ b/netbox/netbox/urls.py @@ -17,7 +17,7 @@ from .admin import admin_site openapi_info = openapi.Info( title="NetBox API", - default_version='v2', + default_version='v3', description="API to access NetBox", terms_of_service="https://github.com/netbox-community/netbox", license=openapi.License(name="Apache v2 License"), @@ -59,9 +59,9 @@ _patterns = [ path('api/users/', include('users.api.urls')), path('api/virtualization/', include('virtualization.api.urls')), path('api/status/', StatusView.as_view(), name='api-status'), - path('api/docs/', schema_view.with_ui('swagger'), name='api_docs'), - path('api/redoc/', schema_view.with_ui('redoc'), name='api_redocs'), - re_path(r'^api/swagger(?P.json|.yaml)$', schema_view.without_ui(), name='schema_swagger'), + path('api/docs/', schema_view.with_ui('swagger', cache_timeout=86400), name='api_docs'), + path('api/redoc/', schema_view.with_ui('redoc', cache_timeout=86400), name='api_redocs'), + re_path(r'^api/swagger(?P.json|.yaml)$', schema_view.without_ui(cache_timeout=86400), name='schema_swagger'), # GraphQL path('graphql/', csrf_exempt(GraphQLView.as_view(graphiql=True, schema=schema)), name='graphql'),