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

Request Validation does not ignore Header parameters with name Accept, Content-Type or Authorization #165

Open
thejamescollins opened this issue May 5, 2022 · 0 comments

Comments

@thejamescollins
Copy link

Thanks for this very useful package 😀

When validating a request using an OpenAPI specification that contains a Parameter definition for a header parameter named Authorization, the following errors occurs:

League\OpenAPIValidation\PSR7\Exception\Validation\InvalidHeaders: Value "Basic dXNlcm5hbWU6cGFzc3dvcmQ=" for header "Authorization" is invalid for Request [get /users]

vendor/league/openapi-psr7-validator/src/PSR7/Exception/Validation/AddressValidationFailed.php:28
vendor/league/openapi-psr7-validator/src/PSR7/Exception/Validation/InvalidHeaders.php:35
vendor/league/openapi-psr7-validator/src/PSR7/Validators/HeadersValidator.php:46
vendor/league/openapi-psr7-validator/src/PSR7/Validators/ValidatorChain.php:25
vendor/league/openapi-psr7-validator/src/PSR7/RequestValidator.php:79
tests/AssertValidateTrait.php:35
tests/Unit/Handlers/UsersTest.php:68

This Authorization parameter should be ignored by the validator, according to https://swagger.io/specification/#parameter-object

If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.

I believe all Header parameters named Accept, Content-Type or Authorization should be ignored entirely in the validator.

Steps to replicate

Minimal OpenAPI specification:

openapi: 3.0.0
info:
  title: Test API
  version: "1"
paths:
  /users:
    get:
      description: Get users
      parameters:
      - name: Authorization
        in: header
        schema:
          type: string
          format: uuid
      responses:
        default:
          description: response description
      security:
        - basicAuth: []
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
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

No branches or pull requests

1 participant