Skip to content

Provide an easy way to document query params for detail_routes #5382

@blueyed

Description

@blueyed

There does not seem to be an easy way to document query parameters for a detail
view.

  1. Would it be feasible to support something like a input_serializer_class
    argument, from where CoreAPI Link Fields (with query for the "Query
    Parameters" used in docs/link.html) could be derived from?

  2. This could then even set validated_data on the request (or pass a new
    argument for/with it)?

This would simplify the pattern with:

class CustomInputSerializer(serializers.Serializer):
    query_arg = serializers.CharField(required=True)


@detail_route(methods=['get'])
def custom_action(self, request, uuid=None):
    """Some custom action.

    Query arguments:

     - ``query_arg``:
       something, e.g. "2017-08-15" (**required**).
    """
    obj = self.get_object()

    input = CustomInputSerializer(data=request.GET)
    input.is_valid(raise_exception=True)

    # Use input.validated_data['query_arg']

to

@detail_route(methods=['get'])
def custom_action(self, request, uuid=None):
    """Some custom action."""
    obj = self.get_object()

    # Use request.validated_data['query_arg']

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy