Skip to content

Commit

Permalink
Merge pull request #155 from swisspush/develop
Browse files Browse the repository at this point in the history
Release 0.9.12
  • Loading branch information
lbovet authored Oct 28, 2020
2 parents 93a3c69 + 0da9cb1 commit d99e2bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
25 changes: 15 additions & 10 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])}))
Expand All @@ -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
Expand Down

0 comments on commit d99e2bf

Please sign in to comment.