title: Documenting a DRF GET endpoint with multiple responses using Swagger
body: <p>I have a GET endpoint for a RESTful API I am creating using Django.
  This endpoint reads three values from the URL's query string. A particular parameter in the query string has the potential to change the data (include extra fields and change the structure slightly) which is returned in the JSON response from this endpoint.</p>
  
  <p>This endpoint is not tied directly to a single model. My view subclasses <code>RetrieveAPIView</code>, in the view, I override the <code>get_object</code> method and some logic is performed to query multiple models, make some decisions and return an ordered dictionary.</p>
  
  <p>My problem is as follows:</p>
  
  <p>I would like to document this endpoint using Swagger. I am using <code>drf-yasg</code> to generate my Swagger documentation. I have no serializers declared for this view; since I manually construct an ordered dictionary in <code>get_object</code> I don't see the purpose of declaring one. I'm not sure how to document my endpoint using <code>drf-yasg</code>.</p>
  
  <p>I have discovered only one approach to document the endpoint, but it is quite ugly and bloats my code, and I'm wondering if there is a better approach.</p>
  
  <p>By declaring an <code>openapi.Response</code> object, and supplying this object to the <code>@swagger_auto_schema</code> decorator Swagger displays the two possible responses, but describing the entire response really bloats my code. Here is an example if what currently works to document the endpoint:</p>
  
  <pre><code>class View(RetrieveAPIView):
  
      http_method_names = ['get']
  
      response_json = {
          'Response if X query parameter is something': {
              'key1': 'string',
              'key3': {
                  'key4': 0,
                  'key5': 'string',
                  'key6': 'string'
              }
          },
          'Response if X query parameter is something else': {
              'key1': 'string',
              'key2': 'string'
          }
      }
      swagger_get_responses = openapi.Response(description='Description for the set of responses',
                                               examples=response_json)
  
      @swagger_auto_schema(responses={200: swagger_get_responses})
      def get(self, request, *args, **kwargs):
          return super().get(request, args, kwargs)
  
      def get_object(self):
          // Execute a method on a model that queries other models, performs some logic, and 
          // then returns an ordered dict which is then returned by this function.
  
  </code></pre>
  
  <p>Is there a better approach to this problem? Is there a better Django design pattern/feature of the Django framework or drf-yasg library that I can apply here that will help me handle multiple response bodies?</p>