Closed Neokil closed 2 years ago
Good questions! The code in SpecBaseObject is quite generic and not related to Schema definitions directly. The idea was that if we know the type of a property to return a value that fits in that type. That means empty array for array type and false for a boolean that is not explicitily set. There are some values that have a default value of true, e.g.
which corresponds to the spec:
http://spec.openapis.org/oas/v3.0.3#properties additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. Consistent with JSON Schema, additionalProperties defaults to true.
For the cases you name, we need to check if they need to be adjusted.
fixed. thanks for reporting!
When you are defining a Parameter like this:
and you try to get settings on that "code"-Property that are not set you will get values instead of null or undefined. For example trying to get the "exclusiveMinimum"-Property will return "false" instead of null/undefined. This causes other frameworks like "justinrainbow/json-schema" to be unable to handle this. I found the code responsible for this behaviour in
src/SpecBaseObject.php::__get (Line 341)
:Is there a reason why array and boolean are specially handled here? From my POV that is strange because when I am trying to get the value of a setting that is not set I would expect those to be undefined. Best example is the "exclusiveMinimum"-Setting of the Integer-Type which will be set to false by this function if not set what will cause the schema to be invalid because there is no minimum defined.