core icon indicating copy to clipboard operation
core copied to clipboard

identifier non writable is documented in .json schema but not in .jsonld one

Open celinederoland opened this issue 3 years ago • 1 comments

API Platform version(s) affected: 2.6.8

Description
Hello, I noticed that in .jsonld documentation, the api properties marked as identifier and not writable are removed from the documentation generated in .jsonld (it's shown in documentation generated in .json format and on the default graphical interface of the documentation provided by ApiPlatform). I'm not sure if it is the expected behaviour or a bug ? And if this is the expected behaviour, does someone know the reason ?

How to reproduce
The official api-platform demo reproduces the problem : (in https://demo.api-platform.com/docs.jsonld the Book schema starts with the property 'isbn', in https://demo.api-platform.com/docs.json the Book schema starts with the property id image

An interesting side effect : on the admin the property appears with OpenApiAdmin component, and doesn't appear with HydraAdmin component image

Possible Solution
It's due to the condition here https://github.com/api-platform/core/blob/6ab093e902a3a7b72f023458cd0f9e5f06eb4b50/src/Hydra/Serializer/DocumentationNormalizer.php#L205 if (true === $propertyMetadata->isIdentifier() && false === $propertyMetadata->isWritable()) { continue; } If I comment those 3 lines of code, then the property appear in jsonLd documentation and is marked as identifier, and not writable.

Additional Context
In the screenshot below you can see the definition of the resource, with a non writeable identifier named 'atlasId' and a second property 'name' of type string. On the right, you can see that the 'atlasId' property doesn't appear at all in the jsonld representation of the documentation (it starts with the next property 'name') and it appears in the json representation of the documentation (note : the behaviour of the API itself is correct, and the integrated graphical html documentation does show the property to, As far as I can see, only .jsonld representation of the documentation is affected). In the second screen-shot, you can see the result with the 3 lines commented.

desappear-in-jsonld do-not-desappear-when-i-comment

celinederoland avatar Aug 29 '22 05:08 celinederoland

It looks like a wanted behavior but I don't understand why, can you check @dunglas ?

You added it here: https://github.com/api-platform/core/pull/2424

soyuka avatar Sep 17 '22 16:09 soyuka

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 05 '23 16:01 stale[bot]

This bug is targeting 2.7, as API Platform 3.2 is out, version 2.7 has reached end of life. Therefore we'll close this issue.

We recommend to upgrade to API Platform 3.0, Les-Tilleuls.coop can offer paid support to help or even migrate your projects if they have tests.

We want to fund a Long Term Stable version of API Platform, if you or your organization would like to contribute to LTS support, please visit our Open Collective crowdfunding.

soyuka avatar Oct 17 '23 09:10 soyuka