HollyPony / JSONMockGenerator

Mock generator Client Side Configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON Mock Generator

Simple mock endpoint with autogenerated / configurable return values.

This project aims to fake your reals endpoints instead of waiting another unfinish backend dev.

The idea is to configure the return values in body request. Watether the type and the route.

The API doesn't matter the HTTP method used and the nested route called.

Online endpoint available at jmgen.herokuapp.com/

Powered by Node-restify and ChanceJS

Features

  • The API doesn't matter the HTTP method used and the nested route called : GET === PUT
  • Create random object with or without parameters
  • Use a full mapped ChanceJS lib

Installation

  • Clone project locally
  • Do npm install with version of node installed > 13
  • Run in debug with npm run serve or start a server with npm start

API Doc

You can go to whatever the route you want. So, / will get the same result as /test or /test/deeped.with.extension.

The important data will be queryUrl params and body datas (for POST).

Important note about the merging between query url and body, body will be arbitrary prior (technicaly Object.assign(query, body)). Feel free to submit a request or a PR if you have relevant arguments.

Most of features are shown as sample. For further documentation refer to ChanceJS.

For list use _length=[listsize]

For object use {property: value}. Value can be a ChanceJs function like name. So {login: 'name'} result to a {login: 'randomName'}

Examples

Get a random object

Input (random object)

{}

Output (random object)

{
  "id": 2263426013331456
}

Demo (random object)

Get a list

Input (list)

{
  "_length": 3
}

Output (list)

[
  { "id": 4669038997274624 },
  { "id": 2258162581241856 },
  { "id": 3514527639404544 }
]

Demo (list)

Get an object

Input (object)

{
  "name": "name",
  "birthday": "birthday",
  "city": "city",
  "genre": "male"
}

Output (object)

{
  "name": "Nell Pittman",
  "date": "1972-12-25T15:53:38.118Z",
  "cite": "Seecivoc",
  "genre": "male"
}

Demo (object)

Get an object list

Input (object list)

{
  "_length": 3,
  "name": "name",
  "birthday": "birthday",
  "city": "city",
  "genre": "male"
}

Output (object list)

[
  {
    "name": "Alberta Ruiz",
    "date": "1982-02-27T23:42:45.881Z",
    "city": "Bizhugge",
    "genre": "male"
  },
  {
    "name": "Sean Dennis",
    "date": "1953-07-16T23:43:14.530Z",
    "city": "Lufrirno",
    "genre": "male"
  },
  {
    "name": "Nancy Stevenson",
    "date": "1976-09-01T10:47:20.845Z",
    "city": "Takufe",
    "genre": "male"
  }
]

Demo (object list)

Roadmap

  • Create list with eight in a range
  • Add Sample element (Get User ...)
  • Pas url for keywords (with elements and verbs like "list")
  • Insert a config file on startup (json-server like)

About

Mock generator Client Side Configuration

License:MIT License


Languages

Language:JavaScript 100.0%