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

TypeError when trying to validate a "nullable": false property #227

Open
leNEKO opened this issue May 2, 2024 · 0 comments
Open

TypeError when trying to validate a "nullable": false property #227

leNEKO opened this issue May 2, 2024 · 0 comments

Comments

@leNEKO
Copy link

leNEKO commented May 2, 2024

Given a schema:

openapi: 3.0.0
info:
  title: test
  version: test
  description: test
  termsOfService: test
paths:
  /api/data:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - value
              properties:
                value:
                  nullable: false
                  oneOf:
                    - type: string
                    - type: boolean
      responses:
        '200':
          description: A response
          content:
            application/json:
              schema:
                type: string

Validating a POST /api/data request with a payload like this:

{
  "value": null
}

Give a TypeError error with the message in_array(): Argument #2 ($haystack) must be of type array, null given message from

return ! is_string($this->parentSchema->type) && in_array('null', $this->parentSchema->type);

Instead of a InvalidBody exception.

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