Fixing “No operations defined in spec!” error on Api Platform

Fixing “No operations defined in spec!” error on Api Platform

Tags
Symfony
API Platform
Bug Fixing
Published
Oct 23, 2022
API Platform is just great. You can build your very configurable API with solid standards in a few minutes. However, if your project is based on DDD, it means that your Entity classes are probably outside the default src/Entity directory. And if you want to use the API Platform with such a case, then you’ll face that the bundle does not generate any route for your API resources even if you mark them with the ApiResource annotation or attribute. And if you want to debug what’s going on by visiting your api/docs route, then you’ll see the error below:
notion image
 
To fix this error, you need to register your custom directories like this:
notion image
After that, your resources will be available for the API Platform. Happy coding!

Loading Comments...