Skip to content

Commit c8c4998

Browse files
sebastien-rossetmichaelpro1
authored andcommitted
[Python experimental] Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info (OpenAPITools#6033)
* Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info * Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info
1 parent 1c59950 commit c8c4998

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed

modules/openapi-generator/src/main/resources/python/configuration.mustache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ class Configuration(object):
271271
result.debug = self.debug
272272
return result
273273

274+
def __setattr__(self, name, value):
275+
object.__setattr__(self, name, value)
276+
{{#hasHttpSignatureMethods}}
277+
if name == "signing_info" and value is not None:
278+
# Ensure the host paramater from signing info is the same as
279+
# Configuration.host.
280+
value.host = self.host
281+
{{/hasHttpSignatureMethods}}
282+
274283
@classmethod
275284
def set_default(cls, default):
276285
"""Set default instance of configuration.

samples/client/petstore/python-asyncio/petstore_api/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ def __deepcopy__(self, memo):
195195
result.debug = self.debug
196196
return result
197197

198+
def __setattr__(self, name, value):
199+
object.__setattr__(self, name, value)
200+
198201
@classmethod
199202
def set_default(cls, default):
200203
"""Set default instance of configuration.

samples/client/petstore/python-experimental/petstore_api/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ def __deepcopy__(self, memo):
199199
result.debug = self.debug
200200
return result
201201

202+
def __setattr__(self, name, value):
203+
object.__setattr__(self, name, value)
204+
202205
@classmethod
203206
def set_default(cls, default):
204207
"""Set default instance of configuration.

samples/client/petstore/python-tornado/petstore_api/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ def __deepcopy__(self, memo):
199199
result.debug = self.debug
200200
return result
201201

202+
def __setattr__(self, name, value):
203+
object.__setattr__(self, name, value)
204+
202205
@classmethod
203206
def set_default(cls, default):
204207
"""Set default instance of configuration.

samples/client/petstore/python/petstore_api/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ def __deepcopy__(self, memo):
199199
result.debug = self.debug
200200
return result
201201

202+
def __setattr__(self, name, value):
203+
object.__setattr__(self, name, value)
204+
202205
@classmethod
203206
def set_default(cls, default):
204207
"""Set default instance of configuration.

samples/openapi3/client/petstore/python-experimental/petstore_api/configuration.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ def __deepcopy__(self, memo):
246246
result.debug = self.debug
247247
return result
248248

249+
def __setattr__(self, name, value):
250+
object.__setattr__(self, name, value)
251+
if name == "signing_info" and value is not None:
252+
# Ensure the host paramater from signing info is the same as
253+
# Configuration.host.
254+
value.host = self.host
255+
249256
@classmethod
250257
def set_default(cls, default):
251258
"""Set default instance of configuration.

samples/openapi3/client/petstore/python/petstore_api/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ def __deepcopy__(self, memo):
199199
result.debug = self.debug
200200
return result
201201

202+
def __setattr__(self, name, value):
203+
object.__setattr__(self, name, value)
204+
202205
@classmethod
203206
def set_default(cls, default):
204207
"""Set default instance of configuration.

0 commit comments

Comments
 (0)