Make it explicit in JSON Schema that one and only one of the properties are required.
- Dominant language
- C#
- Stars
- 41
- Forks
- 24
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 6
Description
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](https://json-schema.org/understanding-json-schema/reference/combining.html#oneof):
```json
{
"$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).
Contributor guide
Research direction
Locate the JSON Schema definition for Envelope and review its existing properties and referenced Attachment, GherkinDocument, and Hook schemas. Add the oneOf structure described in the issue, then validate that an Envelope with exactly one supported property is accepted while zero or multiple properties are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100