swagger-api / swagger-api/swagger-codegen
[Python] TypeError: __init__() got an unexpected keyword argument 'encode_multipart'
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When calling a DELETE API that has consumes = "application/x-www-form-urlencoded", I get the error in the subject.
Swagger-codegen version
2.3.1
Swagger declaration file content or url
...
"delete": {
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "successful response",
"schema": {
"$ref": "#/definitions/MyResponse"
}
}
},
"parameters": [
{
"description": "User identifier",
"required": true,
"type": "string",
"name": "user",
"in": "path"
},
{
"description": "List of file names to delete",
"items": {
"type": "string"
},
"required": true,
"collectionFormat": "csv",
"in": "path",
"type": "array",
"name": "fileNames"
}
],
"description": "Deletes files for a user",
"summary": "Delete Files",
"operationId": "deleteFiles"
}
Command line used for generation
swagger-codegen generate -i "https://my-url" -l python -o "/my-path" -DpackageName=my_project -DprojectName=my-project
using python 2.7.10, with urllib3 1.22, on Mac OS 10.13.
Steps to reproduce
My code calls something like user_api.delete_files('johndoe', ['foo']). It prints this error:
Traceback (most recent call last):
File "examples.py", line 41, in <module>
user_api.delete_files('johndoe', ['foo'])
File "build/bdist.macosx-10.13-intel/egg/my_project/api/user_api.py", line 1245, in delete_tags
File "build/bdist.macosx-10.13-intel/egg/my_project/api/user_api.py", line 1331, in delete_tags_with_http_info
File "build/bdist.macosx-10.13-intel/egg/my_project/api_client.py", line 322, in call_api
File "build/bdist.macosx-10.13-intel/egg/my_project/api_client.py", line 153, in __call_api
File "build/bdist.macosx-10.13-intel/egg/my_project/api_client.py", line 388, in request
File "build/bdist.macosx-10.13-intel/egg/my_project/rest.py", line 265, in DELETE
File "build/bdist.macosx-10.13-intel/egg/my_project/rest.py", line 175, in request
File "/Library/Python/2.7/site-packages/urllib3/request.py", line 66, in request
**urlopen_kw)
File "/Library/Python/2.7/site-packages/urllib3/request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/Library/Python/2.7/site-packages/urllib3/poolmanager.py", line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/Library/Python/2.7/site-packages/urllib3/connectionpool.py", line 617, in urlopen
**response_kw)
File "/Library/Python/2.7/site-packages/urllib3/response.py", line 467, in from_httplib
**response_kw)
TypeError: __init__() got an unexpected keyword argument 'encode_multipart'
Related issues/PRs
N/A
Suggest a fix/enhancement
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated rest.py DELETE/request path and api_client.py call_api shown in the traceback, then compare how a DELETE operation with application/x-www-form-urlencoded is passed to urllib3. Reproduce the failure with the supplied delete_files example and verify that the generated client completes the request without the encode_multipart TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100