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

Validating required fields when using allOf #113

Open
nussbam opened this issue Apr 4, 2019 · 2 comments
Open

Validating required fields when using allOf #113

nussbam opened this issue Apr 4, 2019 · 2 comments

Comments

@nussbam
Copy link

nussbam commented Apr 4, 2019

When using allOf it is not checked if the fields referenced in required are existing

Example:

BaseData:
   properties:
      BaseProperty:
         type: string

ActualData:
    allOf:
      - $ref: '#/BaseData'
       - type: object
         required:
            - objectDoesntExist

This is a valid configuration according to the validator.

Expected behavior:

This should throw a validation error, hinting that the required field doesn't exist

@jdegre
Copy link

jdegre commented Jul 8, 2019

I think that the definition above is actually correct. It requires the type ActualData to comply with the following constraints:

  • It must be an object
  • It may have a property called BaseProperty and, if so, such property must be a string
  • It must have a property called objectDoesntExist, but nothing is said about its type

It is true that in most cases a mismatch between 'properties' and 'required' is due to an error, but not necessarily.

@nussbam
Copy link
Author

nussbam commented Sep 9, 2019

It must have a property called objectDoesntExist, but nothing is said about its type

It is not checked if it has a property called "objectDoesntExist".
The example is currently seen as valid, even though there is no property "objectDoesntExist", which I see as a misleading / wrong behavior

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

2 participants