Skip to content
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() is required when @OA\Property #2240

Open
maxence-futures opened this issue Mar 8, 2024 · 7 comments
Open

@OA\Items() is required when @OA\Property #2240

maxence-futures opened this issue Mar 8, 2024 · 7 comments

Comments

@maxence-futures
Copy link

I got this error after installation, without any documentation wrote in api.
Route file is ok,
security file is ok.

User Warning: @OA\Items() is required when @OA\Property(property="translations") has type "array" in

@DjordyKoert
Copy link
Collaborator

As the message suggest, you need to add a @OA\Items() for your translations property.

 * @OA\Property(
 *      property="translations"
 *      type="array",
 *      @OA\Items()
 * )

@maxence-futures
Copy link
Author

maxence-futures commented Mar 11, 2024

As I said, there no documentation wrote, the property="translations" just doesn't exist in our project.

@DjordyKoert
Copy link
Collaborator

Do you have some more context?

This warning is thrown inside the underlying swagger-php:
https://github.com/zircote/swagger-php/blob/038da8ad219f1e9c3f82c5d84c47da3b6f35039c/src/Annotations/Schema.php#L488

@maxence-futures
Copy link
Author

  • bundle version : "nelmio/api-doc-bundle": "^4.23"
  • config :
    areas: # to filter documented areas
        path_patterns:
            - ^/v1/. # Accepts routes under /v1 except /v1/doc
        disable_default_routes: true
  • And yes we are using Symfony's attributes.

This warning came after installation and initialization of nelmio bundle, no more.

@DjordyKoert
Copy link
Collaborator

This bundle should automatically add the OA\Items on the version you are using to array properties.

$property->type = 'array';
/** @var OA\Items $property */
$property = Util::getChild($property, OA\Items::class);

Could you try and find the class inside your codebase which has a "translations" property

public array $translations;

That class should probably contain more information about why it does not add the OA\Items

@maxence-futures
Copy link
Author

This is the problem, there is no var called translations in our project, I really don't know from where this error can come.

@DjordyKoert
Copy link
Collaborator

DjordyKoert commented Mar 11, 2024

You could try dumping $this by temporarily editing the place where the warning is thrown inside swagger-php inside your vendor.
https://github.com/zircote/swagger-php/blob/038da8ad219f1e9c3f82c5d84c47da3b6f35039c/src/Annotations/Schema.php#L488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants