drf_openapi icon indicating copy to clipboard operation
drf_openapi copied to clipboard

Nested serializer on response schema

Open fernandolins opened this issue 8 years ago • 0 comments

  • DRF OpenAPI version: 1.0.0
  • Python version: 3.6.3
  • Operating System: OS X

Description

I have a model which has two relationship with two different models one is a ForeignKey and the other is a ManyToMany. The list view of this model shows only two depth levels, but I would like to see all depth levels or choose the level that I want passing depth=3 in class Meta

Current Behavior:

{
  "count": 0,
  "next": "string",
  "previous": "string",
  "results": [
    {
      "id": 0,
      "countries": [ ],
      "category": { },
      "title": "string",
      "description": "string"
    }
  ]
}

Expected behavior:

{
  "count": 0,
  "next": "string",
  "previous": "string",
  "results": [
    {
      "id": 0,
      "countries": [
        {
          "id": 0,
          "code": "string"
        }
      ],
      "category": {
        "id": 0,
        "name": "string"
      },
      "title": "string",
      "description": "string"
    }
  ]
}

Is there a way to do that? Or do you think it's may be a new feature?

fernandolins avatar Nov 16 '17 20:11 fernandolins