Skip to content

Commit

Permalink
Merge pull request #10957 from swagger-api/goDeni-issue-10948
Browse files Browse the repository at this point in the history
Go deni issue 10948
  • Loading branch information
HugoMario authored Mar 28, 2021
2 parents 7d8ec67 + 3a9fd55 commit e5ef6cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public static final String PACKAGE_URL = "packageUrl";
public static final String DEFAULT_LIBRARY = "urllib3";

public static final String WRITE_BINARY_OPTION = "writeBinary";

protected String packageName; // e.g. petstore_api
protected String packageVersion;
protected String projectName; // for setup.py, e.g. petstore-api
Expand Down Expand Up @@ -174,6 +176,11 @@ public void processOpts() {
setPackageVersion("1.0.0");
}

if (additionalProperties.containsKey(WRITE_BINARY_OPTION)) {
boolean optionValue = Boolean.parseBoolean(String.valueOf(additionalProperties.get(WRITE_BINARY_OPTION)));
additionalProperties.put(WRITE_BINARY_OPTION, optionValue);
}

additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ class ApiClient(object):
content_disposition).group(1)
path = os.path.join(os.path.dirname(path), filename)

with open(path, "wb") as f:
with open(path, {{^writeBinary}}"w"{{/writeBinary}}{{#writeBinary}}"wb"{{/writeBinary}}) as f:
f.write(response.data)

return path
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/python/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.19-SNAPSHOT
2.4.20-SNAPSHOT
2 changes: 1 addition & 1 deletion samples/client/petstore/python/petstore_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def __deserialize_file(self, response):
content_disposition).group(1)
path = os.path.join(os.path.dirname(path), filename)

with open(path, "wb") as f:
with open(path, "w") as f:
f.write(response.data)

return path
Expand Down

0 comments on commit e5ef6cb

Please sign in to comment.