#31819: Django + Django REST Framework generates API errors with swagger -------------------------------------+------------------------------------- Reporter: drwonky | Owner: nobody Type: Bug | Status: new Component: Core | Version: 3.0 (Other) | Keywords: swagger regex Severity: Normal | javascrip rest openapi Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- The Django Validators use the syntax \Z to designate an end of line, similar to the more conventional $ marker.
This swagger ticket gives context to the following: https://github.com /swagger-api/swagger-editor/issues/1601 Javascript uses the $ as the end anchor, this has slightly different semantics to the intended \Z anchor in Python. The problem is that swagger chokes on this syntax, and looking at the code it comes directly from the Python regexes being exported to the openapi spec. I propose 2 possible solutions: 1. Change the Django regexes to use the $ anchor, this may have unintended behavior. The \Z regex is not valid as an anchor in Javascript. 2. Run all of the python regexes through a simple replace, changing \Z for $ I'm open to any other suggestions, but as I see it now, the yaml produced from Django regexes is not compliant with Javascript and javascript validators by extension. I can manually edit yaml files, but I'd like to have a dynamic API endpoint for schema definitions. -- Ticket URL: <https://code.djangoproject.com/ticket/31819> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.d5e8d90a630e4a70f203b12c74ef1104%40djangoproject.com.