Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot assert on actual headers: Rack mutates header key #262

Open
adsteel opened this issue May 4, 2020 · 1 comment
Open

Cannot assert on actual headers: Rack mutates header key #262

adsteel opened this issue May 4, 2020 · 1 comment
Labels

Comments

@adsteel
Copy link

adsteel commented May 4, 2020

Given an OpenApi3 swagger yaml definition for a header:

x-Role: &Role
  in: "header"
  name: "Role"
  required: true
  schema:
    type: "string"
    enum: ["A", "B"]

And given a valid request:

curl ... -H "Role: A"

Committee, when raising an error, raises the following error for this request:

Committee::InvalidRequest:
       #/paths/... missing required parameters: Role

This is because Rack mutates all http headers, and Role becomes HTTP_ROLE.

This would seem unrelated to this gem, except that it is designed as Rack middleware, so it seems odd that it wouldn't work with rack conventions.

I'm not too familiar with the gem yet, but a first idea for a solution might be to cast all swagger-defined headers into HTTP_x formats before passing to validation.

@ota42y
Copy link
Member

ota42y commented May 9, 2020

https://www.rubydoc.info/github/rack/rack/file/SPEC

HTTP_ Variables
Variables corresponding to the client-supplied HTTP request headers (i.e., variables whose names begin with HTTP_). The presence or absence of these variables should correspond with the presence or absence of the appropriate HTTP header in the request. See RFC3875 section 4.1.18 for specific behavior.

OK we need remove HTTP_ prefix before validating header.

@ota42y ota42y added the bug label May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants