Add caching to schema views

This commit is contained in:
Jake Howard 2022-08-23 08:39:38 +01:00
parent 8dea738893
commit 67095752d2
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -27,16 +27,13 @@ schema_view = get_schema_view(
urlpatterns = [ urlpatterns = [
re_path( re_path(
r"^swagger(?P<format>\.json|\.yaml)$", r"^swagger(?P<format>\.json|\.yaml)$",
schema_view.without_ui(cache_timeout=0), schema_view.without_ui(cache_timeout=60 * 60),
name="schema-json", name="schema-json",
), ),
re_path( path(
r"^swagger/$", "swagger/",
schema_view.with_ui("swagger", cache_timeout=0), schema_view.with_ui("swagger", cache_timeout=60 * 60),
name="schema-swagger-ui", name="schema-swagger-ui",
), ),
re_path(
r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"
),
path("", RedirectView.as_view(pattern_name="api:schema-swagger-ui")), path("", RedirectView.as_view(pattern_name="api:schema-swagger-ui")),
] + api_urlpatterns ] + api_urlpatterns