Skip to content

Drop coreapi support for DRF 3.17 #9583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 0 additions & 2 deletions requirements/requirements-optionals.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Optional packages which may be used with REST framework.
coreapi==2.3.1
coreschema==0.0.4
django-filter
django-guardian>=2.4.0,<2.5
inflection==0.5.1
Expand Down
16 changes: 2 additions & 14 deletions rest_framework/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,20 @@ def unicode_http_header(value):
postgres_fields = None


# coreapi is required for CoreAPI schema generation
try:
import coreapi
except ImportError:
coreapi = None

# uritemplate is required for OpenAPI and CoreAPI schema generation
# uritemplate is required for OpenAPI schema generation
try:
import uritemplate
except ImportError:
uritemplate = None


# coreschema is optional
try:
import coreschema
except ImportError:
coreschema = None


# pyyaml is optional
try:
import yaml
except ImportError:
yaml = None


# inflection is optional
try:
import inflection
Expand Down
44 changes: 0 additions & 44 deletions rest_framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
returned by list views.
"""
import operator
import warnings
from functools import reduce

from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured
Expand All @@ -14,8 +13,6 @@
from django.utils.text import smart_split, unescape_string_literal
from django.utils.translation import gettext_lazy as _

from rest_framework import RemovedInDRF317Warning
from rest_framework.compat import coreapi, coreschema
from rest_framework.fields import CharField
from rest_framework.settings import api_settings

Expand Down Expand Up @@ -48,13 +45,6 @@ def filter_queryset(self, request, queryset, view):
"""
raise NotImplementedError(".filter_queryset() must be overridden.")

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return []

def get_schema_operation_parameters(self, view):
return []

Expand Down Expand Up @@ -186,23 +176,6 @@ def to_html(self, request, queryset, view):
template = loader.get_template(self.template)
return template.render(context)

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
name=self.search_param,
required=False,
location='query',
schema=coreschema.String(
title=force_str(self.search_title),
description=force_str(self.search_description)
)
)
]

def get_schema_operation_parameters(self, view):
return [
{
Expand Down Expand Up @@ -348,23 +321,6 @@ def to_html(self, request, queryset, view):
context = self.get_template_context(request, queryset, view)
return template.render(context)

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
name=self.ordering_param,
required=False,
location='query',
schema=coreschema.String(
title=force_str(self.ordering_title),
description=force_str(self.ordering_description)
)
)
]

def get_schema_operation_parameters(self, view):
return [
{
Expand Down
Empty file.
Empty file.
71 changes: 0 additions & 71 deletions rest_framework/management/commands/generateschema.py

This file was deleted.

95 changes: 0 additions & 95 deletions rest_framework/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import contextlib
import warnings
from base64 import b64decode, b64encode
from collections import namedtuple
from urllib import parse
Expand All @@ -15,8 +14,6 @@
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _

from rest_framework import RemovedInDRF317Warning
from rest_framework.compat import coreapi, coreschema
from rest_framework.exceptions import NotFound
from rest_framework.response import Response
from rest_framework.settings import api_settings
Expand Down Expand Up @@ -151,12 +148,6 @@ def to_html(self): # pragma: no cover
def get_results(self, data):
return data['results']

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
return []

def get_schema_operation_parameters(self, view):
return []

Expand Down Expand Up @@ -313,36 +304,6 @@ def to_html(self):
context = self.get_html_context()
return template.render(context)

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
fields = [
coreapi.Field(
name=self.page_query_param,
required=False,
location='query',
schema=coreschema.Integer(
title='Page',
description=force_str(self.page_query_description)
)
)
]
if self.page_size_query_param is not None:
fields.append(
coreapi.Field(
name=self.page_size_query_param,
required=False,
location='query',
schema=coreschema.Integer(
title='Page size',
description=force_str(self.page_size_query_description)
)
)
)
return fields

def get_schema_operation_parameters(self, view):
parameters = [
{
Expand Down Expand Up @@ -530,32 +491,6 @@ def get_count(self, queryset):
except (AttributeError, TypeError):
return len(queryset)

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
name=self.limit_query_param,
required=False,
location='query',
schema=coreschema.Integer(
title='Limit',
description=force_str(self.limit_query_description)
)
),
coreapi.Field(
name=self.offset_query_param,
required=False,
location='query',
schema=coreschema.Integer(
title='Offset',
description=force_str(self.offset_query_description)
)
)
]

def get_schema_operation_parameters(self, view):
parameters = [
{
Expand Down Expand Up @@ -933,36 +868,6 @@ def to_html(self):
context = self.get_html_context()
return template.render(context)

def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
fields = [
coreapi.Field(
name=self.cursor_query_param,
required=False,
location='query',
schema=coreschema.String(
title='Cursor',
description=force_str(self.cursor_query_description)
)
)
]
if self.page_size_query_param is not None:
fields.append(
coreapi.Field(
name=self.page_size_query_param,
required=False,
location='query',
schema=coreschema.Integer(
title='Page size',
description=force_str(self.page_size_query_description)
)
)
)
return fields

def get_schema_operation_parameters(self, view):
parameters = [
{
Expand Down
Loading
Loading