-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix mlm:artifact_type
check missing
#52
Conversation
This seems to work correctly when doing item validations via Fix found. Waiting on release to tag and use it... |
Commenting here due to the stac-node-validator issue. I think all of the STAC or STAC extension schemas (except for MLM afaik) are using draft-07. I'd be careful with adding a new schema version to decrease chances of issues. You are facing them with ajv right now in stac-node validator and I'm not sure whether you have checked other validators than pystac? Like in C# or so? I think I'd try to avoid mixing schema versions, especially newer ones for the sake of avoiding potential issues downstream. JSON Schema checks in many places throughout STAC are not really complete anyway (e.g. summaries) so not sure it's that important to use the unevaluatedProperties? I think I personally would rather remove the unevaluatedProperties in this case as it's ony for checking for typos / additional mlm: fields, but not actually needed for actual field validations. Alternatively, is there a way you can dereference the schema before publishing so that you don't need unevaluatedProperties? |
@m-mohr If you know a way, please let me know. I've tried for multiple hours, and I cannot find an alternative approach to |
This seems to work: It needs you to repeat the property names in the patternProperties though, but at least only once as you can also $ref the patternProperties itself in allOf. But I think I'd just remove the check alltogether if you are not fancy to repeat the values. Code: {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"allOf": [
{"$ref": "#/definitions/fields"},
{"$ref": "#/definitions/mlm_field_not_found"}
],
"definitions": {
"fields": {
"properties": {
"mlm:field1": {},
"mlm:field2": {},
}
},
"mlm_field_not_found": {
"patternProperties": {
"^mlm:(?!(field1|field2)).+$": { "not": {} }
}
}
}
} |
Yeah. Adding the fields in the regex this way is equivalent to duplicating the definition rather than using |
It's not duplicating the schema for the properties though. It's just the names, so comparably short. The same applies partially with the required fields. But yeah, all options are not ideal. I think I'd remove the check. There are more extension that don't check it. |
@m-mohr The check cannot be removed because I explicitly disallow certain fields combinations to redefine under assets/items as they would introduce misinterpretation of the contents. |
That's much more duplication compared to #52 (comment) though. Am I missing something? |
Not really. I would have to copy every field name within the regex, and maintain both regexes with their separate combinations of fields. It makes it harder to read and more prone to errors. At least, schema references are flagged by IDEs if they are invalid. |
0aa3c47
to
80c9d42
Compare
80c9d42
to
e8f785b
Compare
Just got an idea worth trying. {
"allOf": [
{"$ref": "#/definitions/all-fields"},
{"not": {"required": ["mlm:disallowed"]}}
],
"definitions": {
"all-fields": {
"properties": {
"mlm:allowed": {},
"mlm:disallowed": {}
},
"patternProperties": {
"^(?!mlm:)": {}
},
"additionalProperties": false
}
}
} |
7a50ec2
to
6d8f615
Compare
6d8f615
to
abf4a5e
Compare
Description
mlm:artifact_type
property check for a Model Asset definition.The
mlm:artifact_type
is now mutually and exclusively required by the corresponding Asset withmlm:model
role.mlm:artifact_type
check now enforced.Related Issue
mlm:artifact_type
in JSON schema #42Type of Change
Note
"Potentially" breaking change if the MLM definition was not formed as described by the README, but not breaking if the worded requirement was applied although unchecked.
Checklist
CONTRIBUTING.md
guide;make check
;Google
format for all the methods and classes that I used.