OpenAPI on calculated field add an extra items
fields even if openApiContext
define an object
#6391
Labels
items
fields even if openApiContext
define an object
#6391
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 editing
ApiProperty
is enough to fix the issue.The text was updated successfully, but these errors were encountered: