> For the complete documentation index, see [llms.txt](https://builtwithluv.gitbook.io/mockit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://builtwithluv.gitbook.io/mockit/fixture.md).

# Fixture

## Properties

\*required

| key                                                                       | description                                                                                                               | default                              |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| description                                                               | Information about this fixture. This gets display on the client for you to easily decide on which contract to choose from | "No description added"               |
| url\*                                                                     | API endpoint                                                                                                              |                                      |
| statusCode                                                                | Response code                                                                                                             | 200                                  |
| id                                                                        | Unique id of the fixture                                                                                                  | uuidv4                               |
| default                                                                   | If contracts have the same method and url, then use the one with the default value of `true`                              | false                                |
| method                                                                    | HTTP method                                                                                                               | GET                                  |
| data                                                                      | Data to send                                                                                                              |                                      |
| handler(req,res)                                                          | Custom response handler                                                                                                   |                                      |
| headers                                                                   | Response headers                                                                                                          | {'Content-Type': 'application/json'} |
| <p>validator: {</p><p>  url: string;</p><p>  headers: Headers</p><p>}</p> | Endpoint to test against                                                                                                  |                                      |

### Example fixture

{% code title="fixture.js" %}

```javascript
module.exports = {
  default: true,
  description: "Testing service api",
  method: 'GET',
  url: '/api/test',
  statusCode: 200,
  headers: {
    'Content-Type': 'text/plain'
  },
  data: 'Hello World!',
  handler: (req, res) => {
    // Use handlers to do very fine grained responses
    const data = req.body;
    res.json({ message: 'Overrides data specified above.' );
  },
  validator: {
    url: 'http://realwebserver.com/api',
    headers: {
      'Authorization': '*****',
    }
  }
};
```

{% endcode %}
