Mock Filename Convention

Extension

The last three dots are reserved for the HTTP Method, Response Status Code, and File Extension.

api/user.GET.200.json

You can also use .empty or .unknown if you don’t want a Content-Type header in the response.

Supported Methods

ACL, BIND, CHECKOUT, CONNECT, COPY, DELETE, GET, HEAD, LINK, LOCK, M-SEARCH, MERGE, MKACTIVITY, MKCALENDAR, MKCOL, MOVE, NOTIFY, OPTIONS, PATCH, POST, PROPFIND, PROPPATCH, PURGE, PUT, QUERY, REBIND, REPORT, SEARCH, SOURCE, SUBSCRIBE, TRACE, UNBIND, UNLINK, UNLOCK, UNSUBSCRIBE

Splats

Anything within square brackets is always matched.

For example, for /api/company/123/user/789, the filename could be:

api/company/[id]/user/[uid].GET.200.json

Comments

Comments are anything within parentheses, including them. They are ignored for routing purposes, so they have no effect on the URL mask. For example, these two are for /api/foo

api/foo(my comment).GET.200.json
api/foo.GET.200.json

A filename can have many comments.

Default Mock for a Route

You can add the comment: (default). Otherwise, the first file in alphabetical order wins.

api/user(default).GET.200.json

Query String Params

The query string is ignored for routing purposes. It’s only used for documenting the URL contract.

api/video?limit=[limit].GET.200.json

On Windows, filenames containing "?" are not permitted, but since that’s part of the query string, it’s ignored anyway.

Index-like Routes

If you have api/foo and api/foo/bar, you have two options:

Option A. Standard naming:

api/foo.GET.200.json
api/foo/bar.GET.200.json

Option B. Omit the URL on the filename:

api/foo/.GET.200.json
api/foo/bar.GET.200.json