Skip to content

Commit

Permalink
minor formatting, using path params properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdevel committed Feb 4, 2016
1 parent ff25933 commit 6156c07
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function initialize(args) {

if (apiDocValidation.errors.length) {
console.error(loggingKey, 'Validating schema before populating paths');
console.error(loggingKey, 'validation errors', JSON.stringify(apiDocValidation.errors, null, ' '));
console.error(loggingKey, 'validation errors',
JSON.stringify(apiDocValidation.errors, null, ' '));
throw new Error(loggingKey + 'args.apiDoc was invalid. See the output.');
}
}
Expand Down Expand Up @@ -103,18 +104,17 @@ function initialize(args) {
pathParameters;

if (methodParameters.length) {
var apiParams = methodDoc.parameters;
var defaultsMiddleware;

// no point in default middleware if we don't have any parameters with defaults.
if (apiParams.filter(byDefault).length) {
defaultsMiddleware = buildDefaultsMiddleware({parameters: apiParams});
if (methodParameters.filter(byDefault).length) {
defaultsMiddleware = buildDefaultsMiddleware({parameters: methodParameters});
}

var coercionMiddleware = buildCoercionMiddleware({parameters: apiParams});
var coercionMiddleware = buildCoercionMiddleware({parameters: methodParameters});
var validationMiddleware = buildValidationMiddleware({
errorTransformer: errorTransformer,
parameters: apiParams,
parameters: methodParameters,
schemas: apiDoc.definitions
});

Expand All @@ -137,8 +137,10 @@ function initialize(args) {

if (apiDocValidation.errors.length) {
console.error(loggingKey, 'Validating schema after populating paths');
console.error(loggingKey, 'validation errors', JSON.stringify(apiDocValidation.errors, null, ' '));
throw new Error(loggingKey + 'args.apiDoc was invalid after populating paths. See the output.');
console.error(loggingKey, 'validation errors',
JSON.stringify(apiDocValidation.errors, null, ' '));
throw new Error(loggingKey +
'args.apiDoc was invalid after populating paths. See the output.');
}
}

Expand Down

0 comments on commit 6156c07

Please sign in to comment.