          self.stdout.write(output.decode())
  
      def get_renderer(self, format):
          renderer_cls = {
              'corejson': CoreJSONRenderer,
              'openapi': OpenAPIRenderer,
              'openapi-json': JSONOpenAPIRenderer,
          }[format]
  
          return renderer_cls()
 
</s> remove         return json.dumps(structure, indent=4).encode()
 </s> add         return json.dumps(structure, indent=4).encode('utf-8')


class OpenAPIRenderer(BaseRenderer):
    media_type = 'application/vnd.oai.openapi'
    charset = None
    format = 'openapi'

    def __init__(self):
        assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'

    def render(self, data, media_type=None, renderer_context=None):
        return yaml.dump(data, default_flow_style=False).encode('utf-8')


class JSONOpenAPIRenderer(BaseRenderer):
    media_type = 'application/vnd.oai.openapi+json'
    charset = None
    format = 'openapi-json'

    def render(self, data, media_type=None, renderer_context=None):
        return json.dumps(data, indent=2).encode('utf-8') </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' </s> remove         assert coreapi, 'Using OpenAPIRenderer, but `coreapi` is not installed.'
        assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'
 </s> add         assert coreapi, 'Using CoreAPIOpenAPIRenderer, but `coreapi` is not installed.'
        assert yaml, 'Using CoreAPIOpenAPIRenderer, but `pyyaml` is not installed.' </s> remove         assert coreapi, 'Using JSONOpenAPIRenderer, but `coreapi` is not installed.'
 </s> add         assert coreapi, 'Using CoreAPIJSONOpenAPIRenderer, but `coreapi` is not installed.'
            'openapi': renderers.OpenAPIRenderer,
            'openapi-json': renderers.JSONOpenAPIRenderer,
          self.stdout.write(output.decode())
  
      def get_renderer(self, format):
          renderer_cls = {
            'openapi': renderers.OpenAPIRenderer,
            'openapi-json': renderers.JSONOpenAPIRenderer,
            'openapi': renderers.OpenAPIRenderer,
            'openapi-json': renderers.JSONOpenAPIRenderer,
            'openapi': renderers.OpenAPIRenderer,
            'openapi-json': renderers.JSONOpenAPIRenderer,
          }[format]
  
          return renderer_cls()
keep keep keep keep replace replace replace 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