Skip to content

get_category() in SchemaGenerator doesn't behave as expected #4468

@prajjwol

Description

@prajjwol

Checklist

  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

If you have two end points:

/self supporting [DELETE, GET, PUT] and /version/self supporting [GET, PUT]

both will have same category self. Thus when schema is generated the GET and PUT methods from 1st end point will be overwritten and the schema will only show DELETE as accepted method for that endpoint

Expected behavior

Methods should not be overwritten.

Work Around

I have edited https://github.com/tomchristie/django-rest-framework/blob/d0ed482d7094e94b8cbfdc6c0f8335e02d79b765/rest_framework/schemas.py#L108 portion with this for now so it would behave as expected

   for category, action, link in links:
        if category is None:
            content[action] = link
        elif link.url in content:
            content[link.url][action] = link
        else:
            content[link.url] = {action: link}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions