You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the above snippet in your OpenAPI spec, generating the python-client and try to import/run it will fail with either of the following errors until you provide an extra backslash (to escape the generated one).
Instead of '\' it should output '\\' for the {{defaultValue}} mustache template.
File "/python/your_api/models/test_param.py", line 34
escape: Optional[constr(strict=True, max_length=1, min_length=1)] = '\'
SyntaxError: unterminated string literal (detected at line 34)
File "/python/your_api/models/test_param.py", line 81
"escape": obj.get("escape") if obj.get("escape") is not None else '\',
SyntaxError: unterminated string literal (detected at line 81)
Bug Report Checklist
Description
We have got an OpenAPI specification which has a defaultValue for a String of
"\\"
(backslash).The python-nextgen (nowadays python) generator does not escape the backslash while generating the python model code on two occasions.
openapi-generator version
openapi-generator 6.6.0.0 (using the maven plugin)
OpenAPI declaration file content or url
Generation Details
Maven-Plugin using "python-nextgen"
Steps to reproduce
Using the above snippet in your OpenAPI spec, generating the python-client and try to import/run it will fail with either of the following errors until you provide an extra backslash (to escape the generated one).
Instead of
'\'
it should output'\\'
for the{{defaultValue}}
mustache template.Related issues/PRs
#15031
Suggest a fix
The following code escapes line breaks and single quotes, but not the escape char (backslash) before doing so.
AbstractPythonCodegen.java::toDefaultValue (135)
Probably better (untested):
The text was updated successfully, but these errors were encountered: