It seems that at v2.1 overriding the default value of default_operation_path_resolver bundle configuration parameter does not make any difference, for instance api_platform.operation_path_resolver.dash value still results with route paths like /my_resource.
It seems that the service which is passed to the ApiLoader class is hardcoded and hence the bundle configuration parameter is ignored:
https://github.com/api-platform/core/blob/2.1/src/Bridge/Symfony/Bundle/Resources/config/api.xml#L35
The quick a little hacky workaround for this (to force ApiPlatform to use dash strategy in path generation) is to override one of the services:
services:
api_platform.path_segment_name_generator:
alias: api_platform.path_segment_name_generator.dash
default_operation_path_resolver is deprecated, you have to use path_segment_name_generator instead:
api_platform:
path_segment_name_generator: 'api_platform.path_segment_name_generator.dash'
I had a problem with dashes too.
Once API Platform 2.1 is installed, with both configurations (the deprecated one or the new one), pathes with dashes did not work anymore, leading to 404 Not Found.
Fun fact: with the new configuration, in the Routing page of the profiler, the route/path row was green with Route matches, in spite of the 404 error.
Now it works for me after cache cleanup (and the new configuration).
Hope this helps.
Think this can be closed? Had the same issue as @vViktorPL but switching to path_segment_name_generator fixed all my problems.
Most helpful comment
default_operation_path_resolveris deprecated, you have to usepath_segment_name_generatorinstead: