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

Implement implicit reverse url name generation #361

Merged
merged 2 commits into from
Jun 26, 2022

Conversation

SmileyChris
Copy link
Contributor

Fixes #355

Huh, I had assumed this is how it worked anyway.

@vitalik
Copy link
Owner

vitalik commented Jun 14, 2022

Hi @SmileyChris

Just wondering what would be the best approach when url is the same for get/post methods

@api.post('/tasks')
def create_task(request):
     pass

@api.get('/tasks')
def list_tasks(request):
     pass

As I understand the last added name ("list_tasks") will be the name for that path (while some users might expect it to be create_task)

also there might be conflicts - if users have the same function name (like list_items) in multiple modules/routers...

maybe the best approach is to generarate url name (and open api operation_id) based on tags and function name

f.e.

@router.get('/')
def list_tasks(request):
    return ...


....

api.add_router('/tasks/', router, tags=['tasks'])

the resulting url name should be api-1.0.0:tasks:list_tasks (the "tasks" taken from the first tag assigned to router)

@SmileyChris
Copy link
Contributor Author

SmileyChris commented Jun 14, 2022 via email

vitalik added a commit that referenced this pull request Jun 26, 2022
@vitalik vitalik merged commit a59085f into vitalik:master Jun 26, 2022
vitalik added a commit that referenced this pull request Jun 26, 2022
vitalik added a commit that referenced this pull request Jun 26, 2022
duducp pushed a commit to duducp/django-ninja that referenced this pull request Sep 18, 2022
duducp pushed a commit to duducp/django-ninja that referenced this pull request Sep 18, 2022
duducp pushed a commit to duducp/django-ninja that referenced this pull request Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Reverse url names are not auto generated
2 participants