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

url_scheme does not respect selected scheme when loading from local file. #178

Open
mitchellkingsley opened this issue Jul 12, 2019 · 0 comments

Comments

@mitchellkingsley
Copy link

When using a URI to specify a local swagger file on windows, client.request() throws a ValueError.

Code Run:

app = App.create('file:///C:/Users/.../api.json')
client = Client()
params = dict(param1="example_string", param2 = "example_string2")

opt = dict(url_netloc='localhost:8500', url_scheme='https')

op = app.op['ExampleTag', 'ExampleID']
req_and_resp = op(param1=params)
response = client.request(req_and_resp, opt=opt)

The reported error:

Traceback (most recent call last):
  File ".\swagger_api.py", line 12, in <module>
    response = client.request(req_and_resp)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyswagger\contrib\client\requests.py", line 39, in request
    req.prepare(scheme=self.prepare_schemes(req), handle_files=False)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyswagger\core.py", line 568, in prepare_schemes
    raise ValueError('No schemes available: {0}'.format(req.schemes))
ValueError: No schemes available: ['file']

In the swagger provided there is no scheme specified, so it seems like the standard is followed:

If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.

From looking around it seems like I should be able to specify a scheme to use via 'url_scheme' in opt. It seems like that selection isn't being honored.

If I am doing something wrong, any help would be greatly appreciated.

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