diff --git a/app/actions.ts b/app/actions.ts index 3be4180..b07c289 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -185,7 +185,7 @@ export const save = () => { } } if (state.main.dataStale) { - promises.push(axios.post('data.json', getState().main.tree.data)); + promises.push(axios.post('/data.json', getState().main.tree.data)); if (!state.main.schemaStale) { beforeMessage = 'Saving data file'; afterMessage = 'Data file saved on disk'; diff --git a/app/cms.ts b/app/cms.ts index 2393256..9c75851 100644 --- a/app/cms.ts +++ b/app/cms.ts @@ -500,7 +500,7 @@ export const modelToSchema = (model): RootSchemaElement => { return Object.assign({} as RootSchemaElement, { $schema: schemaVersion }, root); }; export const _modelToSchema = (model: Model): SchemaElement => { - const element: SchemaElement = {type: Type.TObject, properties: {}, patternProperties: {} }; + const element: SchemaElement = {type: Type.TObject, properties: {} }; element.title = model.name; if (model.type === NodeType.TYPE_TREE) { const treeModel: TreeModel = model as TreeModel; diff --git a/index.js b/index.js index 95a351e..db755aa 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,14 @@ module.exports.run = function(options) { res.send("OK"); }); }); + app.post('/schema.json', function (req, res) { + var json = req.body; + fs.writeFile(modelFile, JSON.stringify(json, undefined, 2), function (err) { + if (err) console.log(err); + console.log("File " + modelFile + " saved"); + res.send("OK"); + }); + }); } if (isDeveloping) {