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

Operation IDs have ugly prefixes that change across runs #79

Closed
shmulvad opened this issue May 22, 2024 · 4 comments
Closed

Operation IDs have ugly prefixes that change across runs #79

shmulvad opened this issue May 22, 2024 · 4 comments

Comments

@shmulvad
Copy link

Problem

Django Ninja JWT does not explicitly set the operation ID parameter, so it is partially auto-generated. When the OpenAPI schema is generated, this results in ugly names for the operation IDs like 99fab5a9_controller_refresh_token and 1ba7e0e7_controller_verify_token and so on. I would also argue that controller is an implementation detail and should not be a part of the name. My preferred operation IDs would simply refresh_token, verify_token and so on, very similar to what is already defined for the url_name.

You could argue that these ugly operation IDs might not be a problem, but the reason I care is that I use codegen tools to generate a TypeScript schema for my frontend. The naming of the generated methods are based on the operation IDs, so this is a big issue. Also, the prefix seems to not be consistent across runs but change, which is an issue when re-running the codegen.

Proposed Solution

Explicitly set the operation_id parameter for TokenObtainPairController, AsyncTokenObtainPairController, etc. If you are worried about naming conflicts, the operation IDs could be prepended with some value the user defines in the NINJA_JWT settings.

@eadwinCode
Copy link
Owner

@shmulvad Sorry for late response. I think what your proposal make sense. I will look into it.

@eadwinCode
Copy link
Owner

Also, you do know that operation_id has to be unique else swagger might be calling an endpoint with similar tag

@eadwinCode
Copy link
Owner

eadwinCode commented Jul 9, 2024

This will be resolved in ninja-jwt new release. Sorry for the delay. Totally forgot about this

@eadwinCode
Copy link
Owner

This has been fixed with the new release

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

No branches or pull requests

2 participants