improve definition of keyword relationships (affects and affectedBy) #125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current implementation is very limited. To change the functionality of a relationship, the keywords themselves must be changed (violation of the Openclose principle).
AffectedBy
AffectedBy defines a relationship where the output is affected by the defined keywords. In most cases, this means that a “true” can be changed to a “false” (e.g. maxContains for contains) or simply defines which data the keyword affects (e.g. additionalProperties uses properties and patternProperties). In some cases, however, the presence of the other keyword means that the keyword in question can deliver neither true nor false (e.g. minContains for contains).
To solve this problem without completely linking the keywords, we define the type of relationship (
AffectByType
).AffectType:
Extends means that the keyword is fully evaluated, but the true output can be affected by another keyword and changed to false.
Replace means that the keyword is not evaluated (neither as an applicator nor as an assertion), but the other keyword takes over completely.
sample for contains Keyword:
Affects
Affects defines keywords that are modified by this keyword. In most cases, the absence of this keyword is not a big problem, but for some it means that the other is not needed (e.g. minContains has no meaning without contains)
Solution Affects becomes a default value if keyword is absent.