title: Swagger with django - why am I getting a missing coreapi.Document error?
body: <p>I'm trying to get a nice swagger UI working for a django webserver, but am running into a cryptic error.</p>
  <p>urls.py</p>
  <pre><code>from django.urls import path
  from djangofun import views
  from rest_framework.schemas import get_schema_view
  from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer
  
  schema_view = get_schema_view(title='API', renderer_classes=[OpenAPIRenderer, SwaggerUIRenderer])
  
  urlpatterns = [
      path('', schema_view),
      path('hello/', views.hello)
  ]
  </code></pre>
  <p>views.py</p>
  <pre><code>from django.http import HttpResponse
  from django.views.decorators.http import require_http_methods
  
  @require_http_methods([&quot;GET&quot;])
  def hello(request):
      return HttpResponse(&quot;Hello world&quot;)
  </code></pre>
  <p>The error, displayed as a webpage at localhost: <a href="https://i.stack.imgur.com/9RFMC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9RFMC.png" alt="The error I get when I load up localhost/" /></a></p>
  <p>I am unsure how to correct this issue, perhaps I am missing something obvious? The documentation (that I found) didn't help. Note that if I remove the <code>renderer_classes</code> kwarg from the <code>get_schema_view</code> function, there is no error, but I am not given the swagger UI I am looking for.</p>
  <p>Traceback:</p>
  <pre><code>Environment:
  
  
  Request Method: GET
  Request URL: http://localhost/
  
  Django Version: 4.1
  Python Version: 3.9.13
  Installed Applications:
  ['django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'rest_framework',
   'rest_framework_swagger']
  Installed Middleware:
  ['django.middleware.security.SecurityMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware']
  
  
  
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py&quot;, line 55, in inner
      response = get_response(request)
    File &quot;/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py&quot;, line 220, in _get_response
      response = response.render()
    File &quot;/usr/local/lib/python3.9/site-packages/django/template/response.py&quot;, line 114, in render
      self.content = self.rendered_content
    File &quot;/usr/local/lib/python3.9/site-packages/rest_framework/response.py&quot;, line 70, in rendered_content
      ret = renderer.render(self.data, accepted_media_type, context)
    File &quot;/usr/local/lib/python3.9/site-packages/rest_framework_swagger/renderers.py&quot;, line 54, in render
      self.set_context(data, renderer_context)
    File &quot;/usr/local/lib/python3.9/site-packages/rest_framework_swagger/renderers.py&quot;, line 68, in set_context
      renderer_context['spec'] = OpenAPIRenderer().render(
    File &quot;/usr/local/lib/python3.9/site-packages/rest_framework_swagger/renderers.py&quot;, line 34, in render
      return OpenAPICodec().encode(data, **options)
    File &quot;/usr/local/lib/python3.9/site-packages/rest_framework_swagger/renderers.py&quot;, line 16, in encode
      raise TypeError('Expected a `coreapi.Document` instance')
  
  Exception Type: TypeError at /
  Exception Value: Expected a `coreapi.Document` instance
  </code></pre>