I've configured DRF with NamespaceVersioning, and when I load the SWAGGER view of my API, I get the following error:
django.core.exceptions.ImproperlyConfigured: "books(/?|/(?P<response_format>[^/]+)$" is not a valid regular expression: missing ), unterminated subpattern at position 5
So after debugging the code, I've found that drf-spectacular modifies the url patterns by detype_patterns(patterns) method in plumbing.py if NamespaceVersioning is enabled in DRF. That method uses the method analyze_named_regex_pattern(path) for extracting the regex inside the named groups. The issue is that this last method is not extracting correctly the regex inside the named group, because giving my original url path:
books(/?|/(?P<response_format>(basic|standard|extended))/?)$
it extracts (basic|standard|extended))/? as the regex inside the named groud, when the correct regex would be just (basic|standard|extended). So that is what is causing the incorrect regex error, because more characters than needed are being replaced.
Anyway, what is the purpose of detype_patterns(patterns) ? I don't want my url paths to be modified. Is there a way to disable this method by a flag or similar?
I've configured DRF with NamespaceVersioning, and when I load the SWAGGER view of my API, I get the following error:
django.core.exceptions.ImproperlyConfigured: "books(/?|/(?P<response_format>[^/]+)$" is not a valid regular expression: missing ), unterminated subpattern at position 5So after debugging the code, I've found that drf-spectacular modifies the url patterns by
detype_patterns(patterns)method inplumbing.pyif NamespaceVersioning is enabled in DRF. That method uses the methodanalyze_named_regex_pattern(path)for extracting the regex inside the named groups. The issue is that this last method is not extracting correctly the regex inside the named group, because giving my original url path:books(/?|/(?P<response_format>(basic|standard|extended))/?)$it extracts
(basic|standard|extended))/?as the regex inside the named groud, when the correct regex would be just(basic|standard|extended). So that is what is causing the incorrect regex error, because more characters than needed are being replaced.Anyway, what is the purpose of
detype_patterns(patterns)? I don't want my url paths to be modified. Is there a way to disable this method by a flag or similar?