I am new to using json-server and json-schema-faker. I can get it to generate records but when I post to the endpoint, the only thing that it posts to the database is an object with id, why doesn't it have the other fields (i.e name, pro1, pro2 etc). Can anyone help?
Below is my schema:
export const schema = {
"type": "object",
"properties": {
"tests": {
"type": "array",
"minItems": 1,
"maxItems": 6,
"items": {
"type": "object",
"properties": {
"id": {
"type": "number",
"unique": true,
"minimum": 1
},
"name": {
"type": "string"
},
"pro1": {
"type": "integer",
"minimum": 0,
"maximum": 100
},
"pro2": {
"format": "date-time",
"type": "string"
},
"pro3": {
"type": "boolean"
},
"pro4": {
"type": "integer",
"minimum": 1,
"maximum": 10
},
"pro5": {
"type": "integer",
"minimum": 1,
"maximum": 10
}
},
"required": ["id", "name", "pro1", "pro2", "pro3", "pro4", "pro5"]
}
}
},
"required": ["tests"]
};
And my generate file:
import jsf from 'json-schema-faker';
import {schema} from './mockDataSchema';
import fs from 'fs';
import chalk from 'chalk';
const json = JSON.stringify(jsf(schema));
fs.writeFile("./src/api/db.json", json, function(err){
if (err){
return console.log(chalk.red(err));
}else{
return console.log(chalk.green("Mock Data Generated"));
}
});