Display v2 endpoints to swagger (#2352)
This commit is contained in:
parent
d2ac7bf84a
commit
31330fed3e
|
@ -1,5 +1,3 @@
|
||||||
import os
|
|
||||||
|
|
||||||
from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension
|
from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension
|
||||||
from drf_spectacular.plumbing import build_bearer_security_scheme_object
|
from drf_spectacular.plumbing import build_bearer_security_scheme_object
|
||||||
|
|
||||||
|
@ -44,8 +42,6 @@ def custom_preprocessing_hook(endpoints):
|
||||||
filtered = []
|
filtered = []
|
||||||
|
|
||||||
# your modifications to the list of operations that are exposed in the schema
|
# your modifications to the list of operations that are exposed in the schema
|
||||||
api_type = os.environ.get("API_TYPE", "v1")
|
|
||||||
api_type_v2 = os.environ.get("API_TYPE", "v2")
|
|
||||||
|
|
||||||
for path, path_regex, method, callback in endpoints:
|
for path, path_regex, method, callback in endpoints:
|
||||||
if path.startswith("/api/v1/providers"):
|
if path.startswith("/api/v1/providers"):
|
||||||
|
@ -57,9 +53,7 @@ def custom_preprocessing_hook(endpoints):
|
||||||
if path.startswith("/api/v1/oauth/authorize"):
|
if path.startswith("/api/v1/oauth/authorize"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if path.startswith(f"/api/{api_type}") or path.startswith(
|
if path.startswith("/api/v1") or path.startswith("/api/v2"):
|
||||||
f"/api/{api_type_v2}"
|
|
||||||
):
|
|
||||||
filtered.append((path, path_regex, method, callback))
|
filtered.append((path, path_regex, method, callback))
|
||||||
|
|
||||||
return filtered
|
return filtered
|
||||||
|
|
Loading…
Reference in New Issue