Skip to content

Wrong documentation generated for SearchFilter with date properties and exact mode #3320

@idsplus-carlos

Description

@idsplus-carlos

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

  1. Add SearchFilter to a class with a DateTime property
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions