-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Annotation output for propertyDependencies
#1367
Comments
I agree completely. |
I don't think transformations are relevant to how I'm not convinced that not producing annotations results in more verbose schemas. It's possible to construct a schema where that's true, but it wouldn't be a very useful schema. The schema from the example says that "foo" can be absolutely any value of any type, but if it's a string and its value is "foo1", then apply the schema. The "any value of any type" part is what I consider unrealistic. In any real schema, "foo" is going to need to be more fully defined anyway. It's going to have valid values, or at least be constrained to a string. So, you're not just defining "foo" for the sake of Something we haven't mentioned yet is that if Although I can see how some people might expect to see |
|
To extend @karenetheridge note, The specification says this for
|
Note: |
propertyDependencies
was originally proposed as a replacement for a complex and verbose pattern to apply a schema to an instance based on the value of a property, similarly to OpenAPI'sdiscriminator
, but with more native JSON-Schema-like functionality. It was added todraft-next
(post-2020-12) here.Proposed as a replacement for this pattern, one could expect that it would work the same in all cases, however I added a test to the Suite recently to cover the interation between
propertyDependencies
andunevaluatedProperties
:This is supposed to be analogous to:
In the latter schema,
unevaluatedProperties
can "see into"/if
to recognize that thefoo
property is declared. If the value offoo
isfoo1
, then the/if
subschema passes and produces an annotation thatfoo
is a known property, sounevaluatedProperties
subsequently ignores the property and passes validation.However, as it is currently defined,
propertyDependencies
produces no annotations. That means, for the former schema,unevaluatedProperties
wouldn't know about thefoo
property, so it would produce an error. Therefore the current definition fails to meet the explicit purpose of this keyword: a replacement for this commonif
/then
,discriminator
-like pattern.This could be solved by requiring
propertyDependencies
to produce an annotation of the properties listed within it (just likeproperties
does). (We would also need to updateunevaluatedProperties
to consider that annotation.)If we maintain that
propertyDependencies
does not produce an annotation, then the author is required to define the property elsewhere:I believe this counteracts the verbosity reduction benefit that
propertyDependencies
provides.NOTE Interactions with other keywords, including
unevaluatedProperties
was not explored in the original proposal.The text was updated successfully, but these errors were encountered: