# Conflicts:
#	modules/swagger-codegen/src/main/resources/go/api.mustache
#	samples/client/petstore/go/go-petstore/pet_api.go
#	samples/client/petstore/go/go-petstore/store_api.go
#	samples/client/petstore/go/go-petstore/user_api.go
This commit is contained in:
Guo Huang 2016-05-03 10:03:48 -07:00
commit 3168de5f74
319 changed files with 9338 additions and 4574 deletions

30
bin/groovy-petstore.sh Executable file
View File

@ -0,0 +1,30 @@
#!/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 -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l groovy -o samples/client/petstore/groovy -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ 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/Javascript -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l javascript -o samples/client/petstore/javascript"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Javascript -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l javascript -o samples/client/petstore/javascript"
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

View File

@ -20,7 +20,7 @@ public class CodegenModel {
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
public List<CodegenProperty> optionalVars = new ArrayList<CodegenProperty>(); // a list of optional properties
public List<CodegenProperty> allVars;
public List<String> allowableValues;
public Map<String, Object> allowableValues;
// Sorted sets of required parameters.
public Set<String> mandatory = new TreeSet<String>();

View File

@ -133,6 +133,161 @@ public class DefaultCodegen {
return objs;
}
/**
* post process enum defined in model's properties
*
* @param objs Map of models
* @return maps of models with better enum support
*/
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
// for enum model
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
Map<String, Object> allowableValues = cm.allowableValues;
List<Object> values = (List<Object>) allowableValues.get("values");
List<Map<String, String>> enumVars = new ArrayList<Map<String, String>>();
String commonPrefix = findCommonPrefixOfVars(values);
int truncateIdx = commonPrefix.length();
for (Object value : values) {
Map<String, String> enumVar = new HashMap<String, String>();
String enumName;
if (truncateIdx == 0) {
enumName = value.toString();
} else {
enumName = value.toString().substring(truncateIdx);
if ("".equals(enumName)) {
enumName = value.toString();
}
}
enumVar.put("name", toEnumVarName(enumName, cm.dataType));
enumVar.put("value", toEnumValue(value.toString(), cm.dataType));
enumVars.add(enumVar);
}
cm.allowableValues.put("enumVars", enumVars);
}
// for enum model's properties
for (CodegenProperty var : cm.vars) {
Map<String, Object> allowableValues = var.allowableValues;
// handle ArrayProperty
if (var.items != null) {
allowableValues = var.items.allowableValues;
}
if (allowableValues == null) {
continue;
}
//List<String> values = (List<String>) allowableValues.get("values");
List<Object> values = (List<Object>) allowableValues.get("values");
if (values == null) {
continue;
}
// put "enumVars" map into `allowableValues", including `name` and `value`
List<Map<String, String>> enumVars = new ArrayList<Map<String, String>>();
String commonPrefix = findCommonPrefixOfVars(values);
int truncateIdx = commonPrefix.length();
for (Object value : values) {
Map<String, String> enumVar = new HashMap<String, String>();
String enumName;
if (truncateIdx == 0) {
enumName = value.toString();
} else {
enumName = value.toString().substring(truncateIdx);
if ("".equals(enumName)) {
enumName = value.toString();
}
}
enumVar.put("name", toEnumVarName(enumName, var.datatype));
enumVar.put("value", toEnumValue(value.toString(), var.datatype));
enumVars.add(enumVar);
}
allowableValues.put("enumVars", enumVars);
// handle default value for enum, e.g. available => StatusEnum.AVAILABLE
if (var.defaultValue != null) {
String enumName = null;
for (Map<String, String> enumVar : enumVars) {
if (toEnumValue(var.defaultValue, var.datatype).equals(enumVar.get("value"))) {
enumName = enumVar.get("name");
break;
}
}
if (enumName != null) {
var.defaultValue = toEnumDefaultValue(enumName, var.datatypeWithEnum);
}
}
}
}
return objs;
}
/**
* Returns the common prefix of variables for enum naming
*
* @param vars List of variable names
* @return the common prefix for naming
*/
public String findCommonPrefixOfVars(List<Object> vars) {
try {
String[] listStr = vars.toArray(new String[vars.size()]);
String prefix = StringUtils.getCommonPrefix(listStr);
// exclude trailing characters that should be part of a valid variable
// e.g. ["status-on", "status-off"] => "status-" (not "status-o")
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
} catch (ArrayStoreException e) {
return "";
}
}
/**
* Return the enum default value in the language specifed format
*
* @param value enum variable name
* @param datatype data type
* @return the default value for the enum
*/
public String toEnumDefaultValue(String value, String datatype) {
return datatype + "." + value;
}
/**
* Return the enum value in the language specifed format
* e.g. status becomes "status"
*
* @param value enum variable name
* @param datatype data type
* @return the sanitized value for enum
*/
public String toEnumValue(String value, String datatype) {
if ("number".equalsIgnoreCase(datatype)) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
}
}
/**
* Return the sanitized variable name for enum
*
* @param value enum variable name
* @param datatype data type
* @return the sanitized variable name for enum
*/
public String toEnumVarName(String value, String datatype) {
String var = value.replaceAll("\\W+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {
return var;
}
}
// override with any special post-processing
@SuppressWarnings("static-method")
@ -456,7 +611,7 @@ public class DefaultCodegen {
/**
* Return the Enum name (e.g. StatusEnum given 'status')
*
* @param property Codegen property object
* @param property Codegen property
* @return the Enum name
*/
@SuppressWarnings("static-method")
@ -1012,7 +1167,9 @@ public class DefaultCodegen {
ModelImpl impl = (ModelImpl) model;
if(impl.getEnum() != null && impl.getEnum().size() > 0) {
m.isEnum = true;
m.allowableValues = impl.getEnum();
// comment out below as allowableValues is not set in post processing model enum
m.allowableValues = new HashMap<String, Object>();
m.allowableValues.put("values", impl.getEnum());
Property p = PropertyBuilder.build(impl.getType(), impl.getFormat(), null);
m.dataType = getSwaggerType(p);
}
@ -1144,7 +1301,8 @@ public class DefaultCodegen {
}
}
if (p instanceof BaseIntegerProperty) {
// type is integer and without format
if (p instanceof BaseIntegerProperty && !(p instanceof IntegerProperty) && !(p instanceof LongProperty)) {
BaseIntegerProperty sp = (BaseIntegerProperty) p;
property.isInteger = true;
/*if (sp.getEnum() != null) {
@ -1210,7 +1368,8 @@ public class DefaultCodegen {
property.isByteArray = true;
}
if (p instanceof DecimalProperty) {
// type is number and without format
if (p instanceof DecimalProperty && !(p instanceof DoubleProperty) && !(p instanceof FloatProperty)) {
DecimalProperty sp = (DecimalProperty) p;
property.isFloat = true;
/*if (sp.getEnum() != null) {

View File

@ -88,7 +88,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
"Int32",
"Int64",
"Float",
"Guid",
"Guid?",
"System.IO.Stream", // not really a primitive, we include it to avoid model import
"Object")
);
@ -115,7 +115,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("list", "List");
typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
typeMapping.put("uuid", "Guid");
typeMapping.put("uuid", "Guid?");
}
public void setReturnICollection(boolean returnICollection) {
@ -203,11 +203,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
}
@Override
public String toEnumName(CodegenProperty property) {
return StringUtils.capitalize(property.name) + "Enum?";
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
@ -223,7 +218,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
}
}
}
return objs;
// process enum in models
return postProcessModelsEnum(objs);
}
@Override
@ -544,4 +540,54 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public void setSourceFolder(String sourceFolder) {
this.sourceFolder = sourceFolder;
}
@Override
public String toEnumVarName(String name, String datatype) {
String enumName = sanitizeName(name);
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");
enumName = camelize(enumName) + "Enum";
LOGGER.info("toEnumVarName = " + enumName);
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) + "Enum";
}
/*
@Override
public String toEnumName(CodegenProperty property) {
String enumName = sanitizeName(property.name);
if (!StringUtils.isEmpty(modelNamePrefix)) {
enumName = modelNamePrefix + "_" + enumName;
}
if (!StringUtils.isEmpty(modelNameSuffix)) {
enumName = enumName + "_" + modelNameSuffix;
}
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(enumName)) {
LOGGER.warn(enumName + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + enumName));
enumName = "model_" + enumName; // e.g. return => ModelReturn (after camelize)
}
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
*/
}

View File

@ -60,6 +60,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
// mapped to String as a workaround
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
@ -230,4 +231,59 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
}
}
@Override
public String toEnumValue(String value, String datatype) {
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return "\'" + escapeText(value) + "\'";
}
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
return datatype + "_" + value;
}
@Override
public String toEnumVarName(String name, String datatype) {
// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = new String(name);
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String enumName = sanitizeName(underscore(name).toUpperCase());
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public String toEnumName(CodegenProperty property) {
String enumName = toModelName(property.name) + "Enum";
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// process enum in models
return postProcessModelsEnum(objs);
}
}

View File

@ -308,75 +308,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objMap) {
Map<String, Object> objs = super.postProcessModels(objMap);
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
for (CodegenProperty var : cm.vars) {
Map<String, Object> allowableValues = var.allowableValues;
// handle ArrayProperty
if (var.items != null) {
allowableValues = var.items.allowableValues;
}
if (allowableValues == null) {
continue;
}
List<String> values = (List<String>) allowableValues.get("values");
if (values == null) {
continue;
}
// put "enumVars" map into `allowableValues", including `name` and `value`
List<Map<String, String>> enumVars = new ArrayList<Map<String, String>>();
String commonPrefix = findCommonPrefixOfVars(values);
int truncateIdx = commonPrefix.length();
for (String value : values) {
Map<String, String> enumVar = new HashMap<String, String>();
String enumName;
if (truncateIdx == 0) {
enumName = value;
} else {
enumName = value.substring(truncateIdx);
if ("".equals(enumName)) {
enumName = value;
}
}
enumVar.put("name", toEnumVarName(enumName));
enumVar.put("jsonname", value);
enumVar.put("value", value);
enumVars.add(enumVar);
}
allowableValues.put("enumVars", enumVars);
// handle default value for enum, e.g. available => StatusEnum.AVAILABLE
// HACK: strip ? from enum
if (var.datatypeWithEnum != null) {
var.vendorExtensions.put(DATA_TYPE_WITH_ENUM_EXTENSION, var.datatypeWithEnum.substring(0, var.datatypeWithEnum.length() - 1));
}
if (var.defaultValue != null) {
String enumName = null;
for (Map<String, String> enumVar : enumVars) {
if (var.defaultValue.replace("\"", "").equals(enumVar.get("value"))) {
enumName = enumVar.get("name");
break;
}
}
if (enumName != null && var.vendorExtensions.containsKey(DATA_TYPE_WITH_ENUM_EXTENSION)) {
var.defaultValue = var.vendorExtensions.get(DATA_TYPE_WITH_ENUM_EXTENSION) + "." + enumName;
}
}
}
}
return objs;
return super.postProcessModels(objMap);
}
public void setTargetFramework(String dotnetFramework) {
@ -436,18 +368,34 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
return codegenModel;
}
private String findCommonPrefixOfVars(List<String> vars) {
String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()]));
// exclude trailing characters that should be part of a valid variable
// e.g. ["status-on", "status-off"] => "status-" (not "status-o")
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
@Override
public String toEnumValue(String value, String datatype) {
if ("int?".equalsIgnoreCase(datatype) || "long?".equalsIgnoreCase(datatype) ||
"double?".equalsIgnoreCase(datatype) || "float?".equalsIgnoreCase(datatype)) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
}
}
private String toEnumVarName(String value) {
@Override
public String toEnumVarName(String value, String datatype) {
// number
if ("int?".equals(datatype) || "long?".equals(datatype) ||
"double?".equals(datatype) || "float?".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String var = value.replaceAll("_", " ");
var = WordUtils.capitalizeFully(var);
var = var.replaceAll("\\W+", "");
if (var.matches("\\d.*")) {
return "_" + var;
} else {

View File

@ -11,6 +11,7 @@ import io.swagger.models.parameters.Parameter;
import io.swagger.models.properties.*;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -89,6 +90,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
instantiationTypes.put("map", "HashMap");
typeMapping.put("date", "Date");
typeMapping.put("file", "File");
typeMapping.put("UUID", "String");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
@ -651,6 +653,28 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
return codegenModel;
}
@Override
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
objs = super.postProcessModelsEnum(objs);
String lib = getLibrary();
if (StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) {
List<Map<String, String>> imports = (List<Map<String, String>>)objs.get("imports");
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
// for enum model
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
cm.imports.add(importMapping.get("JsonValue"));
Map<String, String> item = new HashMap<String, String>();
item.put("import", importMapping.get("JsonValue"));
imports.add(item);
}
}
}
return objs;
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
if(serializeBigDecimalAsString) {
@ -696,63 +720,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
for (CodegenProperty var : cm.vars) {
Map<String, Object> allowableValues = var.allowableValues;
// handle ArrayProperty
if (var.items != null) {
allowableValues = var.items.allowableValues;
}
if (allowableValues == null) {
continue;
}
List<String> values = (List<String>) allowableValues.get("values");
if (values == null) {
continue;
}
// put "enumVars" map into `allowableValues", including `name` and `value`
List<Map<String, String>> enumVars = new ArrayList<Map<String, String>>();
String commonPrefix = findCommonPrefixOfVars(values);
int truncateIdx = commonPrefix.length();
for (String value : values) {
Map<String, String> enumVar = new HashMap<String, String>();
String enumName;
if (truncateIdx == 0) {
enumName = value;
} else {
enumName = value.substring(truncateIdx);
if ("".equals(enumName)) {
enumName = value;
}
}
enumVar.put("name", toEnumVarName(enumName));
enumVar.put("value", value);
enumVars.add(enumVar);
}
allowableValues.put("enumVars", enumVars);
// handle default value for enum, e.g. available => StatusEnum.AVAILABLE
if (var.defaultValue != null) {
String enumName = null;
for (Map<String, String> enumVar : enumVars) {
if (var.defaultValue.equals(enumVar.get("value"))) {
enumName = enumVar.get("name");
break;
}
}
if (enumName != null) {
var.defaultValue = var.datatypeWithEnum + "." + enumName;
}
}
}
}
return objs;
return postProcessModelsEnum(objs);
}
@Override
@ -848,16 +816,35 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected boolean needToImport(String type) {
return super.needToImport(type) && type.indexOf(".") < 0;
}
private static String findCommonPrefixOfVars(List<String> vars) {
/*
@Override
public String findCommonPrefixOfVars(List<String> vars) {
String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()]));
// exclude trailing characters that should be part of a valid variable
// e.g. ["status-on", "status-off"] => "status-" (not "status-o")
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
}
*/
private static String toEnumVarName(String value) {
String var = value.replaceAll("\\W+", "_").toUpperCase();
@Override
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) + "Enum";
}
@Override
public String toEnumVarName(String value, String datatype) {
// number
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
"Float".equals(datatype) || "Double".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {
@ -865,6 +852,16 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
}
}
@Override
public String toEnumValue(String value, String datatype) {
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
"Float".equals(datatype) || "Double".equals(datatype)) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
}
}
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
// This generator uses inline classes to define enums, which breaks when
// dealing with models that have subTypes. To clean this up, we will analyze

