'Error message "`coreapi` must be installed for schema support"
I am trying to generate Swagger documentation using drf_yasg
and it was working fine, but now it’s not.
It’s giving me an error and I can not find a solution for it.
Why am I getting this error?
Environment:
Request Method: GET
Request URL: http://0.0.0.0:8007/doc/
Django Version: 3.2.4
Python Version: 3.9.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'rest_framework',
'drf_yasg',
'promotions',
'vendor',
'settings']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'includes.common.middlewares.identity.IdentityMiddleware',
'includes.common.middlewares.timezone.TimezoneMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/drf_yasg/views.py", line 92, in get
generator = self.generator_class(info, version, url, patterns=[])
File "/usr/local/lib/python3.9/site-packages/drf_yasg/generators.py", line 183, in __init__
self._gen = SchemaGenerator(info.title, url, info.get('description', ''), patterns, urlconf)
File "/usr/local/lib/python3.9/site-packages/rest_framework/schemas/coreapi.py", line 120, in __init__
assert coreapi, '`coreapi` must be installed for schema support.'
Exception Type: AssertionError at /doc/
Exception Value: `coreapi` must be installed for schema support.
Solution 1:[1]
It was a silly mistake. I had made a directory to store extra files and drf_yasg
was considering it as an app and was trying to generate URLs for it.
I removed the __init__.py
files from that directory and it worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | shilin agre |