Lines 24-29
const generateMockData = type => {
Link Here
|
24 |
return [faker.lorem.word(), faker.lorem.word()]; |
24 |
return [faker.lorem.word(), faker.lorem.word()]; |
25 |
case "number": |
25 |
case "number": |
26 |
return faker.number.float(); |
26 |
return faker.number.float(); |
|
|
27 |
case "date": |
28 |
return new Date().toISOString().split("T")[0]; |
29 |
case "date-time": |
30 |
return new Date().toISOString(); |
27 |
default: |
31 |
default: |
28 |
return faker.lorem.word(); |
32 |
return faker.lorem.word(); |
29 |
} |
33 |
} |
Lines 35-41
const generateDataFromSchema = (properties, values = {}) => {
Link Here
|
35 |
if (values.hasOwnProperty(key)) { |
39 |
if (values.hasOwnProperty(key)) { |
36 |
mockData[key] = values[key]; |
40 |
mockData[key] = values[key]; |
37 |
} else { |
41 |
} else { |
38 |
mockData[key] = generateMockData(value.type); |
42 |
let type = |
|
|
43 |
value?.format == "date" || value?.format == "date-time" |
44 |
? value.format |
45 |
: value.type; |
46 |
mockData[key] = generateMockData(type); |
39 |
} |
47 |
} |
40 |
}); |
48 |
}); |
41 |
return mockData; |
49 |
return mockData; |
42 |
- |
|
|