Why You Should Always Specify IDs in Stubs β
Explicitly defining UUID-based IDs in your stub configurations unlocks powerful capabilities in GripMock, from precise stub management to seamless developer workflows. Here's why IDs are essential:
1. Universal Identification π β
Every stub MUST have a UUIDv4 identifier:
yaml
- id: 7f746310-a470-43dc-9eeb-355dff50d2a9 # β
Valid UUIDv4
service: BookingService
method: GetBooking
input:
equals:
bookingId: "booking_123"
output:
data:
bookingTime:
startTime: "2024-01-01T00:00:00Z"
endTime: "2024-01-01T23:59:59Z"- β Don't use custom strings like
my_stub_123 - β
Generate with
uuidgenor online tools
2. Admin Panel Efficiency π β
Instantly locate stubs in the web UI:
bash
# Open in your browser
http://localhost:4771/#/stubs/7f746310-a470-43dc-9eeb-355dff50d2a9/showWARNING
Search by ID in the admin panel is not available yet; use the direct URL for now.
3. Dead Stub Detection π§Ή β
Clean up abandoned stubs via API:
bash
# Find unused stubs
curl http://localhost:4771/api/stubs/unused
# Delete if unused
curl -X DELETE http://localhost:4771/api/stubs/7f746310-a470-43dc-9eeb-355dff50d2a94. Live Reloading Magic π β
WARNING
Warning! If you do not specify IDs in your stubs, IDs may change when the file is updated.
Enable automatic updates without restarting GripMock:
bash
# .env configuration
STUB_WATCHER_ENABLED=true # Default value: true
STUB_WATCHER_INTERVAL=5000ms # Default value: 1s.
STUB_WATCHER_TYPE=fsnotify # Filesystem events. Default value: fsnotify. Other options: timer.- Edit
stubs/feature_x.yamlin your IDE - GripMock auto-updates only modified stubs
- No API calls or restarts needed
INFO
In timer mode, GripMock does not reload all stubs every N seconds. It reloads only files with updated modification times.
5. Collision Prevention β οΈ β
Unique IDs prevent conflicts in multi-team environments:
yaml
# Team A's stub
- id: 6e8b4c2a-3d8f-4a1b-8c9d-0e7f2a9b8c7d
service: Payments
method: Process
# Team B's stub
- id: 9f1a2b3c-4d5e-6f7a-8b9c-0d1e2f3a4b5c
service: Payments
method: RefundKey Implementation Rules π β
- π UUIDv4 required (no custom formats)
- π Auto-reloading requires both:
idfield in YAML/JSONSTUB_WATCHER_ENABLED=true
- π« Never reuse IDs across environments