Skip to content

Commit

Permalink
[Java][Spring] Fix for #8659 - Different in-parameter types generated…
Browse files Browse the repository at this point in the history
… for api and delegate for files (#9331)
  • Loading branch information
EmhyrVarEmreis committed Apr 26, 2021
1 parent 812d563 commit b9a1c8f
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ public void processOpts() {
}
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());

typeMapping.put("file", "org.springframework.core.io.Resource");
importMapping.put("org.springframework.core.io.Resource", "org.springframework.core.io.Resource");
typeMapping.put("file", "org.springframework.web.multipart.MultipartFile");
importMapping.put("org.springframework.web.multipart.MultipartFile", "org.springframework.web.multipart.MultipartFile");

if (useOptional) {
writePropertyBack(USE_OPTIONAL, useOptional);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class {{classname}} {
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientException {
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.web.multipart.MultipartFile>{{/collectionFormat}}{{^collectionFormat}}org.springframework.web.multipart.MultipartFile{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientException {
{{#returnType}}
return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).getBody();
{{/returnType}}
Expand Down Expand Up @@ -99,7 +99,7 @@ public class {{classname}} {
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
public ResponseEntity<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientException {
public ResponseEntity<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.web.multipart.MultipartFile>{{/collectionFormat}}{{^collectionFormat}}org.springframework.web.multipart.MultipartFile{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientException {
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
{{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class {{classname}}Test {
@Test
public void {{operationId}}Test() {
{{#allParams}}
{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.core.io.Resource>{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.Resource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}} = null;
{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection<org.springframework.web.multipart.MultipartFile>{{/collectionFormat}}{{^collectionFormat}}org.springframework.web.multipart.MultipartFile{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}} = null;
{{/allParams}}
{{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package {{configPackage}};
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
{{/useSpringfox}}
import org.springframework.stereotype.Controller;
{{^useSpringfox}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,18 +1028,18 @@ public void testRestTemplateWithUseAbstractionForFiles() throws IOException {
Path defaultApi = Paths.get(output + "/src/main/java/xyz/abcdef/api/MultipartApi.java");
TestUtils.assertFileContains(defaultApi,
//multiple files
"multipartArray(java.util.Collection<org.springframework.core.io.Resource> files)",
"multipartArrayWithHttpInfo(java.util.Collection<org.springframework.core.io.Resource> files)",
"multipartArray(java.util.Collection<org.springframework.web.multipart.MultipartFile> files)",
"multipartArrayWithHttpInfo(java.util.Collection<org.springframework.web.multipart.MultipartFile> files)",
"formParams.addAll(\"files\", files.stream().collect(Collectors.toList()));",

//mixed
"multipartMixed(org.springframework.core.io.Resource file, MultipartMixedMarker marker)",
"multipartMixedWithHttpInfo(org.springframework.core.io.Resource file, MultipartMixedMarker marker)",
"multipartMixed(org.springframework.web.multipart.MultipartFile file, MultipartMixedMarker marker)",
"multipartMixedWithHttpInfo(org.springframework.web.multipart.MultipartFile file, MultipartMixedMarker marker)",
"formParams.add(\"file\", file);",

//single file
"multipartSingle(org.springframework.core.io.Resource file)",
"multipartSingleWithHttpInfo(org.springframework.core.io.Resource file)",
"multipartSingle(org.springframework.web.multipart.MultipartFile file)",
"multipartSingleWithHttpInfo(org.springframework.web.multipart.MultipartFile file)",
"formParams.add(\"file\", file);"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -235,7 +235,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -248,11 +248,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -238,7 +238,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -251,11 +251,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -235,7 +235,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -248,11 +248,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FormatTest {
private byte[] _byte;

@JsonProperty("binary")
private org.springframework.core.io.Resource binary;
private org.springframework.web.multipart.MultipartFile binary;

@JsonProperty("date")
@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void setByte(byte[] _byte) {
this._byte = _byte;
}

public FormatTest binary(org.springframework.core.io.Resource binary) {
public FormatTest binary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
return this;
}
Expand All @@ -249,11 +249,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) {

@Valid

public org.springframework.core.io.Resource getBinary() {
public org.springframework.web.multipart.MultipartFile getBinary() {
return binary;
}

public void setBinary(org.springframework.core.io.Resource binary) {
public void setBinary(org.springframework.web.multipart.MultipartFile binary) {
this.binary = binary;
}

Expand Down
Loading

0 comments on commit b9a1c8f

Please sign in to comment.