Skip to content

Drop deprecated coreapi support#9895

Open
browniebroke wants to merge 6 commits intoencode:mainfrom
browniebroke:refactor/drop-coreapi
Open

Drop deprecated coreapi support#9895
browniebroke wants to merge 6 commits intoencode:mainfrom
browniebroke:refactor/drop-coreapi

Conversation

@browniebroke
Copy link
Member

@browniebroke browniebroke commented Feb 18, 2026

Description

Note

Most of this PR was AI generated (Claude code). At time of opening this, I haven't had time to carefully review the code myself yet, and will put it in ready for review when I've done so. I've now review it and what is removed makes sense, but I'm not sure if there is more we can/shoul remove...

Opening this as another attempt to do #9583 opening this for visibility in case others are interested.

Testing status:

  • Ran the drf-spectacular test suite against this branch: Test against branch without coreapi browniebroke/drf-spectacular#1
  • Installed the branch on a real project, made sure that the browsable API works as expected, and docs are generated with drf-spectacular and the test suite passes
  • Same as above on another project
  • Anything else...? Suggestions welcome

FYI @TGoddessana as you started the original PR (do you still have the old commits somewhere?)

Give this a spin

If you want to install this branch on your project:

uv add https://github.com/browniebroke/django-rest-framework/archive/refactor/drop-coreapi.tar.gz

refs #8453

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the deprecated CoreAPI-based schema/documentation stack from Django REST framework, leaving OpenAPI as the only built-in schema generation/rendering path and cleaning up associated tests, templates, and optional dependencies.

Changes:

  • Remove CoreAPI schema generation, renderers, docs views/templates/assets, and the CoreAPIClient.
  • Simplify schema views/management command to OpenAPI-only behavior.
  • Delete CoreAPI-focused tests and update remaining tests to match the new surface area.

Reviewed changes

Copilot reviewed 44 out of 49 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/urls.py Removes docs URLConf usage; leaves empty urlpatterns for test suite.
tests/test_templatetags.py Removes CoreAPI templating tests and related imports.
tests/test_renderers.py Removes DocumentationRenderer/SchemaJSRenderer/CoreAPI renderer tests and imports.
tests/test_filters.py Removes CoreAPI schema field testing and mocks tied to CoreAPI.
tests/test_encoders.py Removes JSONEncoder behavior test specific to coreapi objects.
tests/test_api_client.py Deletes CoreAPIClient integration tests and fixtures.
tests/schemas/test_managementcommand.py Removes CoreAPI mode tests; keeps OpenAPI management command coverage.
tests/schemas/test_get_schema_view.py Removes CoreAPI schema view test path; keeps OpenAPI assertions.
tests/schemas/test_coreapi.py Deletes the CoreAPI schema generator/inspector test suite.
rest_framework/utils/encoders.py Removes JSONEncoder special-casing of coreapi Document/Error objects.
rest_framework/test.py Removes CoreAPIClient from the testing utilities module.
rest_framework/templatetags/rest_framework.py Removes CoreAPI-docs-specific template tags/filters.
rest_framework/templates/rest_framework/schema.js Deletes CoreAPI schema JS bootstrap template.
rest_framework/templates/rest_framework/docs/sidebar.html Deletes legacy interactive docs sidebar template.
rest_framework/templates/rest_framework/docs/link.html Deletes legacy interactive docs endpoint template.
rest_framework/templates/rest_framework/docs/langs/shell.html Deletes CoreAPI CLI snippet template.
rest_framework/templates/rest_framework/docs/langs/shell-intro.html Deletes CoreAPI CLI install snippet template.
rest_framework/templates/rest_framework/docs/langs/python.html Deletes CoreAPI Python client snippet template.
rest_framework/templates/rest_framework/docs/langs/python-intro.html Deletes CoreAPI Python client install snippet template.
rest_framework/templates/rest_framework/docs/langs/javascript.html Deletes CoreAPI JS client snippet template.
rest_framework/templates/rest_framework/docs/langs/javascript-intro.html Deletes CoreAPI JS client loading snippet template.
rest_framework/templates/rest_framework/docs/interact.html Deletes interactive “try it” modal template.
rest_framework/templates/rest_framework/docs/index.html Deletes legacy interactive docs index template.
rest_framework/templates/rest_framework/docs/error.html Deletes legacy docs error template.
rest_framework/templates/rest_framework/docs/document.html Deletes legacy docs document layout template.
rest_framework/templates/rest_framework/docs/auth/token.html Deletes legacy docs token auth modal template.
rest_framework/templates/rest_framework/docs/auth/session.html Deletes legacy docs session auth modal template.
rest_framework/templates/rest_framework/docs/auth/basic.html Deletes legacy docs basic auth modal template.
rest_framework/static/rest_framework/docs/js/jquery.json-view.min.js Deletes legacy docs JSON viewer dependency.
rest_framework/static/rest_framework/docs/js/api.js Deletes legacy docs interactive client JS.
rest_framework/static/rest_framework/docs/img/grid.png Removes legacy docs image asset.
rest_framework/static/rest_framework/docs/img/favicon.ico Removes legacy docs favicon asset.
rest_framework/static/rest_framework/docs/css/jquery.json-view.min.css Deletes legacy docs JSON viewer CSS.
rest_framework/static/rest_framework/docs/css/highlight.css Deletes legacy docs syntax highlight CSS.
rest_framework/static/rest_framework/docs/css/base.css Deletes legacy docs base styling.
rest_framework/schemas/views.py Makes SchemaView renderer selection OpenAPI-only.
rest_framework/schemas/coreapi.py Deletes CoreAPI schema generator/inspectors module.
rest_framework/schemas/init.py Removes CoreAPI exports/selection logic; exports OpenAPI AutoSchema/SchemaGenerator.
rest_framework/renderers.py Deletes CoreAPI renderers + documentation renderer/SchemaJS renderer implementations.
rest_framework/pagination.py Removes CoreAPI get_schema_fields() hooks from pagination classes.
rest_framework/management/commands/generateschema.py Removes CoreAPI modes/format options; OpenAPI-only output.
rest_framework/filters.py Removes CoreAPI get_schema_fields() hooks from filter backends.
rest_framework/documentation.py Deletes legacy docs URL helpers (include_docs_urls, etc.).
rest_framework/compat.py Removes optional coreapi/coreschema shims; keeps uritemplate/yaml/requests optionals.
rest_framework/authtoken/views.py Removes CoreAPI ManualSchema definition from token view.
rest_framework/init.py Removes RemovedInDRF318Warning deprecation warning class.
pyproject.toml Removes CoreAPI-related optional deps; adjusts dependency groups (adds requests, adds uritemplate).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 51 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@browniebroke browniebroke added this to the 3.17 milestone Feb 19, 2026
@browniebroke browniebroke marked this pull request as ready for review February 19, 2026 08:16
@browniebroke
Copy link
Member Author

