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

Allow null as standalone type #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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