diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e2efbd5..cc6b847 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "apikana", - "version": "0.9.11", + "version": "0.9.12", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8247b00..badd3ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apikana", - "version": "0.9.11", + "version": "0.9.12", "description": "Integrated tools for REST API design - アピ", "main": "index.js", "bin": { diff --git a/src/generate.js b/src/generate.js index 6b9ebf0..39b7720 100644 --- a/src/generate.js +++ b/src/generate.js @@ -499,16 +499,7 @@ module.exports = { var type = fileToType[path.parse(value).base]; this.update('#/definitions/' + type); } - if(this.key === 'id' && this.parent.key === value) { - this.delete(this.key); - } }); - var out = path.resolve(dest, 'model/openapi'); - fse.mkdirsSync(out); - fs.writeFileSync(path.resolve(out, 'api.json'), JSON.stringify(restApi, null, 2)); - fs.writeFileSync(path.resolve(out, 'api.yaml'), yaml.stringify(restApi, 6, 2)); - fs.writeFileSync(path.resolve(out, 'complete-api.json'), JSON.stringify(completeApi, null, 2)); - fs.writeFileSync(path.resolve(out, 'complete-api.yaml'), yaml.stringify(completeApi, 6, 2)); var promises = modelNames .map(modelName => ({ modelName, schema: Object.assign({}, completeApi.definitions[modelName])})) @@ -526,7 +517,21 @@ module.exports = { return jsonSchemaAvro().convert(fullSchema).then(avroSchema => fs.writeFileSync(path.resolve(avroOutputDir, fileName + '.avsc'), JSON.stringify(avroSchema, 6, 2))); }); - return Promise.all(promises); + + return Promise.all(promises).then( () => { + traverse.forEach(completeApi, function (value) { + if(this.key === 'id' && this.parent.key === value) { + this.delete(this.key); + } + }); + + var out = path.resolve(dest, 'model/openapi'); + fse.mkdirsSync(out); + fs.writeFileSync(path.resolve(out, 'api.json'), JSON.stringify(restApi, null, 2)); + fs.writeFileSync(path.resolve(out, 'api.yaml'), yaml.stringify(restApi, 6, 2)); + fs.writeFileSync(path.resolve(out, 'complete-api.json'), JSON.stringify(completeApi, null, 2)); + fs.writeFileSync(path.resolve(out, 'complete-api.yaml'), yaml.stringify(completeApi, 6, 2)); + }); }); // Traverse the reference tree to keep only the needed definitions for the root schema