|
Post by michaeldu on Aug 4, 2020 2:30:23 GMT
Is it meaningful for "patternProperties" when "additionalProperties" is false? for example,
"WatchdogTimer": {
"additionalProperties": false,
"description": "This type describes the host watchdog timer functionality for this system.",
"longDescription": "This type shall contain properties that describe the host watchdog timer functionality for this ComputerSystem.",
"patternProperties": {
"^([a-zA-Z_][a-zA-Z0-9_]*)?@(odata|Redfish|Message)\\.[a-zA-Z_][a-zA-Z0-9_]*$": {
"description": "This property shall specify a valid odata or Redfish property.",
"type": [
"array",
"boolean",
"integer",
"number",
"null",
"object",
"string"
]
}
},
"properties": {
"FunctionEnabled": { ......
The patternProperties is used to restrict the names of extra properties. But the additionalProperties "false" means no extra properies. So what is the meaning for these two keywords?
|
|
|
Post by mraineri on Aug 4, 2020 13:54:10 GMT
We use the "patternProperties" term to allow for payload annotations so we don't have to explicitly call out every variant of a payload annotation per property in the schema file. As far as I know, even though additionalProperties is false, you can still add more properties that match the patternProperties term. So, as long as the property is explicitly called out, or matches the additionalProperties term, then the property in the response is valid.
|
|
|
Post by jautor on Aug 4, 2020 14:14:27 GMT
Yes, in JSON schema, "patternProperties" is evaluated separately before "additionalProperties". You can think of those as a decreasing level of property name specificity. First, properties with specific names, then properties-that-match-a-specific-pattern, then anything-else. The Redfish schemas don't allow "anything else" (with some exceptions), and that pattern only allows property-level annotations (e.g. "BootSourceOverrideTarget@Redfish.AllowableValues") that might be inserted by a service. You'll see in the pattern that there must be an "@" along with the annotation namespaces we support (Redfish, OData and Message).
Hope that clears it up?
Jeff
|
|
|
Post by michaeldu on Aug 5, 2020 5:40:19 GMT
It is different understanding from the JSON schema. json-schema.org/understanding-json-schema/reference/object.html?highlight=patternproperties""" The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword. By default any additional properties are allowed. The additionalProperties keyword may be either a boolean or an object. If additionalProperties is a boolean and set to false, no additional properties will be allowed. """ It doesn't conflict to add patternProperties when the additionalProperties is false. Just want to make sure we are on the same page.
|
|