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

Normalize URLs before executing request #180

Open
guerda opened this issue Aug 7, 2019 · 1 comment
Open

Normalize URLs before executing request #180

guerda opened this issue Aug 7, 2019 · 1 comment

Comments

@guerda
Copy link

guerda commented Aug 7, 2019

I'm using a Swagger API which is out of my control and has the basePath incorrectly set with a trailing /.
This causes pyswagger to request a URL which has a double slash in the URL part. Spring Boot (hosting the service) prevents this and declines the request immediately, which leads to an error message if I want to execute a call:

b'{"timestamp":1565196246823,"status":500,"error":"Internal Server Error","exception":"org.springframework.security.web.firewall.RequestRejectedException","message":"The request was rejected because the URL was not normalized.","path":"/search//v1/search"}'

Would it be possible to normalize the URL before executing the request?
as far as I understood, the initial load of the OpenAPI spec is normalized (core.py, line 283). https://github.com/pyopenapi/pyswagger/blob/develop/pyswagger/core.py#L283

I could imagine that this would fix some errors in URLs.

Thanks in advance for your help!

@jroeland
Copy link

I am having the same issue as well.
Here is how to reproduce it with the example schema:

from pyswagger import App 
from pyswagger.contrib.client.requests import Client
app = App.create('http://petstore.swagger.io/v2/swagger.json')
client = Client()
resp = client.request(app.op['getInventory']())
print(resp._Response__url)
# out: '//petstore.swagger.io/v2/store/inventory'

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