v13.9.3

Filename Convention

The convention is for mocks within your config.mocksDir. Files that don’t follow the convention are served as GET 200 or GET 206 (partial content, e.g., for videos).

Extension (three dots)

The last three dots are reserved for the: 1) HTTP Method, 2) Response Status Code, and 3) File Extension.

api/user.GET.200.json

You can 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

Dynamic Segments

Anything within square brackets are 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