'Inheritance in REST with specific query parameter of child classes
I have tried replicating simple use-case that I am trying to achieve.
- Here we have vehicles and vehicles can be two-wheeler or four-wheeler or any other subtype in future.
- We may have many cars or bike in garage at any given point in time.
- I want to expose REST API which gives the status of vehicles in Garage irrespective of vehicle type (all vehicle should be returned)
- This is single common API. Only single rest API gives this status in response (may be using Json Inheritance).
Problem: This single rest service will may have query parameters which would be specific to child classes:
http://hostname/vehicle?name=demovehicle&steeringwheel=tilt
http://hostname/vehicle?name=demovehicle&steeringwheel=tilt&steeringhandle=iron
I am trying to understand how this can be implemented since we have single service and query parameters will not be present in all tables since it is not common across all child tables.
One thought I had to maintain query parameter and type of vehicle catalog in backend to figure out what query parameter belong to which vehicle type.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

