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

Special characters in path parameters not handled correctly #117

Closed
olipratt opened this issue Apr 1, 2017 · 3 comments
Closed

Special characters in path parameters not handled correctly #117

olipratt opened this issue Apr 1, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@olipratt
Copy link
Contributor

olipratt commented Apr 1, 2017

Hi,

Firstly - thanks for creating pyswagger!

I'm having issues using URL special characters (e.g. ?, / etc.) in path parameters with pyswagger.

Do you agree pyswagger should be URL quoting these parameters with e.g. this function before making requests?

As an example, if I try out the swagger UI here and try the GET /user/{username} operation with username asd?asd, the request made is: GET http://petstore.swagger.io/v2/user/asd%3Fasd.

Now try the same thing with pyswagger, e.g.:

from pyswagger import App, Security
from pyswagger.contrib.client.requests import Client
app = App.create("http://petstore.swagger.io/v2/swagger.json")
client = Client(Security(app))
client.request(app.s('/user/{username}').get(username='asd?asd'))

and pyswagger does exactly GET /v2/user/asd?asd which is really a GET for username asd with a query parameter.

Looking at the code, I think pyswagger should be doing some quoting of path parameters around here.

pyswagger does handle query parameters correctly (I think requests is actually encoding them because they are passed to it separately, but requests can't encode the path as it's provided as one string so relies on pyswagger encoding the right parts):

...
client.request(app.s('/user/login').get(username='asd?asd', password='asd/asd'))

Results in GET /v2/user/login?username=asd%3Fasd&password=asd%2Fasd the same as if you use the swagger UI for /user/login with the same parameters.

@mission-liao
Copy link
Member

Thanks for the investigation, it's very clear. I think it's bug since every control characters in url should be escaped. The fix would be included in next release.

@mission-liao mission-liao self-assigned this Apr 1, 2017
@mission-liao mission-liao added this to the v0.8.28 milestone Apr 1, 2017
mission-liao added a commit that referenced this issue Apr 15, 2017
- #117
- also clean up for io.Request.reset
mission-liao added a commit that referenced this issue Apr 15, 2017
[fix]
missing body parameter when referenced from “parameters” field
- #116
- #119

special characters in path parameters not handled correctly
- #117

query parameter doesn't pass to Webapp2's client
- #114
@olipratt
Copy link
Contributor Author

I saw that you made a fix here and release V0.8.28 - I took that version and the fix seems to work great.

Thanks for fixing and the quick turnaround!

@mission-liao
Copy link
Member

I should update a comment in issue board directly.

mission-liao added a commit to pyopenapi/pyopenapi that referenced this issue Aug 12, 2017
mission-liao added a commit to pyopenapi/pyopenapi that referenced this issue Aug 12, 2017
[fix]
missing body parameter when referenced from “parameters” field
- pyopenapi/pyswagger#116
- pyopenapi/pyswagger#119

special characters in path parameters not handled correctly
- pyopenapi/pyswagger#117

query parameter doesn't pass to Webapp2's client
- pyopenapi/pyswagger#114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants