JSONField schema with nested serializer

117 views
Skip to first unread message

Ata Mahjoubfar

unread,
Jan 12, 2017, 2:21:57 PM1/12/17
to Django REST framework
I am trying to use a nested serializer to enforce schema of a JSONField, which is a list of objects with specific fields. I pass the many=True flag to the nested serialized, but the auto-generated JSON form, html form, and schema does not show the required fields of the JSONField objects. The JSONField ("types" here) shows up as an empty array:
{
    "types": [],
    "shape": null
}
Is there any way for me to set the minimum number of items required along with the many=True flag? I assume that would show the fields of the nested serializer in the raw JSON input of the Django Rest Framework. Is there any better solution?

Allan Nozomu Fukasawa

unread,
Jan 16, 2017, 1:00:37 PM1/16/17
to Django REST framework
Hi,

I have the same problem, I think this is not supported yet because I couldn't find a solution anywhere.
In my case I'm doing the swagger documentation and can't change the 'example model' that uses this kind of JSON.

Allan

Jeff dambly

unread,
May 25, 2017, 3:15:31 PM5/25/17
to Django REST framework
I am also running into a similar issue, did you ever find a solution for this?

--Jeff
Reply all
Reply to author
Forward
0 new messages