Dorthu / openapi3

A Python3 OpenAPI 3 Spec Parser
BSD 3-Clause "New" or "Revised" License
118 stars 47 forks source link

Call prepared request with env. Variable to Use http proxy #37

Open GyoOkuda opened 3 years ago

GyoOkuda commented 3 years ago

Currently, openapi3 doesn't honor HTTP_PROXY/HTTPS_PROXY environment variable. and, no another way to set http proxy / ca_bundle in openapi3.

As Described in https://github.com/psf/requests/issues/2807#issuecomment-1462910095 , to honor environment variable, environment setting dict should be taken from requests.Session.merge_environment_settings , and requests.Session.send should be called with it.

Dorthu commented 3 years ago

I believe all of these settings can be specified on the Session object directly; after #39 I think a better solution would be something like this:


def my_session_factory() -> requests.Session:
  session = requests.Session()
  session.verify = True
  session.proxy = "https://some.proxy.org"
  session.cert = ("/path/to/cert", "/path/to/key")
  return session

spec = OpenAPI(some_yaml, session_factory=my_session_factory)