$ref, $anchor and $dynamicRef, $dynamicAnchor #322
Replies: 1 comment 2 replies
-
That's not correct. Dynamic references and normal references are resolved in different ways. It's not just a matter of when references are resolved. Technically, there is some overlap of behavior, but only when you use a dynamic reference wrong. When using a dynamic reference the wrong way, it falls back to behaving like a normal reference. I'm trying to change that so there is less of this kind of misunderstanding. Your example of a dynamic reference is not correct (although technically not allowed). It can't express dynamic behavior because it doesn't reference a dynamic anchor. This StackOverflow answer may help you better understand this feature, https://stackoverflow.com/questions/69728686/69774520#69774520 |
Beta Was this translation helpful? Give feedback.
-
Reading the specifications I understand that the only difference between $ref, $anchor and $dynamicRef, $dynamicAnchor consists in the moment in which references are resolved, at schema load for $ref, at runtime for $dynamicRef. I found that this method of doubling the number of words is quite difficult to follow and understand. Instead I would prefer something like this:
This fallback system would allow us to use the shorthand version for most of the cases, and would be self-descriptive for the rest.
would be the same as:
while dynamic ref would be:
I don't know if this schema compositing method is possible, I just wanted to describe a way of thinking. Personally when in my work I combine two words into a variable name there is a sign for future trouble, and I try to avoid that whenever is possible. In json-schema specs are multiple places where keywords having almost similar functionalities are conceived as separate keywords instead of single keyword with an extra attribute.
Beta Was this translation helpful? Give feedback.
All reactions