When a default is set for a new property in an if/then structure the unevaluated error is triggered.
To reproduce:
$schema = json_decode(
<<<JSON
{
"type": "object",
"properties": {
"in": {
"type": "string",
"enum": ["query", "path", "header", "cookie"]
}
},
"if": {
"properties": {
"in": {
"const": "path"
}
}
},
"then": {
"properties": {
"style": {
"default": "simple",
"type": "string"
}
}
},
"unevaluatedProperties": false
}
JSON
);
$data = (object)[
'in' => 'path'
];
$validator = new \Opis\JsonSchema\Validator();
$error = $validator->validate($data, $schema)->error();
if ($error !== null) {
echo 'Error: ' . $error->message() . PHP_EOL;
echo 'Args: ' . json_encode($error->args()) . PHP_EOL;
}
This shows:
Error: Unevaluated object properties not allowed: {properties}
Args: {"properties":["style"]}
The example is taken from OpenAPI specification v3.1, linked here: https://spec.openapis.org/oas/ . When unevaluatedProperties is changed to additionalProperties there is no issue.
When setting the allowDefaults option to false there is also no issue.
When a default is set for a new property in an if/then structure the unevaluated error is triggered.
To reproduce:
This shows:
Error: Unevaluated object properties not allowed: {properties}
Args: {"properties":["style"]}
The example is taken from OpenAPI specification v3.1, linked here: https://spec.openapis.org/oas/ . When unevaluatedProperties is changed to additionalProperties there is no issue.
When setting the allowDefaults option to false there is also no issue.