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

" in JSON values are not escaped correctly #719

Closed
kylef opened this issue Jun 21, 2019 · 0 comments · Fixed by #721
Closed

" in JSON values are not escaped correctly #719

kylef opened this issue Jun 21, 2019 · 0 comments · Fixed by #721
Labels

Comments

@kylef
Copy link
Member

kylef commented Jun 21, 2019

Given the following API Blueprint, with an MSON property href":

# API Name

## GET /

+ Response 200 (application/json)
    + Attributes
        + `href"`

The final parse result contains a JSON String:

"{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"href\"\": {\n      \"type\": \"string\"\n    }\n  }\n}"

Note the " is not correctly escaped (\"href\"\") it should be escaped an extra time inside the key quotes.

$ ./bin/drafter dd.apib -f json | jq .content[0].content[0].content[0].content[0].content[1].content[2].content
"{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"href\"\": {\n      \"type\": \"string\"\n    }\n  }\n}"

$ ./bin/drafter dd.apib -f json | jq .content[0].content[0].content[0].content[0].content[1].content[2].content -r
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "href"": {
      "type": "string"
    }
  }
}

$ ./bin/drafter dd.apib -f json | jq .content[0].content[0].content[0].content[0].content[1].content[2].content -r | jq
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 6, column 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant