OpenAPI, Swagger and Redoc
Note
This feature was introduced in RDMO 2.3.
Optionally, RDMO can be configured to use drf-spectacular, which provides:
the automatic generation of an OpenAPI 3.0 specification at
/api/v1/schema/
a browsable Swagger interface at
/api/v1/swagger/
a browsable Redoc API documentation at
/api/v1/redoc/
To enable those features install the openapi
dependency group together with RDMO:
pip install rdmo[openapi]
Then add the following to your `config/settings/local.py:
INSTALLED_APPS += [
'drf_spectacular',
'drf_spectacular_sidecar'
]
REST_FRAMEWORK.update({
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning',
'DEFAULT_VERSION': 'v1',
'ALLOWED_VERSIONS': ('v1', ),
})
and the following to your config/urls.py
:
urlpatterns = [
path('', home, name='home'),
path('about/', about, name='about'),
path('api/', api, name='api'),
path('', include('rdmo.core.urls')),
path('api/v1/', include('rdmo.core.urls.v1')),
path('api/v1/', include('rdmo.core.urls.v1.openapi')), # <-- this line
path('admin/', admin.site.urls),
]