NelmioApiDocBundle: Incompatibility with DoctrineBundle v2.8
Hi,
When I upgraded the doctrine/doctrine-bundle from 2.7 to 2.8, the NelmioApiDocBundle stopped to work:
The service "nelmio_api_doc.model_describers.object" has a dependency on a
non-existent service "annotations.reader".
Looks like the doctrine/doctrine-bundle moved their dependency on doctrine/annotations from the required to require-dev section, starting from version 2.8.0.
Any advice, workaround, or maybe a new version of this great bundle which will work with the recent DoctrineBundle, please? š
P.S. The NelmioApiDocBundle is great, btw. Thanks!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 16 (5 by maintainers)
doctrine/annotationswill be optional soon in swagger-php: https://github.com/zircote/swagger-php/pull/1508@DjordyKoert Oh, I see that there is multiple new releases today - Iāll try to upgrade that bundle and see what happens - thanks!
Iām having the same issue when using NelmioApiDocBundle in prod. Setting
framework.annotations.enabled: truesolves it for now, but itās deprecated since Symfony 6.4:Also, NelmioApiDocBundle is indeed great, thank you for the work!
Thanks for the additional details. I think the root cause is that you use NelmioApiDocBundle as a dev dependency, Symfony core moves more and more to enabling features by default only if they are available in prod (the
willBeAvailablefield in https://github.com/symfony/symfony/blob/c301d9a49a1562b39d8c28eee2b5f4791d51ab14/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L971 checks that).An immediate solution for you is to add
framework.annotations: trueto your dev config.Longer term I see either:
packages/dev/nelmio.yamlenabling the annotationsI prefer just modifying the recipe personally although thatās possibly bothering for people also using NelmioApiDocBundle as a dev dependency and that will have the same issue (because of doctrine-bundle or another dependency) until they upgrade to the new recipeā¦
Thank you ā¤ļø
I donāt really understand the root cause here,
zircote/swagger-phpstill has a dependency ondoctrine/annotationsso it should still work fine.Which version of NelmioApiDocBundle are you using? Is it v3.x? Are you activating annotations in your framework bundle config? (i.e.
framework.annotations: true)If not too sensitive, having your composer.lock (maybe without the private packages if you use any) could help pinpoint the root issue.
Unfortunately thatās a hard dependency as we use the annotations from
zircote/swagger-phpas models. Unless they remove the dependency in their bundle first, it would be a too big investment to remote this dependency here.The latest version solved it for me as well, thank you!
I think upgrading the recipe is a fine solution. Meanwhile, those who use NelmioApiDocBundle as a dev dependency can update
framework.annotationsuntil new version is released.Thank you for your help!