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

Example does not work with remote swagger json file #3

Open
mpetyx opened this issue Mar 28, 2014 · 4 comments
Open

Example does not work with remote swagger json file #3

mpetyx opened this issue Mar 28, 2014 · 4 comments

Comments

@mpetyx
Copy link

mpetyx commented Mar 28, 2014

Hello,
I really liked the idea of this project, but I am not yet able to run the example code.

I am trying to execute:

import json

from swaggerpy.client import SwaggerClient
from swaggerpy.http_client import SynchronousHttpClient

http_client = SynchronousHttpClient()
http_client.set_basic_auth('swagger.wordnik.com', 'hey', 'peekaboo')

ari = SwaggerClient(
    # "http://localhost:8088/ari/api-docs/resources.json",
    "http://swagger.wordnik.com/#!/pet.json",
    http_client=http_client)

but i get this:

Traceback (most recent call last):
  File "/path/swaggerToObject.py", line 16, in <module>
    http_client=http_client)
  File "/Library/Python/2.7/site-packages/swaggerpy/client.py", line 178, in __init__
    self.api_docs = loader.load_resource_listing(url_or_resource)
  File "/Library/Python/2.7/site-packages/swaggerpy/swagger_model.py", line 161, in load_resource_listing
    resource_listing = json_load_url(self.http_client, resources_url)
  File "/Library/Python/2.7/site-packages/swaggerpy/swagger_model.py", line 122, in json_load_url
    resp = http_client.request('GET', url)
  File "/Library/Python/2.7/site-packages/swaggerpy/http_client.py", line 178, in request
    return self.session.send(self.session.prepare_request(req))
AttributeError: 'Session' object has no attribute 'prepare_request'

Any ideas?
Thank you very much!

@yunw
Copy link

yunw commented Apr 19, 2014

I also have problem to try out the sample. Which I got is:

Traceback (most recent call last):
File "path/swagger-py/sample.py", line 5, in
from swaggerpy.client import SwaggerClient
File "path/swaggerpy/init.py", line 13, in
from swagger_model import load_file, load_json, load_url, Loader
ImportError: No module named 'swagger_model'

Can someone help out too? Thanks very much

@ghost
Copy link

ghost commented May 19, 2015

I have the same problem too!
C:\Python34\python.exe D:/strikersoft_git/crowdsoft-test/web-api-tests/api-loadtests/tmp.py
Traceback (most recent call last):
File "D:/strikersoft_git/crowdsoft-test/web-api-tests/api-loadtests/tmp.py", line 1, in
from swaggerpy import client
File "C:\Python34\lib\site-packages\swaggerpy__init__.py", line 13, in
from swagger_model import load_file, load_json, load_url, Loader
ImportError: No module named 'swagger_model'

Process finished with exit code 1

@s-hoviegar
Copy link

I have the same problem. I tried to install swaggerpy with command pip install swaggerpy, but it says it's already installed. These codes are obsolete and out of date there are many problems in them.

@DIMON1702
Copy link

DIMON1702 commented Feb 9, 2020

I got rid of errors when I commented out these 2 lines in __init__.py

# from swagger_model import load_file, load_json, load_url, Loader
# from processors import SwaggerProcessor, SwaggerError

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

4 participants