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

python: invalid code due to comments starting or ending with double quotes #1239

Open
russaa opened this issue May 23, 2019 · 1 comment
Open
Labels
bug good first issue Not necessarily easy, but doesn't require deep quicktype knowledge Python Python Output

Comments

@russaa
Copy link

russaa commented May 23, 2019

when generating python code, the generated syntax becomes invalid if there are comments (i.e. "description" fields in the JSON schema) that start or end with double quotes

Example

for the JSON schema fragment:

"properties": {
  "type": {
    "description": "type is \"output\"",
    "minLength": 1,
    "oneOf": [
	  {
	    "$ref": "#/definitions/MessageType"
	  }
    ]
  },

the generated (invalid) python 3.7 code fragment is

"""type is "output""""
type: MessageType

Solution

the generator for python should check the first and last character of a documentation-comment (i.e. the "description" field value) -- and if this is the case, the emitted code should "escape" these characters (e.g. prepend/append a newline or space character)

@nithin-sudarsan
Copy link

nithin-sudarsan commented Sep 30, 2024

@russaa @inferrinizzard please check the above PR and I would appreciate it if you could take some time to review the changes and provide feedback when convenient.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Not necessarily easy, but doesn't require deep quicktype knowledge Python Python Output
Projects
None yet
Development

No branches or pull requests

3 participants