Overview
The Vehicle Images API allows you to manage images associated with vehicles in the DriveX system. Each vehicle can have multiple images (up to 15), with one designated as the main/primary image.Model Structure
VehicleImage
TheVehicleImage entity represents an image associated with a vehicle.
Unique identifier for the vehicle image
The associated vehicle (ManyToOne relationship). This field is excluded from JSON responses to prevent circular references.
URL or path to the image file
Indicates whether this is the primary/main image for the vehicle
Relationship with Vehicle
Vehicle images use a ManyToOne relationship with theVehicle entity:
- Each
VehicleImagebelongs to exactly oneVehicle - Each
Vehiclecan have multipleVehicleImagerecords (OneToMany from Vehicle’s perspective) - Maximum of 15 images per vehicle
- The
vehiclefield in the response is excluded via@JsonIgnoreto prevent circular serialization issues
Endpoints
Upload Vehicle Image
The ID of the vehicle to add the image to
URL or path to the vehicle image
Set to
true to mark this as the primary image for the vehicleVehicleImage object.
ID of the newly created image record
The URL of the uploaded image
Whether this is the main image
- Maximum of 15 images per vehicle
- Vehicle must exist (returns error if not found)
List Vehicle Images
The ID of the vehicle whose images to retrieve
VehicleImage objects.
Error Handling
| Error | Description |
|---|---|
IllegalStateException | Thrown when attempting to add more than 15 images to a vehicle |
RuntimeException | Thrown when the specified vehicle ID does not exist |
Business Rules
- Image Limit: Each vehicle can have a maximum of 15 images
- Main Image: At least one image should typically be marked as
isMain: truefor display purposes - Vehicle Reference: Images must be associated with an existing vehicle
- Database Table: Images are stored in the
vehicle_imagestable