Set schema url for Swagger via env variable (#2823)

# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
This commit is contained in:
Ildar Iskhakov 2023-08-18 14:22:48 +08:00 committed by GitHub
parent c9cb4328e8
commit 3d46eea353
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -3,7 +3,7 @@ version: "3.9"
x-labels: &oncall-labels x-labels: &oncall-labels
- "com.grafana.oncall.env=dev" - "com.grafana.oncall.env=dev"
x-user: &oncall-user "appuser" x-user: &oncall-user "root"
x-oncall-build: &oncall-build-args x-oncall-build: &oncall-build-args
context: ./engine context: ./engine

View file

@ -260,11 +260,18 @@ SPECTACULAR_SETTINGS = {
"SERVE_INCLUDE_SCHEMA": False, "SERVE_INCLUDE_SCHEMA": False,
# OTHER SETTINGS # OTHER SETTINGS
"PREPROCESSING_HOOKS": [ "PREPROCESSING_HOOKS": [
"engine.included_path.custom_preprocessing_hook" "engine.included_path.custom_preprocessing_hook" # Custom hook to include only paths from SPECTACULAR_INCLUDED_PATHS
], # Custom hook to include only paths from SPECTACULAR_INCLUDED_PATHS ],
"SERVE_URLCONF": ("apps.api.urls"), "SERVE_URLCONF": ("apps.api.urls"),
"SWAGGER_UI_SETTINGS": {"supportedSubmitMethods": []}, # Disable "Try it out" button for all endpoints "SWAGGER_UI_SETTINGS": {
"supportedSubmitMethods": [], # Disable "Try it out" button for all endpoints
},
"SERVE_PUBLIC": False,
} }
# Use custom scheme if env var exists
SWAGGER_UI_SETTINGS_URL = os.getenv("SWAGGER_UI_SETTINGS_URL")
if SWAGGER_UI_SETTINGS_URL:
SPECTACULAR_SETTINGS["SWAGGER_UI_SETTINGS"]["url"] = SWAGGER_UI_SETTINGS_URL
SPECTACULAR_INCLUDED_PATHS = [ SPECTACULAR_INCLUDED_PATHS = [
"/features", "/features",

View file

@ -160,4 +160,5 @@ REST_FRAMEWORK = {
), ),
"DEFAULT_AUTHENTICATION_CLASSES": [], "DEFAULT_AUTHENTICATION_CLASSES": [],
"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",), "DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
} }