-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
$dynamicAnchor
inside propertyDependencies
#615
Comments
This is a bit tricky b/c |
We have tests that do exactly this already with JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json Lines 352 to 398 in 716b95d
|
I'm working up a PR to illustrate a non-conflicting way that this could work. |
I don't understand why you're saying it's undefined behavior. Consider the schema {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://localhost:1234/draft2020-12/dynamicanchor-in-propertydependencies.json",
"$defs": {
"inner": {
"$id": "inner",
"$dynamicAnchor": "foo",
"type": "object",
"additionalProperties": {
"$dynamicRef": "#foo"
}
}
},
"propertyDependencies": {
"expectedTypes": {
"strings": {
"$id": "east",
"$dynamicAnchor": "foo",
"type": "string",
"$ref": "inner"
},
"integers": {
"$id": "west",
"$dynamicAnchor": "foo",
"type": "integer",
"$ref": "inner"
}
}
}
} It's pretty clear to me that Yes, you could have that anchor spread across multiple properties, and that would be invalid/undefined. {
...,
"propertyDependencies": {
"expectedTypes": {
"strings": {
"$id": "east",
"$dynamicAnchor": "foo",
"type": "string",
"$ref": "inner"
},
"integers": {
"$id": "west",
"$dynamicAnchor": "foo",
"type": "integer",
"$ref": "inner"
}
},
"anotherProp": {
"valueA": {
"$id": "north",
"$dynamicAnchor": "foo",
"type": "string",
"$ref": "inner"
},
"valueB": {
"$id": "south",
"$dynamicAnchor": "foo",
"type": "integer",
"$ref": "inner"
}
}
}
} But the first schema doesn't do that. |
I could also write {
"anyOf": [
{
"$dynamicAnchor": "foo",
"type": "integer"
},
{
"$dynamicAnchor": "foo",
"type": "string"
}
]
} I would say that this is perfectly valid, but the behavior is undefined. It doesn't prevent us from having tests for the defined cases. |
Because it's not the object-level dynamic scope, it's the resource-level dynamic scope. Read json-schema-org/json-schem-spec#1140 if you want the gory details. |
For that matter, since we haven't actually made the changes in issue 1140, this is even simpler: These schemas produce the same URI for different schema locations, and that results in undefined behavior (URI fragments are resource scoped, it doesn't matter whether the specific object is in the dynamic scope or not). |
Ah, my mistake- the |
propertyDependencies
is a conditional keyword. Similarly toif
/then
/else
, you can repeat a$dynamicAnchor
inside multiple branches, and$dynamicRef
should be able to find the right one.The text was updated successfully, but these errors were encountered: