Navigation Menu

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

Don't strip href #6

Closed
john-kurkowski opened this issue Nov 25, 2015 · 4 comments
Closed

Don't strip href #6

john-kurkowski opened this issue Nov 25, 2015 · 4 comments

Comments

@john-kurkowski
Copy link

First off, I'm really happy to discover this addon. swagger-ui leaves something to be desired in SPA-land. This is a handy integration I didn't want to bootstrap myself. Thank you!

I'm having trouble with swagger-ui.js#L69-L73:

        // and remove href links that will also attempt to route us out of our known ember routes
        let anchors = that.$('#resources_container a');
        if (anchors) {
          anchors.removeAttr('href');
        }

This makes external links unclickable. Can't have the whole world in my Ember app :). I'm missing its original intent. I've deleted it in my fork, but I don't think that's the answer. Could you explain your code comment more?

Can you restore links? Or warn if they'll route you outside the app? Or make it configurable? (Not that swagger-ui needs yet another input param.)

@rynam0
Copy link
Owner

rynam0 commented Nov 25, 2015

Glad to hear someone else is giving this a go and thanks for reporting the issue.

The reason I decided to remove the href attributes inside the resources_container was that swagger-ui added hash-bang urls (as can be seen in the screenshot below). Clicking to expand/collapse the docs caused the url to update to an unknown ember route (#!/pets in the example). I don't know if this only happens when using locationType: 'hash' in environment.js but I could certainly explore that some more.

It may also be possible to remove specific href attributes leaving your external links intact. An example of a swagger.json file that demonstrates the issue would be super. If you could supply one I would be more than happy to take a look.

screen shot 2015-11-25 at 4 27 55 pm

@john-kurkowski
Copy link
Author

My use case is similar to the http://swagger.io and mailto links in your screenshot. Those hrefs are fine, left alone by ember-swagger-ui. But here's a fork of Pet Store with a link in one of the description fields, supporting GFM: Gist / raw. Its href gets stripped out.

I see your use case now. I'm using an extension of the history location type, not hash. Maybe you can refine the selector based on the above example doc. Additionally, you could only disable the links if the app is using an extension of the hash location type.

@rynam0 rynam0 closed this as completed in e4956a9 Nov 27, 2015
@rynam0
Copy link
Owner

rynam0 commented Nov 27, 2015

@john-kurkowski: Thanks for the example spec file. I'm oddly enough unable to reproduce the issue in my project after removing the code in question. I think it best not to remove the href attributes as the component could be extended to remove problematic hrefs if needed. I don't think this component should make assumptions and remove them by default. Thanks again for reporting this.

@john-kurkowski
Copy link
Author

That works too! Thanks!

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

2 participants