watson-developer-cloud / sdk-example-editor

Web application that helps edit SDK examples from an OpenAPI file.
https://watson-developer-cloud.github.io/sdk-example-editor/
MIT License
1 stars 1 forks source link

backslash is stripped from examples #53

Closed SirSpidey closed 4 years ago

SirSpidey commented 5 years ago

Describe the bug The first backslash \ of a request example is stripped and cannot be added. I think it is stripped as soon as the file is opened in the editor, rendering all those examples incorrect.

To Reproduce Steps to reproduce the behavior:

  1. Open a definition file in YAML
  2. Paste in this example:
    curl -k -X PUT -H "Authorization: Bearer {token}" -H "cache-control: no-cache" -d "{\"description\":\"{role_description}\",\"permissions\":\"{permissions}\"}" "https://{cpd_cluster_host}{:port}/icp4d-api/v1/roles/{role_name}"

    Note that the description in the -d payload is escaped.

  3. Note that the first escaped quotation mark in description is stripped so that the output is
    curl -k -X ... -d "{"description\":\"{role_description}\",...}
  4. Try to manually enter the \. You can't

Expected behavior escaped characters are left as is

Screenshots If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

germanattanasio commented 5 years ago

Can you use ' rather than "?

germanattanasio commented 5 years ago
curl -k -X PUT -H "Authorization: Bearer {token}" -H "cache-control: no-cache" -d '{ "description": "{role_description}", "permissions": "{permissions} "}' 'https://{cpd_cluster_host}{:port}/icp4d-api/v1/roles/{role_name}'
SirSpidey commented 5 years ago

We use this syntax (and have for a while) so that it works on both Linux-based and Windows OSs. Tools should support what we want to document, not the other way around ;-)

germanattanasio commented 5 years ago

So you are saying that my example doesn't work in Windows?

SirSpidey commented 5 years ago

I'm saying that your issue is separate from this issue: that the tool doesn't fully support encoded examples.

germanattanasio commented 5 years ago

I was just suggesting a better way to do the examples that will solve the problem

watson-github-bot commented 4 years ago

:tada: This issue has been resolved in version 0.5.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: