swagger2 icon indicating copy to clipboard operation
swagger2 copied to clipboard

UpperCase header validation failes

Open mic-kor opened this issue 7 years ago • 1 comments

I'm having the following parameter specified in my Swagger spec:

name: X-Test-Version in: header type: string required: true default: 1 When I'm validating the request it returns: { "code": "SWAGGER_REQUEST_VALIDATION_FAILED", "errors": [ { "expected": { "type": "string" }, "where": "header" } ] } Printing out some statements in validate.ts gives me: for headers: {...... 'x-test-version': '1' ....} for headers[parameter.name]: X-Test-Version

Code of validate.ts: case 'header': value = (headers || {})[parameter.name]; break;

So it is trying to get the value via headers[X-Test-Version], which cannot be found, so value is undefined. The following would solve the issue: case 'header': value = (headers || {})[(parameter.name).toLowerCase()]; break;

mic-kor avatar May 16 '18 07:05 mic-kor

Would appreciate a PR with this change plus a unit test! Thanks.

carlansley avatar May 16 '18 20:05 carlansley