-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: don't require full top-level validation in non-cyclic-non-top-level refs #162
Conversation
e629094
to
8241ba2
Compare
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.
|
45d7ad4
to
c5831fe
Compare
@RichAyotte this should be ready now |
I've checkout the branch and ran a few tests and observed a few new behaviours. When a $ref is specified without "properties": {
"kind": {
"const": "double_baking_evidence"
},
"bh1": {
"$ref": "#/definitions/TezosBlockHeader"
},
"bh2": {
"$ref": "#/definitions/TezosBlockHeader"
} Adding "properties": {
"kind": {
"const": "double_baking_evidence"
},
"bh1": {
"unevaluatedProperties": false,
"$ref": "#/definitions/TezosBlockHeader"
},
"bh2": {
"unevaluatedProperties": false,
"$ref": "#/definitions/TezosBlockHeader"
}
} The second new behaviour is with items. The errors are "MichelineMichelsonV1Expression": {
"type": ["array", "object"],
"oneOf": [
...// removed 3 irrelevant items here
{
"type": "array",
"items": {
"$ref": "#/definitions/MichelineMichelsonV1Expression"
}
},
{
"type": "object",
"properties": {
"prim": {
"type": "string",
"maxLength": 256,
"format": "anyString"
},
"args": {
"type": "array",
"items": {
"$ref": "#/definitions/MichelineMichelsonV1Expression"
}
},
"annots": {
"type": "array",
"items": {
"type": "string",
"maxLength": 256,
"format": "anyString"
}
}
}
}
]
} |
I forgot to add, the changes here resolve issue #161 🚀 |
Re: refs -- thanks! Yes, this did change the behavior -- previously, all I'll take a closer look at/investigate schemas that were previously compiling and now don't due to this. |
Yes, I see a regression on validator(
{
$schema: 'http://json-schema.org/draft-07/schema#',
$defs: {
A: {
type: ['array', 'object'],
oneOf: [
{
type: 'array',
items: {
$ref: '#/$defs/A'
}
},
{
type: 'object',
required: [],
additionalProperties: false,
properties: {}
}
]
}
},
$ref: '#/$defs/A'
},
{ mode: 'strong' }
) Looks like we need actual propagation for cyclic refs. I assume that |
I'm not sure what cyclic means here but here's the "TezosDoubleBakingEvidenceOperation": {
"type": "object",
"allOf": [{ "$ref": "#/definitions/TezosBaseOperation" }],
"required": ["kind", "bh1", "bh2"],
"properties": {
"kind": {
"const": "double_baking_evidence"
},
"bh1": {
"unevaluatedProperties": false,
"$ref": "#/definitions/TezosBlockHeader"
},
"bh2": {
"unevaluatedProperties": false,
"$ref": "#/definitions/TezosBlockHeader"
}
}
}, |
That doesn't look like a regression. Perhaps we could enable the new behavior as an opt-in or only on non-cyclic refs to avoid regressions |
@RichAyotte updated |
8ba7df8
to
3167a72
Compare
c2f743a
to
d9f4f2b
Compare
Everything looks really good now and all my tests pass. Thanks for putting this patch together so quickly 🙏 |
b1b3fef
to
113ef14
Compare
@RichAyotte I added more tests/safeguards and fixed an issue that detected. |
bf925e6
to
4e90ceb
Compare
This will allow application of partial refs that would be revalidated separately on the top-level.
4e90ceb
to
dc6f3ce
Compare
(lint fixes / code formatting only in the last pushes) |
Everything still looks good 👍 |
Merged and published as |
Upd: use |
I'm glad you found it and I just tested with |
Refs: #161 (comment)
This will allow e.g. this to compile in strong mode: