API Platform version(s) affected: 2.5.3
Description
When using SearchFilter on date properties and exact mode, the generated documentation is incorrect. It used to generated a pair of properties, one simple string filter (ie: date_prop: string) and one string array filter (ie: date_prop[]: string[]). Now both are simple strings, even when the second one is named date_prop[].
How to reproduce
- Add SearchFilter to a class with a DateTime property
- Add that property to the SearchFilter's properties, with "exact" mode
Possible Solution
The problems lies in DocumentationNormalizer. When it detects a type that's not in Type::$builtinTypes it defaults to $type = ['string'], irregardless of it being a collection or not. Simple solution would be to return another default when encountering a collection, for example replacing:
$type = \in_array($data['type'], Type::$builtinTypes, true) ? $this->jsonSchemaTypeFactory->getType(new Type($data['type'], false, null, $data['is_collection'] ?? false)) : ['type' => 'string'];
with
$type = \in_array($data['type'], Type::$builtinTypes, true) ? $this->jsonSchemaTypeFactory->getType(new Type($data['type'], false, null, $data['is_collection'] ?? false)) : $this->jsonSchemaTypeFactory->getType(new Type('string', false, null, $data['is_collection'] ?? false));
Additional Context
API Platform version(s) affected: 2.5.3
Description
When using SearchFilter on date properties and exact mode, the generated documentation is incorrect. It used to generated a pair of properties, one simple string filter (ie:
date_prop: string) and one string array filter (ie:date_prop[]: string[]). Now both are simple strings, even when the second one is nameddate_prop[].How to reproduce
Possible Solution
The problems lies in DocumentationNormalizer. When it detects a type that's not in Type::$builtinTypes it defaults to $type = ['string'], irregardless of it being a collection or not. Simple solution would be to return another default when encountering a collection, for example replacing:
$type = \in_array($data['type'], Type::$builtinTypes, true) ? $this->jsonSchemaTypeFactory->getType(new Type($data['type'], false, null, $data['is_collection'] ?? false)) : ['type' => 'string'];with
$type = \in_array($data['type'], Type::$builtinTypes, true) ? $this->jsonSchemaTypeFactory->getType(new Type($data['type'], false, null, $data['is_collection'] ?? false)) : $this->jsonSchemaTypeFactory->getType(new Type('string', false, null, $data['is_collection'] ?? false));Additional Context