What is the equivalent of `paramType: form` in the Core API of DJango Rest Swagger 2?

185 Views Asked by At

In the old django rest swagger, you can specify paramType: form in the docstring of the viewset and retrieve the parameter via request.data['param_x'], as follows:

class FooViewSet(viewsets.ViewSet):
  """
  Make something cool
  ---
  parameters:
  - name: param_x
    required: true
    paramType: form
  """

  def list(self, request):
    param_x = request.data['param_x']
    # do something cool...

In the newer version, I usually use coreapi.Field to specify the properties of the parameters, and set the param type to the location argument key (e.g. core.api.Field(name='param_x', location='query')). All the available location values are discussed in the documentation. However, none of them seemed to be doing what I expected (not even location='form').

How do you set the parameter type to form with the newer version of django rest swagger? I'm probably missing something here.

0

There are 0 best solutions below