Skip to content

Conversation

JurianArie
Copy link

@JurianArie JurianArie commented Mar 15, 2024

The validator throws an exception with the following (API enforces that only one of the fields is filled):

Data passed:

[
    'department_id' => null,
    'team_id' => 1,
]

Schema:

- oneOf:
    - type: object
      properties:
        department_id:
          type: integer
        team_id:
          type: 'null'
      required:
        - department_id
    - type: object
      properties:
        department_id:
          type: 'null'
        team_id:
          type: integer
      required:
        - team_id

With the proposed change the validator would not throw an exception any more.

@leNEKO
Copy link

leNEKO commented May 2, 2024

Hi, it seems that there is not a such null type in the openapi specification (see https://swagger.io/docs/specification/data-models/data-types/#null).

@JurianArie
Copy link
Author

@leNEKO openapi 3.1 does have a "null" type: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0 under the section "Swap nullable for type arrays"

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 this pull request may close these issues.

2 participants