forked from kogosoftwarellc/open-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves kogosoftwarellc#875: adds response arg to openapi-response-v…
…alidator errorTransformer callback
- Loading branch information
Showing
3 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ges/openapi-response-validator/test/data-driven/use-errorTransformer-with-response-arg.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = { | ||
constructorArgs: { | ||
responses: { | ||
200: { | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
definitions: null, | ||
|
||
errorTransformer: function (openapiError, jsonschemaError, response) { | ||
return `Incorrect type "${typeof response.foo}" for "${openapiError.path}": ${openapiError.message}`; | ||
}, | ||
}, | ||
|
||
inputStatusCode: 200, | ||
inputResponseBody: { foo: 2345 }, | ||
|
||
expectedValidationError: { | ||
message: 'The response was not valid.', | ||
errors: ['Incorrect type "number" for "foo": must be string'], | ||
}, | ||
}; |