apibuilder-mock-generator
TypeScript icon, indicating that this package has built-in type declarations

0.0.13 • Public • Published

Build Status

apibuilder-mock-generator

A mock data generator based on API Builder specifications for JavaScript

Install

npm install apibuilder-mock-generator

Usage

The following example assumes the service.json file refers to the apibuilder specs, which can be downloaded using the apibuilder CLI with the following command:

apibuilder download apicollective apibuilder-spec latest service > service.json
import { createMockGenerator } from 'apibuilder-mock-generator';
import serviceJson from './service.json';

const generator = createMockGenerator(serviceJson);

generator.model('model');
// =>
// {
//   "name": "dolorum",
//   "plural": "nam",
//   "description": "eveniet",
//   "deprecation": {
//     "description": "id"
//   },
//   "fields": [
//     {
//       "name": "eaque",
//       "type": "ad",
//       "description": "consequuntur",
//       "deprecation": {
//         "description": "vel"
//       },
//       "default": "laboriosam",
//       "required": false,
//       "minimum": 38729,
//       "maximum": 49706,
//       "example": "numquam",
//       "attributes": [
//         {
//           "name": "totam",
//           "value": {},
//           "description": "dolores",
//           "deprecation": {
//             "description": "in"
//           }
//         }
//       ],
//       "annotations": [
//         "ducimus"
//       ]
//     }
//   ],
//   "attributes": [
//     {
//       "name": "voluptatum",
//       "value": {},
//       "description": "est",
//       "deprecation": {
//         "description": "non"
//       }
//     }
//   ]
// }

Check the API reference for more details on mock generators.

License

MIT

Package Sidebar

Install

npm i apibuilder-mock-generator

Weekly Downloads

40

Version

0.0.13

License

MIT

Unpacked Size

105 kB

Total Files

45

Last publish

Collaborators

  • roryh
  • ctumolosus