-
-
Notifications
You must be signed in to change notification settings - Fork 486
uuidstr url converter instead of shadowing django uuid #1453
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
Conversation
ninja/router.py
Outdated
@@ -320,6 +320,13 @@ def add_api_operation( | |||
include_in_schema: bool = True, | |||
openapi_extra: Optional[Dict[str, Any]] = None, | |||
) -> None: | |||
if "{uuid:" in path: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think a regex based check would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@baseplate-admin good question...
wondering if django allows doing stuff like /path/<UUID:var>
(case insensitive) or /path/< uuid :var>
(space)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think django allows that.
By default, Django's URL dispatcher is case-sensitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But i still think that regex based check is far better. It helps with edge cases.
For example what if someone does: {uuid::
// Note the double ":"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, just in case replaced it with ignore case regex
Before django ninja shadowed django's uuid to be able to to get string value from url:
Now added custom converted
uuidstr
django 6.0 will not allow shadowing
addresses #1452 #1266