Skip to content

Commit ea41f84

Browse files
Release new minor version (#218)
2 parents a1e1c4c + bca572e commit ea41f84

File tree

5 files changed

+13448
-1452
lines changed

5 files changed

+13448
-1452
lines changed

bin/apikana

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,27 @@ function generate() {
133133
var plop = nodePlop(__dirname + '/../src/plopfile_start.js', { defaults });
134134
var generator = plop.getGenerator('start');
135135
const model = Object.assign({}, packageJSON, { api: openapi });
136+
137+
// Workaround for validatorjs to fix wildcard on `paths`
138+
const paths = [];
139+
Object.values(model.api.paths).forEach(path => paths.push(path));
140+
model.api.paths = paths;
141+
142+
if (defaults.validation) {
143+
const Validator = require('validatorjs')
144+
const validator = new Validator(model.api, defaults.validation);
145+
if(!validator.check()) {
146+
log(colors.bold(colors.red('Validation of the OpenAPI definition has failed with ' + validator.errorCount + ' errors')));
147+
Object.entries(validator.errors.all()).forEach(errorEntry => {
148+
const [errorField, error] = errorEntry;
149+
log(colors.bold(colors.red(errorField + ": " + error)))
150+
});
151+
process.exit(1);
152+
}
153+
}
154+
136155
generator.runActions(model).then(_ => {
137-
require('../src/generate').generate(path.resolve(source), params.target());
156+
require('../src/generate').generate(defaults, path.resolve(source), params.target());
138157
});
139158
}
140159

0 commit comments

Comments
 (0)