I'm making APIs documentation by swagger In my swagger editor, I'm returning this response
{
"id": "70020ed1-50fe-4c7e-afed",
"email": "test123@gmail.com",
"authentication_token": "xzmsjvvkvgf448449"
}
by the code below from swagger editor
responses:
200:
description: User credentials.
schema:
# $ref: '#/definitions/User'
properties:
id:
type: string
example: 70020ed1-50fe-4c7e-afed
email:
type: string
example: test123@gmail.com
authentication_token:
type: string
example: xzmsjvvkvgf448449
I want to show it in a way as I'm getting it in an actual way. like this
{
"message": "User Information & already exist",
"user": {
"id": "2386d9c5-5530-4950-b8fe-",
"email": "saad.arshad@yahoo.com",
"authentication_token": "kagHmoRSmPiu2R"}}
probably in a user object.
You would need to nest your user
in an object:
responses:
200:
description: User credentials.
content:
application/json:
schema:
properties:
message:
type: string
example: "User Information already exists"
user:
type: object
properties:
id:
type: string
example: 70020ed1-50fe-4c7e-afed
email:
type: string
example: test123@gmail.com
authentication_token:
type: string
example: xzmsjvvkvgf448449
See https://swagger.io/docs/specification/data-models/data-types/#nested for more information, as well as a note on how to use references.