Skip to content

Commit 4d00819

Browse files
committed
feat: enable API docs UI
1 parent a89cc7f commit 4d00819

4 files changed

Lines changed: 227 additions & 91 deletions

File tree

django_project/settings/base.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,22 @@
4747
'pangenome_analyses',
4848
'gene_function',
4949
'search',
50-
'ai_assistant'
50+
'ai_assistant',
51+
'drf_spectacular',
52+
'rest_framework',
5153
]
5254

55+
REST_FRAMEWORK = {
56+
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
57+
}
58+
59+
SPECTACULAR_SETTINGS = {
60+
'TITLE': 'PanKB Developer API',
61+
'DESCRIPTION': 'API documentation for PanKB.',
62+
'VERSION': '1.0.0',
63+
'SERVE_INCLUDE_SCHEMA': True,
64+
}
65+
5366
MIDDLEWARE = [
5467
'django.middleware.security.SecurityMiddleware',
5568
'django.contrib.sessions.middleware.SessionMiddleware',

django_project/urls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from django.urls import path
1818
from django.views.generic import TemplateView
19+
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
1920

2021
from home import views as home_views
2122
from about import views as about_views
@@ -191,6 +192,8 @@
191192
path("interop-query/genes", interop_views.genes, name="genes"),
192193
path("interop-query/strains", interop_views.strains, name="strains"),
193194
path("interop-query/gene-strain-pairs", interop_views.gene_strain_pairs, name="gene_strain_pairs"),
194-
195+
196+
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
197+
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
195198
# path('admin/', admin.site.urls) # make the amdin panel inaccessible via its utl (the admin admin is preserved for the potential future needs)
196199
]

0 commit comments

Comments
 (0)