add colllectionFormat support to retrofit

Fix #1364
This commit is contained in:
cbornet
2015-10-11 00:18:10 +02:00
parent 084e7f7199
commit 71c5160739
11 changed files with 215 additions and 3 deletions

View File

@@ -7,7 +7,8 @@ import java.util.List;
public class CodegenParameter {
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam, isBinary;
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer,
secondaryParam, isBinary, isCollectionFormatMulti;
public String baseName, paramName, dataType, collectionFormat, description, baseType, defaultValue;
public String jsonSchema;
public boolean isEnum;
@@ -33,6 +34,7 @@ public class CodegenParameter {
output.paramName = this.paramName;
output.dataType = this.dataType;
output.collectionFormat = this.collectionFormat;
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
output.description = this.description;
output.baseType = this.baseType;
output.isFormParam = this.isFormParam;

View File

@@ -1205,6 +1205,9 @@ public class DefaultCodegen {
p._enum = model._enum;
p.allowableValues = model.allowableValues;
p.collectionFormat = collectionFormat;
if(collectionFormat != null && collectionFormat.equals("multi")) {
p.isCollectionFormatMulti = true;
}
p.paramName = toParamName(qp.getName());
if (model.complexType != null) {

View File

@@ -218,6 +218,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
} else if ("retrofit".equals(getLibrary())) {
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
} else {
supportingFiles.add(new SupportingFile("TypeRef.mustache", invokerFolder, "TypeRef.java"));
}