Hard-coded mock responses with Mockoon

285 views Asked by At

I'm trying to mock an API like this,

GET users/:userID

Then create hard-coded (not templated or faked) responses using data buckets. My data bucket looks like this.

[
  {
    "{{urlParam 'userId'}}": "10000",
    "firstname": "John",
    "lastname": "Doe",
    "friends": []
  },
  {
    "{{urlParam 'userId'}}": "10001",
    "firstname": "Archie",
    "lastname": "Bunker",
    "friends": []
  }
]

Mockoon always returns the entire data bucket contents. Is there any way for me to match the urlParam to an item in my data bucket?

2

There are 2 answers

1
Rubio On

Not currently supported but this feature is being developed.

https://github.com/mockoon/mockoon/issues/124

1
255kb - Mockoon On

Since v1.23.0 you can use CRUD endpoints which automatically create multiple routes to manipulate JSON in a data bucket:

  • GET /resources
  • GET /resources/:id
  • POST /resources
  • PUT /resources/:id

And so on.

It also supports filters, search and pagination through the use of query parameters like ?prop_eq=value&page=2.