      charset = None
      format = 'openapi'
  
      def __init__(self):
          assert coreapi, 'Using OpenAPIRenderer, but `coreapi` is not installed.'
          assert yaml, 'Using OpenAPIRenderer, but `pyyaml` is not installed.'
  
      def render(self, data, media_type=None, renderer_context=None):
          structure = self.get_structure(data)
          return yaml.dump(structure, default_flow_style=False).encode()
  
 
</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         assert coreapi, 'Using JSONOpenAPIRenderer, but `coreapi` is not installed.'
 </s> add         assert coreapi, 'Using CoreAPIJSONOpenAPIRenderer, but `coreapi` is not installed.' </s> remove class JSONOpenAPIRenderer(_BaseOpenAPIRenderer):
 </s> add class CoreAPIJSONOpenAPIRenderer(_BaseOpenAPIRenderer): </s> remove class OpenAPIRenderer(_BaseOpenAPIRenderer):
 </s> add class CoreAPIOpenAPIRenderer(_BaseOpenAPIRenderer): </s> remove         assert coreapi is not None, 'coreapi must be installed.'

        generator = SchemaGenerator(
 </s> add         generator_class = self.get_generator_class()
        generator = generator_class(
        assert coreapi, 'Using CoreAPIOpenAPIRenderer, but `coreapi` is not installed.'
        assert yaml, 'Using CoreAPIOpenAPIRenderer, but `pyyaml` is not installed.'
      charset = None
      format = 'openapi'
  
      def __init__(self):
        assert coreapi, 'Using CoreAPIOpenAPIRenderer, but `coreapi` is not installed.'
        assert yaml, 'Using CoreAPIOpenAPIRenderer, but `pyyaml` is not installed.'
        assert coreapi, 'Using CoreAPIOpenAPIRenderer, but `coreapi` is not installed.'
        assert yaml, 'Using CoreAPIOpenAPIRenderer, but `pyyaml` is not installed.'
  
      def render(self, data, media_type=None, renderer_context=None):
          structure = self.get_structure(data)
          return yaml.dump(structure, default_flow_style=False).encode()
  
keep keep keep keep replace replace 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/renderers.py