Skip to content

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

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

Closed
5 of 6 tasks
prajjwol opened this issue Sep 6, 2016 · 2 comments
Closed
5 of 6 tasks

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

prajjwol opened this issue Sep 6, 2016 · 2 comments

Comments

@prajjwol
Copy link

prajjwol commented Sep 6, 2016

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}
@Nnonexistent
Copy link

I assume #4400 will fix this case

@tomchristie tomchristie added this to the 3.4.7 Release milestone Sep 8, 2016
@tomchristie tomchristie modified the milestones: 3.4.7 Release, 3.4.8 Release Sep 21, 2016
@tomchristie tomchristie modified the milestones: 3.4.8 Release, 3.5.0 Release Sep 29, 2016
@tomchristie
Copy link
Member

Resolved via #4527 (you'll now get nested categories for the second case). Now in the version-3-5 branch.

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

No branches or pull requests

3 participants