Skip to content

To read environment variables while using client generated by open-api-generator #21295

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8

{{>partial_header}}

import os
import copy
import http.client as httplib
import logging
Expand Down Expand Up @@ -416,6 +416,28 @@ conf = {{{packageName}}}.Configuration(
self.proxy_headers = None
"""Proxy headers
"""
self.no_proxy: Optional[str] = None
"""bypass proxy"""

{{!-- custom env‑var overrides --}}
if os.getenv("HTTPS_PROXY"): self.proxy = os.getenv("HTTPS_PROXY")
if os.getenv("https_proxy"): self.proxy = os.getenv("https_proxy")
if os.getenv("HTTP_PROXY"): self.proxy = os.getenv("HTTP_PROXY")
if os.getenv("http_proxy"): self.proxy = os.getenv("http_proxy")
if os.getenv("NO_PROXY"): self.no_proxy = os.getenv("NO_PROXY")
if os.getenv("no_proxy"): self.no_proxy = os.getenv("no_proxy")

{{#cliOptions}}
/**
* {{{description}}}
*/
{{#defaultValue}}
self.{{name}} = {{defaultValue}}
{{/defaultValue}}
{{^defaultValue}}
self.{{name}} = None
{{/defaultValue}}
{{/cliOptions}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this part about cliOptions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will assign variable with None value if we didn't provide any value to it...

self.safe_chars_for_path_param = ''
"""Safe chars for path_param
"""
Expand Down