-
-
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
[BUG][Python] Single quotes in default/example string cause invalid syntax error in generated test code #5981
Closed
5 of 6 tasks
Labels
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
4 tasks
fullcircle23
added a commit
to fullcircle23/openapi-generator
that referenced
this issue
May 27, 2020
fullcircle23
added a commit
to fullcircle23/openapi-generator
that referenced
this issue
May 27, 2020
fullcircle23
added a commit
to fullcircle23/openapi-generator
that referenced
this issue
May 27, 2020
5 tasks
fullcircle23
added a commit
to fullcircle23/openapi-generator
that referenced
this issue
May 28, 2020
fullcircle23
added a commit
to fullcircle23/openapi-generator
that referenced
this issue
May 28, 2020
wing328
pushed a commit
that referenced
this issue
Jun 1, 2020
* [python][client] Fix delimiter collision (#5981) * [python][client] Fix delimiter collision (#5981) update samples * [python][client] Fix delimiter collision (#5981) update samples * [python][client] Fix convert to enum var name (#5981) * [python][client] Fix convert to enum var name (#5981) update samples
wing328
added a commit
that referenced
this issue
Jun 1, 2020
jimschubert
added a commit
that referenced
this issue
Jun 2, 2020
* master: Update Generate.java (#6515) Undo PR #6451 (#6514) Minor enhancement to Python client generator's code format (#6510) [python-experimental] Quicken package loading (#6437) [Python][Client] Fix delimiter collision issue #5981 (#6451) [Java][Jersey2] add petstore integration tests (#6508) UE4 client generator fixes (#6438) Fix docs typos (#6478) [php-laravel] Show required PHP version in docs (#6502) [php-lumen] Show required PHP version in docs (#6501) [Java][Jersey2] Fix typo and script, Log enhancements, HTTP signature, deserialization (#6476) Remove deprecations 5.0 (#6060)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report Checklist
Description
Single quotes in default or example values of type string (e.g. 0xA2D2’C3B0’A2D2’C3B0) cause invalid syntax error in generated test code for Python. The error is a delimiter collision when a value containing single quote is delimited with the same quote. So in a string assignment in generated test code, the above value becomes ’0xA2D2’C3B0’A2D2’C3B0’ instead of “0xA2D2’C3B0’A2D2’C3B0”.
openapi-generator version
4.2.3, master
OpenAPI declaration file content or url
Command line used for generation
java -jar openapi-generator-cli.jar generate -g python -i example.yaml -o example-client
Steps to reproduce
Run the above command.
Expected output:
Actual output:
Related issues/PRs
#2808 #2809
Suggest a fix
PythonClientCodegen.java
.Line 683 (method
toDefaultValue
):Current:
return "'" + ((String) p.getDefault()).replaceAll("'", "\'") + "'";
Change to:
return "\"" + p.getDefault() + "\"";
Line 727 (method
toExampleValueRecursive
):Current:
example = "'" + example + "'";
Change to:
example = "\"" + example + "\"";
PythonClientCodegenTest.java
.The text was updated successfully, but these errors were encountered: