Open monitaurus opened 4 weeks ago
On a personal note, if it's really issue, I can take time to try fix it, with some insights or guidance.
IMO as you customized the schema it should return early at:
Definitely a bug, would love for this to get fixed, lmk if I can assist you (target 3.2 branch)
I'll take a look next week, many thanks for the details 🙇
API Platform version(s) affected: 3.2.22, 3.3.2
Tested on 3.2.22 and replicated on 3.3.2
Description
On a calculated field that returns an
array
, if we add aApiProperty
to change the type intoobject
, the generated OpenAPI does generate a"type": "object"
but there is also an extra"items": {"type": "string"}
.How to reproduce
On a resource, add the following calculated field:
Then access OpenAPI via Swagger, or generate a openapi json to find the extra
items
.Possible Solution
None found at the moment.
Additional Context
Investigation on the factory code:
SchemaPropertyMetadataFactory::create
$propertyMetadata->getBuiltinTypes()
returns["array"]
(view file)array
is considered as a collection of items, and the code define items asstring
by default (view file)$this->getType
returns a property type asarray
withitems
asstring
(view file)The type
object
seems to override the typearray
partially. And as builtin types are computed from PHP type (see doc), I don't think editingApiProperty
is enough to fix the issue.