I am new to Swagger and open api. I am trying to create a model for an object (let us say "package" object).
For the POST method, I don't define an 'id' parameter, since I expect the back-end system to assign a new UUID for the package being created.
{
"name": "My Beautiful Package",
"channel": 0,
"status": 0,
"visibility": true
}
However, for the GET method, the response contains the id (UUID).
{
"id" : "afefeffbd-384fe3",
"name": "My Beautiful Package",
"channel": 0,
"status": 0,
"visibility": true,
"createdOn": "2018-Sep-08",
"createdBy"" 2234
}
So, my question is..,
Should I create two models, one for POST methods and one for GET method?
If I define the 'id' field as optional, it might still get shown in the api as one of the optional parameters. This I don't want.
Also, the response to GET package, returns more data such as "date of creation", "created by', etc. How to handle this?
Thanks to anyone clarifying this.