protected function OpenApiGeneratorBase::fixDefaultFalse in OpenAPI 8.2
Same name and namespace in other branches
- 8 src/Plugin/openapi/OpenApiGeneratorBase.php \Drupal\openapi\Plugin\openapi\OpenApiGeneratorBase::fixDefaultFalse()
Fix default field value as zero instead of FALSE.
Parameters
array $value: JSON Schema field value.
1 call to OpenApiGeneratorBase::fixDefaultFalse()
- OpenApiGeneratorBase::cleanSchema in src/
Plugin/ openapi/ OpenApiGeneratorBase.php - Cleans JSON schema definitions for OpenAPI.
File
- src/
Plugin/ openapi/ OpenApiGeneratorBase.php, line 399
Class
- OpenApiGeneratorBase
- Defines base class for OpenApi Generator plugins.
Namespace
Drupal\openapi\Plugin\openapiCode
protected function fixDefaultFalse(array &$value) {
$type_is_array = isset($value['type']) && $value['type'] === 'array';
$has_properties = isset($value['items']['properties']) && is_array($value['items']['properties']);
$has_default = isset($value['default']) && is_array($value['default']);
if ($type_is_array && $has_properties && $has_default) {
foreach ($value['items']['properties'] as $property_key => $property) {
if ($property['type'] === 'boolean') {
foreach ($value['default'] as &$default_values) {
if (isset($default_values[$property_key]) && empty($default_values[$property_key])) {
$default_values[$property_key] = FALSE;
}
}
}
}
}
}