Cannot get error when getting specific resource and resource doesn't exist


#1

I have the following code:

   /bookings: 
/{BookingID}:
get:
  description: Retrieve a booking
  responses:
    200:
      headers:
        Access-Control-Allow-Origin:
          example: |
            *
      body:
        application/json:
         example: |
            {
              "data": 
                  {
                  "BookingID": 1,
                  "Driver": "John Doe",
                  "VehicleID": 1,
                  "Registration": "CHH708",
                  "Fleet": "DN30",
                  "Destination": "Akaroa",
                  "Notes": "Going to ...",
                  "StartTimezone": null,
                  "Start": "2014/11/20 08:00",
                  "End": "2014/11/20 11:00",
                  "EndTimezone": null,
                  "RecurrenceRule": null,
                  "RecurrenceID": null,
                  "RecurrenceException": null,
                  "Pickup": false
                  },
              "success": true,
              "status": 200
            }

And when I get bookings/1 it returns the right entry but if I try bookings/2 or any id, it also returns that entry, how do I get it to return 404 no such resource ?


#2

Are you using the mocking service?


#3

Yes Christian I am.


#4

Currently, the mocking service takes your examples to provide you with a response when requesting a specific resource. As of today, you’re not able to get responses back based on different error codes for example if you ask for a resource which is not present. It will always provide you with the example. To have such “logic” means more intelligence from the mocking service which has to be implemented. I don’t know if that is somewhere on the Roadmap.

To provide this, you have to provide your own logic unfortunately. If you use Java you can easily create JAX-RS stub and create your own mocking in just sec.

Does that answer your question?