  class Command(BaseCommand):
      help = "Generates configured API schema for project."
  
      def add_arguments(self, parser):
          parser.add_argument('--title', dest="title", default='', type=str)
          parser.add_argument('--url', dest="url", default=None, type=str)
          parser.add_argument('--description', dest="description", default=None, type=str)
          if self.get_mode() == COREAPI_MODE:
 
</s> remove         parser.add_argument('--title', dest="title", default=None, type=str)
 </s> add         parser.add_argument('--title', dest="title", default='', type=str) </s> remove         parser.add_argument('--format', dest="format", choices=['openapi', 'openapi-json', 'corejson'], default='openapi', type=str)
 </s> add         if self.get_mode() == COREAPI_MODE:
            parser.add_argument('--format', dest="format", choices=['openapi', 'openapi-json', 'corejson'], default='openapi', type=str)
        else:
            parser.add_argument('--format', dest="format", choices=['openapi', 'openapi-json'], default='openapi', type=str) </s> remove         assert coreapi is not None, 'coreapi must be installed.'

        generator = SchemaGenerator(
 </s> add         generator_class = self.get_generator_class()
        generator = generator_class( </s> remove from rest_framework.compat import coreapi
from rest_framework.renderers import (
    CoreJSONRenderer, JSONOpenAPIRenderer, OpenAPIRenderer
)
from rest_framework.schemas.generators import SchemaGenerator
 </s> add from rest_framework import renderers
from rest_framework.schemas import coreapi
from rest_framework.schemas.openapi import SchemaGenerator

OPENAPI_MODE = 'openapi'
COREAPI_MODE = 'coreapi'
    def get_mode(self):
        return COREAPI_MODE if coreapi.is_enabled() else OPENAPI_MODE

  class Command(BaseCommand):
      help = "Generates configured API schema for project."
  
    def get_mode(self):
        return COREAPI_MODE if coreapi.is_enabled() else OPENAPI_MODE

      def add_arguments(self, parser):
          parser.add_argument('--title', dest="title", default='', type=str)
          parser.add_argument('--url', dest="url", default=None, type=str)
          parser.add_argument('--description', dest="description", default=None, type=str)
          if self.get_mode() == COREAPI_MODE:
keep keep add keep keep keep keep keep
 Added OpenAPI Schema Generation. (#6532)

Co-authored-by: Lucidiot <lucidiot@protonmail.com>
Co-authored-by: dongfangtianyu <dongfangtianyu@qq.com> 
rest_framework/management/commands/generateschema.py