Swagger: Select model fields in API response

Viewed 138

I have a swagger USER object with few fields, e.g.: id name address

I would like to use the same model for two operations: 1. POST - the client will send a list of users without their ids. e.g.:

[{
   "name": "name1",
   "address": "some address1"
 }, 
 { 
   "name": "name2",
   "address": "some address2"
 }]
  1. GET - the get request will return only the user Ids:

[ { "id": 1 }, { "id": 2 } ]

Is there a way to reuse the same "USER" model for both operations? i.e. to make some kind of fields selection? Or should I create a separate schema for each one of them, one schema for the IDs (GET) and another for the POST?

0 Answers
Related