-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Python client code improperly escaping regex strings #1517
Labels
Comments
After a little more testing, it appears the problem is not just limited to |
Raznic
added a commit
to Raznic/openapi-generator
that referenced
this issue
Nov 24, 2018
* Override PythonClientCodegen toRegularExpression() method to correct issue with backslashes being escaped. This issue was a result of calling escapeText() in the parent DefaultCodegen class.
4 tasks
cbornet
added a commit
to cbornet/openapi-generator
that referenced
this issue
Nov 29, 2018
4 tasks
wing328
pushed a commit
that referenced
this issue
Nov 30, 2018
wing328
pushed a commit
that referenced
this issue
Dec 8, 2018
* Fix escaped regex values in Python client (#1517). * Override PythonClientCodegen toRegularExpression() method to correct issue with backslashes being escaped. This issue was a result of calling escapeText() in the parent DefaultCodegen class. * Only escape unescaped forward slashes in PythonClientCodegen. * Override addRegularExpressionDelimiter in PythonClientCodegen.java such that only unescaped forward slashes in the pattern get escaped. * Adds a new test resource .yaml file for specifically testing this issue. * Check for regular expression modifiers in PythonClientCodegen. * Adds check in postProcessPattern() in PythonClientCodegen.java to check if regular expression has modifiers defined. If so, it throws an exception as modifiers are not currently supported in the Python client. * PythonClientCodegen warns that regex modifiers are not supported. * Changes behavior in PythonClientCodegen.java to no longer throw an IllegalArgumentException in the case that a pattern contains modifiers. A warning message will be logged instead stating that modifiers are not currently supported by the codegen class. * Remove warning for PythonClientCodegen regex modifier support. * Removes warning message from PythonClientCodegen.java stating that regular expression modifiers are not currently supported. Further code review and testing revealed that this feature is already supported and working. * Add updated Python client sample files.
A-Joshi
pushed a commit
to ihsmarkitoss/openapi-generator
that referenced
this issue
Feb 27, 2019
A-Joshi
pushed a commit
to ihsmarkitoss/openapi-generator
that referenced
this issue
Feb 27, 2019
…PITools#1539) * Fix escaped regex values in Python client (OpenAPITools#1517). * Override PythonClientCodegen toRegularExpression() method to correct issue with backslashes being escaped. This issue was a result of calling escapeText() in the parent DefaultCodegen class. * Only escape unescaped forward slashes in PythonClientCodegen. * Override addRegularExpressionDelimiter in PythonClientCodegen.java such that only unescaped forward slashes in the pattern get escaped. * Adds a new test resource .yaml file for specifically testing this issue. * Check for regular expression modifiers in PythonClientCodegen. * Adds check in postProcessPattern() in PythonClientCodegen.java to check if regular expression has modifiers defined. If so, it throws an exception as modifiers are not currently supported in the Python client. * PythonClientCodegen warns that regex modifiers are not supported. * Changes behavior in PythonClientCodegen.java to no longer throw an IllegalArgumentException in the case that a pattern contains modifiers. A warning message will be logged instead stating that modifiers are not currently supported by the codegen class. * Remove warning for PythonClientCodegen regex modifier support. * Removes warning message from PythonClientCodegen.java stating that regular expression modifiers are not currently supported. Further code review and testing revealed that this feature is already supported and working. * Add updated Python client sample files.
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I've got a web server running Django + REST Framework that I am trying to generate Python client code for. One of my Serializers defines a RegexField that includes
\d
as a part of the regular expression. The generator appears to be escaping these characters in the generated client code.Serializer regex:
r'^\d$'
Actual Python client code:
re.search(r'^\\d$', value)
Expected Python client code:
re.search(r'^\d$', value)
openapi-generator version
I've pulled the latest from
master
and the version shows as3.3.4-SNAPSHOT
.OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Generate Python client code.
Try to create a model.
Related issues/PRs
#1392
Suggest a fix/enhancement
My Java is pretty rusty, but I would assume the fix for the Python client would be similar to the one for the Ruby client from the related issue/PR.
The text was updated successfully, but these errors were encountered: