After bumping to 5.3.0-BETA1 I got error:
The definition for "nelmio_api_doc.generator_locator" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.
below SF 5.3 everything is good.
For resolve this issue We need change configuration definition in Container:
https://github.com/nelmio/NelmioApiDocBundle/blob/master/DependencyInjection/NelmioApiDocExtension.php#L132
From:
$container->register('nelmio_api_doc.generator_locator')
->setPublic(false)
->addTag('container.service_locator')
->addArgument(array_combine(
array_keys($config['areas']),
array_map(function ($area) { return new Reference(sprintf('nelmio_api_doc.generator.%s', $area)); }, array_keys($config['areas']))
));
to:
$container->register('nelmio_api_doc.generator_locator', ServiceLocator::class)
->setPublic(false)
->addTag('container.service_locator')
->addArgument(array_combine(
array_keys($config['areas']),
array_map(function ($area) { return new Reference(sprintf('nelmio_api_doc.generator.%s', $area)); }, array_keys($config['areas']))
));
Ready for make PR but I don't know on which branch? 2.x or 3.x?
Fixed in https://github.com/symfony/symfony/issues/40861, thanks a lot!
Thank you too, @GuilhemN
@michaljusiega Any change this fix is also going to be in version 4.2.* of the nelmio/api-doc-bundle?
My builds are failing since today as a result of this.
In case it isn't can you maybe help me with a workaround?
@michaljusiega Any change this fix is also going to be in version 4.2.* of the nelmio/api-doc-bundle?
My builds are failing since today as a result of this.
In case it isn't can you maybe help me with a workaround?
you can use de dev-master while the new version is released
composer update nelmio/api-doc-bundle 4.x-dev
@oesteve @michaljusiega
For my part, I installed the bundle without running the recipes. I did by hand what the recipe was supposed to do (saving the bundle, routes file, configuration file).
And finally I added this in services.yaml:
nelmio_api_doc.generator_locator:
alias: "nelmio_api_doc.generator.default"
public: "true"
@oesteve @michaljusiega
For my part, I installed the bundle without running the recipes. I did by hand what the recipe was supposed to do (saving the bundle, routes file, configuration file).
And finally I added this in services.yaml:nelmio_api_doc.generator_locator:
alias: "nelmio_api_doc.generator.default"
public: "true"
+1.
For lazy devs, this is what the recipe ( https://github.com/symfony/recipes-contrib/tree/master/nelmio/api-doc-bundle/3.0 ) does :
config/packages/nelmio_api_doc.yamlnelmio_api_doc:
documentation:
info:
title: My App
description: This is an awesome app!
version: 1.0.0
areas: # to filter documented areas
path_patterns:
- ^/api(?!/doc$) # Accepts routes under /api except /api/doc
config/routes/nelmio_api_doc.yaml# Expose your documentation as JSON swagger compliant
app.swagger:
path: /api/doc.json
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger }
## Requires the Asset component and the Twig bundle
## $ composer require twig asset
#app.swagger_ui:
# path: /api/doc
# methods: GET
# defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
config/bundles.phpreturn [
// ...
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ["all" => true],
];
And then as said, don't forget to add in your config/services.yaml these lines in the services
nelmio_api_doc.generator_locator:
alias: "nelmio_api_doc.generator.default"
public: "true"
Now run a cache:clear and you should have no errors.
Sorry for the delay, this is now released under 4.3.0.
Most helpful comment
+1.
For lazy devs, this is what the recipe ( https://github.com/symfony/recipes-contrib/tree/master/nelmio/api-doc-bundle/3.0 ) does :
config/packages/nelmio_api_doc.yamlconfig/routes/nelmio_api_doc.yamlconfig/bundles.phpAnd then as said, don't forget to add in your
config/services.yamlthese lines in theservicesNow run a cache:clear and you should have no errors.