OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Installing swagger-client on python [closed]

  • Thread starter Thread starter Dimo Rosenov
  • Start date Start date
D

Dimo Rosenov

Guest
I'm trying to install swagger_client on python but every time I try it with pip it says it can't find it. Does anyone know if there's perhaps a different name or way I have to do it? As I need it in order to do an API call but the company uses a REST API.

I tried doing the following commands in my cmd:

Code:
pip install swagger-client
pip install swagger_client

But then I get an error "no matching distribution found for swagger_client"; it's the same for both swagger_client and swagger-client. Image of install attempt

Code I need to run (haven't changed variables values):

Code:
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: api_key
swagger_client.configuration.api_key['X-API-Token'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# swagger_client.configuration.api_key_prefix['X-API-Token'] = 'Bearer'

# create an instance of the API class
api_instance = swagger_client.UsersApi()
tenantName = tenantName_example # String | The tenant name
userId = 56 # Integer | userId to return

try: 
    # Get user by user id
    api_response = api_instance.get_user_by_id(tenantName, userId)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling UsersApi->getUserById: %s\n" % e)
<p>I'm trying to install swagger_client on python but every time I try it with pip it says it can't find it. Does anyone know if there's perhaps a different name or way I have to do it? As I need it in order to do an API call but the company uses a REST API.</p>
<p>I tried doing the following commands in my cmd:</p>
<pre><code>pip install swagger-client
pip install swagger_client
</code></pre>
<p>But then I get an error "no matching distribution found for swagger_client"; it's the same for both swagger_client and swagger-client.
<a href="https://i.sstatic.net/M6u39Eep.png" rel="nofollow noreferrer">Image of install attempt</a></p>
<p>Code I need to run (haven't changed variables values):</p>
<pre><code>from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: api_key
swagger_client.configuration.api_key['X-API-Token'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# swagger_client.configuration.api_key_prefix['X-API-Token'] = 'Bearer'

# create an instance of the API class
api_instance = swagger_client.UsersApi()
tenantName = tenantName_example # String | The tenant name
userId = 56 # Integer | userId to return

try:
# Get user by user id
api_response = api_instance.get_user_by_id(tenantName, userId)
pprint(api_response)
except ApiException as e:
print("Exception when calling UsersApi->getUserById: %s\n" % e)
</code></pre>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top