I am looking for best practices in RESTful API design for the following use:
Domain object object:
class Vehicle { private String vehicleType; private String colour; private String transmission; private String yearOfIssue; }
Example object:
Vehicle = {vehicleType : 'Car', colour : 'Red', transmission : 'Automatic', yearOfIssue : '2008'};
In this domain model, there is no single unique field identifier (for example, vehicleId), but all the fields of the object together form the primary key (this restriction is present in the database layer).
We do not have the flexibility to change this domain model to add a unique unique field identifier.
So my question is this: if I want to add a simple REST API on top of this domain object that provides simple functionality for CREATE, UPDATE, DELETE and GET Vehicles, then what is best for PATH endpoints for these methods?
Following the example above, if the domain model must have a unique vehicle identifier with a field identifier, then I can imagine the following endpoints:
GET /vehicles/:vehicleId PUT /vehicles/:vehicleId DELETE /vehicles/:vehicleId
I am not aware of a pattern that is similar to this for compound keys:
GET /vehicles/:vehicleTypecolourtransmissionyearOfIssue GET /vehicles/CarRedAutomatic2008
seems wrong.
Any advice on a good template for this use case is welcome.
thanks
design rest api
Joshdavies
source share