I have a REST API uploadFeed that uploads the user feed based on feedType (string value taken input as part of the request body) . Different feedtype provides a different pojo model in the request body altogether.
For e.g If the feedType is lets say "TYPE1", then the API's request-body should look like the following:
{
"feedType":"TYPE1",
"inputModel": {
"a": "somevalue"
"b" : "somevalue",
"c" : "somevalue",
}
}
if the feedType is lets say "TYPE2", then the API's request-body should look like the following:
{
"feedType":"TYPE2",
"inputModel": {
"x": "somevalue"
"y" : "somevalue",
"z" : "somevalue",
}
}
Now I want to avoid providing different REST API endpoints for the two feedTypes. I am thinking of rather providing a serialised object of the inputModel as input and then deserialise at the backend based on the feedType. For .e.g
{
"feedType":"TYPE2",
"inputModel": "<<serialized object>>"
}
Is this a good REST API design or is there any better alternative.