From 7773b115cb890a57245f547f38e0299687389ce0 Mon Sep 17 00:00:00 2001 From: p172913 Date: Sat, 17 May 2025 20:15:21 +0530 Subject: [PATCH] TO read environment variables while using client generated by open-api-generator --- .../resources/python/configuration.mustache | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/python/configuration.mustache b/modules/openapi-generator/src/main/resources/python/configuration.mustache index 0dca8be3583a..d225fe1fd21e 100644 --- a/modules/openapi-generator/src/main/resources/python/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/python/configuration.mustache @@ -1,7 +1,7 @@ # coding: utf-8 {{>partial_header}} - +import os import copy import http.client as httplib import logging @@ -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}} self.safe_chars_for_path_param = '' """Safe chars for path_param """