NelmioApiDoc - Hide documentation section by default - symfony

By default, ApiDoc lists out all operations for each API endpoint, like this:
In the Swagger demo, however, operations are hidden by default until the user chooses to show them.
Is there a configuration option for ApiDoc that will hide operations by default? I haven't found anything like this in the documentation.

Documentation section can be hidden by default with parameter default_sections_opened:
nelmio_api_doc.default_sections_opened: false
Default value for this parameter is true. See configuration reference.

You must change your config.yml file like this (default_sections_opened to false):
nelmio_api_doc:
name: 'API documentation'
exclude_sections: []
**default_sections_opened: false**
motd:
template: 'NelmioApiDocBundle::Components/motd.html.twig'
request_listener:
enabled: true
parameter: _doc
sandbox:
enabled: false

Related

Parameter in parameter in services.yml

I am using symfony5 and what I want to achive is to use a parameter in another parameter. Is it possible? Of course I've searchd for it, but did not find a solution. For example:
media:
extendions:
- pdf
path: '%kernel.project_dir%/media/'
incomingPdf:
#path: '%kernel.project_dir%/media/incoming/pdf'
path: '#=parameter("media")["path"]incoming/pdf'
It says, expressions is not allowed in parameters.
In incomingPdf I want to use defined media['path']s value.

Symfony FOSRestBundle enableMaxDepthChecks default to true

Is it possible to set the default value for enableMaxDepthChecks to true?
Currently I have to add the following annotation to every route:
#View(serializerEnableMaxDepthChecks=true)
Is there a way to set this in the config or elsewhere to be the default?
Place this into your config.yml
jms_serializer:
default_context:
serialization:
enable_max_depth_checks: true
BUT! After making these changes, the parameter serializerEnableMaxDepthChecks becomes non-working, so you can't set it to false , and I don't know why...

Cannot import resource error, FosRestBundle Throws InvalidArgumentException

Hello i have a strange problem, while using FostRestBundle.
First error is :
InvalidArgumentException: Every parent controller must have get{SINGULAR}Action($id) method
where {SINGULAR} is a singular form of associated object
And the second one :
Cannot import resource "/home/a15net/public_html/game/src/ATL/ContentBundle/Resources/config/api_routing.yml" from "/home/a15net/public_html/game/app/config/routing.yml".
I'v checked my all "YAML" files but there was no indent problems.
Tried to update composer twice nothing helped.
Edit : Config.yml > http://goo.gl/dqCAu
You have to remove the 'type' from this import statement fro your routing.yml
atl_content_api:
resource: "#ATLContentBundle/Resources/config/api_routing.yml"
Inside the api_routing.yml you can specify the rest type for each controller like,
acme_user_rest:
resource: Acme\UserBundle\Controller\UserRestController
prefix: /api
type: rest
this blog will help you to implement the sme
--- NOT --- SOLUTION :
If a route has a parent route, you must not put "type:rest" to it. You have to use "type:rest" only in parent routes.
Sample :
catalogs:
type: rest
prefix: api
resource: ATL\CatalogBundle\Controller\API\CatalogsController
options:
expose: true
taxonomy:
parent: catalogs
resource: ATL\CatalogBundle\Controller\API\TaxonomyController
options:
expose: true
I will not choose this as correct answer until more comments and other solution suggestions writed.
Edit
When you remove type:rest from children route, it is not a rest route anymore.

"You cannot define a mapping item when in a sequence" when running phpunit in symfony

I'm getting the following errors when I try to run phpunit on my symfony project:
$ phpunit -c app
1) [...]\DefaultControllerTest::testIndex
Symfony\Component\Config\Exception\FileLoaderLoadException: Cannot import resource "/srv/http/typeform/app/config/config.yml" from "/srv/http/typeform/app/config/config_dev.yml".
/srv/http/typeform/vendor/symfony/src/Symfony/Component/Config/Loader/FileLoader.php:89
[...]
/srv/http/typeform/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:39
/srv/http/typeform/src/QuickyForm/PublicBundle/Tests/Controller/DefaultControllerTest.php:11
Caused by
Symfony\Component\Yaml\Exception\ParseException: You cannot define a mapping item when in a sequence in "\/srv\/http\/typeform\/app\/config\/config.yml"
/usr/share/pear/Symfony/Component/Yaml/Parser.php:116
[...]
/srv/http/typeform/app/bootstrap.php.cache:520
/srv/http/typeform/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:39
/srv/http/typeform/src/QuickyForm/PublicBundle/Tests/Controller/DefaultControllerTest.php:11
It seems that it crash when I call static::createClient();
Here's my config_test.yml
imports:
- { resource: config_dev.yml }
The errors you are getting suggest that the app is failing to parse your 'config.yml' because "You cannot define a mapping item when in a sequence".
This means that in a yml file when defining array values you cannot provide both mapping entries in the form "key: value" and sequence entries in the form "- item" - all values must be either one or the other form.
So, this is ok:
group:
key: value
key: value
This is also ok:
group:
- item
- item
This is not ok:
group:
key: value
- item
The errors suggest that there is an occurrence of the last form in your config.yml, although if this is the case it ought to cause problems running your app in the browser and not just under phpunit.
Additionally, to redbirdo's answer, you should be aware that you might need to use - under the required tag's items. For example:
UserLogin:
type: "object"
required:
- email
- password
security:
basicAuth: [] .......

where to change translationFallback to true in symfony 2 doctrine translatable

I need to switch 'translation fallback' and 'persistDefaultLocaleTranslation' on.
I know how to change it: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md#default-locale
but don't know where should I access that listener.. Maybe in config.yml? how??
I am looking for something like this:
(config.yml)
...
translatable-extension:
translationFallback:true
persistDefaultLocaleTranslation: true
If you have the StofDoctrineExtensionsBundle installed (https://github.com/stof/StofDoctrineExtensionsBundle), you can configure the default values for this in config.yml
stof_doctrine_extensions:
default_locale: "%locale%"
translation_fallback: true
persist_default_translation: true
Haven't found this is in any docs, but it is in the configuration for the bundle https://github.com/stof/StofDoctrineExtensionsBundle/blob/master/DependencyInjection/Configuration.php#L30
I'm not sure I fully understand what you are asking but in a typical setup you would have the translation fallback referenced in your config.yml like this.
framework:
translator: { fallback: %locale% }
In this example the locale placeholder references the locale setting in your parameters.ini/parameters.yml file.
I believe this is commented out by default in your config.yml but uncommenting this line will effectively enable translations.
You can see the full list of configuration options with along with their defaults here:
http://symfony.com/doc/current/reference/configuration/framework.html#full-default-configuration

Resources