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

Missing Response Header Validation checks except for 'Content-Type' #201

Closed
Ventrosky opened this issue Apr 7, 2020 · 6 comments · Fixed by #650
Closed

Missing Response Header Validation checks except for 'Content-Type' #201

Ventrosky opened this issue Apr 7, 2020 · 6 comments · Fixed by #650

Comments

@Ventrosky
Copy link
Contributor

Ventrosky commented Apr 7, 2020

openapi3filter.ValidateResponse checks only the"Content-Type"header, not performing controls on other header specified in the schema

For example:

info:
  version: 1.0.0
  title: Test schema
paths:
  /:
    get:
      responses:
        '200':
          description: A json response
          headers:
            x-version:
              schema:
                type: string
          content:
            application/json:    
              schema:
                type: object
                additionalProperties: false
                properties:
                  id:
                    type: integer
                  name:
                    type: string
                required:
                  - id

Should we consider not valid a response missing the "X-Version" header? At the moment is considered valid.

@Ventrosky Ventrosky changed the title Response Header Validation checks only for 'Content-Type' Missing Response Header Validation checks except for 'Content-Type' Apr 7, 2020
@fenollp
Copy link
Collaborator

fenollp commented Apr 7, 2020

Are you not missing the required field?

          headers:
            x-version:
              required: true
              schema:
                type: string

@Ventrosky
Copy link
Contributor Author

Thanks you are right, but fixing the schema I still get a valid response even if the header specified is missing

@fenollp
Copy link
Collaborator

fenollp commented Apr 7, 2020

Indeed AFAICT validation response and request headers against a spec isn't implemented. Care to try?

@Ventrosky
Copy link
Contributor Author

At the moment this feature is not essential, maybe later I could give it a try :)

@mariaefi29
Copy link

I have stumbled upon this library! So far it seems exactly what I need. Thank you!

I need to validate Content-encoding: gzip header in the response, it is required in my spec. Everything is passed, however, the header is not present in the response.

Has something changed since April 2020 or waiting for volunteers to implement it?)

@fenollp
Copy link
Collaborator

fenollp commented Feb 23, 2022

Hi @mariaefi29! I'd be happy to review your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants