NelmioApiDocBundle
NelmioApiDocBundle copied to clipboard
OA\Property as attribute doesn't work, annotation does

I have a model here that I just tried migration to attributes, but I noticed that the OA\Property doesn't work correctly as an attribute.
With annotation:

With attribute:

Hello,
Are you using the latest versions of both zircote/swagger-php and NelmioApiDocBundle?
zircote/swagger-php 4.3.0
nelmio/api-doc-bundle v4.8.2 (and I also tried dev-master)
Interesting that your example works at all without a Schema annotation on the class itself!
Using swagger-php directly on the command line with the following file I get the same for annotation and attribute, so I would suspect the issue is somewhere else.
<?php
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OAT;
/**
* @OA\Schema()
*/
class Model
{
/**
* @OA\Property(example=123)
*/
private int $annId;
#[OAT\Property(example: 222)]
private int $attId;
}
Running openapi:
$ ./bin/openapi -b scratch/prop_example.php scratch/prop_example.php
Warning: Required @OA\Info() not found
Warning: Required @OA\PathItem() not found
openapi: 3.0.0
components:
schemas:
Model:
properties:
annId:
type: integer
example: 123
attId:
type: integer
example: 222
type: object
My controller annotations look like this:

I suspect that it is something related to the Nelmio\ApiDocBundle\Annotation\Model class
Hmm, yes, that is possible. Its a pain to get both behaving the same and mixing attributes/annotations from different libraries doesn't make it any easier.
As far as I can see, the "ModelDescriber" logic doesn't do anything with attributes.
You could try to isolate the issue by reducing the code to avoid using bundle annotations while keeping the error. Then you could compare the openapi output with the bundle, I suppose.