I am currently using following libraries of django -
Django==2.2.4
django-pdb==0.6.2
django-rest-swagger==2.2.0
django-service-objects==0.5.0
django-timezone-field==3.0
django-windows-tools==0.2.1
djangorestframework==3.10.2
djongo==1.2.33
It is running on Python version 3.7.4
The problem that I am facing is I can able to generate body part of API using corapi.Field in Autoschema.
class SwaggerSchemaView(APIView):
permission_classes = [AllowAny]
renderer_classes = [
renderers.OpenAPIRenderer,
renderers.SwaggerUIRenderer
]
def get(self, request):
generator = SchemaGenerator()
schema = generator.get_schema(request=request)
return Response(schema)
class ParseResume(APIView):
permission_classes = [AllowAny]
schema = AutoSchema(
manual_fields=[
coreapi.Field(
"data",
required=True,
location="body",
description='Send Json Data',
type="string",
schema=coreschema.Object(),
)
]
)
def post(self, request):
data = request.data
response_data = SetConnections.parse_resume(data)
return Response(response_data)
Now, I can able to generate Swagger view like as follows -
But I want to add a sample data inside this body part through coreapi.Field like as follows -
{
"id": "56-df-pt",
"fname": "John",
"lname": "Doe",
"experience": {
"employee": "Company X",
"period": "1996 - 2002",
"engaged_in": [
{
"work": "Jr. Manager",
"team_size": 5,
"time": "Sep. 1996 - Dec. 1998"
},
{
"work": "Sr. Manager",
"team_size": 5,
"time": "Jan. 1999 - Dec. 2002"
},
]
}
How can I add that? I can't change any version of Django or Python at this moment now.


After long days of being looking for a solution about how to display the nested objects on swagger, I find out that the following python package:
django-rest-swaggerDoes not display nested objects if the serializer contains nested fields ( relations ), how did I find out about it?, checking in the rest-framework website about schema generator :
https://www.django-rest-framework.org/coreapi/schemas/#third-party-packages
There is a line that mention another package called :
drf-yasghttps://drf-yasg.readthedocs.io/en/stable/index.html
This package has improved features such as : nested schemas, named models, response bodies, enum/pattern/min/max validators, form parameters, etc. In that way I decided to install the package with the following steps :
Once the package is been installed you have to add the module on the modules list in settings.py and some additional configuration that I considered appropiate:
then proceed to go to my urls.py and add the following lines to generate the schema view :
I really hope the information provided would be helpful for somebody.
Greetings,