Skip to content

'API Document' ask for wrong params (page) #4996

Closed

Description

@losnuyh

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

# serializers.py
class PostSerializer(serializers.ModelSerializer):
    class Meta:
        model = Post
        fields = 'title', 'content'


# views.py
class PostView(generics.ListCreateAPIView):
    serializer_class = PostSerializer
    queryset = Post.objects.all()

I did not set the pagination.

but in the API Documentation

sample

Because generics.views has a default value of 'PageNumberPagination'(in api_settings)
so..
Not getattr (view, 'pagination_class', None) value is always false.

Activity

  1. losnuyh commented on Mar 17, 2017

    @losnuyh
    ContributorAuthor

    Not getattr (view, 'pagination_class', None) is a phrase in the get_pagination_fields method of the SchemaGenerator class in schemas.py .

  2. lovelydinosaur commented on Mar 17, 2017

    @lovelydinosaur
    Member

    From how you've explained this I don't see any issue.
    It's picking up the default setting.
    Set pagination_class = None on the view/viewset if you want to turn that off for one instance,
    or set it to None in the settings to turn it off globally.

  3. losnuyh commented on Mar 17, 2017

    @losnuyh
    ContributorAuthor

    The 'page' parameter has no role in API Documents.
    The default value of PAGE_SIZE is already None (rest_framework/settings.py)

    I thought it would be better to eliminate the meaningless parameter than to add 'pagination_class = None' for each 'ListView Class'

  4. lovelydinosaur commented on Mar 17, 2017

    @lovelydinosaur
    Member

    Okay, I think I see - misunderstood the problem! 😄

    Issue being that pagination is turned off if PAGE_SIZE=None (regardless of the pagination class that's been set)
    We still want to fix this in the schema generation rather than just changing the existings settings defaults tho - #4997 isn't the right approach.

  5. losnuyh commented on Mar 17, 2017

    @losnuyh
    ContributorAuthor

    Um .. If you do not adjust the default settings

    In 'get_pagination_fields' method, argument 'view' always has 'pagination_class'.

    At this time, it seems difficult to check whether 'pageniation_class' is user-specified or default setting.

    I will think more.
    Thank you for your advice.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions