Operation IDs have ugly prefixes that change across runs
shmulvad opened this issue · 4 comments
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.
@shmulvad Sorry for late response. I think what your proposal make sense. I will look into it.
Also, you do know that operation_id
has to be unique else swagger might be calling an endpoint with similar tag
This will be resolved in ninja-jwt new release. Sorry for the delay. Totally forgot about this
This has been fixed with the new release