Hilzu / express-openapi-validate

Express middleware to validate requests based on an OpenAPI 3 document
Apache License 2.0
75 stars 12 forks source link

Fix: Express headers are always lowercase #36

Closed bemisguided closed 5 years ago

bemisguided commented 5 years ago

The Open API spec says that the parameters name property is case sensitive (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject), however, Express does not treat headers as case-sensitive and instead always shifts them to lowercase when adding them to the req.headers hash object.

This means that defining a header with uppercase characters (which is how people generally define headers) will cause the request validation to fail. This PR request proposes that request headers be treated case-insensitive.

Hilzu commented 5 years ago

Just came back from holiday and will look at this PR this week. Before that can you rebase this on master? The travis build and coveralls should be working now and you should be able to see the results when pushing changes.

bemisguided commented 5 years ago

Sure, no problem. I've rebased. Let's see the CI magic do it's thing.

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 70f033f116e9de74565f2a55df136e152a4fa699 on bemisguided:fix/express-headers-case-insensitive into a4e4fec1b33f5ac828eb809c827e4f421a75481e on Hilzu:master.

bemisguided commented 5 years ago

That should do it.