Skip to content

Commit

Permalink
Provides true path validation. (#17)
Browse files Browse the repository at this point in the history
* Use my forked version of swagger2

* Update to the new version of validateRequest

Providing the route params object from koa.

* Rebuild the dist

* Revert "Rebuild the dist"

This reverts commit 8bbb2c9.

* Updates to use new code in carlansley/swagger2#19

NOTE: We have also injected headers into the validate function, unsure why this wasn't done before.

* Revert "Use my forked version of swagger2"

This reverts commit 11b89d6.

Obviously tests will fail now but at least the PR only contains the required code changes.

* Updated to new version of swagger2
  • Loading branch information
brad-jones authored and carlansley committed Nov 28, 2017
1 parent ce4e714 commit 6cab079
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ export default function(document: swagger.Document): (context: any, next: () =>
}

// check the request matches the swagger schema
const validationErrors = swagger.validateRequest(compiledPath, context.method, context.request.query,
context.request.body);
const validationErrors = swagger.validateRequest(compiledPath, context.method,
context.request.query,
context.request.body,
context.request.headers,
context.params);

if (validationErrors === undefined) {
// operation not defined, return 405 (method not allowed)
Expand Down

0 comments on commit 6cab079

Please sign in to comment.