Getting Started
Installation
- Pick a plan on GitHub Marketplace.
- If that's not already the case, install Mockend GitHub App on your repository (choose "select repositories").
- Create a
.mockend.json
config file to describe your API.
note
Mockend can be installed in repositories owned by users or organizations. In the examples below, we're assuming it's installed on https://github.com/org/repo
.
Config
For a quick start, create a new .mockend.json
at the root of your repository:
{
"Post": {
"title": { "string": {} },
"comments": {
"hasMany": "Comment"
}
},
"Comment": {
"body": { "string": {} },
"post": {
"belongsTo": "Post"
}
}
}
info
Many types (string
, int
, boolean
, dateTime
, regexp
, lorem*
) and custom data are supported, see configuration for a complete list of options.
You can visit https://mockend.com/org/repo/posts
or https://mockend.com/org/repo/graphql
to confirm that everything's working.
REST
Based on the previous config, the following API will be automatically created:
GET https://mockend.com/org/repo/posts
GET https://mockend.com/org/repo/posts/<id>
GET https://mockend.com/org/repo/comments
GET https://mockend.com/org/repo/comments/<id>
Query parameters can be used to filter, sort and paginate lists:
<field>_eq
<field>_ne
equal, not equal<field>_gt
,<field>_gte
,<field>_lt
,<field>_lte
greater than or equal, lower than or equal<field>_contains
,<field>_startsWith
,<field>_endsWith
search string<field>_order=asc|desc
sort datalimit
offset
paginate results
For example, to get posts with title containing word marvel
and ordered by creation date:
GET /posts?title_contains=marvel&createdAt_order=desc
Or the top five most viewed posts:
GET /posts?limit=5&views_order=desc
Or published posts with less than 100 views:
GET /posts?published_eq=true&views_lt=100
POST
, PUT
, PATCH
and DELETE
requests are mocked and changes aren't saved. You can therefore develop forms and make requests without polluting your initial dataset.
POST https://mockend.com/org/repo/posts
PUT https://mockend.com/org/repo/posts/<id>
PATCH https://mockend.com/org/repo/posts/<id>
DELETE https://mockend.com/org/repo/posts/<id>
GraphQL
Documentation for GraphQL is automatically generated and a GraphiQL interface is available at:
https://mockend.com/org/repo/graphql
Data can be queried, filtered and sorted just like with REST.
Working in teams
Mockend supports feature branches. Team members can collaborate, try and discuss changes on .mockend.json
using GitHub's pull requests. Multiple dedicated mock APIs can be created.
To access a feature branch, add ...tree/<branch_name>/...
to Mockend API URL.
For example:
https://mockend.com/org/repo/tree/feat-1234/posts/1
https://mockend.com/org/repo/tree/feat-1234/graphql
Questions
If you have a question or feedback, feel free to contact us :)