Skip to content

Commit

Permalink
Swagger | using env var to setup base url
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Aug 25, 2020
1 parent 816053f commit 3e97282
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/settings.py
Expand Up @@ -262,3 +262,6 @@
ELASTICSEARCH_DSL_AUTOSYNC = True
ELASTICSEARCH_DSL_SIGNAL_PROCESSOR = 'core.common.models.CelerySignalProcessor'
ES_SYNC = True
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ENV = os.environ.get('ENVIRONMENT', 'development')
9 changes: 9 additions & 0 deletions core/urls.py
Expand Up @@ -22,6 +22,13 @@

import core.concepts.views as concept_views
import core.mappings.views as mapping_views
from django.conf import settings

if settings.ENV == 'development':
base_url = "http://localhost:8000"
else:
base_url = "https://api.{}".format(settings.ENV.lower())


SchemaView = get_schema_view(
openapi.Info(
Expand All @@ -31,7 +38,9 @@
),
public=True,
permission_classes=(permissions.AllowAny,),
url=base_url
)

urlpatterns = [
url(r'^swagger(?P<format>\.json|\.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'),
url(r'^swagger/$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.override.yml
Expand Up @@ -16,6 +16,8 @@ services:
volumes:
- .:/code
restart: "no"
environment:
- ENVIRONMENT=development
celery:
build: .
volumes:
Expand Down

0 comments on commit 3e97282

Please sign in to comment.