title: Using FileField/ImageField with Swagger UI and drf-spectacular
body: <p>I have a Django REST Framework project which uses a <code>ModelViewSet</code> to create APIs for a model containing a <code>FileField</code>.</p>
  <p>I've shared a full example of a Django project demonstrating this issue <a href="https://github.com/LondonAppDev/drf-openapi-filefield-issue" rel="nofollow noreferrer">here</a>. But to summarise the key components:</p>
  <p><strong>models.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>from django.db import models
  
  
  class Profile(models.Model):
      image = models.FileField(upload_to='uploads/%Y/%m/%d/')
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>from rest_framework import (
      viewsets,
      serializers,
      parsers,
  )
  
  from sample import models
  
  
  class ProfileSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = models.Profile
          fields = ['id', 'image']
          read_only_fields = ['id']
  
  
  class ProfileViewSet(viewsets.ModelViewSet):
      serializer_class = ProfileSerializer
      queryset = models.Profile.objects.all()
  </code></pre>
  <p><strong>urls.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>from drf_spectacular.views import (
      SpectacularAPIView,
      SpectacularSwaggerView,
  )
  
  from django.contrib import admin
  from django.urls import path, include
  from django.conf.urls.static import static
  from django.conf import settings
  
  from rest_framework.routers import DefaultRouter
  
  from sample import views
  
  
  router = DefaultRouter()
  router.register('profile', views.ProfileViewSet)
  
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('api/schema/', SpectacularAPIView.as_view(), name='api-schema'),
      path(
          'api/docs/',
          SpectacularSwaggerView.as_view(url_name='api-schema'),
          name='api-docs',
      ),
      path('', include(router.urls)),
  ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  <p><strong>settings.py</strong> (<code>REST_FRAMEWORK</code> configuration only):</p>
  <pre class="lang-py prettyprint-override"><code>REST_FRAMEWORK = {
      'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
  }
  
  </code></pre>
  <p><strong>requirements.txt</strong></p>
  <pre><code>Django==3.2.3
  djangorestframework==3.12.4
  drf-spectacular==0.16.0
  </code></pre>
  <p>I am generating browsable Swagger-UI docs using <a href="https://drf-spectacular.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">drf-spectacular</a> to document the API.</p>
  <p>The problem is that the <code>FileField</code> input in Swagger-UI is a <code>string</code> input, and doesn't give the option to set a file:</p>
  <p><a href="https://i.stack.imgur.com/x1Dmp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x1Dmp.png" alt="enter image description here" /></a></p>
  <p>I would like to have a file input where I can choose a file which will be sent to the API.</p>
  <p>My question is: How can I configure DRF or drf-spectacular to show this field?</p>