Skip to content

Commit

Permalink
Merge pull request #11 from kartoza/add_swagger
Browse files Browse the repository at this point in the history
Add swagger
  • Loading branch information
dimasciput authored Sep 23, 2024
2 parents 3a0c5e4 + 385e805 commit a686d30
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ build:
@echo "------------------------------------------------------------------"
@echo "Building in production mode"
@echo "------------------------------------------------------------------"
@docker-compose build
@docker compose build

up:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in production mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} up -d nginx django
@docker compose ${ARGS} up -d nginx django

dev:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in dev mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} up -d dev
@docker compose ${ARGS} up -d dev

shell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling in in production mode"
@echo "------------------------------------------------------------------"
@docker-compose exec django /bin/bash
@docker compose exec django /bin/bash

dev-entrypoint:
@echo
@echo "------------------------------------------------------------------"
@echo "Running in DEVELOPMENT mode"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} exec -T dev "/home/web/django_project/entrypoint.sh"
@docker compose ${ARGS} exec -T dev "/home/web/django_project/entrypoint.sh"

dev-runserver:
@echo
@echo "------------------------------------------------------------------"
@echo "Start django runserver in dev container"
@echo "------------------------------------------------------------------"
@docker-compose $(ARGS) exec -T dev bash -c "nohup python manage.py runserver 0.0.0.0:5000 &"
@docker compose $(ARGS) exec -T dev bash -c "nohup python manage.py runserver 0.0.0.0:5000 &"

dev-load-demo-data:
@echo
Expand All @@ -54,8 +54,8 @@ dev-test:
@echo "------------------------------------------------------------------"
@echo "Run tests"
@echo "------------------------------------------------------------------"
@docker-compose exec -T dev python manage.py collectstatic --noinput
@docker-compose exec -T dev python manage.py test cloud_native_gis.tests --keepdb --noinput
@docker compose exec -T dev python manage.py collectstatic --noinput
@docker compose exec -T dev python manage.py test cloud_native_gis.tests --keepdb --noinput
# TODO: Remove cloud_native_gis.tests by fixing issue https://github.com/kartoza/CloudNativeGIS/issues/7

serve:
Expand Down Expand Up @@ -86,7 +86,7 @@ down:
@echo "------------------------------------------------------------------"
@echo "Removing production instance!!! "
@echo "------------------------------------------------------------------"
@docker-compose down
@docker compose down

test-flake:
@echo
Expand All @@ -102,7 +102,7 @@ wait-db:
@echo "------------------------------------------------------------------"
@echo "Check database is ready or not"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} exec -T db su - postgres -c "until pg_isready; do sleep 5; done"
@docker compose ${ARGS} exec -T db su - postgres -c "until pg_isready; do sleep 5; done"

sleep:
@echo
Expand Down
3 changes: 2 additions & 1 deletion deployment/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ redis==4.3.4

# Library to handle geospatial functions
GeoAlchemy2==0.15.1
geopandas==0.13.2
geopandas==0.14.4
drf-yasg==1.21.7
26 changes: 25 additions & 1 deletion django_project/cloud_native_gis/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,29 @@
from rest_framework.routers import DefaultRouter
from rest_framework_nested.routers import NestedSimpleRouter

from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

from cloud_native_gis.api.layer import (
LayerViewSet, LayerStyleViewSet
)
from cloud_native_gis.api.vector_tile import (VectorTileLayer)

schema_view = get_schema_view(
openapi.Info(
title="Cloud Native GIS API",
default_version='v1',
description="API documentation for the Cloud Native GIS project",
terms_of_service="https://www.example.com/terms/",
contact=openapi.Contact(email="[email protected]"),
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)


router = DefaultRouter()
router.register(
r'layer', LayerViewSet, basename='cloud-native-gis-layer'
Expand All @@ -35,5 +53,11 @@
'maputnik/',
TemplateView.as_view(template_name='cloud_native_gis/maputnik.html'),
name='cloud-native-gis-maputnik'
)
),
path('swagger/',
schema_view.with_ui('swagger', cache_timeout=0),
name='schema-swagger-ui'),
path('redoc/',
schema_view.with_ui('redoc', cache_timeout=0),
name='schema-redoc-ui'),
]
1 change: 1 addition & 0 deletions django_project/core/settings/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'django_cleanup.apps.CleanupConfig',
'django_celery_beat',
'django_celery_results',
'drf_yasg',
)

WEBPACK_LOADER = {
Expand Down

0 comments on commit a686d30

Please sign in to comment.