Request Referencing

Request Referencing with Mockadillo is straightforward. You can reference multiple properties of the Request simply by adding a function to your response.

Mockadillo is empowered by our data generator engine which enables you to reference multiple aspects of the request data that is sent to Mockadillo.

For all functions the largest value you can reference is 100 characters.

Named path variable referencing

This means that for named variables found in path /url/:namedVariableOne/rest/:namedVariableTwo you can reference the namedVariableOne and namedVariableTwo path parameters. To do this you need to use the $$path(pathVariableName)$$ function.

For example:

With the following route path definition

GET /route/:namedVariableOne

With the following response body definition

{
  "Value": "$$path(namedVariableOne)$$"
}

And the following request path

GET /route/someVariableValue

Would yield the response

{
  "Value": "someVariableValue"
}

JSON request body referencing

When you want to access a JSON property from the request body you can use $$jsonBody(path)$$ function. It will resolve to the value found in the request body according to the path parameter using JSONPath syntax with $. implied.

For example:

With the following response body definition

{
  "Value": "$$jsonBody(parent.field.nested)$$"
}

And the following request body

{
  "parent": {
    "field": {
      "nested": "The value we're looking for"
    }
  }
}

Would yield the response

{
  "Value": "The value we're looking for"
}

Header referencing

When you want to access a Header from the request you can use $$header(headerName)$$ function. It will resolve to the value found in the Header if found.

For example:

With the following response body definition

{
  "Value": "$$header(content-type)$$"
}

And the following request header

content-type=application/json

Would yield the response

{
  "Value": "application/json"
}

In case of multiple values found in the request the returned value will be a comma seperated string.

Query parameter referencing

When you want to access a Query parameter from the request URL you can use $$query(queryParameterName)$$ function. It will resolve to the value found in the URL if found.

For example:

With the following response body definition

{
  "Value": "$$query(userID)$$"
}

And the following request path

GET /route/path/users?userID=uuid-is-totally-awesome

Would yield the response

{
  "Value": "uuid-is-totally-awesome"
}

In case of multiple values found in the request the returned value will be a comma seperated string.