Skip to content

Conversation

@TGoddessana
Copy link
Contributor

Description

refs #8453

As discussed in #8453, we are deprecating the coreapi for drf 3.17.

I read the discussion in detail, and I'm wondering if it was decided to “leave all schema generation logic in the library that generates the schema (drf-spectacular), and drf will not be involved in schema generation” (drf-spectacular will be part of drf?) The comments in the linked discussion say that...

Yes. The idea would be to leave (just) the extension points in place, as they are.

@TGoddessana
Copy link
ContributorAuthor

TGoddessana commented Mar 21, 2025

Question while working with PR.

The documentation says: “Support for generating default schemas will be moved to a separate package and then removed”. For this PR, should we remove coreapi and everything related to it, or all code related to the whole rest_framework/schemas/ package?

If you need to remove everything related to schemas from the Rest Framework, you can remove most of the code, tests, etc. in /schemas. What do you team think about this?

@TGoddessana
Copy link
ContributorAuthor

@auvipy I'm sorry if the tags are annoying. But this is the only place we can make design decisions about PR, and I'd love to hear your thoughts on what I should do..

@auvipy
Copy link
Collaborator

yes please fix the merge conflicts as we have to remove it

@TGoddessana
Copy link
ContributorAuthor

I guess this is where we need to make a decision on where we stop supporting it... For example, should we remove all schema-related references in rest_framework.settings since schema generation will stop?

The documentation certainly mentions that we will be removing API documentation, but I'm confused if removing all code like schemas.utils or renderers.CoreJSONRenderer is included in this scope.

@TGoddessana
Copy link
ContributorAuthor

image

For example, the APIView class defaults to the DefaultSchema() class that was included in the schema package.

If we were to remove schema generation, would it be right to remove these codes as well?

@browniebrokebrowniebroke added this to the 3.17 milestone Jul 6, 2025
@browniebroke
Copy link
Member

That's a big one! I didn't expect to see some much code deleted, but I can see there was a lot of tests...

If we were to remove schema generation, would it be right to remove these codes as well?

Would be interesting to see what drf-spectacular or drf-yasg are using to hook into DRF, and make sure we don't break their integration point. Might be a good idea to coordinate this with them.

@TGoddessana
Copy link
ContributorAuthor

Alright, I think it's best to restart the PR, so I've reverted the commit. Both packages directly depend on this part of rest_framework. Let's see this..

(Some parts of this content were generated using AI. :) I think it's a really useful tool for situations like this. But basically, I found and verified all the code references myself.)

drf-spectacular

Essential Components to Maintain

ComponentLocationTypePurposedrf-spectacular Usage
ViewInspectorrest_framework.schemas.inspectorsBase ClassCore schema inspection interfaceInherited by AutoSchema class
BaseSchemaGeneratorrest_framework.schemas.generatorsBase ClassSchema generation interfaceUsed by drf-spectacular generators
BaseEndpointEnumeratorrest_framework.schemas.generatorsBase ClassAPI endpoint discovery logicExtended by EndpointEnumerator
get_pk_descriptionrest_framework.schemas.utilsUtility FunctionPrimary key field descriptionDirect import and usage

Components Safe to Remove