View File

@ -136,6 +136,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
// binary not supported in JavaScript client right now, using String as a workaround
typeMapping.put("ByteArray", "String"); // I don't see ByteArray defined in the Swagger docs.
typeMapping.put("binary", "String");
typeMapping.put("UUID", "String");
importMapping.clear();
@ -870,7 +871,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (allowableValues == null) {
continue;
}
List<String> values = (List<String>) allowableValues.get("values");
List<Object> values = (List<Object>) allowableValues.get("values");
if (values == null) {
continue;
}
@ -879,19 +880,19 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
List<Map<String, String>> enumVars = new ArrayList<Map<String, String>>();
String commonPrefix = findCommonPrefixOfVars(values);
int truncateIdx = commonPrefix.length();
for (String value : values) {
for (Object value : values) {
Map<String, String> enumVar = new HashMap<String, String>();
String enumName;
if (truncateIdx == 0) {
enumName = value;
enumName = value.toString();
} else {
enumName = value.substring(truncateIdx);
enumName = value.toString().substring(truncateIdx);
if ("".equals(enumName)) {
enumName = value;
enumName = value.toString();
}
}
enumVar.put("name", toEnumVarName(enumName));
enumVar.put("value", value);
enumVar.put("name", toEnumVarName(enumName, var.datatype));
enumVar.put("value",toEnumValue(value.toString(), var.datatype));
enumVars.add(enumVar);
}
allowableValues.put("enumVars", enumVars);
@ -928,22 +929,15 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return !defaultIncludes.contains(type)
&& !languageSpecificPrimitives.contains(type);
}
private static String findCommonPrefixOfVars(List<String> vars) {
/*
@Override
public String findCommonPrefixOfVars(List<String> vars) {
String prefix = StringUtils.getCommonPrefix(vars.toArray(new String[vars.size()]));
// exclude trailing characters that should be part of a valid variable
// e.g. ["status-on", "status-off"] => "status-" (not "status-o")
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
}
private static String toEnumVarName(String value) {
String var = value.replaceAll("\\W+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {
return var;
}
}
*/
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
// This generator uses inline classes to define enums, which breaks when
@ -1002,4 +996,41 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return packageName;
}
@Override
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) + "Enum";
}
@Override
public String toEnumVarName(String value, String datatype) {
return value;
/*
// number
if ("Integer".equals(datatype) || "Number".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {
return var;
}
*/
}
@Override
public String toEnumValue(String value, String datatype) {
if ("Integer".equals(datatype) || "Number".equals(datatype)) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
}
}
}

View File

@ -4,6 +4,7 @@ import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@ -12,6 +13,7 @@ import io.swagger.models.properties.*;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
import java.util.regex.Matcher;
@ -111,6 +113,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("object", "object");
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
@ -566,4 +569,57 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
p.example = example;
}
@Override
public String toEnumValue(String value, String datatype) {
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return "\'" + escapeText(value) + "\'";
}
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
return datatype + "_" + value;
}
@Override
public String toEnumVarName(String name, String datatype) {
// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = new String(name);
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String enumName = sanitizeName(underscore(name).toUpperCase());
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public String toEnumName(CodegenProperty property) {
String enumName = underscore(toModelName(property.name)).toUpperCase();
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// process enum in models
return postProcessModelsEnum(objs);
}
}

View File

@ -117,6 +117,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "File");
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
typeMapping.put("UUID", "String");
// remove modelPackage and apiPackage added by default
Iterator<CliOption> itr = cliOptions.iterator();

View File

@ -335,8 +335,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
swiftEnums.add(map);
}
codegenProperty.allowableValues.put("values", swiftEnums);
codegenProperty.datatypeWithEnum =
StringUtils.left(codegenProperty.datatypeWithEnum, codegenProperty.datatypeWithEnum.length() - "Enum".length());
codegenProperty.datatypeWithEnum = toEnumName(codegenProperty);
//codegenProperty.datatypeWithEnum =
// StringUtils.left(codegenProperty.datatypeWithEnum, codegenProperty.datatypeWithEnum.length() - "Enum".length());
// Ensure that the enum type doesn't match a reserved word or
// the variable name doesn't match the generated enum type or the
// Swift compiler will generate an error
@ -483,4 +485,59 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
public void setResponseAs(String[] responseAs) {
this.responseAs = responseAs;
}
@Override
public String toEnumValue(String value, String datatype) {
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return "\'" + escapeText(value) + "\'";
}
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
return datatype + "_" + value;
}
@Override
public String toEnumVarName(String name, String datatype) {
// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = new String(name);
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String enumName = sanitizeName(underscore(name).toUpperCase());
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public String toEnumName(CodegenProperty property) {
String enumName = underscore(toModelName(property.name)).toUpperCase();
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// process enum in models
return postProcessModelsEnum(objs);
}
}

View File

@ -1,17 +0,0 @@
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}("{{{value}}}"){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private String value;
{{{datatypeWithEnum}}}(String value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return value;
}
}

View File

@ -1,3 +0,0 @@
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
}

View File

@ -0,0 +1,20 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{datatype}} value;
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{datatype}} value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(value);
}
}

View File

@ -1,17 +0,0 @@
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}@SerializedName("{{{value}}}")
{{{name}}}("{{{value}}}"){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private String value;
{{{datatypeWithEnum}}}(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}

View File

@ -4,4 +4,4 @@
{{#allowableValues}}{{#enumVars}}
* `{{name}}` (value: `{{value}}`)
{{#enumVars}}{{/allowableValues}}
{{/enumVars}}{{/allowableValues}}

View File

@ -8,78 +8,7 @@ import com.google.gson.annotations.SerializedName;
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>libraries/okhttp-gson/enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>libraries/okhttp-gson/enumClass}}{{/items}}{{/items.isEnum}}
@SerializedName("{{baseName}}")
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}{{/isReadOnly}}
{{/vars}}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return true;{{/hasVars}}
}
@Override
public int hashCode() {
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
{{/vars}}sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
{{#model}}
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>pojo}}{{/isEnum}}
{{/model}}
{{/models}}

View File

@ -0,0 +1,20 @@
/**
* {{^description}}Gets or Sets {{name}}{{/description}}{{#description}}{{description}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{dataType}} value;
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{dataType}} value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(value);
}
}

View File

@ -0,0 +1,20 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{datatype}} value;
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{datatype}} value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(value);
}
}

View File

@ -0,0 +1,71 @@
/**
* {{#description}}{{description}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>libraries/common/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>libraries/common/modelInnerEnum}}{{/items}}{{/items.isEnum}}
@SerializedName("{{baseName}}")
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}{{/isReadOnly}}
{{/vars}}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return true;{{/hasVars}}
}
@Override
public int hashCode() {
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
{{/vars}}sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -17,9 +17,9 @@ import com.google.gson.annotations.SerializedName;
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>libraries/okhttp-gson/enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>libraries/common/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>libraries/okhttp-gson/enumClass}}{{/items}}{{/items.isEnum}}
{{>libraries/common/modelInnerEnum}}{{/items}}{{/items.isEnum}}
@SerializedName("{{baseName}}")
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
{{/vars}}

View File

@ -17,9 +17,9 @@ import com.google.gson.annotations.SerializedName;
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>libraries/okhttp-gson/enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>libraries/common/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>libraries/okhttp-gson/enumClass}}{{/items}}{{/items.isEnum}}
{{>libraries/common/modelInnerEnum}}{{/items}}{{/items.isEnum}}
@SerializedName("{{baseName}}")
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
{{/vars}}

View File

@ -6,11 +6,7 @@ import java.util.Objects;
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
{{#isEnum}}{{>enumOuterClass}}{{/isEnum}}
{{^isEnum}}{{>pojo}}{{/isEnum}}
{{#model}}
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>pojo}}{{/isEnum}}
{{/model}}
{{/models}}

View File

@ -0,0 +1,19 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{dataType}} value;
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{dataType}} value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
}

View File

@ -0,0 +1,19 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{datatype}} value;
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{datatype}} value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
}

View File

@ -1,11 +1,14 @@
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
/**
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
{{>generatedAnnotation}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>enumClass}}{{/items}}{{/items.isEnum}}
{{>modelInnerEnum}}{{/items}}{{/items.isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
{{#vars}}{{^isReadOnly}}

View File

@ -1,17 +1,24 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}
{{{name}}}({{{value}}}){{^-last}},
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}("{{{value}}}"){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/-last}}{{#-last}};
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
private {{datatype}} value;
private String value;
{{{datatypeWithEnum}}}(String value) {
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{datatype}} value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return value;
return String.valueOf(value);
}
}

View File

@ -1,17 +1,24 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}
{{{name}}}({{{value}}}){{^-last}},
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}("{{{value}}}"){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/-last}}{{#-last}};
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
private {{datatype}} value;
private String value;
{{{datatypeWithEnum}}}(String value) {
{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{datatype}} value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return value;
return String.valueOf(value);
}
}

View File

@ -3,11 +3,17 @@
* @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
* @readonly
*/{{/emitJSDoc}}
exports.{{datatypeWithEnum}} = { {{#allowableValues}}{{#enumVars}}
{{#emitJSDoc}} /**
* value: {{value}}
exports.{{datatypeWithEnum}} = {
{{#allowableValues}}
{{#enumVars}}
{{#emitJSDoc}}
/**
* value: {{{value}}}
* @const
*/
{{/emitJSDoc}} {{name}}: "{{value}}"{{^-last}},
{{/-last}}{{/enumVars}}{{/allowableValues}}
};
{{/emitJSDoc}}
"{{name}}": {{{value}}}{{^-last}},
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
};

View File

@ -15,91 +15,6 @@
}(this, function(ApiClient{{#imports}}, {{import}}{{/imports}}) {
'use strict';
{{#models}}{{#model}}{{#emitJSDoc}} /**
* The {{classname}} model module.
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
* @version {{projectVersion}}
*/
/**
* Constructs a new <code>{{classname}}</code>.{{#description}}
* {{description}}{{/description}}
* @alias module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
* @class{{#useInheritance}}{{#parent}}
* @extends {{#parentModel}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{/parentModel}}{{^parentModel}}{{#vendorExtensions.x-isArray}}Array{{/vendorExtensions.x-isArray}}{{#vendorExtensions.x-isMap}}Object{{/vendorExtensions.x-isMap}}{{/parentModel}}{{/parent}}{{#interfaces}}
* @implements module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
* @param {{.}}{{/vendorExtensions.x-all-required}}
*/
{{/emitJSDoc}} var exports = function({{#vendorExtensions.x-all-required}}{{.}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-all-required}}) {
var _this = this;
{{#parent}}{{^parentModel}}{{#vendorExtensions.x-isArray}} _this = new Array();
Object.setPrototypeOf(_this, exports);
{{/vendorExtensions.x-isArray}}{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});{{/parentModel}}
{{#interfaceModels}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});
{{/interfaceModels}}{{/useInheritance}}{{#vars}}{{#required}} _this['{{baseName}}'] = {{name}};{{/required}}
{{/vars}}{{#parent}}{{^parentModel}} return _this;
{{/parentModel}}{{/parent}} };
{{#emitJSDoc}} /**
* Constructs a <code>{{classname}}</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {{=< >=}}{module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> obj Optional instance to populate.
* @return {{=< >=}}{module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> The populated <code>{{classname}}</code> instance.
*/
{{/emitJSDoc}} exports.constructFromObject = function(data, obj) {
if (data){{! TODO: support polymorphism: discriminator property on data determines class to instantiate.}} {
obj = obj || new exports();
{{#parent}}{{^parentModel}} ApiClient.constructFromObject(data, obj, {{vendorExtensions.x-itemType}});
{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.constructFromObject(data, obj);{{/parentModel}}
{{#interfaces}} {{.}}.constructFromObject(data, obj);
{{/interfaces}}{{/useInheritance}}{{#vars}} if (data.hasOwnProperty('{{baseName}}')) {
obj['{{baseName}}']{{{defaultValueWithParam}}}
}
{{/vars}} }
return obj;
}
{{#useInheritance}}{{#parentModel}}
exports.prototype = Object.create({{classname}}.prototype);
exports.prototype.constructor = exports;
{{/parentModel}}{{/useInheritance}}
{{#vars}}{{#emitJSDoc}}
/**{{#description}}
* {{{description}}}{{/description}}
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
* @default {{{defaultValue}}}{{/defaultValue}}
*/
{{/emitJSDoc}} exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}undefined{{/defaultValue}};
{{/vars}}{{#useInheritance}}{{#interfaceModels}}
// Implement {{classname}} interface:{{#allVars}}{{#emitJSDoc}}
/**{{#description}}
* {{{description}}}{{/description}}
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
* @default {{{defaultValue}}}{{/defaultValue}}
*/
{{/emitJSDoc}} exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}undefined{{/defaultValue}};
{{/allVars}}{{/interfaceModels}}{{/useInheritance}}
{{#emitModelMethods}}{{#vars}}{{#emitJSDoc}} /**{{#description}}
* Returns {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
* @return {{{vendorExtensions.x-jsdoc-type}}}
*/
{{/emitJSDoc}} exports.prototype.{{getter}} = function() {
return this['{{baseName}}'];
}
{{#emitJSDoc}} /**{{#description}}
* Sets {{{description}}}{{/description}}
* @param {{{vendorExtensions.x-jsdoc-type}}} {{name}}{{#description}} {{{description}}}{{/description}}
*/
{{/emitJSDoc}} exports.prototype.{{setter}} = function({{name}}) {
this['{{baseName}}'] = {{name}};
}
{{/vars}}{{/emitModelMethods}}
{{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>enumClass}}{{/items}}*/{{/items.isEnum}}{{/vars}}
return exports;
{{/model}}{{/models}}}));
{{#models}}{{#model}}
{{#isEnum}}{{>partial_model_enum_class}}{{/isEnum}}{{^isEnum}}{{>partial_model_generic}}{{/isEnum}}
{{/model}}{{/models}}

View File

@ -0,0 +1,24 @@
{{#emitJSDoc}}
/**
* Enum class {{classname}}.
* @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
* @readonly
*/
{{/emitJSDoc}}
exports.{{classname}} = {
{{#allowableValues}}
{{#values}}
{{#emitJSDoc}}
/**
* value: {{{.}}}
* @const
*/
{{/emitJSDoc}}
"{{{.}}}": "{{{.}}}"{{^-last}},
{{/-last}}
{{/values}}
{{/allowableValues}}
};
return exports;
}));

View File

@ -0,0 +1,103 @@
{{#models}}{{#model}}
{{#emitJSDoc}}
/**
* The {{classname}} model module.
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
* @version {{projectVersion}}
*/
/**
* Constructs a new <code>{{classname}}</code>.{{#description}}
* {{description}}{{/description}}
* @alias module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}
* @class{{#useInheritance}}{{#parent}}
* @extends {{#parentModel}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{/parentModel}}{{^parentModel}}{{#vendorExtensions.x-isArray}}Array{{/vendorExtensions.x-isArray}}{{#vendorExtensions.x-isMap}}Object{{/vendorExtensions.x-isMap}}{{/parentModel}}{{/parent}}{{#interfaces}}
* @implements module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
* @param {{.}}{{/vendorExtensions.x-all-required}}
*/
{{/emitJSDoc}}
var exports = function({{#vendorExtensions.x-all-required}}{{.}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-all-required}}) {
var _this = this;
{{#parent}}{{^parentModel}}{{#vendorExtensions.x-isArray}} _this = new Array();
Object.setPrototypeOf(_this, exports);
{{/vendorExtensions.x-isArray}}{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});{{/parentModel}}
{{#interfaceModels}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{.}}{{/vendorExtensions.x-all-required}});
{{/interfaceModels}}{{/useInheritance}}{{#vars}}{{#required}} _this['{{baseName}}'] = {{name}};{{/required}}
{{/vars}}{{#parent}}{{^parentModel}} return _this;
{{/parentModel}}{{/parent}} };
{{#emitJSDoc}}
/**
* Constructs a <code>{{classname}}</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {{=< >=}}{module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> obj Optional instance to populate.
* @return {{=< >=}}{module:<#invokerPackage><invokerPackage>/</invokerPackage><#modelPackage><modelPackage>/</modelPackage><classname>}<={{ }}=> The populated <code>{{classname}}</code> instance.
*/
{{/emitJSDoc}}
exports.constructFromObject = function(data, obj) {
if (data){{! TODO: support polymorphism: discriminator property on data determines class to instantiate.}} {
obj = obj || new exports();
{{#parent}}{{^parentModel}} ApiClient.constructFromObject(data, obj, {{vendorExtensions.x-itemType}});
{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.constructFromObject(data, obj);{{/parentModel}}
{{#interfaces}} {{.}}.constructFromObject(data, obj);
{{/interfaces}}{{/useInheritance}}{{#vars}} if (data.hasOwnProperty('{{baseName}}')) {
obj['{{baseName}}']{{{defaultValueWithParam}}}
}
{{/vars}} }
return obj;
}
{{#useInheritance}}{{#parentModel}}
exports.prototype = Object.create({{classname}}.prototype);
exports.prototype.constructor = exports;
{{/parentModel}}{{/useInheritance}}
{{#vars}}
{{#emitJSDoc}}
/**{{#description}}
* {{{description}}}{{/description}}
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
* @default {{{defaultValue}}}{{/defaultValue}}
*/
{{/emitJSDoc}}
exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}undefined{{/defaultValue}};
{{/vars}}{{#useInheritance}}{{#interfaceModels}}
// Implement {{classname}} interface:{{#allVars}}
{{#emitJSDoc}}
/**{{#description}}
* {{{description}}}{{/description}}
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
* @default {{{defaultValue}}}{{/defaultValue}}
*/
{{/emitJSDoc}}
exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}undefined{{/defaultValue}};
{{/allVars}}{{/interfaceModels}}{{/useInheritance}}
{{#emitModelMethods}}{{#vars}}
{{#emitJSDoc}}
/**{{#description}}
* Returns {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
* @return {{{vendorExtensions.x-jsdoc-type}}}
*/
{{/emitJSDoc}}
exports.prototype.{{getter}} = function() {
return this['{{baseName}}'];
}
{{#emitJSDoc}}
/**{{#description}}
* Sets {{{description}}}{{/description}}
* @param {{{vendorExtensions.x-jsdoc-type}}} {{name}}{{#description}} {{{description}}}{{/description}}
*/
{{/emitJSDoc}}
exports.prototype.{{setter}} = function({{name}}) {
this['{{baseName}}'] = {{name}};
}
{{/vars}}{{/emitModelMethods}}
{{#vars}}{{#isEnum}}{{>partial_model_inner_enum}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>partial_model_inner_enum}}{{/items}}*/{{/items.isEnum}}{{/vars}}
return exports;
{{/model}}{{/models}}}));

View File

@ -0,0 +1,21 @@
{{#emitJSDoc}}
/**
* Allowed values for the <code>{{baseName}}</code> property.
* @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
* @readonly
*/
{{/emitJSDoc}}
exports.{{datatypeWithEnum}} = {
{{#allowableValues}}
{{#enumVars}}
{{#emitJSDoc}}
/**
* value: {{{value}}}
* @const
*/
{{/emitJSDoc}}
"{{name}}": {{{value}}}{{^-last}},
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
};

View File

@ -1,6 +1,15 @@
public enum {{vendorExtensions.plainDatatypeWithEnum}} {
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[JsonConverter(typeof(StringEnumConverter))]
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
{
{{#allowableValues}}{{#enumVars}}
[EnumMember(Value = "{{jsonname}}")]
{{name}}{{^-last}},
{{/-last}}{{#-last}}{{/-last}}{{/enumVars}}{{/allowableValues}}
/// <summary>
/// Enum {{name}} for {{{value}}}
/// </summary>
[EnumMember(Value = {{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isFloat}}"{{/isFloat}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isFloat}}"{{/isFloat}})]
{{name}}{{#isLong}} = {{{value}}}{{/isLong}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^-last}},
{{/-last}}{{/enumVars}}{{/allowableValues}}
}

View File

@ -13,145 +13,7 @@ using Newtonsoft.Json.Converters;
{{#model}}
namespace {{packageName}}.Model
{
/// <summary>
/// {{description}}
/// </summary>
[DataContract]
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
{ {{#vars}}{{#isEnum}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[JsonConverter(typeof(StringEnumConverter))]
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>enumClass}}{{/items}}{{/items.isEnum}}{{/vars}}
{{#vars}}{{#isEnum}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{emitDefaultValue}})]
public {{{datatypeWithEnum}}} {{name}} { get; set; }
{{/isEnum}}{{/vars}}
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// Initializes a new instance of the <see cref="{{classname}}" />class.
/// </summary>
{{#vars}}{{^isReadOnly}} /// <param name="{{name}}">{{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.</param>
{{/isReadOnly}}{{/vars}}
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{/isReadOnly}}{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/vars}})
{
{{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
if ({{name}} == null)
{
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
}
else
{
this.{{name}} = {{name}};
}
{{/required}}{{/isReadOnly}}{{/vars}}{{#vars}}{{^isReadOnly}}{{^required}}{{#defaultValue}}// use default value if no "{{name}}" provided
if ({{name}} == null)
{
this.{{name}} = {{{defaultValue}}};
}
else
{
this.{{name}} = {{name}};
}
{{/defaultValue}}{{^defaultValue}}this.{{name}} = {{name}};
{{/defaultValue}}{{/required}}{{/isReadOnly}}{{/vars}}
}
{{#vars}}{{^isEnum}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>{{#description}}
/// <value>{{description}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{emitDefaultValue}})]
public {{{datatype}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
{{/isEnum}}{{/vars}}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class {{classname}} {\n");
{{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public {{#parent}} new {{/parent}}string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
// credit: http://stackoverflow.com/a/10454552/677735
return this.Equals(obj as {{classname}});
}
/// <summary>
/// Returns true if {{classname}} instances are equal
/// </summary>
/// <param name="other">Instance of {{classname}} to be compared</param>
/// <returns>Boolean</returns>
public bool Equals({{classname}} other)
{
// credit: http://stackoverflow.com/a/10454552/677735
if (other == null)
return false;
return {{#vars}}{{#isNotContainer}}
(
this.{{name}} == other.{{name}} ||
this.{{name}} != null &&
this.{{name}}.Equals(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
(
this.{{name}} == other.{{name}} ||
this.{{name}} != null &&
this.{{name}}.SequenceEqual(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
{{#vars}}
if (this.{{name}} != null)
hash = hash * 59 + this.{{name}}.GetHashCode();
{{/vars}}
return hash;
}
}
}
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}
{{/model}}
{{/models}}
}

View File

@ -0,0 +1,15 @@
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[JsonConverter(typeof(StringEnumConverter))]
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
{
{{#allowableValues}}{{#enumVars}}
/// <summary>
/// Enum {{name}} for {{{value}}}
/// </summary>
[EnumMember(Value = {{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}})]
{{name}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^-last}},
{{/-last}}{{/enumVars}}{{/allowableValues}}
}

View File

@ -0,0 +1,150 @@
/// <summary>
/// {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
/// </summary>
[DataContract]
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
{
{{#vars}}
{{#isEnum}}
{{>modelInnerEnum}}
{{/isEnum}}
{{#items.isEnum}}
{{#items}}
{{>modelInnerEnum}}
{{/items}}
{{/items.isEnum}}
{{/vars}}
{{#vars}}
{{#isEnum}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{emitDefaultValue}})]
public {{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} { get; set; }
{{/isEnum}}
{{/vars}}
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary>
{{#vars}}
{{^isReadOnly}}
/// <param name="{{name}}">{{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.</param>
{{/isReadOnly}}
{{/vars}}
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} = null{{#hasMore}}, {{/hasMore}}{{/isReadOnly}}{{/vars}})
{
{{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
if ({{name}} == null)
{
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
}
else
{
this.{{name}} = {{name}};
}
{{/required}}{{/isReadOnly}}{{/vars}}
{{#vars}}{{^isReadOnly}}{{^required}}
{{#defaultValue}}// use default value if no "{{name}}" provided
if ({{name}} == null)
{
this.{{name}} = {{{defaultValue}}};
}
else
{
this.{{name}} = {{name}};
}
{{/defaultValue}}
{{^defaultValue}}
this.{{name}} = {{name}};
{{/defaultValue}}
{{/required}}{{/isReadOnly}}{{/vars}}
}
{{#vars}}
{{^isEnum}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>{{#description}}
/// <value>{{description}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{emitDefaultValue}})]
public {{{datatype}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
{{/isEnum}}
{{/vars}}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class {{classname}} {\n");
{{#vars}}sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public {{#parent}} new {{/parent}}string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
// credit: http://stackoverflow.com/a/10454552/677735
return this.Equals(obj as {{classname}});
}
/// <summary>
/// Returns true if {{classname}} instances are equal
/// </summary>
/// <param name="other">Instance of {{classname}} to be compared</param>
/// <returns>Boolean</returns>
public bool Equals({{classname}} other)
{
// credit: http://stackoverflow.com/a/10454552/677735
if (other == null)
return false;
return {{#vars}}{{#isNotContainer}}
(
this.{{name}} == other.{{name}} ||
this.{{name}} != null &&
this.{{name}}.Equals(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
(
this.{{name}} == other.{{name}} ||
this.{{name}} != null &&
this.{{name}}.SequenceEqual(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
{{#vars}}
if (this.{{name}} != null)
hash = hash * 59 + this.{{name}}.GetHashCode();
{{/vars}}
return hash;
}
}
}

View File

@ -0,0 +1,15 @@
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[JsonConverter(typeof(StringEnumConverter))]
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
{
{{#allowableValues}}{{#enumVars}}
/// <summary>
/// Enum {{name}} for {{{value}}}
/// </summary>
[EnumMember(Value = {{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isFloat}}"{{/isFloat}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isFloat}}"{{/isFloat}})]
{{name}}{{#isLong}} = {{{value}}}{{/isLong}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^-last}},
{{/-last}}{{/enumVars}}{{/allowableValues}}
}

View File

@ -2,149 +2,121 @@ package {{packageName}}
{{#operations}}
import (
"strings"
"fmt"
"errors"
{{#imports}} "{{import}}"
"strings"
"fmt"
"errors"
{{#imports}}"{{import}}"
{{/imports}}
)
type {{classname}} struct {
Configuration Configuration
Configuration Configuration
}
func New{{classname}}() *{{classname}}{
configuration := NewConfiguration()
return &{{classname}} {
Configuration: *configuration,
}
func New{{classname}}() *{{classname}} {
configuration := NewConfiguration()
return &{{classname}}{
Configuration: *configuration,
}
}
func New{{classname}}WithBasePath(basePath string) *{{classname}}{
configuration := NewConfiguration()
configuration.BasePath = basePath
return &{{classname}} {
Configuration: *configuration,
}
}
func New{{classname}}WithBasePath(basePath string) *{{classname}} {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &{{classname}}{
Configuration: *configuration,
}
}
{{#operation}}
/**
* {{summary}}
* {{notes}}
* {{summary}}{{#notes}}
* {{notes}}{{/notes}}
*
{{#allParams}} * @param {{paramName}} {{description}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
*/
func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}*{{{returnType}}}, {{/returnType}}*APIResponse, error) {
func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) {
var httpMethod = "{{httpMethod}}"
// create path and map variables
path := a.Configuration.BasePath + "{{path}}"
{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1)
{{/pathParams}}
var httpMethod = "{{httpMethod}}"
// create path and map variables
path := a.Configuration.BasePath + "{{path}}"{{#pathParams}}
path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
{{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set
if &{{paramName}} == nil {
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
}{{/required}}{{/allParams}}
{{#allParams}}
{{#required}}
// verify the required parameter '{{paramName}}' is set
if &{{paramName}} == nil {
return {{#returnType}}new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
}
{{/required}}
{{/allParams}}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}{{#isKeyInHeader}}
// set key with prefix in header
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/isKeyInHeader}}{{#isKeyInQuery}}
// set key with prefix in querystring{{#hasKeyParamName}}
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
// http basic authentication required
if a.Configuration.Username != "" || a.Configuration.Password != ""{
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
}{{/isBasic}}{{#isOAuth}}
// oauth required
if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
}{{/isOAuth}}{{/authMethods}}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}{{#hasQueryParams}}{{#queryParams}}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
{{/queryParams}}{{/hasQueryParams}}
{{#authMethods}}// authentication ({{name}}) required
{{#isApiKey}}{{#isKeyInHeader}}
// set key with prefix in header
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/isKeyInHeader}}{{#isKeyInQuery}}
// set key with prefix in querystring
{{#hasKeyParamName}}
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/hasKeyParamName}}
{{/isKeyInQuery}}{{/isApiKey}}
{{#isBasic}}
// http basic authentication required
if a.Configuration.Username != "" || a.Configuration.Password != ""{
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
}
{{/isBasic}}
{{#isOAuth}}
// oauth required
if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
}
{{/isOAuth}}
{{/authMethods}}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ {{#consumes}}"{{mediaType}}", {{/consumes}} }
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
{{#hasQueryParams}}
{{#queryParams}}
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
{{/queryParams}}
{{/hasQueryParams}}
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
{{#produces}}"{{mediaType}}",
{{/produces}} }
// to determine the Content-Type header
localVarHttpContentTypes := []string {
{{#consumes}}
"{{mediaType}}",
{{/consumes}}
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string {
{{#produces}}
"{{mediaType}}",
{{/produces}}
}
//set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
headerParams["{{baseName}}"] = {{paramName}}
{{/headerParams}}{{/hasHeaderParams}}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}fbs, _ := ioutil.ReadAll(file)
fileBytes = fbs
fileName = file.Name()
{{/isFile}}
{{^isFile}}formParams["{{paramName}}"] = {{paramName}}
{{/isFile}}
{{/formParams}}
{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params
postBody = &{{paramName}}
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}{{#hasHeaderParams}}
{{#headerParams}} // header params "{{baseName}}"
headerParams["{{baseName}}"] = {{paramName}}
{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}}
{{#formParams}}{{#isFile}}
fbs, _ := ioutil.ReadAll(file)
fileBytes = fbs
fileName = file.Name(){{/isFile}}
{{^isFile}} formParams["{{paramName}}"] = {{paramName}}{{/isFile}}{{/formParams}}{{/hasFormParams}}{{#hasBodyParam}}
{{#bodyParams}} // body params
postBody = &{{paramName}}
{{/bodyParams}}{{/hasBodyParam}}
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return {{#returnType}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err
}
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
}
{{#returnType}}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
{{/returnType}}
return {{#returnType}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err
err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}}
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
}
{{/operation}}
{{/operations}}
{{/operation}}{{/operations}}

View File

@ -1,123 +1,120 @@
package {{packageName}}
import (
"strings"
"github.com/go-resty/resty"
"fmt"
"reflect"
"bytes"
"path/filepath"
"bytes"
"fmt"
"path/filepath"
"reflect"
"strings"
"github.com/go-resty/resty"
)
type APIClient struct {
}
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
if (len(contentTypes) == 0){
return ""
}
if contains(contentTypes,"application/json") {
return "application/json"
}
return contentTypes[0] // use the first content type specified in 'consumes'
if len(contentTypes) == 0 {
return ""
}
if contains(contentTypes, "application/json") {
return "application/json"
}
return contentTypes[0] // use the first content type specified in 'consumes'
}
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
if (len(accepts) == 0){
return ""
}
if contains(accepts,"application/json"){
return "application/json"
}
return strings.Join(accepts,",")
if len(accepts) == 0 {
return ""
}
if contains(accepts, "application/json") {
return "application/json"
}
return strings.Join(accepts, ",")
}
func contains(source []string, containvalue string) bool {
for _, a := range source {
if strings.ToLower(a) == strings.ToLower(containvalue) {
return true
}
}
return false
for _, a := range source {
if strings.ToLower(a) == strings.ToLower(containvalue) {
return true
}
}
return false
}
func (c *APIClient) CallAPI(path string, method string,
postBody interface{},
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) (*resty.Response, error) {
postBody interface{},
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) (*resty.Response, error) {
//set debug flag
configuration := NewConfiguration()
resty.SetDebug(configuration.GetDebug())
//set debug flag
configuration := NewConfiguration()
resty.SetDebug(configuration.GetDebug())
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
switch strings.ToUpper(method) {
case "GET":
response, err := request.Get(path)
return response, err
case "POST":
response, err := request.Post(path)
return response, err
case "PUT":
response, err := request.Put(path)
return response, err
case "PATCH":
response, err := request.Patch(path)
return response, err
case "DELETE":
response, err := request.Delete(path)
return response, err
}
switch strings.ToUpper(method) {
case "GET":
response, err := request.Get(path)
return response, err
case "POST":
response, err := request.Post(path)
return response, err
case "PUT":
response, err := request.Put(path)
return response, err
case "PATCH":
response, err := request.Patch(path)
return response, err
case "DELETE":
response, err := request.Delete(path)
return response, err
}
return nil, fmt.Errorf("invalid method %v", method)
return nil, fmt.Errorf("invalid method %v", method)
}
func (c *APIClient) ParameterToString(obj interface{}) string {
if reflect.TypeOf(obj).String() == "[]string" {
return strings.Join(obj.([]string), ",")
} else {
return obj.(string)
}
if reflect.TypeOf(obj).String() == "[]string" {
return strings.Join(obj.([]string), ",")
} else {
return obj.(string)
}
}
func prepareRequest(postBody interface{},
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) *resty.Request {
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) *resty.Request {
request := resty.R()
request := resty.R()
request.SetBody(postBody)
request.SetBody(postBody)
// add header parameter, if any
if len(headerParams) > 0 {
request.SetHeaders(headerParams)
}
// add header parameter, if any
if len(headerParams) > 0 {
request.SetHeaders(headerParams)
}
// add query parameter, if any
if len(queryParams) > 0 {
request.SetQueryParams(queryParams)
}
// add query parameter, if any
if len(queryParams) > 0 {
request.SetQueryParams(queryParams)
}
// add form parameter, if any
if len(formParams) > 0 {
request.SetFormData(formParams)
}
if len(fileBytes) > 0 && fileName != "" {
_, fileNm := filepath.Split(fileName)
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
}
return request
// add form parameter, if any
if len(formParams) > 0 {
request.SetFormData(formParams)
}
if len(fileBytes) > 0 && fileName != "" {
_, fileNm := filepath.Split(fileName)
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
}
return request
}

View File

@ -1,24 +1,22 @@
package {{packageName}}
import (
"net/http"
"net/http"
)
type APIResponse struct {
*http.Response
Message string `json:"message,omitempty"`
*http.Response
Message string `json:"message,omitempty"`
}
func NewAPIResponse(r *http.Response) *APIResponse {
response := &APIResponse{Response: r}
return response
response := &APIResponse{Response: r}
return response
}
func NewAPIResponseWithError(errorMessage string) *APIResponse {
response := &APIResponse{Message: errorMessage}
return response
}
response := &APIResponse{Message: errorMessage}
return response
}

View File

@ -1,59 +1,59 @@
package {{packageName}}
import (
"encoding/base64"
"encoding/base64"
)
type Configuration struct {
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"`
APIKey map[string] string `json:"APIKey,omitempty"`
debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"`
Timeout int `json:"timeout,omitempty"`
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
APIClient APIClient `json:"APIClient,omitempty"`
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
APIKey map[string]string `json:"APIKey,omitempty"`
debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"`
Timeout int `json:"timeout,omitempty"`
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
APIClient APIClient `json:"APIClient,omitempty"`
}
func NewConfiguration() *Configuration {
return &Configuration{
BasePath: "{{basePath}}",
UserName: "",
debug: false,
DefaultHeader: make(map[string]string),
APIKey: make(map[string]string),
APIKeyPrefix: make(map[string]string),
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}",
}
return &Configuration{
BasePath: "{{basePath}}",
UserName: "",
debug: false,
DefaultHeader: make(map[string]string),
APIKey: make(map[string]string),
APIKeyPrefix: make(map[string]string),
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}",
}
}
func (c *Configuration) GetBasicAuthEncodedString() string {
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
}
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
c.DefaultHeader[key] = value
}
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
if c.APIKeyPrefix[APIKeyIdentifier] != ""{
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
}
return c.APIKey[APIKeyIdentifier]
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
}
return c.APIKey[APIKeyIdentifier]
}
func (c *Configuration) SetDebug(enable bool){
c.debug = enable
func (c *Configuration) SetDebug(enable bool) {
c.debug = enable
}
func (c *Configuration) GetDebug() bool {
return c.debug
}
return c.debug
}

View File

@ -1,18 +1,14 @@
package {{packageName}}
{{#models}}
import (
{{#imports}} "{{import}}"
{{/imports}}
{{#models}}{{#imports}}
import ({{/imports}}{{#imports}}
"{{import}}"{{/imports}}{{#imports}}
)
{{#model}}
{{#description}}// {{{description}}}{{/description}}
{{/imports}}{{#model}}{{#description}}
// {{{description}}}{{/description}}
type {{classname}} struct {
{{#vars}}
{{#description}}// {{{description}}}{{/description}}
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
{{/vars}}
{{#vars}}{{#description}}
// {{{description}}}{{/description}}
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
{{/vars}}
}
{{/model}}
{{/models}}
{{/model}}{{/models}}

View File

@ -69,7 +69,7 @@ class ApiClient
* Constructor of the class
* @param Configuration $config config for this ApiClient
*/
public function __construct(Configuration $config = null)
public function __construct(\{{invokerPackage}}\Configuration $config = null)
{
if ($config == null) {
$config = Configuration::getDefaultConfiguration();

View File

@ -60,7 +60,7 @@ use \{{invokerPackage}}\ObjectSerializer;
* Constructor
* @param \{{invokerPackage}}\ApiClient|null $apiClient The api client to use
*/
function __construct($apiClient = null)
function __construct(\{{invokerPackage}}\ApiClient $apiClient = null)
{
if ($apiClient == null) {
$apiClient = new ApiClient();
@ -84,7 +84,7 @@ use \{{invokerPackage}}\ObjectSerializer;
* @param \{{invokerPackage}}\ApiClient $apiClient set the API client
* @return {{classname}}
*/
public function setApiClient(ApiClient $apiClient)
public function setApiClient(\{{invokerPackage}}\ApiClient $apiClient)
{
$this->apiClient = $apiClient;
return $this;

View File

@ -62,55 +62,71 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function swaggerTypes() {
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}};
}
/**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
static $attributeMap = array(
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function attributeMap() {
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
static $setters = array(
{{#vars}}'{{name}}' => '{{setter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function setters() {
return {{#parent}}parent::setters() + {{/parent}}self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
static $getters = array(
{{#vars}}'{{name}}' => '{{getter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function getters() {
return {{#parent}}parent::getters() + {{/parent}}self::$getters;
}
{{#vars}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}const {{datatypeWithEnum}}_{{{name}}} = {{{value}}};
{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{/vars}}
{{#vars}}{{#isEnum}}
/**
* Gets allowable values of the enum
* @return string[]
*/
public function {{getter}}AllowableValues() {
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}
];
}
{{/isEnum}}{{/vars}}
{{#vars}}
/**
* ${{name}} {{#description}}{{{description}}}{{/description}}
* @var {{datatype}}
*/
* ${{name}} {{#description}}{{{description}}}{{/description}}
* @var {{datatype}}
*/
protected ${{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};
{{/vars}}
@ -140,7 +156,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{
return $this->{{name}};
}
/**
* Sets {{name}}
* @param {{datatype}} ${{name}} {{#description}}{{{description}}}{{/description}}
@ -165,7 +181,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{
return isset($this->$offset);
}
/**
* Gets offset.
* @param integer $offset Offset
@ -175,7 +191,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{
return $this->$offset;
}
/**
* Sets value based on offset.
* @param integer $offset Offset
@ -186,7 +202,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{
$this->$offset = $value;
}
/**
* Unsets offset.
* @param integer $offset Offset
@ -196,7 +212,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{
unset($this->$offset);
}
/**
* Gets the string presentation of the object
* @return string

View File

@ -0,0 +1,17 @@
class {{classname}} {
{{#allowableValues}}{{#enumVars}}const {{{name}}} = {{{value}}};
{{/enumVars}}{{/allowableValues}}
{{#vars}}{{#isEnum}}
/**
* Gets allowable values of the enum
* @return string[]
*/
public function {{getter}}AllowableValues() {
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}
];
}
{{/isEnum}}{{/vars}}
}

View File

@ -0,0 +1,169 @@
class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayAccess
{
/**
* Array of property to type mappings. Used for (de)serialization
* @var string[]
*/
static $swaggerTypes = array(
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function swaggerTypes() {
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}};
}
/**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
static $attributeMap = array(
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function attributeMap() {
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
static $setters = array(
{{#vars}}'{{name}}' => '{{setter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function setters() {
return {{#parent}}parent::setters() + {{/parent}}self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
static $getters = array(
{{#vars}}'{{name}}' => '{{getter}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
static function getters() {
return {{#parent}}parent::getters() + {{/parent}}self::$getters;
}
{{#vars}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}const {{datatypeWithEnum}}_{{{name}}} = {{{value}}};
{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{/vars}}
{{#vars}}{{#isEnum}}
/**
* Gets allowable values of the enum
* @return string[]
*/
public function {{getter}}AllowableValues() {
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}
];
}
{{/isEnum}}{{/vars}}
{{#vars}}
/**
* ${{name}} {{#description}}{{{description}}}{{/description}}
* @var {{datatype}}
*/
protected ${{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};
{{/vars}}
/**
* Constructor
* @param mixed[] $data Associated array of property value initalizing the model
*/
public function __construct(array $data = null)
{
{{#parent}}parent::__construct($data);{{/parent}}
if ($data != null) {
{{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}
{{/hasMore}}{{/vars}}
}
}
{{#vars}}
/**
* Gets {{name}}.
* @return {{datatype}}
*/
public function {{getter}}()
{
return $this->{{name}};
}
/**
* Sets {{name}}.
* @param {{datatype}} ${{name}} {{#description}}{{{description}}}{{/description}}
* @return $this
*/
public function {{setter}}(${{name}})
{
{{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
if (!in_array(${{{name}}}, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for '{{name}}', must be one of {{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}");
}{{/isEnum}}
$this->{{name}} = ${{name}};
return $this;
}
{{/vars}}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
{
return isset($this->$offset);
}
/**
* Gets offset.
* @param integer $offset Offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->$offset;
}
/**
* Sets value based on offset.
* @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
public function offsetSet($offset, $value)
{
$this->$offset = $value;
}
/**
* Unsets offset.
* @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->$offset);
}
/**
* Gets the string presentation of the object.
* @return string
*/
public function __toString()
{
if (defined('JSON_PRETTY_PRINT')) {
return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
} else {
return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this));
}
}
}

View File

@ -899,6 +899,33 @@ definitions:
format: password
maxLength: 64
minLength: 10
EnumClass:
type: string
default: '-efg'
enum:
- _abc
- '-efg'
- (xyz)
Enum_Test:
type: object
properties:
enum_string:
type: string
enum:
- UPPER
- lower
enum_integer:
type: integer
format: int32
enum:
- 1
- -1
enum_number:
type: number
format: double
enum:
- 1.1
- -1.2
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'

View File

@ -1,3 +1,4 @@
{
"swagger": "2.0",
"info": {

View File

@ -139,6 +139,14 @@ namespace IO.Swagger.Test
// TODO: unit test for the property 'DateTime'
}
/// <summary>
/// Test the property 'Uuid'
/// </summary>
[Test]
public void UuidTest()
{
// TODO: unit test for the property 'Uuid'
}
/// <summary>
/// Test the property 'Password'
/// </summary>
[Test]

View File

@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
- API version: 1.0.0
- SDK version: 1.0.0
- Build date: 2016-04-21T17:22:44.115+08:00
- Build date: 2016-04-27T22:04:12.906+08:00
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
## Frameworks supported
@ -53,20 +53,28 @@ namespace Example
public void main()
{
// Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = 'YOUR_ACCESS_TOKEN';
var apiInstance = new PetApi();
var body = new Pet(); // Pet | Pet object that needs to be added to the store
var apiInstance = new FakeApi();
var number = number_example; // string | None
var _double = 1.2; // double? | None
var _string = _string_example; // string | None
var _byte = B; // byte[] | None
var integer = 56; // int? | None (optional)
var int32 = 56; // int? | None (optional)
var int64 = 789; // long? | None (optional)
var _float = 3.4; // float? | None (optional)
var binary = B; // byte[] | None (optional)
var date = 2013-10-20; // DateTime? | None (optional)
var dateTime = 2013-10-20T19:20:30+01:00; // DateTime? | None (optional)
var password = password_example; // string | None (optional)
try
{
// Add a new pet to the store
apiInstance.AddPet(body);
// Fake endpoint for testing various parameters
apiInstance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
}
catch (Exception e)
{
Debug.Print("Exception when calling PetApi.AddPet: " + e.Message );
Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message );
}
}
}
@ -79,6 +87,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
@ -108,6 +117,8 @@ Class | Method | HTTP request | Description
- [IO.Swagger.Model.Cat](docs/Cat.md)
- [IO.Swagger.Model.Category](docs/Category.md)
- [IO.Swagger.Model.Dog](docs/Dog.md)
- [IO.Swagger.Model.EnumClass](docs/EnumClass.md)
- [IO.Swagger.Model.EnumTest](docs/EnumTest.md)
- [IO.Swagger.Model.FormatTest](docs/FormatTest.md)
- [IO.Swagger.Model.Model200Response](docs/Model200Response.md)
- [IO.Swagger.Model.ModelReturn](docs/ModelReturn.md)

View File

@ -0,0 +1,91 @@
# IO.Swagger.Api.FakeApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters
# **TestEndpointParameters**
> void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
Fake endpoint for testing various parameters
Fake endpoint for testing various parameters
### Example
```csharp
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class TestEndpointParametersExample
{
public void main()
{
var apiInstance = new FakeApi();
var number = 3.4; // double? | None
var _double = 1.2; // double? | None
var _string = _string_example; // string | None
var _byte = B; // byte[] | None
var integer = 56; // int? | None (optional)
var int32 = 56; // int? | None (optional)
var int64 = 789; // long? | None (optional)
var _float = 3.4; // float? | None (optional)
var binary = B; // byte[] | None (optional)
var date = 2013-10-20; // DateTime? | None (optional)
var dateTime = 2013-10-20T19:20:30+01:00; // DateTime? | None (optional)
var password = password_example; // string | None (optional)
try
{
// Fake endpoint for testing various parameters
apiInstance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
}
catch (Exception e)
{
Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message );
}
}
}
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**number** | **double?**| None |
**_double** | **double?**| None |
**_string** | **string**| None |
**_byte** | **byte[]**| None |
**integer** | **int?**| None | [optional]
**int32** | **int?**| None | [optional]
**int64** | **long?**| None | [optional]
**_float** | **float?**| None | [optional]
**binary** | **byte[]**| None | [optional]
**date** | **DateTime?**| None | [optional]
**dateTime** | **DateTime?**| None | [optional]
**password** | **string**| None | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -10,11 +10,11 @@ Name | Type | Description | Notes
**_Float** | **float?** | | [optional]
**_Double** | **double?** | | [optional]
**_String** | **string** | | [optional]
**_Byte** | **byte[]** | | [optional]
**_Byte** | **byte[]** | |
**Binary** | **byte[]** | | [optional]
**Date** | **DateTime?** | | [optional]
**Date** | **DateTime?** | |
**DateTime** | **DateTime?** | | [optional]
**Password** | **string** | | [optional]
**Password** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -8,12 +8,12 @@ git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="YOUR_GIT_USR_ID"
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="YOUR_GIT_REPO_ID"
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

View File

@ -0,0 +1,418 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using RestSharp;
using IO.Swagger.Client;
namespace IO.Swagger.Api
{
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface IFakeApi
{
#region Synchronous Operations
/// <summary>
/// Fake endpoint for testing various parameters
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns></returns>
void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
/// <summary>
/// Fake endpoint for testing various parameters
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns>ApiResponse of Object(void)</returns>
ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
#endregion Synchronous Operations
#region Asynchronous Operations
/// <summary>
/// Fake endpoint for testing various parameters
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns>Task of void</returns>
System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
/// <summary>
/// Fake endpoint for testing various parameters
/// </summary>
/// <remarks>
/// Fake endpoint for testing various parameters
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns>Task of ApiResponse</returns>
System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
#endregion Asynchronous Operations
}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public class FakeApi : IFakeApi
{
/// <summary>
/// Initializes a new instance of the <see cref="FakeApi"/> class.
/// </summary>
/// <returns></returns>
public FakeApi(String basePath)
{
this.Configuration = new Configuration(new ApiClient(basePath));
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="FakeApi"/> class
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <returns></returns>
public FakeApi(Configuration configuration = null)
{
if (configuration == null) // use the default one in Configuration
this.Configuration = Configuration.Default;
else
this.Configuration = configuration;
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>
/// Gets the base path of the API client.
/// </summary>
/// <value>The base path</value>
public String GetBasePath()
{
return this.Configuration.ApiClient.RestClient.BaseUrl.ToString();
}
/// <summary>
/// Sets the base path of the API client.
/// </summary>
/// <value>The base path</value>
[Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
public void SetBasePath(String basePath)
{
// do nothing
}
/// <summary>
/// Gets or sets the configuration object
/// </summary>
/// <value>An instance of the Configuration</value>
public Configuration Configuration {get; set;}
/// <summary>
/// Gets the default header.
/// </summary>
/// <returns>Dictionary of HTTP header</returns>
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")]
public Dictionary<String, String> DefaultHeader()
{
return this.Configuration.DefaultHeader;
}
/// <summary>
/// Add default header.
/// </summary>
/// <param name="key">Header field name.</param>
/// <param name="value">Header field value.</param>
/// <returns></returns>
[Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")]
public void AddDefaultHeader(string key, string value)
{
this.Configuration.AddDefaultHeader(key, value);
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns></returns>
public void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
{
TestEndpointParametersWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns>ApiResponse of Object(void)</returns>
public ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
{
// verify the required parameter 'number' is set
if (number == null)
throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters");
// verify the required parameter '_double' is set
if (_double == null)
throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters");
// verify the required parameter '_string' is set
if (_string == null)
throw new ApiException(400, "Missing required parameter '_string' when calling FakeApi->TestEndpointParameters");
// verify the required parameter '_byte' is set
if (_byte == null)
throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters");
var localVarPath = "/fake";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new Dictionary<String, String>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/xml",
"application/json"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
localVarPathParams.Add("format", "json");
if (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter
if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter
if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter
if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter
if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter
if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter
if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter
if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter
if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter
if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter
if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter
if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (localVarStatusCode >= 400)
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content);
else if (localVarStatusCode == 0)
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns>Task of void</returns>
public async System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
{
await TestEndpointParametersAsyncWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
}
/// <summary>
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="number">None</param>
/// <param name="_double">None</param>
/// <param name="_string">None</param>
/// <param name="_byte">None</param>
/// <param name="integer">None (optional)</param>
/// <param name="int32">None (optional)</param>
/// <param name="int64">None (optional)</param>
/// <param name="_float">None (optional)</param>
/// <param name="binary">None (optional)</param>
/// <param name="date">None (optional)</param>
/// <param name="dateTime">None (optional)</param>
/// <param name="password">None (optional)</param>
/// <returns>Task of ApiResponse</returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
{
// verify the required parameter 'number' is set
if (number == null)
throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters");
// verify the required parameter '_double' is set
if (_double == null)
throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters");
// verify the required parameter '_string' is set
if (_string == null)
throw new ApiException(400, "Missing required parameter '_string' when calling FakeApi->TestEndpointParameters");
// verify the required parameter '_byte' is set
if (_byte == null)
throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters");
var localVarPath = "/fake";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new Dictionary<String, String>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/xml",
"application/json"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
localVarPathParams.Add("format", "json");
if (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter
if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter
if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter
if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter
if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter
if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter
if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter
if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter
if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter
if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter
if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter
if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (localVarStatusCode >= 400)
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content);
else if (localVarStatusCode == 0)
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
}
}

View File

@ -12,18 +12,15 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Animal
/// </summary>
[DataContract]
public partial class Animal : IEquatable<Animal>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Animal" /> class.
/// Initializes a new instance of the <see cref="Animal" />class.
/// </summary>
/// <param name="ClassName">ClassName (required).</param>
public Animal(string ClassName = null)
{
// to ensure "ClassName" is required (not null)
@ -36,15 +33,14 @@ namespace IO.Swagger.Model
this.ClassName = ClassName;
}
}
/// <summary>
/// Gets or Sets ClassName
/// </summary>
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -57,7 +53,7 @@ namespace IO.Swagger.Model
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -113,6 +109,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,47 +12,44 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// ApiResponse
/// </summary>
[DataContract]
public partial class ApiResponse : IEquatable<ApiResponse>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="ApiResponse" /> class.
/// Initializes a new instance of the <see cref="ApiResponse" />class.
/// </summary>
/// <param name="Code">Code.</param>
/// <param name="Type">Type.</param>
/// <param name="Message">Message.</param>
public ApiResponse(int? Code = null, string Type = null, string Message = null)
{
this.Code = Code;
this.Type = Type;
this.Message = Message;
this.Code = Code;
this.Type = Type;
this.Message = Message;
}
/// <summary>
/// Gets or Sets Code
/// </summary>
[DataMember(Name="code", EmitDefaultValue=false)]
public int? Code { get; set; }
/// <summary>
/// Gets or Sets Type
/// </summary>
[DataMember(Name="type", EmitDefaultValue=false)]
public string Type { get; set; }
/// <summary>
/// Gets or Sets Message
/// </summary>
[DataMember(Name="message", EmitDefaultValue=false)]
public string Message { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -62,12 +59,12 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class ApiResponse {\n");
sb.Append(" Code: ").Append(Code).Append("\n");
sb.Append(" Type: ").Append(Type).Append("\n");
sb.Append(" Message: ").Append(Message).Append("\n");
sb.Append(" Type: ").Append(Type).Append("\n");
sb.Append(" Message: ").Append(Message).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -137,6 +134,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,19 +12,16 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Cat
/// </summary>
[DataContract]
public partial class Cat : Animal, IEquatable<Cat>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Cat" /> class.
/// Initializes a new instance of the <see cref="Cat" />class.
/// </summary>
/// <param name="ClassName">ClassName (required).</param>
/// <param name="Declawed">Declawed.</param>
public Cat(string ClassName = null, bool? Declawed = null)
{
// to ensure "ClassName" is required (not null)
@ -36,23 +33,22 @@ namespace IO.Swagger.Model
{
this.ClassName = ClassName;
}
this.Declawed = Declawed;
this.Declawed = Declawed;
}
/// <summary>
/// Gets or Sets ClassName
/// </summary>
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Declawed
/// </summary>
[DataMember(Name="declawed", EmitDefaultValue=false)]
public bool? Declawed { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -62,11 +58,11 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Cat {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -129,6 +125,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -0,0 +1,175 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Model
{
/// <summary>
///
/// </summary>
[DataContract]
public class CatDogTest : Cat, IEquatable<CatDogTest>
{
/// <summary>
/// Initializes a new instance of the <see cref="CatDogTest" /> class.
/// </summary>
public CatDogTest()
{
this.CatDogInteger = 0;
}
/// <summary>
/// Gets or Sets CatId
/// </summary>
[DataMember(Name="cat_id", EmitDefaultValue=false)]
public long? CatId { get; set; }
/// <summary>
/// Gets or Sets DogId
/// </summary>
[DataMember(Name="dog_id", EmitDefaultValue=false)]
public long? DogId { get; set; }
/// <summary>
/// integer property for testing allOf
/// </summary>
/// <value>integer property for testing allOf</value>
[DataMember(Name="CatDogInteger", EmitDefaultValue=false)]
public int? CatDogInteger { get; set; }
/// <summary>
/// Gets or Sets DogName
/// </summary>
[DataMember(Name="dog_name", EmitDefaultValue=false)]
public string DogName { get; set; }
/// <summary>
/// Gets or Sets CatName
/// </summary>
[DataMember(Name="cat_name", EmitDefaultValue=false)]
public string CatName { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class CatDogTest {\n");
sb.Append(" CatId: ").Append(CatId).Append("\n");
sb.Append(" DogId: ").Append(DogId).Append("\n");
sb.Append(" CatDogInteger: ").Append(CatDogInteger).Append("\n");
sb.Append(" DogName: ").Append(DogName).Append("\n");
sb.Append(" CatName: ").Append(CatName).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public new string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
// credit: http://stackoverflow.com/a/10454552/677735
return this.Equals(obj as CatDogTest);
}
/// <summary>
/// Returns true if CatDogTest instances are equal
/// </summary>
/// <param name="other">Instance of CatDogTest to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(CatDogTest other)
{
// credit: http://stackoverflow.com/a/10454552/677735
if (other == null)
return false;
return
(
this.CatId == other.CatId ||
this.CatId != null &&
this.CatId.Equals(other.CatId)
) &&
(
this.DogId == other.DogId ||
this.DogId != null &&
this.DogId.Equals(other.DogId)
) &&
(
this.CatDogInteger == other.CatDogInteger ||
this.CatDogInteger != null &&
this.CatDogInteger.Equals(other.CatDogInteger)
) &&
(
this.DogName == other.DogName ||
this.DogName != null &&
this.DogName.Equals(other.DogName)
) &&
(
this.CatName == other.CatName ||
this.CatName != null &&
this.CatName.Equals(other.CatName)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
if (this.CatId != null)
hash = hash * 57 + this.CatId.GetHashCode();
if (this.DogId != null)
hash = hash * 57 + this.DogId.GetHashCode();
if (this.CatDogInteger != null)
hash = hash * 57 + this.CatDogInteger.GetHashCode();
if (this.DogName != null)
hash = hash * 57 + this.DogName.GetHashCode();
if (this.CatName != null)
hash = hash * 57 + this.CatName.GetHashCode();
return hash;
}
}
}
}

View File

@ -12,39 +12,36 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Category
/// </summary>
[DataContract]
public partial class Category : IEquatable<Category>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Category" /> class.
/// Initializes a new instance of the <see cref="Category" />class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Name">Name.</param>
public Category(long? Id = null, string Name = null)
{
this.Id = Id;
this.Name = Name;
this.Id = Id;
this.Name = Name;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -54,11 +51,11 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Category {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -121,6 +118,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,19 +12,16 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Dog
/// </summary>
[DataContract]
public partial class Dog : Animal, IEquatable<Dog>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Dog" /> class.
/// Initializes a new instance of the <see cref="Dog" />class.
/// </summary>
/// <param name="ClassName">ClassName (required).</param>
/// <param name="Breed">Breed.</param>
public Dog(string ClassName = null, string Breed = null)
{
// to ensure "ClassName" is required (not null)
@ -36,23 +33,22 @@ namespace IO.Swagger.Model
{
this.ClassName = ClassName;
}
this.Breed = Breed;
this.Breed = Breed;
}
/// <summary>
/// Gets or Sets ClassName
/// </summary>
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Breed
/// </summary>
[DataMember(Name="breed", EmitDefaultValue=false)]
public string Breed { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -62,11 +58,11 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Dog {\n");
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
sb.Append(" Breed: ").Append(Breed).Append("\n");
sb.Append(" Breed: ").Append(Breed).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -129,6 +125,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
/// Gets or Sets EnumClass
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum EnumClass
{
/// <summary>
/// Enum Abc for "_abc"
/// </summary>
[EnumMember(Value = "_abc")]
Abc,
/// <summary>
/// Enum efg for "-efg"
/// </summary>
[EnumMember(Value = "-efg")]
efg,
/// <summary>
/// Enum xyz for "(xyz)"
/// </summary>
[EnumMember(Value = "(xyz)")]
xyz
}
}

View File

@ -0,0 +1,199 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
/// EnumTest
/// </summary>
[DataContract]
public partial class EnumTest : IEquatable<EnumTest>
{
/// <summary>
/// Gets or Sets EnumString
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum EnumStringEnum
{
/// <summary>
/// Enum Upper for "UPPER"
/// </summary>
[EnumMember(Value = "UPPER")]
Upper,
/// <summary>
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower
}
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum EnumIntegerEnum
{
/// <summary>
/// Enum NUMBER_1 for 1
/// </summary>
[EnumMember(Value = "1")]
NUMBER_1 = 1,
/// <summary>
/// Enum NUMBER_MINUS_1 for -1
/// </summary>
[EnumMember(Value = "-1")]
NUMBER_MINUS_1 = -1
}
/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum EnumNumberEnum
{
/// <summary>
/// Enum NUMBER_1_DOT_1 for 1.1
/// </summary>
[EnumMember(Value = "1.1")]
NUMBER_1_DOT_1,
/// <summary>
/// Enum NUMBER_MINUS_1_DOT_2 for -1.2
/// </summary>
[EnumMember(Value = "-1.2")]
NUMBER_MINUS_1_DOT_2
}
/// <summary>
/// Gets or Sets EnumString
/// </summary>
[DataMember(Name="enum_string", EmitDefaultValue=false)]
public EnumStringEnum? EnumString { get; set; }
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
[DataMember(Name="enum_number", EmitDefaultValue=false)]
public EnumNumberEnum? EnumNumber { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="EnumTest" /> class.
/// </summary>
/// <param name="EnumString">EnumString.</param>
/// <param name="EnumInteger">EnumInteger.</param>
/// <param name="EnumNumber">EnumNumber.</param>
public EnumTest(EnumStringEnum? EnumString = null, EnumIntegerEnum? EnumInteger = null, EnumNumberEnum? EnumNumber = null)
{
this.EnumString = EnumString;
this.EnumInteger = EnumInteger;
this.EnumNumber = EnumNumber;
}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class EnumTest {\n");
sb.Append(" EnumString: ").Append(EnumString).Append("\n");
sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n");
sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
// credit: http://stackoverflow.com/a/10454552/677735
return this.Equals(obj as EnumTest);
}
/// <summary>
/// Returns true if EnumTest instances are equal
/// </summary>
/// <param name="other">Instance of EnumTest to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(EnumTest other)
{
// credit: http://stackoverflow.com/a/10454552/677735
if (other == null)
return false;
return
(
this.EnumString == other.EnumString ||
this.EnumString != null &&
this.EnumString.Equals(other.EnumString)
) &&
(
this.EnumInteger == other.EnumInteger ||
this.EnumInteger != null &&
this.EnumInteger.Equals(other.EnumInteger)
) &&
(
this.EnumNumber == other.EnumNumber ||
this.EnumNumber != null &&
this.EnumNumber.Equals(other.EnumNumber)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
if (this.EnumString != null)
hash = hash * 59 + this.EnumString.GetHashCode();
if (this.EnumInteger != null)
hash = hash * 59 + this.EnumInteger.GetHashCode();
if (this.EnumNumber != null)
hash = hash * 59 + this.EnumNumber.GetHashCode();
return hash;
}
}
}
}

View File

@ -12,15 +12,13 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// FormatTest
/// </summary>
[DataContract]
public partial class FormatTest : IEquatable<FormatTest>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="FormatTest" /> class.
/// Initializes a new instance of the <see cref="FormatTest" />class.
/// </summary>
/// <param name="Integer">Integer.</param>
/// <param name="Int32">Int32.</param>
@ -29,12 +27,11 @@ namespace IO.Swagger.Model
/// <param name="_Float">_Float.</param>
/// <param name="_Double">_Double.</param>
/// <param name="_String">_String.</param>
/// <param name="_Byte">_Byte.</param>
/// <param name="_Byte">_Byte (required).</param>
/// <param name="Binary">Binary.</param>
/// <param name="Date">Date.</param>
/// <param name="Date">Date (required).</param>
/// <param name="DateTime">DateTime.</param>
/// <param name="Password">Password.</param>
/// <param name="Password">Password (required).</param>
public FormatTest(int? Integer = null, int? Int32 = null, long? Int64 = null, double? Number = null, float? _Float = null, double? _Double = null, string _String = null, byte[] _Byte = null, byte[] Binary = null, DateTime? Date = null, DateTime? DateTime = null, string Password = null)
{
// to ensure "Number" is required (not null)
@ -46,93 +43,113 @@ namespace IO.Swagger.Model
{
this.Number = Number;
}
this.Integer = Integer;
this.Int32 = Int32;
this.Int64 = Int64;
this._Float = _Float;
this._Double = _Double;
this._String = _String;
this._Byte = _Byte;
this.Binary = Binary;
this.Date = Date;
this.DateTime = DateTime;
this.Password = Password;
// to ensure "_Byte" is required (not null)
if (_Byte == null)
{
throw new InvalidDataException("_Byte is a required property for FormatTest and cannot be null");
}
else
{
this._Byte = _Byte;
}
// to ensure "Date" is required (not null)
if (Date == null)
{
throw new InvalidDataException("Date is a required property for FormatTest and cannot be null");
}
else
{
this.Date = Date;
}
// to ensure "Password" is required (not null)
if (Password == null)
{
throw new InvalidDataException("Password is a required property for FormatTest and cannot be null");
}
else
{
this.Password = Password;
}
this.Integer = Integer;
this.Int32 = Int32;
this.Int64 = Int64;
this._Float = _Float;
this._Double = _Double;
this._String = _String;
this.Binary = Binary;
this.DateTime = DateTime;
}
/// <summary>
/// Gets or Sets Integer
/// </summary>
[DataMember(Name="integer", EmitDefaultValue=false)]
public int? Integer { get; set; }
/// <summary>
/// Gets or Sets Int32
/// </summary>
[DataMember(Name="int32", EmitDefaultValue=false)]
public int? Int32 { get; set; }
/// <summary>
/// Gets or Sets Int64
/// </summary>
[DataMember(Name="int64", EmitDefaultValue=false)]
public long? Int64 { get; set; }
/// <summary>
/// Gets or Sets Number
/// </summary>
[DataMember(Name="number", EmitDefaultValue=false)]
public double? Number { get; set; }
/// <summary>
/// Gets or Sets _Float
/// </summary>
[DataMember(Name="float", EmitDefaultValue=false)]
public float? _Float { get; set; }
/// <summary>
/// Gets or Sets _Double
/// </summary>
[DataMember(Name="double", EmitDefaultValue=false)]
public double? _Double { get; set; }
/// <summary>
/// Gets or Sets _String
/// </summary>
[DataMember(Name="string", EmitDefaultValue=false)]
public string _String { get; set; }
/// <summary>
/// Gets or Sets _Byte
/// </summary>
[DataMember(Name="byte", EmitDefaultValue=false)]
public byte[] _Byte { get; set; }
/// <summary>
/// Gets or Sets Binary
/// </summary>
[DataMember(Name="binary", EmitDefaultValue=false)]
public byte[] Binary { get; set; }
/// <summary>
/// Gets or Sets Date
/// </summary>
[DataMember(Name="date", EmitDefaultValue=false)]
public DateTime? Date { get; set; }
/// <summary>
/// Gets or Sets DateTime
/// </summary>
[DataMember(Name="dateTime", EmitDefaultValue=false)]
public DateTime? DateTime { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
[DataMember(Name="password", EmitDefaultValue=false)]
public string Password { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -142,21 +159,21 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class FormatTest {\n");
sb.Append(" Integer: ").Append(Integer).Append("\n");
sb.Append(" Int32: ").Append(Int32).Append("\n");
sb.Append(" Int64: ").Append(Int64).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" _Float: ").Append(_Float).Append("\n");
sb.Append(" _Double: ").Append(_Double).Append("\n");
sb.Append(" _String: ").Append(_String).Append("\n");
sb.Append(" _Byte: ").Append(_Byte).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
sb.Append(" DateTime: ").Append(DateTime).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Int32: ").Append(Int32).Append("\n");
sb.Append(" Int64: ").Append(Int64).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" _Float: ").Append(_Float).Append("\n");
sb.Append(" _Double: ").Append(_Double).Append("\n");
sb.Append(" _String: ").Append(_String).Append("\n");
sb.Append(" _Byte: ").Append(_Byte).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
sb.Append(" DateTime: ").Append(DateTime).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -289,6 +306,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@ -12,25 +13,34 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// InlineResponse200
/// </summary>
[DataContract]
public partial class InlineResponse200 : IEquatable<InlineResponse200>
{
/// <summary>
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
[JsonConverter(typeof(StringEnumConverter))]
public enum StatusEnum {
public enum StatusEnum
{
/// <summary>
/// Enum Available for "available"
/// </summary>
[EnumMember(Value = "available")]
Available,
/// <summary>
/// Enum Pending for "pending"
/// </summary>
[EnumMember(Value = "pending")]
Pending,
/// <summary>
/// Enum Sold for "sold"
/// </summary>
[EnumMember(Value = "sold")]
Sold
}
@ -47,14 +57,14 @@ namespace IO.Swagger.Model
/// Initializes a new instance of the <see cref="InlineResponse200" /> class.
/// Initializes a new instance of the <see cref="InlineResponse200" />class.
/// </summary>
/// <param name="PhotoUrls">PhotoUrls.</param>
/// <param name="Name">Name.</param>
/// <param name="Tags">Tags.</param>
/// <param name="Id">Id (required).</param>
/// <param name="Category">Category.</param>
/// <param name="Tags">Tags.</param>
/// <param name="Status">pet status in the store.</param>
/// <param name="Name">Name.</param>
/// <param name="PhotoUrls">PhotoUrls.</param>
public InlineResponse200(List<string> PhotoUrls = null, string Name = null, long? Id = null, Object Category = null, List<Tag> Tags = null, StatusEnum? Status = null)
public InlineResponse200(List<Tag> Tags = null, long? Id = null, Object Category = null, StatusEnum? Status = null, string Name = null, List<string> PhotoUrls = null)
{
// to ensure "Id" is required (not null)
if (Id == null)
@ -65,26 +75,20 @@ namespace IO.Swagger.Model
{
this.Id = Id;
}
this.PhotoUrls = PhotoUrls;
this.Name = Name;
this.Category = Category;
this.Tags = Tags;
this.Category = Category;
this.Status = Status;
this.Name = Name;
this.PhotoUrls = PhotoUrls;
}
/// <summary>
/// Gets or Sets PhotoUrls
/// Gets or Sets Tags
/// </summary>
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
[DataMember(Name="tags", EmitDefaultValue=false)]
public List<Tag> Tags { get; set; }
/// <summary>
/// Gets or Sets Id
@ -99,10 +103,16 @@ namespace IO.Swagger.Model
public Object Category { get; set; }
/// <summary>
/// Gets or Sets Tags
/// Gets or Sets Name
/// </summary>
[DataMember(Name="tags", EmitDefaultValue=false)]
public List<Tag> Tags { get; set; }
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Returns the string presentation of the object
@ -112,16 +122,17 @@ namespace IO.Swagger.Model
{
var sb = new StringBuilder();
sb.Append("class InlineResponse200 {\n");
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -155,14 +166,9 @@ namespace IO.Swagger.Model
return
(
this.PhotoUrls == other.PhotoUrls ||
this.PhotoUrls != null &&
this.PhotoUrls.SequenceEqual(other.PhotoUrls)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
this.Tags == other.Tags ||
this.Tags != null &&
this.Tags.SequenceEqual(other.Tags)
) &&
(
this.Id == other.Id ||
@ -174,15 +180,20 @@ namespace IO.Swagger.Model
this.Category != null &&
this.Category.Equals(other.Category)
) &&
(
this.Tags == other.Tags ||
this.Tags != null &&
this.Tags.SequenceEqual(other.Tags)
) &&
(
this.Status == other.Status ||
this.Status != null &&
this.Status.Equals(other.Status)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
) &&
(
this.PhotoUrls == other.PhotoUrls ||
this.PhotoUrls != null &&
this.PhotoUrls.SequenceEqual(other.PhotoUrls)
);
}
@ -197,21 +208,28 @@ namespace IO.Swagger.Model
{
int hash = 41;
// Suitable nullity checks etc, of course :)
if (this.PhotoUrls != null)
hash = hash * 59 + this.PhotoUrls.GetHashCode();
if (this.Name != null)
hash = hash * 59 + this.Name.GetHashCode();
if (this.Id != null)
hash = hash * 59 + this.Id.GetHashCode();
if (this.Category != null)
hash = hash * 59 + this.Category.GetHashCode();
if (this.Tags != null)
hash = hash * 59 + this.Tags.GetHashCode();
if (this.Id != null)
hash = hash * 59 + this.Id.GetHashCode();
if (this.Category != null)
hash = hash * 59 + this.Category.GetHashCode();
if (this.Status != null)
hash = hash * 59 + this.Status.GetHashCode();
if (this.Name != null)
hash = hash * 59 + this.Name.GetHashCode();
if (this.PhotoUrls != null)
hash = hash * 59 + this.PhotoUrls.GetHashCode();
return hash;
}
}
}
}

View File

@ -16,27 +16,24 @@ namespace IO.Swagger.Model
/// </summary>
[DataContract]
public partial class Model200Response : IEquatable<Model200Response>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Model200Response" /> class.
/// Initializes a new instance of the <see cref="Model200Response" />class.
/// </summary>
/// <param name="Name">Name.</param>
public Model200Response(int? Name = null)
{
this.Name = Name;
this.Name = Name;
}
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public int? Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -49,7 +46,7 @@ namespace IO.Swagger.Model
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -105,6 +102,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -16,27 +16,24 @@ namespace IO.Swagger.Model
/// </summary>
[DataContract]
public partial class ModelReturn : IEquatable<ModelReturn>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="ModelReturn" /> class.
/// Initializes a new instance of the <see cref="ModelReturn" />class.
/// </summary>
/// <param name="_Return">_Return.</param>
public ModelReturn(int? _Return = null)
{
this._Return = _Return;
this._Return = _Return;
}
/// <summary>
/// Gets or Sets _Return
/// </summary>
[DataMember(Name="return", EmitDefaultValue=false)]
public int? _Return { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -49,7 +46,7 @@ namespace IO.Swagger.Model
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -105,6 +102,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -16,15 +16,12 @@ namespace IO.Swagger.Model
/// </summary>
[DataContract]
public partial class Name : IEquatable<Name>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Name" /> class.
/// Initializes a new instance of the <see cref="Name" />class.
/// </summary>
/// <param name="_Name">_Name (required).</param>
/// <param name="Property">Property.</param>
public Name(int? _Name = null, string Property = null)
{
// to ensure "_Name" is required (not null)
@ -36,29 +33,27 @@ namespace IO.Swagger.Model
{
this._Name = _Name;
}
this.Property = Property;
this.Property = Property;
}
/// <summary>
/// Gets or Sets _Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public int? _Name { get; set; }
/// <summary>
/// Gets or Sets SnakeCase
/// </summary>
[DataMember(Name="snake_case", EmitDefaultValue=false)]
public int? SnakeCase { get; private set; }
/// <summary>
/// Gets or Sets Property
/// </summary>
[DataMember(Name="property", EmitDefaultValue=false)]
public string Property { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -68,12 +63,12 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Name {\n");
sb.Append(" _Name: ").Append(_Name).Append("\n");
sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n");
sb.Append(" Property: ").Append(Property).Append("\n");
sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n");
sb.Append(" Property: ").Append(Property).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -143,6 +138,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,40 +12,46 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Order
/// </summary>
[DataContract]
public partial class Order : IEquatable<Order>
{
{
/// <summary>
/// Order Status
/// </summary>
/// <value>Order Status</value>
[JsonConverter(typeof(StringEnumConverter))]
public enum StatusEnum {
public enum StatusEnum
{
/// <summary>
/// Enum Placed for "placed"
/// </summary>
[EnumMember(Value = "placed")]
Placed,
/// <summary>
/// Enum Approved for "approved"
/// </summary>
[EnumMember(Value = "approved")]
Approved,
/// <summary>
/// Enum Delivered for "delivered"
/// </summary>
[EnumMember(Value = "delivered")]
Delivered
}
/// <summary>
/// Order Status
/// </summary>
/// <value>Order Status</value>
[DataMember(Name="status", EmitDefaultValue=false)]
public StatusEnum? Status { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Order" /> class.
/// Initializes a new instance of the <see cref="Order" />class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="PetId">PetId.</param>
@ -53,14 +59,20 @@ namespace IO.Swagger.Model
/// <param name="ShipDate">ShipDate.</param>
/// <param name="Status">Order Status.</param>
/// <param name="Complete">Complete (default to false).</param>
public Order(long? Id = null, long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, StatusEnum? Status = null, bool? Complete = null)
{
this.Id = Id;
this.PetId = PetId;
this.Quantity = Quantity;
this.ShipDate = ShipDate;
this.Status = Status;
this.Id = Id;
this.PetId = PetId;
this.Quantity = Quantity;
this.ShipDate = ShipDate;
this.Status = Status;
// use default value if no "Complete" provided
if (Complete == null)
{
@ -72,38 +84,32 @@ namespace IO.Swagger.Model
}
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
[DataMember(Name="petId", EmitDefaultValue=false)]
public long? PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
[DataMember(Name="quantity", EmitDefaultValue=false)]
public int? Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
[DataMember(Name="shipDate", EmitDefaultValue=false)]
public DateTime? ShipDate { get; set; }
/// <summary>
/// Gets or Sets Complete
/// </summary>
[DataMember(Name="complete", EmitDefaultValue=false)]
public bool? Complete { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -113,15 +119,15 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Order {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" PetId: ").Append(PetId).Append("\n");
sb.Append(" Quantity: ").Append(Quantity).Append("\n");
sb.Append(" ShipDate: ").Append(ShipDate).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Complete: ").Append(Complete).Append("\n");
sb.Append(" PetId: ").Append(PetId).Append("\n");
sb.Append(" Quantity: ").Append(Quantity).Append("\n");
sb.Append(" ShipDate: ").Append(ShipDate).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Complete: ").Append(Complete).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -212,6 +218,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,40 +12,46 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Pet
/// </summary>
[DataContract]
public partial class Pet : IEquatable<Pet>
{
{
/// <summary>
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
[JsonConverter(typeof(StringEnumConverter))]
public enum StatusEnum {
public enum StatusEnum
{
/// <summary>
/// Enum Available for "available"
/// </summary>
[EnumMember(Value = "available")]
Available,
/// <summary>
/// Enum Pending for "pending"
/// </summary>
[EnumMember(Value = "pending")]
Pending,
/// <summary>
/// Enum Sold for "sold"
/// </summary>
[EnumMember(Value = "sold")]
Sold
}
/// <summary>
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
[DataMember(Name="status", EmitDefaultValue=false)]
public StatusEnum? Status { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Pet" /> class.
/// Initializes a new instance of the <see cref="Pet" />class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Category">Category.</param>
@ -53,7 +59,6 @@ namespace IO.Swagger.Model
/// <param name="PhotoUrls">PhotoUrls (required).</param>
/// <param name="Tags">Tags.</param>
/// <param name="Status">pet status in the store.</param>
public Pet(long? Id = null, Category Category = null, string Name = null, List<string> PhotoUrls = null, List<Tag> Tags = null, StatusEnum? Status = null)
{
// to ensure "Name" is required (not null)
@ -74,44 +79,43 @@ namespace IO.Swagger.Model
{
this.PhotoUrls = PhotoUrls;
}
this.Id = Id;
this.Category = Category;
this.Tags = Tags;
this.Status = Status;
this.Id = Id;
this.Category = Category;
this.Tags = Tags;
this.Status = Status;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
[DataMember(Name="category", EmitDefaultValue=false)]
public Category Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Tags
/// </summary>
[DataMember(Name="tags", EmitDefaultValue=false)]
public List<Tag> Tags { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -121,15 +125,15 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Pet {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -220,6 +224,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,31 +12,28 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// SpecialModelName
/// </summary>
[DataContract]
public partial class SpecialModelName : IEquatable<SpecialModelName>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="SpecialModelName" /> class.
/// Initializes a new instance of the <see cref="SpecialModelName" />class.
/// </summary>
/// <param name="SpecialPropertyName">SpecialPropertyName.</param>
public SpecialModelName(long? SpecialPropertyName = null)
{
this.SpecialPropertyName = SpecialPropertyName;
this.SpecialPropertyName = SpecialPropertyName;
}
/// <summary>
/// Gets or Sets SpecialPropertyName
/// </summary>
[DataMember(Name="$special[property.name]", EmitDefaultValue=false)]
public long? SpecialPropertyName { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -49,7 +46,7 @@ namespace IO.Swagger.Model
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -105,6 +102,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -12,39 +12,36 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// Tag
/// </summary>
[DataContract]
public partial class Tag : IEquatable<Tag>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="Tag" /> class.
/// Initializes a new instance of the <see cref="Tag" />class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Name">Name.</param>
public Tag(long? Id = null, string Name = null)
{
this.Id = Id;
this.Name = Name;
this.Id = Id;
this.Name = Name;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -54,11 +51,11 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class Tag {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -121,6 +118,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -0,0 +1,143 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Model
{
/// <summary>
///
/// </summary>
[DataContract]
public class TagCategoryTest : Category, IEquatable<TagCategoryTest>
{
/// <summary>
/// Initializes a new instance of the <see cref="TagCategoryTest" /> class.
/// </summary>
public TagCategoryTest()
{
this.TagCategoryInteger = 0;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// integer property for testing allOf
/// </summary>
/// <value>integer property for testing allOf</value>
[DataMember(Name="TagCategoryInteger", EmitDefaultValue=false)]
public int? TagCategoryInteger { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class TagCategoryTest {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" TagCategoryInteger: ").Append(TagCategoryInteger).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public new string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
// credit: http://stackoverflow.com/a/10454552/677735
return this.Equals(obj as TagCategoryTest);
}
/// <summary>
/// Returns true if TagCategoryTest instances are equal
/// </summary>
/// <param name="other">Instance of TagCategoryTest to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(TagCategoryTest other)
{
// credit: http://stackoverflow.com/a/10454552/677735
if (other == null)
return false;
return
(
this.Id == other.Id ||
this.Id != null &&
this.Id.Equals(other.Id)
) &&
(
this.TagCategoryInteger == other.TagCategoryInteger ||
this.TagCategoryInteger != null &&
this.TagCategoryInteger.Equals(other.TagCategoryInteger)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
if (this.Id != null)
hash = hash * 57 + this.Id.GetHashCode();
if (this.TagCategoryInteger != null)
hash = hash * 57 + this.TagCategoryInteger.GetHashCode();
if (this.Name != null)
hash = hash * 57 + this.Name.GetHashCode();
return hash;
}
}
}
}

View File

@ -12,15 +12,13 @@ using Newtonsoft.Json.Converters;
namespace IO.Swagger.Model
{
/// <summary>
///
/// User
/// </summary>
[DataContract]
public partial class User : IEquatable<User>
{
{
/// <summary>
/// Initializes a new instance of the <see cref="User" /> class.
/// Initializes a new instance of the <see cref="User" />class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Username">Username.</param>
@ -30,70 +28,69 @@ namespace IO.Swagger.Model
/// <param name="Password">Password.</param>
/// <param name="Phone">Phone.</param>
/// <param name="UserStatus">User Status.</param>
public User(long? Id = null, string Username = null, string FirstName = null, string LastName = null, string Email = null, string Password = null, string Phone = null, int? UserStatus = null)
{
this.Id = Id;
this.Username = Username;
this.FirstName = FirstName;
this.LastName = LastName;
this.Email = Email;
this.Password = Password;
this.Phone = Phone;
this.UserStatus = UserStatus;
this.Id = Id;
this.Username = Username;
this.FirstName = FirstName;
this.LastName = LastName;
this.Email = Email;
this.Password = Password;
this.Phone = Phone;
this.UserStatus = UserStatus;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Username
/// </summary>
[DataMember(Name="username", EmitDefaultValue=false)]
public string Username { get; set; }
/// <summary>
/// Gets or Sets FirstName
/// </summary>
[DataMember(Name="firstName", EmitDefaultValue=false)]
public string FirstName { get; set; }
/// <summary>
/// Gets or Sets LastName
/// </summary>
[DataMember(Name="lastName", EmitDefaultValue=false)]
public string LastName { get; set; }
/// <summary>
/// Gets or Sets Email
/// </summary>
[DataMember(Name="email", EmitDefaultValue=false)]
public string Email { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
[DataMember(Name="password", EmitDefaultValue=false)]
public string Password { get; set; }
/// <summary>
/// Gets or Sets Phone
/// </summary>
[DataMember(Name="phone", EmitDefaultValue=false)]
public string Phone { get; set; }
/// <summary>
/// User Status
/// </summary>
/// <value>User Status</value>
[DataMember(Name="userStatus", EmitDefaultValue=false)]
public int? UserStatus { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
@ -103,17 +100,17 @@ namespace IO.Swagger.Model
var sb = new StringBuilder();
sb.Append("class User {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Username: ").Append(Username).Append("\n");
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
sb.Append(" LastName: ").Append(LastName).Append("\n");
sb.Append(" Email: ").Append(Email).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Phone: ").Append(Phone).Append("\n");
sb.Append(" UserStatus: ").Append(UserStatus).Append("\n");
sb.Append(" Username: ").Append(Username).Append("\n");
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
sb.Append(" LastName: ").Append(LastName).Append("\n");
sb.Append(" Email: ").Append(Email).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Phone: ").Append(Phone).Append("\n");
sb.Append(" UserStatus: ").Append(UserStatus).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
@ -218,6 +215,6 @@ namespace IO.Swagger.Model
return hash;
}
}
}
}

View File

@ -69,8 +69,11 @@
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Animal.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Cat.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Dog.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\FormatTest.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\EnumClass.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\EnumTest.cs" />
<Compile Include="TestEnum.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\ApiResponse.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\FormatTest.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

View File

@ -1,28 +1,12 @@
<Properties StartupItem="SwaggerClientTest.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/EnumTest.cs">
<Files>
<File FileName="TestPet.cs" Line="29" Column="39" />
<File FileName="TestOrder.cs" Line="99" Column="6" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="711" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/EnumTest.cs" Line="18" Column="58" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs" Line="1" Column="1" />
<File FileName="TestEnum.cs" Line="28" Column="75" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/EnumClass.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="MonoDevelop.NUnit.TestPad">
<State name="__root__">
<Node name="SwaggerClientTest" expanded="True">
<Node name="SwaggerClientTest" expanded="True">
<Node name="SwaggerClientTest" expanded="True">
<Node name="TestPet" expanded="True">
<Node name="TestPet" expanded="True">
<Node name="TestGetPetByIdAsyncWithHttpInfo" selected="True" />
</Node>
</Node>
</Node>
</Node>
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />

View File

@ -0,0 +1,39 @@
using NUnit.Framework;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace SwaggerClientTest.TestEnum
{
[TestFixture ()]
public class TestEnum
{
public TestEnum ()
{
}
/// <summary>
/// Test EnumClass
/// </summary>
[Test ()]
public void TestEnumClass ()
{
// test serialization for string
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumClass.Abc), "\"_abc\"");
// test serialization for number
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumTest.EnumIntegerEnum.NUMBER_MINUS_1), "\"-1\"");
// test cast to int
Assert.AreEqual ((int)EnumTest.EnumIntegerEnum.NUMBER_MINUS_1, -1);
}
}
}

View File

@ -73,14 +73,14 @@ namespace SwaggerClientTest.TestOrder
}
/* comment out the test case as the method is not defined in original petstore spec
* we will re-enable this after updating the petstore server
*
/*
* Skip the following test as the fake endpiont has been removed from the swagger spec
* We'll uncomment below after we update the Petstore server
/// <summary>
/// Test GetInvetoryInObject
/// Test TestGetInventoryInObject
/// </summary>
[Test ()]
public void TestGetInventoryInObject ()
public void TestGetInventoryInObject()
{
// set timeout to 10 seconds
Configuration c1 = new Configuration (timeout: 10000);
@ -95,9 +95,18 @@ namespace SwaggerClientTest.TestOrder
{
Assert.IsInstanceOf (typeof(int?), Int32.Parse(entry.Value));
}
}
*/
}*/
/// <summary>
/// Test Enum
/// </summary>
[Test ()]
public void TestEnum ()
{
Assert.AreEqual (Order.StatusEnum.Approved.ToString(), "Approved");
}
}
}

View File

@ -1,9 +0,0 @@
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll

View File

@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge
- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-04-27T21:14:49.805-07:00
- Build date: 2016-05-02T15:51:26.331+01:00
- Build package: class io.swagger.codegen.languages.GoClientCodegen
## Installation

View File

@ -1,123 +1,120 @@
package petstore
import (
"strings"
"github.com/go-resty/resty"
"fmt"
"reflect"
"bytes"
"path/filepath"
"bytes"
"fmt"
"path/filepath"
"reflect"
"strings"
"github.com/go-resty/resty"
)
type APIClient struct {
}
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
if (len(contentTypes) == 0){
return ""
}
if contains(contentTypes,"application/json") {
return "application/json"
}
return contentTypes[0] // use the first content type specified in 'consumes'
if len(contentTypes) == 0 {
return ""
}
if contains(contentTypes, "application/json") {
return "application/json"
}
return contentTypes[0] // use the first content type specified in 'consumes'
}
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
if (len(accepts) == 0){
return ""
}
if contains(accepts,"application/json"){
return "application/json"
}
return strings.Join(accepts,",")
if len(accepts) == 0 {
return ""
}
if contains(accepts, "application/json") {
return "application/json"
}
return strings.Join(accepts, ",")
}
func contains(source []string, containvalue string) bool {
for _, a := range source {
if strings.ToLower(a) == strings.ToLower(containvalue) {
return true
}
}
return false
for _, a := range source {
if strings.ToLower(a) == strings.ToLower(containvalue) {
return true
}
}
return false
}
func (c *APIClient) CallAPI(path string, method string,
postBody interface{},
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) (*resty.Response, error) {
postBody interface{},
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) (*resty.Response, error) {
//set debug flag
configuration := NewConfiguration()
resty.SetDebug(configuration.GetDebug())
//set debug flag
configuration := NewConfiguration()
resty.SetDebug(configuration.GetDebug())
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
switch strings.ToUpper(method) {
case "GET":
response, err := request.Get(path)
return response, err
case "POST":
response, err := request.Post(path)
return response, err
case "PUT":
response, err := request.Put(path)
return response, err
case "PATCH":
response, err := request.Patch(path)
return response, err
case "DELETE":
response, err := request.Delete(path)
return response, err
}
switch strings.ToUpper(method) {
case "GET":
response, err := request.Get(path)
return response, err
case "POST":
response, err := request.Post(path)
return response, err
case "PUT":
response, err := request.Put(path)
return response, err
case "PATCH":
response, err := request.Patch(path)
return response, err
case "DELETE":
response, err := request.Delete(path)
return response, err
}
return nil, fmt.Errorf("invalid method %v", method)
return nil, fmt.Errorf("invalid method %v", method)
}
func (c *APIClient) ParameterToString(obj interface{}) string {
if reflect.TypeOf(obj).String() == "[]string" {
return strings.Join(obj.([]string), ",")
} else {
return obj.(string)
}
if reflect.TypeOf(obj).String() == "[]string" {
return strings.Join(obj.([]string), ",")
} else {
return obj.(string)
}
}
func prepareRequest(postBody interface{},
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) *resty.Request {
headerParams map[string]string,
queryParams map[string]string,
formParams map[string]string,
fileName string,
fileBytes []byte) *resty.Request {
request := resty.R()
request := resty.R()
request.SetBody(postBody)
request.SetBody(postBody)
// add header parameter, if any
if len(headerParams) > 0 {
request.SetHeaders(headerParams)
}
// add header parameter, if any
if len(headerParams) > 0 {
request.SetHeaders(headerParams)
}
// add query parameter, if any
if len(queryParams) > 0 {
request.SetQueryParams(queryParams)
}
// add query parameter, if any
if len(queryParams) > 0 {
request.SetQueryParams(queryParams)
}
// add form parameter, if any
if len(formParams) > 0 {
request.SetFormData(formParams)
}
if len(fileBytes) > 0 && fileName != "" {
_, fileNm := filepath.Split(fileName)
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
}
return request
// add form parameter, if any
if len(formParams) > 0 {
request.SetFormData(formParams)
}
if len(fileBytes) > 0 && fileName != "" {
_, fileNm := filepath.Split(fileName)
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
}
return request
}

View File

@ -1,24 +1,22 @@
package petstore
import (
"net/http"
"net/http"
)
type APIResponse struct {
*http.Response
Message string `json:"message,omitempty"`
*http.Response
Message string `json:"message,omitempty"`
}
func NewAPIResponse(r *http.Response) *APIResponse {
response := &APIResponse{Response: r}
return response
response := &APIResponse{Response: r}
return response
}
func NewAPIResponseWithError(errorMessage string) *APIResponse {
response := &APIResponse{Message: errorMessage}
return response
}
response := &APIResponse{Message: errorMessage}
return response
}

View File

@ -1,12 +1,8 @@
package petstore
import (
)
type Category struct {
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}

View File

@ -1,59 +1,59 @@
package petstore
import (
"encoding/base64"
"encoding/base64"
)
type Configuration struct {
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"`
APIKey map[string] string `json:"APIKey,omitempty"`
debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"`
Timeout int `json:"timeout,omitempty"`
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
APIClient APIClient `json:"APIClient,omitempty"`
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
APIKey map[string]string `json:"APIKey,omitempty"`
debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"`
Timeout int `json:"timeout,omitempty"`
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
APIClient APIClient `json:"APIClient,omitempty"`
}
func NewConfiguration() *Configuration {
return &Configuration{
BasePath: "http://petstore.swagger.io/v2",
UserName: "",
debug: false,
DefaultHeader: make(map[string]string),
APIKey: make(map[string]string),
APIKeyPrefix: make(map[string]string),
UserAgent: "Swagger-Codegen/1.0.0/go",
}
return &Configuration{
BasePath: "http://petstore.swagger.io/v2",
UserName: "",
debug: false,
DefaultHeader: make(map[string]string),
APIKey: make(map[string]string),
APIKeyPrefix: make(map[string]string),
UserAgent: "Swagger-Codegen/1.0.0/go",
}
}
func (c *Configuration) GetBasicAuthEncodedString() string {
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
}
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
c.DefaultHeader[key] = value
}
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
if c.APIKeyPrefix[APIKeyIdentifier] != ""{
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
}
return c.APIKey[APIKeyIdentifier]
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
}
return c.APIKey[APIKeyIdentifier]
}
func (c *Configuration) SetDebug(enable bool){
c.debug = enable
func (c *Configuration) SetDebug(enable bool) {
c.debug = enable
}
func (c *Configuration) GetDebug() bool {
return c.debug
}
return c.debug
}

View File

@ -8,12 +8,12 @@ git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="YOUR_GIT_USR_ID"
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="YOUR_GIT_REPO_ID"
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

View File

@ -1,14 +1,10 @@
package petstore
import (
)
type ModelApiResponse struct {
Code int32 `json:"code,omitempty"`
Type_ string `json:"type,omitempty"`
Message string `json:"message,omitempty"`
Code int32 `json:"code,omitempty"`
Type_ string `json:"type,omitempty"`
Message string `json:"message,omitempty"`
}

View File

@ -1,21 +1,21 @@
package petstore
import (
"time"
"time"
)
type Order struct {
Id int64 `json:"id,omitempty"`
PetId int64 `json:"petId,omitempty"`
Quantity int32 `json:"quantity,omitempty"`
ShipDate time.Time `json:"shipDate,omitempty"`
// Order Status
Status string `json:"status,omitempty"`
Complete bool `json:"complete,omitempty"`
Id int64 `json:"id,omitempty"`
PetId int64 `json:"petId,omitempty"`
Quantity int32 `json:"quantity,omitempty"`
ShipDate time.Time `json:"shipDate,omitempty"`
// Order Status
Status string `json:"status,omitempty"`
Complete bool `json:"complete,omitempty"`
}

View File

@ -1,20 +1,17 @@
package petstore
import (
)
type Pet struct {
Id int64 `json:"id,omitempty"`
Category Category `json:"category,omitempty"`
Name string `json:"name,omitempty"`
PhotoUrls []string `json:"photoUrls,omitempty"`
Tags []Tag `json:"tags,omitempty"`
// pet status in the store
Status string `json:"status,omitempty"`
Id int64 `json:"id,omitempty"`
Category Category `json:"category,omitempty"`
Name string `json:"name,omitempty"`
PhotoUrls []string `json:"photoUrls,omitempty"`
Tags []Tag `json:"tags,omitempty"`
// pet status in the store
Status string `json:"status,omitempty"`
}

File diff suppressed because it is too large Load Diff

View File

@ -1,282 +1,264 @@
package petstore
import (
"strings"
"fmt"
"errors"
"encoding/json"
"strings"
"fmt"
"errors"
"encoding/json"
)
type StoreApi struct {
Configuration Configuration
Configuration Configuration
}
func NewStoreApi() *StoreApi{
configuration := NewConfiguration()
return &StoreApi {
Configuration: *configuration,
}
func NewStoreApi() *StoreApi {
configuration := NewConfiguration()
return &StoreApi{
Configuration: *configuration,
}
}
func NewStoreApiWithBasePath(basePath string) *StoreApi{
configuration := NewConfiguration()
configuration.BasePath = basePath
return &StoreApi {
Configuration: *configuration,
}
func NewStoreApiWithBasePath(basePath string) *StoreApi {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &StoreApi{
Configuration: *configuration,
}
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
*
* @param orderId ID of the order that needs to be deleted
* @return void
*/
func (a StoreApi) DeleteOrder (orderId string) (*APIResponse, error) {
func (a StoreApi) DeleteOrder(orderId string) (APIResponse, error) {
var httpMethod = "Delete"
// create path and map variables
path := a.Configuration.BasePath + "/store/order/{orderId}"
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
var httpMethod = "Delete"
// create path and map variables
path := a.Configuration.BasePath + "/store/order/{orderId}"
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
// verify the required parameter 'orderId' is set
if &orderId == nil {
return nil, errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder")
}
// verify the required parameter 'orderId' is set
if &orderId == nil {
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder")
}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string {
"application/xml",
"application/json",
}
//set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
}
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err
}
if err != nil {
return NewAPIResponse(httpResponse.RawResponse), err
}
return NewAPIResponse(httpResponse.RawResponse), err
return *NewAPIResponse(httpResponse.RawResponse), err
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*
* @return map[string]int32
*/
func (a StoreApi) GetInventory () (*map[string]int32, *APIResponse, error) {
func (a StoreApi) GetInventory() (map[string]int32, APIResponse, error) {
var httpMethod = "Get"
// create path and map variables
path := a.Configuration.BasePath + "/store/inventory"
var httpMethod = "Get"
// create path and map variables
path := a.Configuration.BasePath + "/store/inventory"
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (api_key) required
// authentication (api_key) required
// set key with prefix in header
headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key")
// set key with prefix in header
headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key")
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string {
"application/json",
}
//set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
}
var successPayload = new(map[string]int32)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return successPayload, NewAPIResponse(httpResponse.RawResponse), err
}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
return successPayload, NewAPIResponse(httpResponse.RawResponse), err
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
var successPayload = new(map[string]int32)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
*
* @param orderId ID of pet that needs to be fetched
* @return Order
*/
func (a StoreApi) GetOrderById (orderId int64) (*Order, *APIResponse, error) {
func (a StoreApi) GetOrderById(orderId int64) (Order, APIResponse, error) {
var httpMethod = "Get"
// create path and map variables
path := a.Configuration.BasePath + "/store/order/{orderId}"
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
var httpMethod = "Get"
// create path and map variables
path := a.Configuration.BasePath + "/store/order/{orderId}"
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
// verify the required parameter 'orderId' is set
if &orderId == nil {
return new(Order), nil, errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById")
}
// verify the required parameter 'orderId' is set
if &orderId == nil {
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById")
}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string {
"application/xml",
"application/json",
}
//set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
}
var successPayload = new(Order)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return successPayload, NewAPIResponse(httpResponse.RawResponse), err
}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
return successPayload, NewAPIResponse(httpResponse.RawResponse), err
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
var successPayload = new(Order)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
}
/**
* Place an order for a pet
*
*
* @param body order placed for purchasing the pet
* @return Order
*/
func (a StoreApi) PlaceOrder (body Order) (*Order, *APIResponse, error) {
func (a StoreApi) PlaceOrder(body Order) (Order, APIResponse, error) {
var httpMethod = "Post"
// create path and map variables
path := a.Configuration.BasePath + "/store/order"
var httpMethod = "Post"
// create path and map variables
path := a.Configuration.BasePath + "/store/order"
// verify the required parameter 'body' is set
if &body == nil {
return new(Order), nil, errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder")
}
// verify the required parameter 'body' is set
if &body == nil {
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder")
}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := make(map[string]string)
var postBody interface{}
var fileName string
var fileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string {
"application/xml",
"application/json",
}
//set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ }
// body params
postBody = &body
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
}
var successPayload = new(Order)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// body params
postBody = &body
if err != nil {
return successPayload, NewAPIResponse(httpResponse.RawResponse), err
}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
return successPayload, NewAPIResponse(httpResponse.RawResponse), err
var successPayload = new(Order)
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
}

View File

@ -1,12 +1,8 @@
package petstore
import (
)
type Tag struct {
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}

View File

@ -1,24 +1,21 @@
package petstore
import (
)
type User struct {
Id int64 `json:"id,omitempty"`
Username string `json:"username,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Phone string `json:"phone,omitempty"`
// User Status
UserStatus int32 `json:"userStatus,omitempty"`
Id int64 `json:"id,omitempty"`
Username string `json:"username,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Phone string `json:"phone,omitempty"`
// User Status
UserStatus int32 `json:"userStatus,omitempty"`
}

Some files were not shown because too many files have changed in this diff Show More