              'paths': self.get_paths(data)
          }
  
  
  class OpenAPIRenderer(_BaseOpenAPIRenderer):
      media_type = 'application/vnd.oai.openapi'
      charset = None
      format = 'openapi'
  
      def __init__(self):
 
</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 class JSONOpenAPIRenderer(_BaseOpenAPIRenderer):
 </s> add class CoreAPIJSONOpenAPIRenderer(_BaseOpenAPIRenderer): </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.' </s> remove INSERT_INTO_COLLISION_FMT = """
Schema Naming Collision.

coreapi.Link for URL path {value_url} cannot be inserted into schema.
Position conflicts with coreapi.Link for URL path {target_url}.

Attempted to insert link with keys: {keys}.

Adjust URLs to avoid naming collision or override `SchemaGenerator.get_keys()`
to customise schema structure.
"""


class LinkNode(OrderedDict):
    def __init__(self):
        self.links = []
        self.methods_counter = Counter()
        super().__init__()

    def get_available_key(self, preferred_key):
        if preferred_key not in self:
            return preferred_key

        while True:
            current_val = self.methods_counter[preferred_key]
            self.methods_counter[preferred_key] += 1

            key = '{}_{}'.format(preferred_key, current_val)
            if key not in self:
                return key


def insert_into(target, keys, value):
    """
    Nested dictionary insertion.

    >>> example = {}
    >>> insert_into(example, ['a', 'b', 'c'], 123)
    >>> example
    LinkNode({'a': LinkNode({'b': LinkNode({'c': LinkNode(links=[123])}}})))
    """
    for key in keys[:-1]:
        if key not in target:
            target[key] = LinkNode()
        target = target[key]

    try:
        target.links.append((keys[-1], value))
    except TypeError:
        msg = INSERT_INTO_COLLISION_FMT.format(
            value_url=value.url,
            target_url=target.url,
            keys=keys
        )
        raise ValueError(msg)


def distribute_links(obj):
    for key, value in obj.items():
        distribute_links(value)

    for preferred_key, link in obj.links:
        key = obj.get_available_key(preferred_key)
        obj[key] = link


def is_custom_action(action):
    return action not in {
        'retrieve', 'list', 'create', 'update', 'partial_update', 'destroy'
    }


 </s> add 
class CoreAPIOpenAPIRenderer(_BaseOpenAPIRenderer):
              'paths': self.get_paths(data)
          }
  
  
class CoreAPIOpenAPIRenderer(_BaseOpenAPIRenderer):
      media_type = 'application/vnd.oai.openapi'
      charset = None
      format = 'openapi'
  
      def __init__(self):
keep keep keep keep 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