Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] Add new R client generator #6351

Merged
merged 9 commits into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bin/r-petstore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/swagger-codegen/src/main/resources/r -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l r -o samples/client/petstore/r_test -DpackageName=petstore $@"

java $JAVA_OPTS -jar $executable $ags
10 changes: 10 additions & 0 deletions bin/windows/r-petstore.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l r -o samples\client\petstore\r

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CodegenParameter {

public String example; // example value (x-example)
public String jsonSchema;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
public boolean isString, isNumeric, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
public boolean isListContainer, isMapContainer;
public boolean isFile, notFile;
public boolean isEnum;
Expand Down Expand Up @@ -133,6 +133,7 @@ public CodegenParameter copy() {
output.isBinary = this.isBinary;
output.isByteArray = this.isByteArray;
output.isString = this.isString;
output.isNumeric = this.isNumeric;
output.isInteger = this.isInteger;
output.isLong = this.isLong;
output.isDouble = this.isDouble;
Expand Down Expand Up @@ -209,6 +210,8 @@ public boolean equals(Object o) {
return false;
if (isString != that.isString)
return false;
if (isNumeric != that.isNumeric)
return false;
if (isInteger != that.isInteger)
return false;
if (isLong != that.isLong)
Expand Down Expand Up @@ -298,6 +301,7 @@ public int hashCode() {
result = 31 * result + (example != null ? example.hashCode() : 0);
result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0);
result = 31 * result + (isString ? 13:31);
result = 31 * result + (isNumeric ? 13:31);
result = 31 * result + (isInteger ? 13:31);
result = 31 * result + (isLong ? 13:31);
result = 31 * result + (isFloat ? 13:31);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CodegenProperty implements Cloneable {
public boolean hasMore, required, secondaryParam;
public boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
public boolean isPrimitiveType, isContainer, isNotContainer;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime;
public boolean isString, isNumeric, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime;
public boolean isListContainer, isMapContainer;
public boolean isEnum;
public boolean isReadOnly = false;
Expand Down Expand Up @@ -115,6 +115,7 @@ public int hashCode()
result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode());
result = prime * result + ((hasValidation ? 13:31));
result = prime * result + ((isString ? 13:31));
result = prime * result + ((isNumeric ? 13:31));
result = prime * result + ((isInteger ? 13:31));
result = prime * result + ((isLong ?13:31));
result = prime * result + ((isFloat ? 13:31));
Expand Down Expand Up @@ -261,6 +262,9 @@ public boolean equals(Object obj) {
return false;
}

if (this.isNumeric != other.isNumeric) {
return false;
}
if (this.isInteger != other.isInteger) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CodegenResponse {
public List<Map<String, Object>> examples;
public String dataType, baseType, containerType;
public boolean hasHeaders;
public boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBoolean, isDate, isDateTime;
public boolean isString, isNumeric, isInteger, isLong, isFloat, isDouble, isByteArray, isBoolean, isDate, isDateTime;
public boolean isDefault;
public boolean simpleType;
public boolean primitiveType;
Expand Down Expand Up @@ -69,12 +69,13 @@ public boolean equals(Object o) {
return false;
if (isFile != that.isFile)
return false;
if (isNumeric != that.isNumeric)
return false;
if (schema != null ? !schema.equals(that.schema) : that.schema != null)
return false;
if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null)
return false;
return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null;

}

@Override
Expand All @@ -88,6 +89,7 @@ public int hashCode() {
result = 31 * result + (baseType != null ? baseType.hashCode() : 0);
result = 31 * result + (containerType != null ? containerType.hashCode() : 0);
result = 31 * result + (isDefault ? 13:31);
result = 31 * result + (isNumeric ? 13:31);
result = 31 * result + (simpleType ? 13:31);
result = 31 * result + (primitiveType ? 13:31);
result = 31 * result + (isMapContainer ? 13:31);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1647,19 +1647,7 @@ public CodegenProperty fromProperty(String name, Property p) {
if (p instanceof BaseIntegerProperty && !(p instanceof IntegerProperty) && !(p instanceof LongProperty)) {
BaseIntegerProperty sp = (BaseIntegerProperty) p;
property.isInteger = true;
/*if (sp.getEnum() != null) {
List<Integer> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for(Integer i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;

// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}*/
property.isNumeric = true;
}
if (p instanceof IntegerProperty) {
IntegerProperty sp = (IntegerProperty) p;
Expand All @@ -1681,6 +1669,7 @@ public CodegenProperty fromProperty(String name, Property p) {
if (p instanceof LongProperty) {
LongProperty sp = (LongProperty) p;
property.isLong = true;
property.isNumeric = true;
if (sp.getEnum() != null) {
List<Long> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
Expand Down Expand Up @@ -1732,6 +1721,7 @@ public CodegenProperty fromProperty(String name, Property p) {
if (p instanceof DoubleProperty) {
DoubleProperty sp = (DoubleProperty) p;
property.isDouble = true;
property.isNumeric = true;
if (sp.getEnum() != null) {
List<Double> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
Expand All @@ -1749,6 +1739,7 @@ public CodegenProperty fromProperty(String name, Property p) {
if (p instanceof FloatProperty) {
FloatProperty sp = (FloatProperty) p;
property.isFloat = true;
property.isNumeric = true;
if (sp.getEnum() != null) {
List<Float> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
Expand Down Expand Up @@ -2377,12 +2368,16 @@ public CodegenResponse fromResponse(String responseCode, Response response) {
r.isBoolean = true;
} else if (Boolean.TRUE.equals(cm.isLong)) {
r.isLong = true;
r.isNumeric = true;
} else if (Boolean.TRUE.equals(cm.isInteger)) {
r.isInteger = true;
r.isNumeric = true;
} else if (Boolean.TRUE.equals(cm.isDouble)) {
r.isDouble = true;
r.isNumeric = true;
} else if (Boolean.TRUE.equals(cm.isFloat)) {
r.isFloat = true;
r.isNumeric = true;
} else if (Boolean.TRUE.equals(cm.isByteArray)) {
r.isByteArray = true;
} else if (Boolean.TRUE.equals(cm.isBinary)) {
Expand Down
Loading