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

Dashes in nicknames are replaced with underscores #1303

Closed
ghost opened this issue May 21, 2015 · 3 comments
Closed

Dashes in nicknames are replaced with underscores #1303

ghost opened this issue May 21, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented May 21, 2015

For example if the nickname of my resource is add-pet, I'd see it in the UI as add_pet. In the raw JSON, nickname: add-pet. Also <> is being scrubbed, so I want something with enum like add-pet-<type>, it shows up as add_pet_type. Where is this happening?

@webron
Copy link
Contributor

webron commented May 21, 2015

Where do you see it?

@ghost
Copy link
Author

ghost commented May 21, 2015

I added code to include the resource-title (aka nickname) in the resource listings. In operation.handlebars:

<ul class='operations' >
    <li class='{{method}} operation' id='{{parentId}}_{{nickname}}'>
      <div class='heading'>
          <div class='resource-title-bar'>
            <span class='resource-title'>
              <a href='#!/{{parentId}}/{{nickname}}' class="resource-title toggleOperation {{#if deprecated}}deprecated{{/if}}"><strong>{{nickname}}</strong></a>
            </span>
          </div>
        <h3>
          <span class='http_method'>
          <a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{method}}</a>
          </span>
          <span class='path'>
          <a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation {{#if deprecated}}deprecated{{/if}}">{{path}}</a>
          </span>
        </h3>

@ghost
Copy link
Author

ghost commented May 21, 2015

Found it. It's in swagger-client.js:

SwaggerResource.prototype.sanitize = function (nickname) {
  var op;
  op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
  op = op.replace(/((_){2,})/g, '_');
  op = op.replace(/^(_)*/g, '');
  op = op.replace(/([_])*$/g, '');
  return op;
};

o.nickname = this.sanitize(o.nickname);

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

No branches or pull requests

1 participant