Skip to content

Example does not work with remote swagger json file #3

@mpetyx

Description

@mpetyx

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions