You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Hello, I've had some issues with using the deprecation system.
According to the documentation, it is possible to mark a property/operation/resource as deprecated using the parameter deprecationReason. However, it's a bit unclear if the reason itself is supposed to be displayed or not. The documentation explicitly shows that it should be the case for GraphQL, displaying a screenshot, but simply states this :
With JSON-lD / Hydra, an owl:deprecated annotation property will be added to the appropriate data structure
With Swagger / OpenAPI, a deprecated property will be added
With GraphQL, the isDeprecated and deprecationReason properties will be added to the schema
However, using SwaggerUI and ReDoc, I cannot get the actual reason from the deprecationReason property.
With JSON-lD, The owl:deprecated annotation property is just a boolean
With SwaggerUI, it simply states : "Warning: Deprecated"
I couldn't verify GraphQL because I was unable to make it work but I trust the documentation
I find this behavior very strange because what's the point in specifying the deprecation reason if it is not used, or only as a boolean?
How to reproduce
Simply setup a new project :
Run `symfony new apip-deprecation-test --version="6.4.*" (tested with Sf 6.4)
Install some Composer dependencies, like : api-platform/core:3.4.10, api-platform/graphql, doctrine/orm, symfony/asset, symfony/twig-bundle
Create a simple Entity, and mark some Operations/Properties as deprecated using deprecationReason :
Run the server using symfony server:start and connect to the API Doc at https://127.0.0.1:8000/api (or equivalent URI based on your own config)
Documentation in SwaggerUI will only show a tag with Deprecated and write Warning: Deprecated. ReDoc will only show a tag. JSON-lD will display a owl:deprecated: true property. But the actual message filled in deprecationReason will never be shown.
Possible Solution
It's quite confusing to be allowed to input a string for the deprecationReason property only to never be able to actually show it to the users of the API Documentation. It could be important to explain why a property/operation/resource is being deprecated and how to update the code accordingly. So I have the following suggestions:
Add the message to the documentation. For instance with SaggerUI, instead of "Warning: Deprecated.", write "Warning: Deprecated. . This would be the best option.
Change the ?string $deprecationReason = null by bool $deprecated = false, this is straightforward and reflects the actual behavior. This is the worst option since it would be a BC and demand time to replace everything in the codebase.
Update the documentation to be more precise about the actual behavior of deprecationReason, by explaining that the reason will not be wrote for SwaggerUI, ReDoc and JSON-lD. This is the easiest solution, but it would still mean that the text in deprecationReason is pretty useless
Additional Context
Here are the screenshots from the generated API Documentation based on a simple project:
SwaggerUI :
ReDoc:
JSON-lD:
I hope I've been understanding things correctly.
Thanks !
The text was updated successfully, but these errors were encountered:
API Platform version(s) affected: 3.4.10
Description
Hello, I've had some issues with using the deprecation system.
According to the documentation, it is possible to mark a property/operation/resource as deprecated using the parameter
deprecationReason
. However, it's a bit unclear if the reason itself is supposed to be displayed or not. The documentation explicitly shows that it should be the case for GraphQL, displaying a screenshot, but simply states this :However, using SwaggerUI and ReDoc, I cannot get the actual reason from the
deprecationReason
property.owl:deprecated
annotation property is just a booleanI find this behavior very strange because what's the point in specifying the deprecation reason if it is not used, or only as a boolean?
How to reproduce
Simply setup a new project :
api-platform/core:3.4.10
,api-platform/graphql
,doctrine/orm
,symfony/asset
,symfony/twig-bundle
deprecationReason
:symfony server:start
and connect to the API Doc athttps://127.0.0.1:8000/api
(or equivalent URI based on your own config)Deprecated
and writeWarning: Deprecated
. ReDoc will only show a tag. JSON-lD will display aowl:deprecated: true
property. But the actual message filled indeprecationReason
will never be shown.Possible Solution
It's quite confusing to be allowed to input a string for the
deprecationReason
property only to never be able to actually show it to the users of the API Documentation. It could be important to explain why a property/operation/resource is being deprecated and how to update the code accordingly. So I have the following suggestions:?string $deprecationReason = null
bybool $deprecated = false
, this is straightforward and reflects the actual behavior. This is the worst option since it would be a BC and demand time to replace everything in the codebase.deprecationReason
, by explaining that the reason will not be wrote for SwaggerUI, ReDoc and JSON-lD. This is the easiest solution, but it would still mean that the text indeprecationReason
is pretty uselessAdditional Context
Here are the screenshots from the generated API Documentation based on a simple project:
SwaggerUI :
ReDoc:
JSON-lD:
I hope I've been understanding things correctly.
Thanks !
The text was updated successfully, but these errors were encountered: