Skip to content

Commit

Permalink
Merge branch 'master' into issue-1173
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMario authored Dec 3, 2023
2 parents d807fb9 + b52a470 commit 6cdbcfa
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-generators</artifactId>
<version>1.0.45</version>
<version>1.0.46-SNAPSHOT</version>
<packaging>jar</packaging>

<build>
Expand Down Expand Up @@ -262,7 +262,7 @@
</dependencies>
<properties>
<maven.compiler.release>8</maven.compiler.release>
<swagger-codegen-version>3.0.51</swagger-codegen-version>
<swagger-codegen-version>3.0.52-SNAPSHOT</swagger-codegen-version>
<swagger-parser-version>2.1.19</swagger-parser-version>
<swagger-core-version>2.2.19</swagger-core-version>
<jackson-version>2.15.3</jackson-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -2338,6 +2339,9 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
} else {
codegenResponse.baseType = codegenProperty.baseType;
}
if (isFileTypeSchema(responseSchema)) {
codegenResponse.getVendorExtensions().put(CodegenConstants.IS_FILE_EXT_NAME, Boolean.TRUE);
}
}
codegenResponse.dataType = codegenProperty.datatype;

Expand Down Expand Up @@ -4412,6 +4416,21 @@ protected void setParameterJson(CodegenParameter codegenParameter, Schema parame
codegenParameter.isJson = true;
}
}

protected boolean isFileTypeSchema(Schema schema) {
final Schema fileTypeSchema;
if (StringUtils.isNotBlank(schema.get$ref())) {
fileTypeSchema = OpenAPIUtil.getSchemaFromRefSchema(schema, openAPI);
} else {
fileTypeSchema = schema;
}
if (fileTypeSchema.getProperties() != null) {
final Collection<Schema> propertySchemas = fileTypeSchema.getProperties().values();
return propertySchemas.stream().anyMatch(propertySchema -> "string".equalsIgnoreCase(propertySchema.getType())
&& "binary".equalsIgnoreCase(propertySchema.getFormat()));
}
return false;
}

@Override
public boolean needsUnflattenedSpec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import javax.ws.rs.core.SecurityContext;
{{/jakarta}}
{{#useBeanValidation}}
{{#jakarta}}
import javax.validation.constraints.*;
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/handlebars/JavaVertXServer/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import java.io.Serializable;
{{/serializableModel}}
{{#useBeanValidation}}
{{#jakarta}}
import javax.validation.constraints.*;
import javax.validation.Valid;
import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/handlebars/python/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):

:return: The token for basic HTTP authentication.
"""
return urllib3.util.make_headers(
basic_auth=self.username + ':' + self.password
).get('authorization')
token = ""
if self.username or self.password:
token = urllib3.util.make_headers(
basic_auth=self.username + ':' + self.password
).get('authorization')
return token

def auth_settings(self):
"""Gets Auth Settings dict for api client.
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/handlebars/python/rest.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class RESTResponse(io.IOBase):

def getheaders(self):
"""Returns a dictionary of the response headers."""
return self.urllib3_response.getheaders()
return self.urllib3_response.headers

def getheader(self, name, default=None):
"""Returns a given response header."""
return self.urllib3_response.getheader(name, default)
return self.urllib3_response.headers.get(name, default)


class RESTClientObject(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BaseAPI {
* @extends {Error}
*/
export class RequiredError extends Error {
name: "RequiredError"
name = "RequiredError"
constructor(public field: string, msg?: string) {
super(msg);
}
Expand Down

0 comments on commit 6cdbcfa

Please sign in to comment.