Skip to content
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 not escaped #2808

Closed
5 of 6 tasks
fsonntag opened this issue May 3, 2019 · 3 comments
Closed
5 of 6 tasks

[BUG][PYTHON] Single quotes not escaped #2808

fsonntag opened this issue May 3, 2019 · 3 comments

Comments

@fsonntag
Copy link
Contributor

fsonntag commented May 3, 2019

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.

@auto-labeler
Copy link

auto-labeler bot commented May 3, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@yeuser
Copy link

yeuser commented May 3, 2019

+1

@gpor0
Copy link

gpor0 commented May 5, 2019

Same issue for Java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants