Skip to content

Commit

Permalink
Add swagger to generate Domains API documentation
Browse files Browse the repository at this point in the history
This commit adds swagger as a documentation generator for REST framework as well as
an easy way to test the domains administrative end-points.

Signed-off-by: Francisco Trivino <[email protected]>
  • Loading branch information
f-trivino committed Jan 25, 2023
1 parent 21e07d3 commit dd73e58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/ipa-tuura/root/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
'creds',
'rest_framework',
'domains',
'rest_framework_swagger',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -158,3 +159,10 @@
'WRITABLE_IFACE': 'ipa',
'WRITABLE_USER': 'admin',
}

# admin endpoint so that we can handle permissions and required fields only for authenticated users
#REST_FRAMEWORK = {
# 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',)
#}

REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' }
6 changes: 5 additions & 1 deletion src/ipa-tuura/root/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from django.urls import include, path, re_path
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Domains API')

urlpatterns = [
path('admin/', admin.site.urls),
path('scim/v2/', include('django_scim.urls')),
path('creds/', include('creds.urls')),
path('domains/v1/', include('domains.urls')),
re_path('domains/doc', schema_view)
]

0 comments on commit dd73e58

Please sign in to comment.