kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

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

Open Ventrosky opened this issue 5 years ago • 6 comments

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 avatar Apr 07 '20 05:04 Ventrosky

Are you not missing the required field?

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

fenollp avatar Apr 07 '20 10:04 fenollp

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

Ventrosky avatar Apr 07 '20 11:04 Ventrosky

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

fenollp avatar Apr 07 '20 16:04 fenollp

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

Ventrosky avatar Apr 08 '20 12:04 Ventrosky

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?)

mariaefi29 avatar Jan 13 '22 06:01 mariaefi29

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

fenollp avatar Feb 23 '22 09:02 fenollp