Skip to content

Commit e846404

Browse files
authored
Fix Python DELETE bug introduced in earlier commit
The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the standard Python generator. This commit fixes that bug and also includes the updated samples.
1 parent 69f715c commit e846404

File tree

6 files changed

+6
-6
lines changed
  • modules/openapi-generator/src/main/resources/python
  • samples
    • client/petstore
      • python/petstore_api
      • python_disallowAdditionalPropertiesIfNotPresent/petstore_api
    • openapi3/client
      • extensions/x-auth-id-alias/python/x_auth_id_alias
      • features/dynamic-servers/python/dynamic_servers
      • petstore/python/petstore_api

6 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class RESTClientObject(object):
137137
headers['Content-Type'] = 'application/json'
138138
if query_params:
139139
url += '?' + urlencode(query_params)
140-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
140+
if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
141141
request_body = None
142142
if body is not None:
143143
request_body = json.dumps(body)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def request(self, method, url, query_params=None, headers=None,
145145
headers['Content-Type'] = 'application/json'
146146
if query_params:
147147
url += '?' + urlencode(query_params)
148-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
148+
if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
149149
request_body = None
150150
if body is not None:
151151
request_body = json.dumps(body)

samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def request(self, method, url, query_params=None, headers=None,
145145
headers['Content-Type'] = 'application/json'
146146
if query_params:
147147
url += '?' + urlencode(query_params)
148-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
148+
if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
149149
request_body = None
150150
if body is not None:
151151
request_body = json.dumps(body)

samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def request(self, method, url, query_params=None, headers=None,
145145
headers['Content-Type'] = 'application/json'
146146
if query_params:
147147
url += '?' + urlencode(query_params)
148-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
148+
if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
149149
request_body = None
150150
if body is not None:
151151
request_body = json.dumps(body)

samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def request(self, method, url, query_params=None, headers=None,
145145
headers['Content-Type'] = 'application/json'
146146
if query_params:
147147
url += '?' + urlencode(query_params)
148-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
148+
if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
149149
request_body = None
150150
if body is not None:
151151
request_body = json.dumps(body)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def request(self, method, url, query_params=None, headers=None,
145145
headers['Content-Type'] = 'application/json'
146146
if query_params:
147147
url += '?' + urlencode(query_params)
148-
if re.search('json', headers['Content-Type'], re.IGNORECASE):
148+
if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
149149
request_body = None
150150
if body is not None:
151151
request_body = json.dumps(body)

0 commit comments

Comments
 (0)