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

Prevent escaping html in path params? #1637

Closed
chriskessel opened this issue Sep 30, 2015 · 9 comments
Closed

Prevent escaping html in path params? #1637

chriskessel opened this issue Sep 30, 2015 · 9 comments

Comments

@chriskessel
Copy link

I'm using swagger via the built in threescale (api service provider) stuff, so I'm not sure which ui version that maps to. I'm telling my code to generate swagger 2.0.

I've got a REST entry point that takes an "itemID" parameter and that ID has forward slash (/) characters in it. It looks something like this: 2015/09/30/14/41/18/681/mfq15U. I've defined the @path regex to interpret that as one param, not a bunch of little ones.

The problem is when I use the Swagger UI and put 2015/09/30/14/41/18/681/mfq15U into the "itemId" text box then click "Try it out!", it html escapes all the / characters and ends up creating an invalid request that looks like:

https:/foobar.com/2015%2F09%2F30%2F14%2F41%2F18%2F681%2Fmfq15U

Whereas I need it to look like this:

https://foobar.com/2015/09/30/14/41/18/681/mfq15U

Is there some way I can configure swagger UI to not escape those characters?

@fehguy
Copy link
Contributor

fehguy commented Oct 7, 2015

take a look here:

swagger-api/swagger-js#280

You'll have to undo that commit. It's not a configuration, but we could make it so with a PR if you'd like to tackle it.

@danielfosse
Copy link

sorry for a late comment but we had the same problem and I want to share the solution.
the solution is to change the regexp on @path on the rest endpoint in java to {path:[a-zA-Z0-9_/%-]*}.
This will enable the sending of a path through swagger, swagger encodes the path but jaxrs will decode it for you.

@nmalik
Copy link

nmalik commented Jul 28, 2016

were you able to solve this issue?

@webron
Copy link
Contributor

webron commented Jun 9, 2017

This should no longer be an issue with the new UI.

@webron webron closed this as completed Jun 9, 2017
@SriramZafin
Copy link

I have downloaded swagger-ui-3.4.4, but I am still running into this problem.
Is there a specific version that I need to download to prevent escaping html in my path params?

@fehguy
Copy link
Contributor

fehguy commented Nov 15, 2017

@webron can correct me as he loves to do, but I think what you're after is illegal in the OAS specification. Allowing a forward slash in your path parameter will effectively create a new operation (in the OAS world) and make your request indeterministic. So I don't expect that you'll get this addressed in swagger-ui.

I think in the 2.x branch there was a hack that allowed people to do this--it did make the behavior illegal wrt the spec though.

@SriramZafin
Copy link

I dont necessarily need user to input a slash ;

I would have a text that goes like this on the textbox by default;
{param0:{'accountName':'sample'}

Where the accountName value can be changed by the user to query the specific ones.

At the moment, when I hit the execute button, this text box value translates to %7Bparam0%3A%7B'accountName'%3A'sample'%7D

Any workarounds will be really helpful

@webron
Copy link
Contributor

webron commented Nov 15, 2017

@SriramZafin it would be better if you filed a new ticket, following the issue template to provide the details.

@SriramZafin
Copy link

#3915

Created this ticket , please have a look

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

6 participants