Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2808
Closed
Open
Issue created May 03, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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.

Assignee
Assign to
Time tracking