Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route name generation is not working as before #5008

Closed
Cryde opened this issue Sep 24, 2022 · 6 comments
Closed

Route name generation is not working as before #5008

Cryde opened this issue Sep 24, 2022 · 6 comments
Labels

Comments

@Cryde
Copy link

Cryde commented Sep 24, 2022

API Platform version(s) affected: 2.7.0

Description
In previous version when I did a bin/console debug:router all the route generated by API Plateform had a generated name which I was able to use as reference in my project.
When upgrading to 2.7 it's not the case anymore.

Before :

 ----------------------------------------------- -------- -------- ------ ------------------------------------------------ 
  Name                                            Method   Scheme   Host   Path                                            
 ----------------------------------------------- -------- -------- ------ ------------------------------------------------                  
  api_comment_threads_get_item                    GET      ANY      ANY    /api/comment_threads/{id}.{_format}             
  api_comments_get_collection                     GET      ANY      ANY    /api/comments.{_format}                         
  api_comments_post_collection                    POST     ANY      ANY    /api/comments.{_format}                         
  api_comments_get_item                           GET      ANY      ANY    /api/comments/{id}.{_format}                    

After :

 ----------------------------------------------------------- -------- -------- ------ ------------------------------------------------ 
  Name                                                        Method   Scheme   Host   Path                                            
 ----------------------------------------------------------- -------- -------- ------ ------------------------------------------------                                  
  _api_/comments/{id}.{_format}_get                           GET      ANY      ANY    /api/comments/{id}.{_format}                    
  _api_/comments.{_format}_get_collection                     GET      ANY      ANY    /api/comments.{_format}                         
  _api_/comments.{_format}_post                               POST     ANY      ANY    /api/comments.{_format}                         
  _api_/comment_threads/{id}.{_format}_get                    GET      ANY      ANY    /api/comment_threads/{id}.{_format}             

How to reproduce
Have some entities in 2.6.8 then upgrade to 2.7.0
Run each time : bin/console debug:router

Possibile workaround
Add name property in each operations and name it as API plateform did before.

@soyuka
Copy link
Member

soyuka commented Sep 29, 2022

With the metadata backward compatibility flag to true?

@Cryde
Copy link
Author

Cryde commented Sep 30, 2022

@soyuka

In 2.7 with the flag set to true but without migrating operations to the new way : it works
But if I migrate the operation and let the flag to true : not working

Why this behavior has change ? Is it something that will come back ?

@norkunas
Copy link
Contributor

norkunas commented Oct 6, 2022

Same here. api route names are different with new metadata system BUT ALSO metadata backward compatibility is false.

@Cryde
Copy link
Author

Cryde commented Oct 8, 2022

I've seen a strange behavior (I don't know if it's normal or not)

When I define operation like this (and define a name for the route) :

#[ApiResource(operations: [
    new Get(
        name: 'api_get_item'
    )
])]

The debug:router works as expected.

But if I do it this way :

#[Get(
    name: 'api_get_item'
)]

The route name defined here is not taken into account.
It will be something like that : _api_/xxx/{slug}.{_format}_get

@Cryde
Copy link
Author

Cryde commented Nov 10, 2022

@soyuka
I will test it but I think this issue will be solve like #5082 by #5090

@stale
Copy link

stale bot commented Jan 9, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 9, 2023
@stale stale bot closed this as completed Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants