Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

_find_field_serializers Tries to parse drf native serializer - drf v 3 #167

Closed
subsetpark opened this issue Dec 9, 2014 · 0 comments
Closed

Comments

@subsetpark
Copy link

On django-rest-swagger 0.2.3:

With a debug statement inserted at line 238 of docgenerator.py, I see that swagger is introspecting all the different serializers I have declared. But it also, at times, prints this:

Getting fields for <class 'rest_framework.serializers.ListSerializer'>

And then fails with:

Traceback (most recent call last):
  File "/Users/zachsmith/makespace/site/ve/lib/python2.7/site-packages/rest_framework/views.py", line 403, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/zachsmith/makespace/site/ve/lib/python2.7/site-packages/rest_framework_swagger/views.py", line 137, in get
    'models': generator.get_models(apis),
  File "/Users/zachsmith/makespace/site/ve/lib/python2.7/site-packages/rest_framework_swagger/docgenerator.py", line 111, in get_models
    self._find_field_serializers(serializers)
  File "/Users/zachsmith/makespace/site/ve/lib/python2.7/site-packages/rest_framework_swagger/docgenerator.py", line 244, in _find_field_serializers
    serializers_set.update(self._find_field_serializers((field.__class__, ), serializers_set))
  File "/Users/zachsmith/makespace/site/ve/lib/python2.7/site-packages/rest_framework_swagger/docgenerator.py", line 239, in _find_field_serializers
    fields = serializer().get_fields()
  File "/Users/zachsmith/makespace/site/ve/lib/python2.7/site-packages/rest_framework/serializers.py", line 442, in __init__
    assert self.child is not None, '`child` is a required argument.'

It seems that what is happening is, when swagger hits a serializer that I have defined with many=True (or perhaps with a ListField, which is the same in DRF3), it tries to instantiate the ListSerializer—not my serializer—and then can't introspect it.

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

No branches or pull requests

1 participant