-
-
Notifications
You must be signed in to change notification settings - Fork 951
Description
API Platform version(s) affected: 3.4 (problem seems to be in 4.0 seen that the if's mentioned aren't altered)
Description
Using the following attribute, the false values are considered null and thus not shown on the documentation even though they are specified.
Boolean Example:
#[ApiProperty(default: false, example: false)]
Integer Example:
#[ApiProperty(default: 0, example: 0)]
Possible Solution
The problem seems to originate from the SchemaPropertyMetadataFactory file. The following 2 lines (89 and 96):
if (!\array_key_exists('default', $propertySchema) && !empty($default = $propertyMetadata->getDefault()) && (!\count($types) || null === ($className = $types[0]->getClassName()) || !$this->isResourceClass($className))) {
if (!\array_key_exists('example', $propertySchema) && !empty($example = $propertyMetadata->getExample())) {
False is also considered empty, the solution would be to explicitly check for null values.
if (!\array_key_exists('default', $propertySchema) && null !== ($default = $propertyMetadata->getDefault()) && (!\count($types) || null === ($className = $types[0]->getClassName()) || !$this->isResourceClass($className))) {
if (!\array_key_exists('example', $propertySchema) && null !== ($example = $propertyMetadata->getExample())) {