Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python swagger client set host and port

How should you specify host and port in the python client library auto-generated by swagger-codegen?

The only documentation that I found is here.

like image 220
Daniel Kats Avatar asked Dec 18 '22 00:12

Daniel Kats


1 Answers

Bit of an old one but since this is where I landed first when searching, I'll provide my solution:

configuration = swagger_client.Configuration()
configuration.host = 'http://127.0.0.1:8000'
api_client = swagger_client.ApiClient(configuration=configuration)
api_instance = swagger_client.DefaultApi(api_client=api_client)

But since the configuration gets hard coded, for our project I'll likely end up having a different client for different environments (staging, prod etc).

like image 174
fquinner Avatar answered Dec 27 '22 01:12

fquinner