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

Old PR comes back to haunt me: validating required properties actually exist #157

Open
marcelstoer opened this issue Nov 25, 2020 · 1 comment

Comments

@marcelstoer
Copy link
Contributor

marcelstoer commented Nov 25, 2020

Years ago I contributed two PRs #83 and #84 which added validation to ensure properties declared as required actually exist.

The test case I contributed uses a definition like so:

OfferingRequired:
allOf:
- $ref: '#/definitions/Offering'
required:
- contentId # <-- all required properties are inherited
- start
- end

Today I learned folks might actually put this into their API specs like so instead:

 OfferingRequired:
  allOf:
    - $ref: '#/definitions/Offering'
    - type: object
      required:
        - contentId                        # <-- all required properties are "inherited" through the composition of Offering 
        - start
        - end

@JamesMessinger in your experience is this a common enough variant that I should adjust the code through a PR accordingly?

@marcelstoer
Copy link
Contributor Author

According to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#composition-and-inheritance-polymorphism it is expected(?) that you use allOf to compose something out of a $ref object and an "anonymous" local object.

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