New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"@OA\\Items() parent type must be "array" in " #6194
Comments
|
Yes, I saw the version 3.1 of the OpenAPI specification: it now allows an array. When But, as I see only two possible paths:
For the future, for sure The biggest problem, however, is that it is not possible to document external endpoints with One problem, many causes as of what it seems. In the meantime, I dropped |
API Platform version(s) affected: 3.2.* (still present in 3.2.15)
Description
How to reproduce
Create an entity that uses an embeddable.
Trying to get the documentation in Swagger, causes the error.
The error is triggered in
zircote/swagger-php
:https://github.com/zircote/swagger-php/blob/a6d8a93e5daa83d3b959221b0f8f176953d145e9/src/Annotations/Items.php#L53-L56
It expects
$parent->type
bearray
while it actually is anarray
with two values:The fact that
TestEmbeddable::setTestArrayOrNull()
accepts anarray
or anull
value causes$parent->type
to have an array with the two possible acceptable values:array
andnull
.With
api-platform/core:3.1.*
this error didn't happened.Possible Solution
I think the problem may be in
ApiPlatform\JsonSchema\SchemaFactory
, but I'm not able to understand what changed that now causes the error.Additional Context
The code that adds the nullability is this:
core/src/JsonSchema/Metadata/Property/Factory/SchemaPropertyMetadataFactory.php
Lines 278 to 282 in bfd759b
Is here that
$type->type
is not=== 'array'
but is equal to['array', 'null']
and this breakszircote/swagger-php
.I don't know if the issue has to be fixed in
zircote/swagger-php
or here, inapi-platform/core
.Digging deeper in this issue, I noticed the add of
null
is done on purpose (correctly):d793ffb#diff-32d96682e97b6e04a17576ec737dd6cd19face8782e30713fe1fbf254e9ffaf2R89
d793ffb#diff-32d96682e97b6e04a17576ec737dd6cd19face8782e30713fe1fbf254e9ffaf2R241
The root cause of the issue
I'm not sure how to deal with this, but it seems to me that ApiPlatform generates OpenApi docs for version 3.1, while
zircote/swagger-php
doesn't still fully support it.Unsure where (and what) to fix this 🤔
Some usefult links
(Possible) Solution
Use the Swagger UI integrated in ApiPlatform:
The types returned are not precise, but, at least, it works...
The text was updated successfully, but these errors were encountered: