-
-
Notifications
You must be signed in to change notification settings - Fork 887
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
strictProperties #193
Comments
I am not sure I understand what problem this keyword solves that is not already solved by existing keywords. |
because additionnalProperties only apply to properties declared at the same level. In the following exemple, if my schema is a mix between 2 schema (part of each), i have no way currently to restrict to properties i require. The only way would be stictProperties. {
"$schema": "http://json-schema.org/schema#",
"id": "http://xy.com/schema/schemaC.json",
"allOf": [{
"$ref": "schemaA.json"
}, {
"$ref": "schemaB.json"
}, {
"required": [
"propA1",
"propA3",
"propA4",
"propA7",
"propB2",
"propB4",
"propB5"
],
"strictProperties": true
}]
} With |
I see nothing in the proposal that would suggest it is the case. |
According to the proposal, this schema: {
"required": [
"propA1",
"propA3",
"propB2",
"propB4",
],
"strictProperties": true
} is equivalent to: {
"properties": {
"propA1": {},
"propA3": {},
"propB2": {},
"propB4": {}
},
"required": [
"propA1",
"propA3",
"propB2",
"propB4",
],
"additionalProperties": false
} So it is just a syntax sugar that can be added with macro keyword definition. Can be added to ajv-keywords I think |
it is not equivalent. that means if i use a shema with external properties using $ref and i use required in the parent shema with "strictProperties" it will require and only accept properties in "required" property. With external properties, the property "additionalProperties" will not work as i would like. |
What do you mean by "external properties"? In any case strictProperties should be only affected by properties and other keywords in the same schema object, it can't take into account properties in other objects. |
Closing the issue. I will not be implementing any keywords with global visibility until they are added to the standard. And I am strongly against it, I think keywords should only have local visibility. I haven't been presented with a single use-case for properties that cannot be expressed using existing JSON-schema vocabulary. I like the idea of $merge/$patch keywords though, extending the schema is indeed not supported and it is needed to extend meta-schemas, for example. If you are interested in strictProperties keyword with local visibility, we can add it to ajv-keywords as I suggested (I already wrote the code, just need to add test cases...) |
it would be great to add strictProperties support
https://github.com/fge/json-schema-validator/wiki/v5:-strictProperties
The text was updated successfully, but these errors were encountered: