I created a basic capapap C # application that returns JSON.
There will be several classes in my system, as an example I will use cars.
I have an abstract class called Car, which has many different types of cars that are inherited from Car. Examples are a truck, sedan, limo, bulldozer, ambulance, etc. All of them have some additional properties.
Everything in my application works as expected, but when I request / api / Cars / and return all the cars, I can get something like this:
{ "Id": 6290, "Make": "GM", "Model": "Yukon", "Seats": 7 }, { "Id": 6291, "Make": "Caterpillar", "Model": "D11T", "BucketWidth": 14.5 }, { "Id": 6292, "Make": "Braun", "Model": "Express", "Siren": "ACME" }
So, as a person consuming this, how do they know that the first element is an SUV, the second is a bulldozer, and the third is an ambulance?
Am I adding a property to a base class called "CarType" that they will use conditionally to map it to the class at the end?