kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Only swagger for /api/v1
rodzic
098fe7e119
commit
1fa648ecea
|
@ -254,6 +254,7 @@ build_docs:
|
|||
DJANGO_SETTINGS_MODULE: config.settings.local
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
CACHE_URL: "redis://redis:6379/0"
|
||||
API_TYPE: "v1"
|
||||
before_script:
|
||||
- cd api
|
||||
- pip3 install poetry
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension
|
||||
import os
|
||||
|
||||
class CustomOAuthExt(OpenApiAuthenticationExtension):
|
||||
target_class = "funkwhale_api.common.authentication.OAuth2Authentication"
|
||||
|
@ -24,3 +25,12 @@ class CustomOAuthExt(OpenApiAuthenticationExtension):
|
|||
flows[flow_type]["scopes"] = scope_backend.get_all_scopes()
|
||||
|
||||
return {"type": "oauth2", "flows": flows}
|
||||
|
||||
def custom_preprocessing_hook(endpoints):
|
||||
filtered = []
|
||||
# your modifications to the list of operations that are exposed in the schema
|
||||
api_type = os.environ['API_TYPE']
|
||||
for (path, path_regex, method, callback) in endpoints:
|
||||
if path.startswith(f"/api/{api_type}"):
|
||||
filtered.append((path, path_regex, method, callback))
|
||||
return filtered
|
||||
|
|
|
@ -131,6 +131,7 @@ SPECTACULAR_SETTINGS = {
|
|||
"OAUTH2_FLOWS": ["authorizationCode"],
|
||||
"OAUTH2_AUTHORIZATION_URL": "/authorize",
|
||||
"OAUTH2_TOKEN_URL": "/api/v1/oauth/token/",
|
||||
'PREPROCESSING_HOOKS': ["config.schema.custom_preprocessing_hook"],
|
||||
}
|
||||
|
||||
if env.bool("WEAK_PASSWORDS", default=False):
|
||||
|
|
Ładowanie…
Reference in New Issue