|
75 | 75 | from rest_framework import routers |
76 | 76 | from rest_framework.documentation import include_docs_urls |
77 | 77 | from rest_framework import permissions |
78 | | -from drf_yasg.views import get_schema_view |
79 | | -from drf_yasg import openapi |
| 78 | +from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView |
80 | 79 | from api import drf_views as api_views |
81 | 80 | from flash_update import views as flash_views |
82 | 81 | from per import drf_views as per_views |
|
171 | 170 |
|
172 | 171 | router.register(r"review-country", api_views.CountryOfFieldReportToReviewViewset, basename="review_country") |
173 | 172 |
|
174 | | -api_schema_view = get_schema_view( |
175 | | - openapi.Info( |
176 | | - title="IFRC-GO API", |
177 | | - default_version='v1', |
178 | | - description="IFRC-GO API Openapi schema", |
179 | | - contact=openapi. Contact( email="[email protected]"), # TODO: Update this |
180 | | - ), |
181 | | - public=True, |
182 | | - permission_classes=(permissions.AllowAny,), |
183 | | -) |
184 | | - |
185 | 173 | # Country Plan apis |
186 | 174 | router.register(r"country-plan", country_plan_views.CountryPlanViewset, basename="country_plan") |
187 | 175 |
|
|
244 | 232 | url(r"^api/v2/exportperresults/", per_views.ExportAssessmentToCSVViewset.as_view()), |
245 | 233 | url(r"^api/v2/local-unit/(?P<pk>\d+)", LocalUnitDetailAPIView.as_view()), |
246 | 234 | url(r"^api/v2/local-unit/", LocalUnitListAPIView.as_view()), |
247 | | - url(r"^docs/", include_docs_urls(title="IFRC GO API", public=False)), |
248 | | - url(r'^api-docs(?P<format>\.json|\.yaml)$', |
249 | | - api_schema_view.without_ui(cache_timeout=settings.OPEN_API_DOCS_TIMEOUT), name='api-schema'), |
250 | 235 | url(r"^tinymce/", include("tinymce.urls")), |
251 | 236 | url(r"^$", RedirectView.as_view(url="/admin")), |
252 | 237 | # url(r'^', admin.site.urls), |
253 | 238 | url(r"^favicon\.ico$", RedirectView.as_view(url="/static/favicon.ico")), |
254 | 239 | url(r"^server-error-for-devs", DummyHttpStatusError.as_view()), |
255 | 240 | url(r"^exception-error-for-devs", DummyExceptionError.as_view()), |
256 | 241 | path("i18n/", include("django.conf.urls.i18n")), |
| 242 | + # Docs |
| 243 | + url(r"^docs/", include_docs_urls(title="IFRC GO API", public=False)), # TODO: Remove this? |
| 244 | + path("api-docs/", SpectacularAPIView.as_view(), name='schema'), |
| 245 | + path("api-docs/swagger-ui/", SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), |
| 246 | + path("api-docs/redoc/", SpectacularRedocView.as_view(url_name='schema'), name='redoc'), |
| 247 | + |
257 | 248 | ] |
258 | 249 |
|
259 | 250 | if settings.DEBUG: |
|
0 commit comments