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

Make it explicit in JSON Schema that one and only one of the properties are required. #65

Open
aslakhellesoy opened this issue Jan 13, 2022 · 0 comments

Comments

@aslakhellesoy
Copy link
Contributor

aslakhellesoy commented Jan 13, 2022

The JSON Schema for Envelope doesn't currently emphasise that one and only one of its properties must be defined. I believe the correct way to do this is using oneOf:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "title": "Demo",
  "oneOf": [
    {
      "properties": {
        "attachment": {
          "$ref": "./Attachment.json"
        }
      },
      "required": ["attachment"]
    },
    {
      "properties": {
        "gherkinDocument": {
          "$ref": "./GherkinDocument.json"
        }
      },
      "required": ["gherkinDocument"]
    },
    {
      "properties": {
        "hook": {
          "$ref": "./Hook.json"
        }
      },
      "required": ["hook"]
    }
  ]
}

(additional properties elided for brevity).

@mattwynne mattwynne transferred this issue from cucumber/common Sep 29, 2022
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