Core: Serializer Group ignored on Swagger documentation

Created on 14 May 2018  路  1Comment  路  Source: api-platform/core

Hello,

I'm using API-Platform using a Resource Yaml file. And some cusotm stuff (Data provider for example).
I Have a strange bahavior at this point.

Each of my operations have specific Serializer Group and each property have a list of serialization group related to the operations. So I expect to see this reflected in the Swagger documentation and see only the property defined by the serialization groups.

But it's not the case. the DocumentationNormalizer return all the propreties of each object.

Digging a little bit in the code I found that the problem is coming from ExtractorPropertyNameCollectionFactory.

During the process everything is operating as expected and the properties are filtered by serialization group. But so at line 65 we have a condition who is basically getting all the the properties of the resource and reinjecting all of them:

if ($properties = $this->extractor->getResources()[$resourceClass]['properties'] ?? false) {
            foreach ($properties as $propertyName => $property) {
                $propertyNames[$propertyName] = $propertyName;
            }
 }

If I comment this the doc seem to work as expected.

Can I have a confirmation it's a bug or not ?

Thanks.

Most helpful comment

I ran into this same issue recently as well, I would vote that this is a bug. I would expect only properties in a serialization group to be displayed in the swagger documentation. However, the above snippet makes anything with an "ApiProperty" annotation be displayed as well.

>All comments

I ran into this same issue recently as well, I would vote that this is a bug. I would expect only properties in a serialization group to be displayed in the swagger documentation. However, the above snippet makes anything with an "ApiProperty" annotation be displayed as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stipic picture stipic  路  3Comments

CvekCoding picture CvekCoding  路  3Comments

theshaunwalker picture theshaunwalker  路  3Comments

mahmoodbazdar picture mahmoodbazdar  路  3Comments

bendavies picture bendavies  路  3Comments