question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I’m using API plaform for my development and I have some problem when i use prefix in routing.yml and custom Action.

My routing.yml :

api:
    resource: '.'
    type:     'api_platform'
    prefix: '/api'

app:
    resource: '@AppBundle/Action/'
    type:     'annotation'
    prefix: '/api'

I wrote a custom Action :

class ApiCustomersPost
{
    /**
     * @Route(
     *     name="API_Customers_post",
     *     path="/customers",
     *     defaults={"_api_resource_class"=Customers::class, "_api_collection_operation_name"="post"}
     * )
     * @Method("POST")
     */
    public function __invoke($data) 
    {
        return $data;
    }
}

When a I go to the doc I can see my route prefixed by “/api”

capture d ecran 2017-01-30 a 12 53 15

And the base URL in documentation is : capture d ecran 2017-01-30 a 12 56 32

I this case, when I want to test my route, the documentation try to call “/api/api/customers” capture d ecran 2017-01-30 a 12 59 20

But my routing is ok : with php bin/console router:debug I get : API_Customers_post POST ANY ANY /api/customers

And It work when I call the route /api/customerswith postman.

How can I handle this ?

Regards,

TF

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
meyerbaptistecommented, Jun 30, 2017
1reaction
Simperfitcommented, Jun 27, 2017

This has been fixed in core by @meyerbaptiste

Read more comments on GitHub >

github_iconTop Results From Across the Web

RoutePrefix vs Route
Route prefixes are associated with routes by design in attribute routing. It is used to set a common prefix for an entire controller....
Read more >
Route Prefix in Web API with Examples
The Attribute Routing Route Prefix in Web API is used to specify the common route prefix at the controller level to eliminate the...
Read more >
Prefixes vs Routes vs Network - Routing & Switching
A route is a particular entry in the routing table. A route is composed of a prefix, and either a next hop IP,...
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
Routes defined in the routes/api.php file are nested within a route group by the RouteServiceProvider . Within this group, the /api URI prefix...
Read more >
ip-prefix-routes | Junos OS
A pure Type 5 route advertises the summary IP prefix and includes a BGP extended community called a router MAC. The router MAC...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found