How to define common JSON wrapper for each response?

38 views
Skip to first unread message

Gaurav Kumar

unread,
May 24, 2016, 11:05:07 PM5/24/16
to Swagger
The API we are developing provides data in this format- 

{
 
"data": [
   
{
     
"key": "value"
   
},
   
{
     
"key2":"value2"
   
}
 
],
 
"errorList": []
}

i.e there is "data" JSON array and "errorList" JSON array in which the response is wrapped. Instead of defining "data" and "errorList' for each API response, is it possible to define it on a global level so that we don't end up with lots of boiler plate definitions? I understand that we can define a model and let other models extend this model but that doesn't help with response definition. I am yet to see an example which shows how to define a response wrapper. 

All suggestions are welcome. 

Thanks,
Gaurav 
Reply all
Reply to author
Forward
0 new messages