@auvipy did you want to check anything in particular before we decide to merge it? I realise it's quite a big one...

@auvipy
Copy link
Collaborator

auvipy commented Mar 2, 2026

sure

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 51 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


class CustomAutoSchema(AutoSchema):
def get_link(self, path, method, base_url):
def get_operation(self, path, method):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain a bit about the rename?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The from rest_framework.schemas import AutoSchema now resolve to rest_framework.schemas.openapi.AutoSchema instead of rest_framework.schemas.coreapi.AutoSchema.

The get_link method from the Core API version doesn't exist in the Open API variant, but the get_operation is the equivalent: it collects paths, filters and pagination parameters for the API schema. The CoreAPI version was returning a coreapi.Link object while the Open API returns a dict following the schema Open API expects.

So it's not really a rename, it's more of an API difference between the 2 AutoSchema variants.

generator_class = coreapi.SchemaGenerator
else:
generator_class = openapi.SchemaGenerator
generator_class = openapi.SchemaGenerator
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drf already have build in openapi schema generator? just want to clear my self about this

Copy link
Member Author

@browniebroke browniebroke Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the difference with the coreapi.SchemaGenerator, but as it was what was returned when coreapi wasn't installed, this branch is left untouched.

We might be able to remove that in the future but as far as I understand this is out of scope here.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
# Conflicts:
#	docs/api-guide/testing.md
@TGoddessana
Copy link
Contributor

I apologize for the delayed response. There are currently no commit records for the previous version. :( Since design discussions hadn't taken place yet, I felt it would be premature for me to proceed with a PR. Thank you so much for your excellent work on the project.

@TGoddessana
Copy link
Contributor

If we are not involved in schema creation, should we also remove the schema-related configuration code in settings.py? Or should we consider it an interface for third-party packages?

from docs...

DEFAULT_SCHEMA_CLASS
A view inspector class that will be used for schema generation.

Schema generation controls
SCHEMA_COERCE_PATH_PK
If set, this maps the 'pk' identifier in the URL conf onto the actual field name when generating a schema path parameter. Typically this will be 'id'. This gives a more suitable representation as "primary key" is an implementation detail, whereas "identifier" is a more general concept.
Default: True

SCHEMA_COERCE_METHOD_NAMES
If set, this is used to map internal viewset method names onto external action names used in the schema generation. This allows us to generate names that are more suitable for an external representation than those that are used internally in the codebase.
Default: {'retrieve': 'read', 'destroy': 'delete'}

DEFAULT_SCHEMA_CLASS
COERCE_DECIMAL_TO_STRING
UPLOADED_FILES_USE_URL
URL_FORMAT_OVERRIDE
FORMAT_SUFFIX_KWARG

drf-spectacular directly uses these items from the existing DRF's settings.py.

@auvipy
Copy link
Collaborator

auvipy commented Mar 4, 2026

may be we can defer this for 3.18? in the mean time we will learn more about the available best packages and other goodies....

@browniebroke
Copy link
Member Author

If we are not involved in schema creation, should we also remove the schema-related configuration code in settings.py? Or should we consider it an interface for third-party packages?

For me that's the interface for 3rd party packages and should not be changed here. We can review later, but the only point of this PR is to do the bare minimum to eliminate the dependency on the coreapi package. the project is archived and is widely out of date, it uses some old setuptools APIs which are being removed, so it's becoming more and more a liability

may be we can defer this for 3.18? in the mean time we will learn more about the available best packages and other goodies....

By "this" do you mean this PR or what was suggested in the message directly above? I'd like to get this PR merged for 3.17 but more than happy to review @TGoddessana suggestions after 3.17...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants