-
Notifications
You must be signed in to change notification settings - Fork 2
/
node_usage_esm.js
57 lines (52 loc) · 1.35 KB
/
node_usage_esm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//import { ODataMockGenerator } from "omg-odata-mock-generator" in your code after npm install
import { ODataMockGenerator } from "../dist/esm/bundle.js";
import fs from "fs";
function getMetadata() {
// using metadata from https://services.odata.org/V3/OData/OData.svc/$metadata
return fs.readFileSync("./samples/metadata.xml", "utf-8");
}
function run() {
const metadata = getMetadata();
const options = {
defaultLengthOfEntitySets: 3,
mockDataRootURI: "my/path",
rules: {
skipMockGeneration: ["Persons", "Suppliers"],
variables: {
categoryIds: [1, 2, 3],
},
faker: {
Product: {
Name: "commerce.productName",
},
},
distinctValues: ["Categories"],
predefined: {
Category: {
ID: "$ref:categoryIds",
Name: {
reference: "ID",
values: [
{
key: 1,
value: "Category1",
},
{
key: 2,
value: "Category2",
},
{
key: 3,
value: "Category3",
},
],
},
},
},
},
};
const generator = new ODataMockGenerator(metadata, options);
const mockData = generator.createMockData();
console.log(JSON.stringify(mockData));
}
run();