Skip to content
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

Consider adding fields for detail/list route + GET + query params to schema generation #4441

Closed
shangxiao opened this issue Aug 25, 2016 · 4 comments
Milestone

Comments

@shangxiao
Copy link
Contributor

shangxiao commented Aug 25, 2016

I have a ViewSet list_route that is setup for GET using query parameters. The CoreAPI schema generator does not include these serializer fields in the schema but I think they should be considered for inclusion (although I'm not entirely sure how one would go about determining that 😊)

I know that filter_fields will be included in the schema, however, essentially this list_route is more of a RPC action related to the collection, rather than an action that returns a list.

class ExampleViewSet(ModelViewSet):
    ...
    @list_route(methods=['get'], serializer_class=SpecificSerializer)
    def specific_list_action(self, request):
        serializer = self.get_serializer(data=request.query_params)
        ...
@tomchristie tomchristie modified the milestone: 3.5.0 Release Sep 29, 2016
@tomchristie
Copy link
Member

There's no way we'd be able to automatically determine when we should do this.

However, the version-3-5 branch now includes plenty of improvements to the schema generation API. We'll be documenting these in order to ensure that they're fully customizable.

@ramusus
Copy link

ramusus commented Mar 22, 2017

Any progress on this feature? I see version 3.6 already released, so is there any way to include fields in the schema for @list_route methods?

@ramusus
Copy link

ramusus commented Mar 23, 2017

@tomchristie I think there is a way to determine which fields are associated to @list_route decorated view. For example, it's possible to define filter_class as well as serializer_class and take those fields from associated filter class. But the problem is deeper: @list_route decorated view are not treated as list view in is_list_view() method here https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/schemas.py#L137 during schema generation. And as result fields are not collected from get_pagination_fields() and get_filter_fields()at all.

@xordoquy
Copy link
Collaborator

@ramusus feel free to open a PR if you think you can get something working. I'm also considering working on "less obvious" cases for documentation / schema generation though I can't commit to anything.

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

No branches or pull requests

4 participants