Hi all,
With all the talk of validator tooling and the need to test it, Greg and I talked about the possibility of having a “mock API” set up so that anyone doing anything that required and API to bounce things off of could do so.
Fast-forward a strong cup of tea and a few hours in a quiet morning yesterday, and we now have the HSDS Mock API available on Github:
It’s a tiny Python program which provides a HTTP API for you to test tooling against. It currently covers all the endpoints defined by the HSDS API Specification, and it’s straightforward to add more.
It works by taking JSON files in the data
directory of the application, and pushing them out over HTTP to provide a barebones API. It’s seeded with a few examples taken from the HSDS Specification repo now, but it’s straightforward to add your own data if you want – just drop JSON files into the appropriate directory!
You only need to add files for individual services, organizations, etc. The Mock API will handle wrapping these up into API Pages for e.g. when you request GET /services
.
You can run it locally on your computer, or host it on your servers to mimic a remote API.
There are two key limitations at this point in time, but these can be overcome with a moderate amount of effort based on community priorities:
- It doesn’t handle parameters. It’s pretty naïve, in that it just gives you everything it’s got in terms of data. This is mostly a limitation of time and it could be implemented, but we’d run up against the fact that the API has to read individual JSON files which would be very slow for some queries.
- It doesn’t come with much sample data. As noted, it comes with sample data taken from the HSDS Specification repo but I would like to add more. This is just a matter of effort to come up with a sample dataset that is internally coherent and broad enough to test validators, interfaces, and other tooling against.