ComponentLocationTypeReason for Removal
AutoSchema (DRF's implementation)rest_framework.schemasClassReplaced by drf-spectacular's AutoSchema
CoreAPI schema generatorsrest_framework.schemas.coreapiModuleLegacy schema format
OpenAPI 2.0 generatorsrest_framework.schemas.openapiModuleSuperseded by drf-spectacular
Schema view implementationsrest_framework.schemas.viewsModuleCustom implementations available

Critical Interfaces to Preserve

InterfaceMethod/AttributeRequired for Compatibility
ViewInspectorget_operation()Method signature and base behavior
ViewInspectorget_description()Method signature
ViewInspectorget_summary()Method signature
BaseEndpointEnumeratorget_api_endpoints()Method signature and return format
BaseEndpointEnumeratorget_path_from_regex()Method signature
BaseSchemaGeneratorBase interfaceClass structure and constructor

drf-yasg

Essential Components to Maintain

ComponentLocationTypePurposedrf-yasg Usage
EndpointEnumeratorrest_framework.schemas.generatorsBase ClassAPI endpoint discovery logicExtended by custom EndpointEnumerator
SchemaGeneratorrest_framework.schemas.openapiBase ClassOpenAPI schema generationUsed as base for drf-yasg generator
get_pk_descriptionrest_framework.schemas.utilsUtility FunctionPrimary key field descriptionDirect import and usage
get_pk_namerest_framework.schemas.generatorsUtility FunctionPrimary key field name extractionDirect import and usage
endpoint_orderingrest_framework.schemas.generatorsUtility FunctionEndpoint sorting logicDirect import and usage
AutoSchemarest_framework.schemasClassSchema inspection interfaceUsed internally by SwaggerAutoSchema

Components Safe to Remove

ComponentLocationTypeReason for Removal
DRF's default OpenAPI implementationrest_framework.schemas.openapiImplementationReplaced by drf-yasg's implementation
CoreAPI schema generatorsrest_framework.schemas.coreapiModuleLegacy schema format
Default schema view implementationsrest_framework.schemas.viewsModuleCustom implementations available

Critical Interfaces to Preserve

InterfaceMethod/AttributeRequired for Compatibility
EndpointEnumeratorget_path_from_regex()Method signature and regex processing
EndpointEnumeratorshould_include_endpoint()Method signature for endpoint filtering
SchemaGeneratorBase class structureConstructor and inheritance compatibility
AutoSchemaview attributeUsed by SwaggerAutoSchema._sch.view
Utility functionsImport pathsAll utility function locations must remain stable

Key Differences from drf-spectacular

Aspectdrf-yasgdrf-spectacular
Base Schema ClassUses AutoSchema internallyInherits from ViewInspector
Generator ApproachExtends SchemaGeneratorUses BaseSchemaGenerator
Endpoint DiscoveryHeavily customizes EndpointEnumeratorExtends BaseEndpointEnumerator
Utility DependenciesMore extensive use of DRF utilitiesMinimal utility usage

@TGoddessana
Copy link
ContributorAuthor

TGoddessana commented Sep 21, 2025

In my view, there are two possible approaches:

  1. Remove all schema-related code and settings from DRF, requiring both packages to redefine the relevant dependency code within the schemas package. This would fully eliminate the schema generation logic, which I believe results in a cleaner overall design.

  2. Retain the dependent code as summarized above. While this would leave some legacy code in place, it would preserve compatibility.

From a maintenance perspective, I tend to favor Option 1 (removing all schema-related code). The deprecation of coreapi has been clearly noted in both the codebase and documentation for some time, and it seems more sustainable for DRF not to maintain direct dependencies on third-party packages(similar to how Django continues to evolve without holding back updates purely for compatibility with DRF.).

@TGoddessana
Copy link
ContributorAuthor

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

DEFAULT_SCHEMA_CLASS COERCE_DECIMAL_TO_STRING UPLOADED_FILES_USE_URL URL_FORMAT_OVERRIDE FORMAT_SUFFIX_KWARG 

As long as DRF does not participate in schema creation, could removing the DEFAULT_SCHEMA_CLASS api from the above items be a good starting point?

@browniebroke
Copy link
Member

Sorry about the lack of feedback here, I'm not too sure how to get this one across the line without breaking other documentation packages like drf-spectacular, and will need some time to understand that.

We are aiming to move the project to @django-commons on Friday and as part of the move, we're planning to do a release. With the list of unreleased changes on main, we will have to bump the minor digit to 3.17, but realistically this PR won't make the cut.

Would you be interested in sending a pull request to update the deprecation warning from 3.17 to 3.18? feel free to say no if you won't have time...

Thanks!

@browniebrokebrowniebroke removed this from the 3.17 milestone Oct 29, 2025
@browniebroke
Copy link
Member

As this is a bit time sensitive, I've done it in #9810

Let's go back to this once it's merged. Thanks for your patience.

@auvipy
Copy link
Collaborator

lets wait until 3.18

@TGoddessana
Copy link
ContributorAuthor

I apologize for the delayed response. I've been personally busy and going through a difficult time.

Thank you for working on the package. As you suggested, I think it would be best to consider up to version 3.18.

As mentioned, I think the cleanest approach is to remove all schema-related code (packages, tests). It won't be easy to maintain the code without breaking the integration points for both packages (drf-spectacular, drf-yasg).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@TGoddessana@auvipy@browniebroke