[BUG][PYTHON] Single quotes not escaped
Created by: fsonntag
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix
Description
Single quotes are not escaped and break the code. From the given example, the inline_object.py
contains this line:
def __init__(self, highlight='A text containing 'single' quotes'): # noqa: E501
.
Expected:
def __init__(self, highlight='A text containing \'single\' quotes'): # noqa: E501
or:
def __init__(self, highlight="A text containing 'single' quotes"): # noqa: E501
openapi-generator version
v4.0.0-beta3
OpenAPI declaration file content or url
{
"openapi": "3.0.0",
"info": {
"title": "Single quote example",
"version": "1.0.0"
},
"paths": {
"/example": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"highlight": {
"type": "string",
"example": "A text containing 'single' quotes"
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
-->
Command line used for generation
java -jar openapi-generator-cli-4.0.0-beta3.jar generate -i example.json -g python -o example-client
Steps to reproduce
Run the given command with the given example.
Related issues/PRs
Nothing found
Suggest a fix
Escape single quotes or use double quotes. I'm not familiar with the source code of the generator, so I can't fix it. If given a hint where put the fix, I'd be happy to open a PR.