forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/develop_2.0' into java-auth
Conflicts: modules/swagger-codegen/src/main/resources/Java/apiInvoker.mustache samples/client/petstore/java/src/main/java/io/swagger/client/ApiInvoker.java
This commit is contained in:
commit
4d25d264c4
31
bin/swift-petstore.sh
Executable file
31
bin/swift-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -o samples/client/petstore/swift"
|
||||||
|
|
||||||
|
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags
|
@ -3,6 +3,8 @@ package com.wordnik.swagger.codegen;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -12,12 +14,17 @@ import java.util.Set;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.wordnik.swagger.codegen.examples.ExampleGenerator;
|
import com.wordnik.swagger.codegen.examples.ExampleGenerator;
|
||||||
import com.wordnik.swagger.models.ArrayModel;
|
import com.wordnik.swagger.models.ArrayModel;
|
||||||
|
import com.wordnik.swagger.models.ComposedModel;
|
||||||
import com.wordnik.swagger.models.Model;
|
import com.wordnik.swagger.models.Model;
|
||||||
import com.wordnik.swagger.models.ModelImpl;
|
import com.wordnik.swagger.models.ModelImpl;
|
||||||
import com.wordnik.swagger.models.Operation;
|
import com.wordnik.swagger.models.Operation;
|
||||||
@ -53,8 +60,9 @@ import com.wordnik.swagger.models.properties.RefProperty;
|
|||||||
import com.wordnik.swagger.models.properties.StringProperty;
|
import com.wordnik.swagger.models.properties.StringProperty;
|
||||||
import com.wordnik.swagger.util.Json;
|
import com.wordnik.swagger.util.Json;
|
||||||
|
|
||||||
|
|
||||||
public class DefaultCodegen {
|
public class DefaultCodegen {
|
||||||
Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
||||||
|
|
||||||
protected String outputFolder = "";
|
protected String outputFolder = "";
|
||||||
protected Set<String> defaultIncludes = new HashSet<String>();
|
protected Set<String> defaultIncludes = new HashSet<String>();
|
||||||
@ -192,6 +200,7 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toParamName(String name) {
|
public String toParamName(String name) {
|
||||||
|
name = removeNonNameElementToCamelCase(name);
|
||||||
if(reservedWords.contains(name)) {
|
if(reservedWords.contains(name)) {
|
||||||
return escapeReservedWord(name);
|
return escapeReservedWord(name);
|
||||||
}
|
}
|
||||||
@ -466,100 +475,28 @@ public class DefaultCodegen {
|
|||||||
m.classVarName = toVarName(name);
|
m.classVarName = toVarName(name);
|
||||||
m.modelJson = Json.pretty(model);
|
m.modelJson = Json.pretty(model);
|
||||||
m.externalDocs = model.getExternalDocs();
|
m.externalDocs = model.getExternalDocs();
|
||||||
int count = 0;
|
|
||||||
if(model instanceof ArrayModel) {
|
if(model instanceof ArrayModel) {
|
||||||
ArrayModel am = (ArrayModel) model;
|
ArrayModel am = (ArrayModel) model;
|
||||||
ArrayProperty arrayProperty = new ArrayProperty(am.getItems());
|
ArrayProperty arrayProperty = new ArrayProperty(am.getItems());
|
||||||
CodegenProperty cp = fromProperty(name, arrayProperty);
|
addParentContainer(m, name, arrayProperty);
|
||||||
if(cp.complexType != null && !defaultIncludes.contains(cp.complexType))
|
|
||||||
m.imports.add(cp.complexType);
|
|
||||||
m.parent = toInstantiationType(arrayProperty);
|
|
||||||
String containerType = cp.containerType;
|
|
||||||
if(instantiationTypes.containsKey(containerType))
|
|
||||||
m.imports.add(instantiationTypes.get(containerType));
|
|
||||||
if(typeMapping.containsKey(containerType)) {
|
|
||||||
containerType = typeMapping.get(containerType);
|
|
||||||
cp.containerType = containerType;
|
|
||||||
m.imports.add(containerType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (model instanceof RefModel) {
|
else if (model instanceof RefModel) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
} else if (model instanceof ComposedModel) {
|
||||||
else {
|
final ComposedModel composed = (ComposedModel) model;
|
||||||
|
final RefModel parent = (RefModel) composed.getParent();
|
||||||
|
final String parentModel = toModelName(parent.getSimpleRef());
|
||||||
|
m.parent = parentModel;
|
||||||
|
addImport(m, parentModel);
|
||||||
|
final ModelImpl child = (ModelImpl) composed.getChild();
|
||||||
|
addVars(m, child.getProperties(), child.getRequired());
|
||||||
|
} else {
|
||||||
ModelImpl impl = (ModelImpl) model;
|
ModelImpl impl = (ModelImpl) model;
|
||||||
if(impl.getAdditionalProperties() != null) {
|
if(impl.getAdditionalProperties() != null) {
|
||||||
MapProperty mapProperty = new MapProperty(impl.getAdditionalProperties());
|
MapProperty mapProperty = new MapProperty(impl.getAdditionalProperties());
|
||||||
CodegenProperty cp = fromProperty(name, mapProperty);
|
addParentContainer(m, name, mapProperty);
|
||||||
if(cp.complexType != null && !defaultIncludes.contains(cp.complexType))
|
|
||||||
m.imports.add(cp.complexType);
|
|
||||||
m.parent = toInstantiationType(mapProperty);
|
|
||||||
String containerType = cp.containerType;
|
|
||||||
if(instantiationTypes.containsKey(containerType))
|
|
||||||
m.imports.add(instantiationTypes.get(containerType));
|
|
||||||
if(typeMapping.containsKey(containerType)) {
|
|
||||||
containerType = typeMapping.get(containerType);
|
|
||||||
cp.containerType = containerType;
|
|
||||||
m.imports.add(containerType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(impl.getProperties() != null && impl.getProperties().size() > 0) {
|
|
||||||
m.hasVars = true;
|
|
||||||
m.hasEnums = false;
|
|
||||||
for(String key: impl.getProperties().keySet()) {
|
|
||||||
Property prop = impl.getProperties().get(key);
|
|
||||||
|
|
||||||
if(prop == null) {
|
|
||||||
LOGGER.warn("null property for " + key);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CodegenProperty cp;
|
|
||||||
try{
|
|
||||||
cp = fromProperty(key, prop);
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
System.out.println("failed to process model " + name);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
cp.required = null;
|
|
||||||
if(impl.getRequired() != null) {
|
|
||||||
for(String req : impl.getRequired()) {
|
|
||||||
if(key.equals(req))
|
|
||||||
cp.required = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(cp.complexType != null && !defaultIncludes.contains(cp.complexType)) {
|
|
||||||
m.imports.add(cp.complexType);
|
|
||||||
}
|
|
||||||
m.vars.add(cp);
|
|
||||||
count += 1;
|
|
||||||
if (cp.isEnum)
|
|
||||||
m.hasEnums = true;
|
|
||||||
if(count != impl.getProperties().keySet().size())
|
|
||||||
cp.hasMore = new Boolean(true);
|
|
||||||
if(cp.isContainer != null) {
|
|
||||||
String arrayImport = typeMapping.get("array");
|
|
||||||
if(arrayImport != null &&
|
|
||||||
!languageSpecificPrimitives.contains(arrayImport) &&
|
|
||||||
!defaultIncludes.contains(arrayImport))
|
|
||||||
m.imports.add(arrayImport);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cp.complexType != null &&
|
|
||||||
!languageSpecificPrimitives.contains(cp.complexType) &&
|
|
||||||
!defaultIncludes.contains(cp.complexType))
|
|
||||||
m.imports.add(cp.complexType);
|
|
||||||
|
|
||||||
if(cp.baseType != null &&
|
|
||||||
!languageSpecificPrimitives.contains(cp.baseType) &&
|
|
||||||
!defaultIncludes.contains(cp.baseType))
|
|
||||||
m.imports.add(cp.baseType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m.emptyVars = true;
|
|
||||||
}
|
}
|
||||||
|
addVars(m, impl.getProperties(), impl.getRequired());
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -718,6 +655,7 @@ public class DefaultCodegen {
|
|||||||
operationId = builder.toString();
|
operationId = builder.toString();
|
||||||
LOGGER.warn("generated operationId " + operationId);
|
LOGGER.warn("generated operationId " + operationId);
|
||||||
}
|
}
|
||||||
|
operationId = removeNonNameElementToCamelCase(operationId);
|
||||||
op.path = path;
|
op.path = path;
|
||||||
op.operationId = toOperationId(operationId);
|
op.operationId = toOperationId(operationId);
|
||||||
op.summary = escapeText(operation.getSummary());
|
op.summary = escapeText(operation.getSummary());
|
||||||
@ -1141,6 +1079,62 @@ public class DefaultCodegen {
|
|||||||
co.baseName = tag;
|
co.baseName = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addParentContainer(CodegenModel m, String name, Property property) {
|
||||||
|
final CodegenProperty tmp = fromProperty(name, property);
|
||||||
|
addImport(m, tmp.complexType);
|
||||||
|
m.parent = toInstantiationType(property);
|
||||||
|
final String containerType = tmp.containerType;
|
||||||
|
final String instantiationType = instantiationTypes.get(containerType);
|
||||||
|
if (instantiationType != null) {
|
||||||
|
addImport(m, instantiationType);
|
||||||
|
}
|
||||||
|
final String mappedType = typeMapping.get(containerType);
|
||||||
|
if (mappedType != null) {
|
||||||
|
addImport(m, mappedType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addImport(CodegenModel m, String type) {
|
||||||
|
if (type != null && !languageSpecificPrimitives.contains(type) && !defaultIncludes.contains(type)) {
|
||||||
|
m.imports.add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addVars(CodegenModel m, Map<String, Property> properties, Collection<String> required) {
|
||||||
|
if (properties != null && properties.size() > 0) {
|
||||||
|
m.hasVars = true;
|
||||||
|
m.hasEnums = false;
|
||||||
|
final int totalCount = properties.size();
|
||||||
|
final Set<String> mandatory = required == null ? Collections.<String> emptySet() : new HashSet<String>(required);
|
||||||
|
int count = 0;
|
||||||
|
for (Map.Entry<String, Property> entry : properties.entrySet()) {
|
||||||
|
final String key = entry.getKey();
|
||||||
|
final Property prop = entry.getValue();
|
||||||
|
|
||||||
|
if (prop == null) {
|
||||||
|
LOGGER.warn("null property for " + key);
|
||||||
|
} else {
|
||||||
|
final CodegenProperty cp = fromProperty(key, prop);
|
||||||
|
cp.required = mandatory.contains(key) ? true : null;
|
||||||
|
if (cp.isEnum) {
|
||||||
|
m.hasEnums = true;
|
||||||
|
}
|
||||||
|
count += 1;
|
||||||
|
if (count != totalCount)
|
||||||
|
cp.hasMore = true;
|
||||||
|
if (cp.isContainer != null) {
|
||||||
|
addImport(m, typeMapping.get("array"));
|
||||||
|
}
|
||||||
|
addImport(m, cp.baseType);
|
||||||
|
addImport(m, cp.complexType);
|
||||||
|
m.vars.add(cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m.emptyVars = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* underscore and camelize are copied from Twitter elephant bird
|
/* underscore and camelize are copied from Twitter elephant bird
|
||||||
* https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
|
* https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
|
||||||
*/
|
*/
|
||||||
@ -1166,6 +1160,26 @@ public class DefaultCodegen {
|
|||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove characters not suitable for variable or method name from the input and camelize it
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String removeNonNameElementToCamelCase(String name) {
|
||||||
|
String nonNameElementPattern = "[-_:;#]";
|
||||||
|
name = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String apply(String input) {
|
||||||
|
return StringUtils.capitalize(input);
|
||||||
|
}
|
||||||
|
}), "");
|
||||||
|
if (name.length() > 0) {
|
||||||
|
name = name.substring(0, 1).toLowerCase() + name.substring(1);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public static String camelize(String word) {
|
public static String camelize(String word) {
|
||||||
return camelize(word, false);
|
return camelize(word, false);
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
typeMapping.put("file", "string"); // path to file
|
typeMapping.put("file", "string"); // path to file
|
||||||
typeMapping.put("array", "List");
|
typeMapping.put("array", "List");
|
||||||
typeMapping.put("map", "Dictionary");
|
typeMapping.put("map", "Dictionary");
|
||||||
|
typeMapping.put("object", "Object");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,250 @@
|
|||||||
|
package com.wordnik.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Iterators;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.wordnik.swagger.codegen.*;
|
||||||
|
import com.wordnik.swagger.models.Model;
|
||||||
|
import com.wordnik.swagger.models.Operation;
|
||||||
|
import com.wordnik.swagger.models.parameters.HeaderParameter;
|
||||||
|
import com.wordnik.swagger.models.parameters.Parameter;
|
||||||
|
import com.wordnik.swagger.models.properties.*;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class SwiftGenerator extends DefaultCodegen implements CodegenConfig {
|
||||||
|
private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\{[a-zA-Z_]+\\}");
|
||||||
|
protected String sourceFolder = "Classes/Swaggers";
|
||||||
|
|
||||||
|
public CodegenType getTag() {
|
||||||
|
return CodegenType.CLIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "swift";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates a swift client library.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public SwiftGenerator() {
|
||||||
|
super();
|
||||||
|
outputFolder = "generated-code/swift";
|
||||||
|
modelTemplateFiles.put("model.mustache", ".swift");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".swift");
|
||||||
|
templateDir = "swift";
|
||||||
|
apiPackage = "/APIs";
|
||||||
|
modelPackage = "/Models";
|
||||||
|
|
||||||
|
// Inject application name
|
||||||
|
String appName = System.getProperty("appName");
|
||||||
|
if (appName == null) {
|
||||||
|
appName = "SwaggerClient";
|
||||||
|
}
|
||||||
|
additionalProperties.put("projectName", appName);
|
||||||
|
|
||||||
|
// Inject base url override
|
||||||
|
String basePathOverride = System.getProperty("basePathOverride");
|
||||||
|
if (basePathOverride != null) {
|
||||||
|
additionalProperties.put("basePathOverride", basePathOverride);
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceFolder = appName + "/" + sourceFolder;
|
||||||
|
|
||||||
|
supportingFiles.add(new SupportingFile("Cartfile.mustache", "", "Cartfile"));
|
||||||
|
supportingFiles.add(new SupportingFile("APIHelper.mustache", sourceFolder, "APIHelper.swift"));
|
||||||
|
supportingFiles.add(new SupportingFile("AlamofireImplementations.mustache", sourceFolder, "AlamofireImplementations.swift"));
|
||||||
|
supportingFiles.add(new SupportingFile("Extensions.mustache", sourceFolder, "Extensions.swift"));
|
||||||
|
supportingFiles.add(new SupportingFile("Models.mustache", sourceFolder, "Models.swift"));
|
||||||
|
supportingFiles.add(new SupportingFile("APIs.mustache", sourceFolder, "APIs.swift"));
|
||||||
|
|
||||||
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"Int",
|
||||||
|
"Float",
|
||||||
|
"Double",
|
||||||
|
"Bool",
|
||||||
|
"Void",
|
||||||
|
"String",
|
||||||
|
"Character")
|
||||||
|
);
|
||||||
|
defaultIncludes = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"NSDate",
|
||||||
|
"Array",
|
||||||
|
"Dictionary",
|
||||||
|
"Set",
|
||||||
|
"Any",
|
||||||
|
"Empty",
|
||||||
|
"AnyObject")
|
||||||
|
);
|
||||||
|
reservedWords = new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"class", "break", "as", "associativity", "deinit", "case", "dynamicType", "convenience", "enum", "continue",
|
||||||
|
"false", "dynamic", "extension", "default", "is", "didSet", "func", "do", "nil", "final", "import", "else",
|
||||||
|
"self", "get", "init", "fallthrough", "Self", "infix", "internal", "for", "super", "inout", "let", "if",
|
||||||
|
"true", "lazy", "operator", "in", "COLUMN", "left", "private", "return", "FILE", "mutating", "protocol",
|
||||||
|
"switch", "FUNCTION", "none", "public", "where", "LINE", "nonmutating", "static", "while", "optional",
|
||||||
|
"struct", "override", "subscript", "postfix", "typealias", "precedence", "var", "prefix", "Protocol",
|
||||||
|
"required", "right", "set", "Type", "unowned", "weak")
|
||||||
|
);
|
||||||
|
|
||||||
|
typeMapping = new HashMap<String, String>();
|
||||||
|
typeMapping.put("array", "Array");
|
||||||
|
typeMapping.put("List", "Array");
|
||||||
|
typeMapping.put("map", "Dictionary");
|
||||||
|
typeMapping.put("date", "NSDate");
|
||||||
|
typeMapping.put("Date", "NSDate");
|
||||||
|
typeMapping.put("DateTime", "NSDate");
|
||||||
|
typeMapping.put("boolean", "Bool");
|
||||||
|
typeMapping.put("string", "String");
|
||||||
|
typeMapping.put("char", "Character");
|
||||||
|
typeMapping.put("short", "Int");
|
||||||
|
typeMapping.put("int", "Int");
|
||||||
|
typeMapping.put("long", "Int");
|
||||||
|
typeMapping.put("integer", "Int");
|
||||||
|
typeMapping.put("Integer", "Int");
|
||||||
|
typeMapping.put("float", "Float");
|
||||||
|
typeMapping.put("number", "Double");
|
||||||
|
typeMapping.put("double", "Double");
|
||||||
|
typeMapping.put("object", "AnyObject");
|
||||||
|
typeMapping.put("file", "NSData");
|
||||||
|
|
||||||
|
importMapping = new HashMap<String, String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
return "_" + name; // add an underscore to the name
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelFileFolder() {
|
||||||
|
return outputFolder + "/" + sourceFolder + modelPackage().replace('.', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiFileFolder() {
|
||||||
|
return outputFolder + "/" + sourceFolder + apiPackage().replace('.', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Property p) {
|
||||||
|
if (p instanceof ArrayProperty) {
|
||||||
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
|
Property inner = ap.getItems();
|
||||||
|
return "[" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (p instanceof MapProperty) {
|
||||||
|
MapProperty mp = (MapProperty) p;
|
||||||
|
Property inner = mp.getAdditionalProperties();
|
||||||
|
return "[String:" + getTypeDeclaration(inner) + "]";
|
||||||
|
}
|
||||||
|
return super.getTypeDeclaration(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSwaggerType(Property p) {
|
||||||
|
String swaggerType = super.getSwaggerType(p);
|
||||||
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(swaggerType)) {
|
||||||
|
type = typeMapping.get(swaggerType);
|
||||||
|
if (languageSpecificPrimitives.contains(type))
|
||||||
|
return toModelName(type);
|
||||||
|
} else
|
||||||
|
type = swaggerType;
|
||||||
|
return toModelName(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toDefaultValue(Property p) {
|
||||||
|
// nil
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toInstantiationType(Property p) {
|
||||||
|
if (p instanceof MapProperty) {
|
||||||
|
MapProperty ap = (MapProperty) p;
|
||||||
|
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||||
|
return "[String:" + inner + "]";
|
||||||
|
} else if (p instanceof ArrayProperty) {
|
||||||
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
|
String inner = getSwaggerType(ap.getItems());
|
||||||
|
return "[" + inner + "]";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenProperty fromProperty(String name, Property p) {
|
||||||
|
CodegenProperty codegenProperty = super.fromProperty(name, p);
|
||||||
|
if (codegenProperty.isEnum) {
|
||||||
|
List<Map<String, String>> swiftEnums = new ArrayList<Map<String, String>>();
|
||||||
|
List<String> values = (List<String>) codegenProperty.allowableValues.get("values");
|
||||||
|
for (String value : values) {
|
||||||
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
map.put("enum", StringUtils.capitalize(value));
|
||||||
|
map.put("raw", value);
|
||||||
|
swiftEnums.add(map);
|
||||||
|
}
|
||||||
|
codegenProperty.allowableValues.put("values", swiftEnums);
|
||||||
|
codegenProperty.datatypeWithEnum =
|
||||||
|
StringUtils.left(codegenProperty.datatypeWithEnum, codegenProperty.datatypeWithEnum.length() - "Enum".length());
|
||||||
|
}
|
||||||
|
return codegenProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiName(String name) {
|
||||||
|
if(name.length() == 0)
|
||||||
|
return "DefaultAPI";
|
||||||
|
return initialCaps(name) + "API";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions) {
|
||||||
|
path = normalizePath(path);
|
||||||
|
List<Parameter> parameters = operation.getParameters();
|
||||||
|
parameters = Lists.newArrayList(Iterators.filter(parameters.iterator(), new Predicate<Parameter>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(@Nullable Parameter parameter) {
|
||||||
|
return !(parameter instanceof HeaderParameter);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
operation.setParameters(parameters);
|
||||||
|
return super.fromOperation(path, httpMethod, operation, definitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizePath(String path) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
int cursor = 0;
|
||||||
|
Matcher matcher = PATH_PARAM_PATTERN.matcher(path);
|
||||||
|
boolean found = matcher.find();
|
||||||
|
while (found) {
|
||||||
|
String stringBeforeMatch = path.substring(cursor, matcher.start());
|
||||||
|
builder.append(stringBeforeMatch);
|
||||||
|
|
||||||
|
String group = matcher.group().substring(1, matcher.group().length() - 1);
|
||||||
|
group = camelize(group, true);
|
||||||
|
builder
|
||||||
|
.append("{")
|
||||||
|
.append(group)
|
||||||
|
.append("}");
|
||||||
|
|
||||||
|
cursor = matcher.end();
|
||||||
|
found = matcher.find();
|
||||||
|
}
|
||||||
|
|
||||||
|
String stringAfterMatch = path.substring(cursor);
|
||||||
|
builder.append(stringAfterMatch);
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ import javax.ws.rs.core.MediaType;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -198,48 +199,43 @@ public class ApiInvoker {
|
|||||||
response = (ClientResponse) builder.get(ClientResponse.class);
|
response = (ClientResponse) builder.get(ClientResponse.class);
|
||||||
}
|
}
|
||||||
else if ("POST".equals(method)) {
|
else if ("POST".equals(method)) {
|
||||||
if(body == null)
|
if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||||
|
String encodedFormParams = this
|
||||||
|
.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
response = builder.type(contentType).post(ClientResponse.class,
|
||||||
|
encodedFormParams);
|
||||||
|
} else if (body == null) {
|
||||||
response = builder.post(ClientResponse.class, null);
|
response = builder.post(ClientResponse.class, null);
|
||||||
else if(body instanceof FormDataMultiPart) {
|
} else if(body instanceof FormDataMultiPart) {
|
||||||
response = builder.type(contentType).post(ClientResponse.class, body);
|
response = builder.type(contentType).post(ClientResponse.class, body);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
else if ("PUT".equals(method)) {
|
else if ("PUT".equals(method)) {
|
||||||
if(body == null)
|
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||||
|
String encodedFormParams = this
|
||||||
|
.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
response = builder.type(contentType).put(ClientResponse.class,
|
||||||
|
encodedFormParams);
|
||||||
|
} else if(body == null) {
|
||||||
response = builder.put(ClientResponse.class, serialize(body));
|
response = builder.put(ClientResponse.class, serialize(body));
|
||||||
else {
|
} else {
|
||||||
if("application/x-www-form-urlencoded".equals(contentType)) {
|
|
||||||
StringBuilder formParamBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
// encode the form params
|
|
||||||
for(String key : formParams.keySet()) {
|
|
||||||
String value = formParams.get(key);
|
|
||||||
if(value != null && !"".equals(value.trim())) {
|
|
||||||
if(formParamBuilder.length() > 0) {
|
|
||||||
formParamBuilder.append("&");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
// move on to next
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response = builder.type(contentType).put(ClientResponse.class, formParamBuilder.toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ("DELETE".equals(method)) {
|
else if ("DELETE".equals(method)) {
|
||||||
if(body == null)
|
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||||
|
String encodedFormParams = this
|
||||||
|
.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
response = builder.type(contentType).delete(ClientResponse.class,
|
||||||
|
encodedFormParams);
|
||||||
|
} else if(body == null) {
|
||||||
response = builder.delete(ClientResponse.class);
|
response = builder.delete(ClientResponse.class);
|
||||||
else
|
} else {
|
||||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
@ -271,13 +267,37 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processAuthParams(String[] authNames, Map<String, String> queryParams, Map<String, String> headerParams) {
|
private void processAuthParams(String[] authNames, Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||||
for(String authName : authNames) {
|
for (String authName : authNames) {
|
||||||
Authentication auth = Configuration.getAuthentication(authName);
|
Authentication auth = Configuration.getAuthentication(authName);
|
||||||
if(auth == null) throw new RuntimeException("Authentication has not been setup for " + authName);
|
if (auth == null) throw new RuntimeException("Authentication has not been setup for " + authName);
|
||||||
auth.processParams(queryParams, headerParams);
|
auth.processParams(queryParams, headerParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getXWWWFormUrlencodedParams(Map<String, String> formParams) {
|
||||||
|
StringBuilder formParamBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (Entry<String, String> param : formParams.entrySet()) {
|
||||||
|
String keyStr = ApiInvoker.parameterToString(param.getKey());
|
||||||
|
String valueStr = ApiInvoker.parameterToString(param.getValue());
|
||||||
|
|
||||||
|
try {
|
||||||
|
formParamBuilder.append(URLEncoder.encode(keyStr, "utf8"))
|
||||||
|
.append("=")
|
||||||
|
.append(URLEncoder.encode(valueStr, "utf8"));
|
||||||
|
formParamBuilder.append("&");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// move on to next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String encodedFormParams = formParamBuilder.toString();
|
||||||
|
if (encodedFormParams.endsWith("&")) {
|
||||||
|
encodedFormParams = encodedFormParams.substring(0,
|
||||||
|
encodedFormParams.length() - 1);
|
||||||
|
}
|
||||||
|
return encodedFormParams;
|
||||||
|
}
|
||||||
|
|
||||||
private Client getClient(String host) {
|
private Client getClient(String host) {
|
||||||
if(!hostMap.containsKey(host)) {
|
if(!hostMap.containsKey(host)) {
|
||||||
Client client = Client.create();
|
Client client = Client.create();
|
||||||
|
@ -44,7 +44,6 @@ public class {{classname}} {
|
|||||||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||||
{{/hasMore}}{{/allParams}})
|
{{/hasMore}}{{/allParams}})
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
|
||||||
return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}});
|
return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}});
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -18,5 +18,6 @@ com.wordnik.swagger.codegen.languages.StaticDocCodegen
|
|||||||
com.wordnik.swagger.codegen.languages.StaticHtmlGenerator
|
com.wordnik.swagger.codegen.languages.StaticHtmlGenerator
|
||||||
com.wordnik.swagger.codegen.languages.SwaggerGenerator
|
com.wordnik.swagger.codegen.languages.SwaggerGenerator
|
||||||
com.wordnik.swagger.codegen.languages.SwaggerYamlGenerator
|
com.wordnik.swagger.codegen.languages.SwaggerYamlGenerator
|
||||||
|
com.wordnik.swagger.codegen.languages.SwiftGenerator
|
||||||
com.wordnik.swagger.codegen.languages.TizenClientCodegen
|
com.wordnik.swagger.codegen.languages.TizenClientCodegen
|
||||||
com.wordnik.swagger.codegen.languages.AkkaScalaClientCodegen
|
com.wordnik.swagger.codegen.languages.AkkaScalaClientCodegen
|
||||||
|
@ -53,10 +53,13 @@ namespace {{invokerPackage}} {
|
|||||||
/// <param name="json"> JSON string
|
/// <param name="json"> JSON string
|
||||||
/// <param name="type"> Object type
|
/// <param name="type"> Object type
|
||||||
/// <returns>Object representation of the JSON string</returns>
|
/// <returns>Object representation of the JSON string</returns>
|
||||||
public static object Deserialize(string json, Type type) {
|
public static object Deserialize(string content, Type type) {
|
||||||
|
if (type.GetType() == typeof(Object))
|
||||||
|
return (Object)content;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject(json, type);
|
return JsonConvert.DeserializeObject(content, type);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new ApiException(500, e.Message);
|
throw new ApiException(500, e.Message);
|
||||||
|
@ -48,6 +48,9 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
|
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
||||||
|
|
||||||
|
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
||||||
|
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
||||||
|
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey;
|
forKey:(NSString*) forKey;
|
||||||
|
|
||||||
|
@ -79,6 +79,51 @@ static bool loggingEnabled = true;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect `Accept` from accepts
|
||||||
|
*/
|
||||||
|
+ (NSString *) selectHeaderAccept:(NSArray *)accepts
|
||||||
|
{
|
||||||
|
if (accepts == nil || [accepts count] == 0) {
|
||||||
|
return @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
|
||||||
|
[accepts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[lowerAccepts addObject:[obj lowercaseString]];
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
if ([lowerAccepts containsObject:@"application/json"]) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [lowerAccepts componentsJoinedByString:@", "];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect `Content-Type` from contentTypes
|
||||||
|
*/
|
||||||
|
+ (NSString *) selectHeaderContentType:(NSArray *)contentTypes
|
||||||
|
{
|
||||||
|
if (contentTypes == nil || [contentTypes count] == 0) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]];
|
||||||
|
[contentTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[lowerContentTypes addObject:[obj lowercaseString]];
|
||||||
|
}];
|
||||||
|
|
||||||
|
if ([lowerContentTypes containsObject:@"application/json"]) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return lowerContentTypes[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey {
|
forKey:(NSString*) forKey {
|
||||||
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
||||||
|
@ -83,12 +83,6 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
{{#pathParams}}[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"{{baseName}}", @"}"]] withString: [SWGApiClient escape:{{paramName}}]];
|
{{#pathParams}}[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"{{baseName}}", @"}"]] withString: [SWGApiClient escape:{{paramName}}]];
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[{{#produces}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
{{#queryParams}}if({{paramName}} != nil) {
|
{{#queryParams}}if({{paramName}} != nil) {
|
||||||
{{#collectionFormat}}
|
{{#collectionFormat}}
|
||||||
@ -103,6 +97,24 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
headerParams[@"{{baseName}}"] = {{paramName}};
|
headerParams[@"{{baseName}}"] = {{paramName}};
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[{{#produces}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
{{#bodyParam}}
|
{{#bodyParam}}
|
||||||
id __body = {{paramName}};
|
id __body = {{paramName}};
|
||||||
|
@ -41,7 +41,7 @@ class APIClient {
|
|||||||
* @param string $host Base url of the API server (optional)
|
* @param string $host Base url of the API server (optional)
|
||||||
*/
|
*/
|
||||||
function __construct($host = null) {
|
function __construct($host = null) {
|
||||||
if ($host == null) {
|
if ($host === null) {
|
||||||
$this->host = '{{basePath}}';
|
$this->host = '{{basePath}}';
|
||||||
} else {
|
} else {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
@ -92,25 +92,48 @@ class APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* get the user agent of the api client
|
||||||
|
*
|
||||||
|
* @return string user agent
|
||||||
|
*/
|
||||||
|
public function getUserAgent($user_agent) {
|
||||||
|
return $this->user_agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the HTTP timeout value
|
||||||
|
*
|
||||||
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||||
*/
|
*/
|
||||||
public function setTimeout($seconds) {
|
public function setTimeout($seconds) {
|
||||||
if (!is_numeric($seconds))
|
if (!is_numeric($seconds) || $seconds < 0)
|
||||||
throw new \InvalidArgumentException('Timeout variable must be numeric.');
|
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
|
||||||
|
|
||||||
$this->curl_timeout = $seconds;
|
$this->curl_timeout = $seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the HTTP timeout value
|
||||||
|
*
|
||||||
|
* @return string HTTP timeout value
|
||||||
|
*/
|
||||||
|
public function getTimeout() {
|
||||||
|
return $this->curl_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get API key (with prefix if set)
|
* Get API key (with prefix if set)
|
||||||
* @param string key name
|
* @param string key name
|
||||||
* @return string API key with the prefix
|
* @return string API key with the prefix
|
||||||
*/
|
*/
|
||||||
public function getApiKeyWithPrefix($apiKey) {
|
public function getApiKeyWithPrefix($apiKey) {
|
||||||
if (Configuration::$apiKeyPrefix[$apiKey]) {
|
if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
|
||||||
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
||||||
} else {
|
} else if (isset(Configuration::$apiKey[$apiKey])) {
|
||||||
return Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKey[$apiKey];
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +391,7 @@ class APIClient {
|
|||||||
$instance = new $class();
|
$instance = new $class();
|
||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
$original_property_name = $instance::$attributeMap[$property];
|
||||||
if (isset($original_property_name)) {
|
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,32 @@ namespace {{invokerPackage}};
|
|||||||
{{#operations}}
|
{{#operations}}
|
||||||
class {{classname}} {
|
class {{classname}} {
|
||||||
|
|
||||||
function __construct($apiClient) {
|
function __construct($apiClient = null) {
|
||||||
|
if (null === $apiClient) {
|
||||||
|
if (Configuration::$apiClient === null) {
|
||||||
|
Configuration::$apiClient = new APIClient(); // create a new API client if not present
|
||||||
|
$this->apiClient = Configuration::$apiClient;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||||
|
} else {
|
||||||
|
$this->apiClient = $apiClient; // use the one provided by the user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private $apiClient; // instance of the APIClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the API client
|
||||||
|
*/
|
||||||
|
public function getApiClient() {
|
||||||
|
return $this->apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the API client
|
||||||
|
*/
|
||||||
|
public function setApiClient($apiClient) {
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,16 @@ class Configuration {
|
|||||||
public static $username = '';
|
public static $username = '';
|
||||||
public static $password = '';
|
public static $password = '';
|
||||||
|
|
||||||
|
// an instance of APIClient
|
||||||
|
public static $apiClient;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* manually initalize API client
|
||||||
|
*/
|
||||||
|
public static function init() {
|
||||||
|
if (self::$apiClient === null)
|
||||||
|
self::$apiClient = new APIClient();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ from six import iteritems
|
|||||||
|
|
||||||
from ..util import remove_none
|
from ..util import remove_none
|
||||||
|
|
||||||
|
from ..swagger import ApiClient
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
class {{classname}}(object):
|
class {{classname}}(object):
|
||||||
|
|
||||||
@ -68,11 +70,13 @@ class {{classname}}(object):
|
|||||||
files = remove_none(dict({{#formParams}}{{#isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}}))
|
files = remove_none(dict({{#formParams}}{{#isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}}))
|
||||||
body_params = {{#bodyParam}}params.get('{{paramName}}'){{/bodyParam}}{{^bodyParam}}None{{/bodyParam}}
|
body_params = {{#bodyParam}}params.get('{{paramName}}'){{/bodyParam}}{{^bodyParam}}None{{/bodyParam}}
|
||||||
|
|
||||||
accepts = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept([{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
|
@ -253,7 +253,32 @@ class ApiClient(object):
|
|||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def select_header_accept(accepts):
|
||||||
|
"""
|
||||||
|
Return `Accept` based on an array of accepts provided
|
||||||
|
"""
|
||||||
|
if not accepts:
|
||||||
|
return
|
||||||
|
|
||||||
|
accepts = list(map(lambda x: x.lower(), accepts))
|
||||||
|
|
||||||
|
if 'application/json' in accepts:
|
||||||
|
return 'application/json'
|
||||||
|
else:
|
||||||
|
return ', '.join(accepts)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def select_header_content_type(content_types):
|
||||||
|
"""
|
||||||
|
Return `Content-Type` baseed on an array of content_types provided
|
||||||
|
"""
|
||||||
|
if not content_types:
|
||||||
|
return 'application/json'
|
||||||
|
|
||||||
|
content_types = list(map(lambda x: x.lower(), content_types))
|
||||||
|
|
||||||
|
if 'application/json' in content_types:
|
||||||
|
return 'application/json'
|
||||||
|
else:
|
||||||
|
return content_types[0]
|
||||||
|
@ -12,7 +12,7 @@ module {{moduleName}}
|
|||||||
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
|
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
|
||||||
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
||||||
{{#allParams}}{{^required}} # @option opts [{{dataType}}] :{{paramName}} {{description}}
|
{{#allParams}}{{^required}} # @option opts [{{dataType}}] :{{paramName}} {{description}}
|
||||||
{{/required}}{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
|
||||||
def self.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
def self.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
||||||
{{#allParams}}{{#required}}
|
{{#allParams}}{{#required}}
|
||||||
# verify the required parameter '{{paramName}}' is set
|
# verify the required parameter '{{paramName}}' is set
|
||||||
@ -51,7 +51,8 @@ module {{moduleName}}
|
|||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
|
|
||||||
{{#returnType}}response = Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
{{#returnType}}response = Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
{{#returnContainer}}response.map {|response| {{/returnContainer}}obj = {{returnBaseType}}.new() and obj.build_from_hash(response){{#returnContainer}} }{{/returnContainer}}{{/returnType}}{{^returnType}} Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make{{/returnType}}
|
{{#returnContainer}}response.map {|response| {{/returnContainer}}obj = {{returnBaseType}}.new() and obj.build_from_hash(response){{#returnContainer}} }{{/returnContainer}}{{/returnType}}{{^returnType}}Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil{{/returnType}}
|
||||||
end
|
end
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ class {{classname}}(val defBasePath: String = "{{basePath}}",
|
|||||||
{{#allParams}} * @param {{paramName}} {{description}}
|
{{#allParams}} * @param {{paramName}} {{description}}
|
||||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||||
*/
|
*/
|
||||||
def {{nickname}} ({{#allParams}}{{paramName}}: {{dataType}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#returnType}}: Option[{{returnType}}]{{/returnType}} = {
|
def {{nickname}} ({{#allParams}}{{paramName}}: {{dataType}}{{#defaultValue}} /* = {{{defaultValue}}} */{{/defaultValue}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{#returnType}}: Option[{{returnType}}]{{/returnType}} = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}",apiInvoker.escape({{paramName}}))
|
val path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}",apiInvoker.escape({{paramName}}))
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
// APIHelper.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
class APIHelper {
|
||||||
|
static func rejectNil(source: [String:AnyObject?]) -> [String:AnyObject]? {
|
||||||
|
var destination = [String:AnyObject]()
|
||||||
|
for (key, nillableValue) in source {
|
||||||
|
if let value: AnyObject = nillableValue {
|
||||||
|
destination[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if destination.isEmpty {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
// APIs.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
class {{projectName}}API {
|
||||||
|
static let basePath = "{{^basePathOverride}}{{basePath}}{{/basePathOverride}}{{basePathOverride}}"
|
||||||
|
static var credential: NSURLCredential?
|
||||||
|
static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||||
|
}
|
||||||
|
|
||||||
|
class APIBase {
|
||||||
|
func toParameters(encodable: JSONEncodable?) -> [String: AnyObject]? {
|
||||||
|
let encoded: AnyObject? = encodable?.encode()
|
||||||
|
|
||||||
|
if encoded! is [AnyObject] {
|
||||||
|
var dictionary = [String:AnyObject]()
|
||||||
|
for (index, item) in enumerate(encoded as! [AnyObject]) {
|
||||||
|
dictionary["\(index)"] = item
|
||||||
|
}
|
||||||
|
return dictionary
|
||||||
|
} else {
|
||||||
|
return encoded as? [String:AnyObject]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RequestBuilder<T> {
|
||||||
|
var credential: NSURLCredential?
|
||||||
|
var headers: [String:String] = [:]
|
||||||
|
let parameters: [String:AnyObject]?
|
||||||
|
let isBody: Bool
|
||||||
|
let method: String
|
||||||
|
let URLString: String
|
||||||
|
|
||||||
|
required init(method: String, URLString: String, parameters: [String:AnyObject]?, isBody: Bool) {
|
||||||
|
self.method = method
|
||||||
|
self.URLString = URLString
|
||||||
|
self.parameters = parameters
|
||||||
|
self.isBody = isBody
|
||||||
|
}
|
||||||
|
|
||||||
|
func execute() -> Promise<Response<T>> { fatalError("Not implemented") }
|
||||||
|
|
||||||
|
func addHeader(#name: String, value: String) -> Self {
|
||||||
|
if !value.isEmpty {
|
||||||
|
headers[name] = value
|
||||||
|
}
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
func addCredential() -> Self {
|
||||||
|
self.credential = {{projectName}}API.credential
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol RequestBuilderFactory {
|
||||||
|
func getBuilder<T>() -> RequestBuilder<T>.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
|||||||
|
// AlamofireImplementations.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Alamofire
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
func getBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
|
return AlamofireRequestBuilder<T>.self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store manager to retain its reference
|
||||||
|
private var managerStore: [String: Alamofire.Manager] = [:]
|
||||||
|
|
||||||
|
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
|
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||||
|
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func execute() -> Promise<Response<T>> {
|
||||||
|
let managerId = NSUUID().UUIDString
|
||||||
|
// Create a new manager for each request to customize its request header
|
||||||
|
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
|
||||||
|
configuration.HTTPAdditionalHeaders = buildHeaders()
|
||||||
|
let manager = Alamofire.Manager(configuration: configuration)
|
||||||
|
managerStore[managerId] = manager
|
||||||
|
|
||||||
|
let encoding = isBody ? Alamofire.ParameterEncoding.JSON : Alamofire.ParameterEncoding.URL
|
||||||
|
let request = manager.request(Alamofire.Method(rawValue: method)!, URLString, parameters: parameters, encoding: encoding)
|
||||||
|
if let credential = self.credential {
|
||||||
|
request.authenticate(usingCredential: credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
let defer = Promise<Response<T>>.defer()
|
||||||
|
request.responseJSON(options: .AllowFragments) { (req, res, json, error) in
|
||||||
|
managerStore.removeValueForKey(managerId)
|
||||||
|
|
||||||
|
if let error = error {
|
||||||
|
defer.reject(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if res!.statusCode >= 400 {
|
||||||
|
//TODO: Add error entity
|
||||||
|
let error = NSError(domain: res!.URL!.URLString, code: res!.statusCode, userInfo: [:])
|
||||||
|
defer.reject(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if () is T {
|
||||||
|
let response = Response(response: res!, body: () as! T)
|
||||||
|
defer.fulfill(response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let json: AnyObject = json {
|
||||||
|
let body = Decoders.decode(clazz: T.self, source: json)
|
||||||
|
let response = Response(response: res!, body: body)
|
||||||
|
defer.fulfill(response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer.reject(NSError(domain: "localhost", code: 500, userInfo: ["reason": "unreacheable code"]))
|
||||||
|
}
|
||||||
|
return defer.promise
|
||||||
|
}
|
||||||
|
|
||||||
|
private func buildHeaders() -> [String: AnyObject] {
|
||||||
|
var httpHeaders = Manager.defaultHTTPHeaders
|
||||||
|
for (key, value) in self.headers {
|
||||||
|
httpHeaders[key] = value
|
||||||
|
}
|
||||||
|
return httpHeaders
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
github "Alamofire/Alamofire" >= 1.2
|
||||||
|
github "mxcl/PromiseKit" >=1.5.3
|
@ -0,0 +1,52 @@
|
|||||||
|
// Extensions.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Alamofire
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
extension Bool: JSONEncodable {
|
||||||
|
func encode() -> AnyObject { return self }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: JSONEncodable {
|
||||||
|
func encode() -> AnyObject { return self }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: JSONEncodable {
|
||||||
|
func encode() -> AnyObject { return self }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: JSONEncodable {
|
||||||
|
func encode() -> AnyObject { return self }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String: JSONEncodable {
|
||||||
|
func encode() -> AnyObject { return self }
|
||||||
|
}
|
||||||
|
|
||||||
|
private func encodeIfPossible<T>(object: T) -> AnyObject {
|
||||||
|
if object is JSONEncodable {
|
||||||
|
return (object as! JSONEncodable).encode()
|
||||||
|
} else {
|
||||||
|
return object as! AnyObject
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array: JSONEncodable {
|
||||||
|
func encode() -> AnyObject {
|
||||||
|
return self.map(encodeIfPossible)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Dictionary: JSONEncodable {
|
||||||
|
func encode() -> AnyObject {
|
||||||
|
var dictionary = [NSObject:AnyObject]()
|
||||||
|
for (key, value) in self {
|
||||||
|
dictionary[key as! NSObject] = encodeIfPossible(value)
|
||||||
|
}
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}
|
124
modules/swagger-codegen/src/main/resources/swift/Models.mustache
Normal file
124
modules/swagger-codegen/src/main/resources/swift/Models.mustache
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
// Models.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol JSONEncodable {
|
||||||
|
func encode() -> AnyObject
|
||||||
|
}
|
||||||
|
|
||||||
|
class Response<T> {
|
||||||
|
let statusCode: Int
|
||||||
|
let header: [String: String]
|
||||||
|
let body: T
|
||||||
|
|
||||||
|
init(statusCode: Int, header: [String: String], body: T) {
|
||||||
|
self.statusCode = statusCode
|
||||||
|
self.header = header
|
||||||
|
self.body = body
|
||||||
|
}
|
||||||
|
|
||||||
|
convenience init(response: NSHTTPURLResponse, body: T) {
|
||||||
|
let rawHeader = response.allHeaderFields
|
||||||
|
var header = [String:String]()
|
||||||
|
for (key, value) in rawHeader {
|
||||||
|
header[key as! String] = value as? String
|
||||||
|
}
|
||||||
|
self.init(statusCode: response.statusCode, header: header, body: body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var once = dispatch_once_t()
|
||||||
|
class Decoders {
|
||||||
|
static private var decoders = Dictionary<String, ((AnyObject) -> AnyObject)>()
|
||||||
|
|
||||||
|
static func addDecoder<T>(#clazz: T.Type, decoder: ((AnyObject) -> T)) {
|
||||||
|
let key = "\(T.self)"
|
||||||
|
decoders[key] = { decoder($0) as! AnyObject }
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T>(#clazz: [T].Type, source: AnyObject) -> [T] {
|
||||||
|
let array = source as! [AnyObject]
|
||||||
|
return array.map { Decoders.decode(clazz: T.self, source: $0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T, Key: Hashable>(#clazz: [Key:T].Type, source: AnyObject) -> [Key:T] {
|
||||||
|
let sourceDictinoary = source as! [Key: AnyObject]
|
||||||
|
var dictionary = [Key:T]()
|
||||||
|
for (key, value) in sourceDictinoary {
|
||||||
|
dictionary[key] = Decoders.decode(clazz: T.self, source: value)
|
||||||
|
}
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decode<T>(#clazz: T.Type, source: AnyObject) -> T {
|
||||||
|
initialize()
|
||||||
|
if source is T {
|
||||||
|
return source as! T
|
||||||
|
}
|
||||||
|
|
||||||
|
let key = "\(T.self)"
|
||||||
|
if let decoder = decoders[key] {
|
||||||
|
return decoder(source) as! T
|
||||||
|
} else {
|
||||||
|
fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T>(#clazz: T.Type, source: AnyObject?) -> T? {
|
||||||
|
if source is NSNull {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return source.map { (source: AnyObject) -> T in
|
||||||
|
Decoders.decode(clazz: clazz, source: source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T>(#clazz: [T].Type, source: AnyObject?) -> [T]? {
|
||||||
|
if source is NSNull {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return source.map { (someSource: AnyObject) -> [T] in
|
||||||
|
Decoders.decode(clazz: clazz, source: someSource)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeOptional<T, Key: Hashable>(#clazz: [Key:T].Type, source: AnyObject?) -> [Key:T]? {
|
||||||
|
if source is NSNull {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return source.map { (someSource: AnyObject) -> [Key:T] in
|
||||||
|
Decoders.decode(clazz: clazz, source: someSource)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static private func initialize() {
|
||||||
|
dispatch_once(&once) {
|
||||||
|
let dateTimeFormatter = NSDateFormatter()
|
||||||
|
dateTimeFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
|
||||||
|
let dateFormatter = NSDateFormatter()
|
||||||
|
dateFormatter.dateFormat = "yyyy-MM-dd"
|
||||||
|
// Decoder for NSDate
|
||||||
|
Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in
|
||||||
|
let sourceString = source as! String
|
||||||
|
if count(sourceString) == 10 {
|
||||||
|
return dateFormatter.dateFromString(sourceString)!
|
||||||
|
}
|
||||||
|
return dateTimeFormatter.dateFromString(sourceString)!
|
||||||
|
} {{#models}}{{#model}}
|
||||||
|
|
||||||
|
// Decoder for {{{classname}}}
|
||||||
|
Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in
|
||||||
|
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||||
|
var instance = {{classname}}(){{#vars}}{{#isEnum}}
|
||||||
|
instance.{{name}} = (sourceDictionary["{{name}}"] as? String).map { {{classname}}.{{datatypeWithEnum}}(rawValue: $0)! }{{#required}}!{{/required}} {{/isEnum}}{{^isEnum}}
|
||||||
|
instance.{{name}} = Decoders.decode{{^required}}Optional{{/required}}(clazz: {{{baseType}}}.self, source: sourceDictionary["{{name}}"]{{#required}}!{{/required}}){{/isEnum}}{{/vars}}
|
||||||
|
return instance
|
||||||
|
}{{/model}}
|
||||||
|
{{/models}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
{{#operations}}//
|
||||||
|
// {{classname}}.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Alamofire
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
extension {{projectName}}API {
|
||||||
|
{{#description}}
|
||||||
|
/** {{description}} */{{/description}}
|
||||||
|
class {{classname}}: APIBase {
|
||||||
|
{{#operation}}
|
||||||
|
/**
|
||||||
|
{{#summary}}
|
||||||
|
{{{summary}}}
|
||||||
|
{{/summary}}
|
||||||
|
- {{httpMethod}} {{path}}{{#notes}}
|
||||||
|
- {{{notes}}}{{/notes}}{{#subresourceOperation}}
|
||||||
|
- subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}}
|
||||||
|
- defaultResponse: {{defaultResponse}}{{/defaultResponse}}{{#authMethods}}
|
||||||
|
- authMethods: {{authMethods}}{{/authMethods}}{{#responseHeaders}}
|
||||||
|
- responseHeaders: {{responseHeaders}}{{/responseHeaders}}{{#examples}}
|
||||||
|
- examples: {{{examples}}}{{/examples}}{{#externalDocs}}
|
||||||
|
- externalDocs: {{externalDocs}}{{/externalDocs}}{{#hasParams}}
|
||||||
|
{{/hasParams}}{{#allParams}}
|
||||||
|
:param: {{paramName}} ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}}{{/allParams}}
|
||||||
|
|
||||||
|
:returns: Promise<Response<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>> {{description}}
|
||||||
|
*/
|
||||||
|
func {{operationId}}({{#allParams}}{{^secondaryParam}}#{{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
|
||||||
|
{{^pathParams}}let{{/pathParams}}{{#pathParams}}{{^secondaryParam}}var{{/secondaryParam}}{{/pathParams}} path = "{{path}}"{{#pathParams}}
|
||||||
|
path = path.stringByReplacingOccurrencesOfString("{{=<% %>=}}{<%paramName%>}<%={{ }}=%>", withString: "\({{paramName}})", options: .LiteralSearch, range: nil){{/pathParams}}
|
||||||
|
let url = {{projectName}}API.basePath + path
|
||||||
|
{{#bodyParam}}
|
||||||
|
let parameters = {{paramName}}{{^required}}?{{/required}}.encode() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}}
|
||||||
|
let nillableParameters: [String:AnyObject?] = {{^queryParams}}[:]{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}}
|
||||||
|
"{{paramName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
|
||||||
|
]{{/hasMore}}{{/queryParams}}
|
||||||
|
let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}}
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder(method: "{{httpMethod}}", URLString: url, parameters: parameters, isBody: {{^queryParams}}true{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}})
|
||||||
|
}
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
@ -0,0 +1,35 @@
|
|||||||
|
{{#models}}{{#model}}//
|
||||||
|
// {{classname}}.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
{{#description}}
|
||||||
|
|
||||||
|
/** {{description}} */{{/description}}
|
||||||
|
class {{classname}}: JSONEncodable {
|
||||||
|
{{#vars}}{{#isEnum}}
|
||||||
|
enum {{datatypeWithEnum}}: String { {{#allowableValues}}{{#values}}
|
||||||
|
case {{enum}} = "{{raw}}"{{/values}}{{/allowableValues}}
|
||||||
|
}
|
||||||
|
{{/isEnum}}{{/vars}}
|
||||||
|
{{#vars}}{{#isEnum}}{{#description}}/** {{description}} */
|
||||||
|
{{/description}}var {{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{/isEnum}}{{^isEnum}}{{#description}}/** {{description}} */
|
||||||
|
{{/description}}var {{name}}: {{{datatype}}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{/isEnum}}
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
// MARK: JSONEncodable
|
||||||
|
func encode() -> AnyObject {
|
||||||
|
var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}
|
||||||
|
nillableDictionary["{{name}}"] = self.{{name}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}}
|
||||||
|
nillableDictionary["{{name}}"] = self.{{name}}{{^required}}?{{/required}}.rawValue{{/isEnum}}{{^isPrimitiveType}}
|
||||||
|
nillableDictionary["{{name}}"] = self.{{name}}{{^required}}?{{/required}}.encode(){{/isPrimitiveType}}{{/isNotContainer}}{{#isContainer}}
|
||||||
|
nillableDictionary["{{name}}"] = self.{{name}}{{^required}}?{{/required}}.encode(){{/isContainer}}{{/vars}}
|
||||||
|
let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||||
|
return dictionary
|
||||||
|
}
|
||||||
|
}{{/model}}
|
||||||
|
{{/models}}
|
@ -42,17 +42,17 @@ class ExampleGeneratorTest extends FlatSpec with Matchers {
|
|||||||
item.get("contentType") match {
|
item.get("contentType") match {
|
||||||
case `xml` => {
|
case `xml` => {
|
||||||
types += xml
|
types += xml
|
||||||
example should be ("<Pair>\\n" +
|
example should be ("<Pair>\n" +
|
||||||
" <Node>\\n" +
|
" <Node>\n" +
|
||||||
" <name>string</name>\\n" +
|
" <name>string</name>\n" +
|
||||||
" <wrappedChildren>\\n" +
|
" <wrappedChildren>\n" +
|
||||||
" </wrappedChildren>\\n" +
|
" </wrappedChildren>\n" +
|
||||||
" </Node>\\n" +
|
" </Node>\n" +
|
||||||
" <Node>\\n" +
|
" <Node>\n" +
|
||||||
" <name>string</name>\\n" +
|
" <name>string</name>\n" +
|
||||||
" <wrappedChildren>\\n" +
|
" <wrappedChildren>\n" +
|
||||||
" </wrappedChildren>\\n" +
|
" </wrappedChildren>\n" +
|
||||||
" </Node>\\n" +
|
" </Node>\n" +
|
||||||
"</Pair>")
|
"</Pair>")
|
||||||
}
|
}
|
||||||
case `json` => {
|
case `json` => {
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package Java
|
||||||
|
|
||||||
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.scalatest.FlatSpec
|
||||||
|
import org.scalatest.Matchers
|
||||||
|
import org.scalatest.junit.JUnitRunner
|
||||||
|
import com.wordnik.swagger.codegen.languages.JavaClientCodegen
|
||||||
|
import com.wordnik.swagger.models.ComposedModel
|
||||||
|
import com.wordnik.swagger.models.ModelImpl
|
||||||
|
import com.wordnik.swagger.models.RefModel
|
||||||
|
import com.wordnik.swagger.models.properties.StringProperty
|
||||||
|
|
||||||
|
@RunWith(classOf[JUnitRunner])
|
||||||
|
class JavaInheritanceTest extends FlatSpec with Matchers {
|
||||||
|
it should "convert a composed model" in {
|
||||||
|
val model = new ComposedModel().parent(new RefModel("Base")).child(new ModelImpl().additionalProperties(new StringProperty()))
|
||||||
|
|
||||||
|
val codegen = new JavaClientCodegen()
|
||||||
|
val cm = codegen.fromModel("sample", model)
|
||||||
|
|
||||||
|
cm.name should be("sample")
|
||||||
|
cm.classname should be("Sample")
|
||||||
|
cm.parent should be("Base")
|
||||||
|
cm.imports.asScala should be (Set("Base"))
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package objc
|
package Objc
|
||||||
|
|
||||||
import com.wordnik.swagger.codegen.languages.ObjcClientCodegen
|
import com.wordnik.swagger.codegen.languages.ObjcClientCodegen
|
||||||
import com.wordnik.swagger.util.Json
|
import com.wordnik.swagger.util.Json
|
||||||
@ -217,8 +217,8 @@ class ObjcModelTest extends FlatSpec with Matchers {
|
|||||||
cm.description should be ("an array model")
|
cm.description should be ("an array model")
|
||||||
cm.vars.size should be (0)
|
cm.vars.size should be (0)
|
||||||
cm.parent should be ("NSMutableArray")
|
cm.parent should be ("NSMutableArray")
|
||||||
cm.imports.size should be (3)
|
cm.imports.size should be (1)
|
||||||
(cm.imports.asScala.toSet & Set("SWGChildren", "NSArray", "NSMutableArray")).size should be (3)
|
(cm.imports.asScala.toSet & Set("SWGChildren")).size should be (1)
|
||||||
}
|
}
|
||||||
|
|
||||||
it should "convert an map model" in {
|
it should "convert an map model" in {
|
||||||
@ -234,8 +234,8 @@ class ObjcModelTest extends FlatSpec with Matchers {
|
|||||||
cm.description should be ("an map model")
|
cm.description should be ("an map model")
|
||||||
cm.vars.size should be (0)
|
cm.vars.size should be (0)
|
||||||
cm.parent should be ("NSMutableDictionary")
|
cm.parent should be ("NSMutableDictionary")
|
||||||
cm.imports.size should be (3)
|
cm.imports.size should be (1)
|
||||||
(cm.imports.asScala.toSet & Set("SWGChildren", "NSDictionary", "NSMutableDictionary")).size should be (3)
|
(cm.imports.asScala.toSet & Set("SWGChildren")).size should be (1)
|
||||||
}
|
}
|
||||||
|
|
||||||
it should "create proper imports per #316" in {
|
it should "create proper imports per #316" in {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package Java
|
package scala
|
||||||
|
|
||||||
import com.wordnik.swagger.codegen.languages.ScalaClientCodegen
|
import com.wordnik.swagger.codegen.languages.ScalaClientCodegen
|
||||||
import com.wordnik.swagger.util.Json
|
import com.wordnik.swagger.util.Json
|
||||||
@ -218,8 +218,8 @@ class ScalaModelTest extends FlatSpec with Matchers {
|
|||||||
cm.description should be ("an array model")
|
cm.description should be ("an array model")
|
||||||
cm.vars.size should be (0)
|
cm.vars.size should be (0)
|
||||||
cm.parent should be ("ListBuffer[Children]")
|
cm.parent should be ("ListBuffer[Children]")
|
||||||
cm.imports.size should be (3)
|
cm.imports.size should be (2)
|
||||||
(cm.imports.asScala.toSet & Set("List", "ListBuffer", "Children")).size should be (3)
|
(cm.imports.asScala.toSet & Set("ListBuffer", "Children")).size should be (2)
|
||||||
}
|
}
|
||||||
|
|
||||||
it should "convert an map model" in {
|
it should "convert an map model" in {
|
||||||
|
@ -53,10 +53,13 @@ namespace IO.Swagger.Client {
|
|||||||
/// <param name="json"> JSON string
|
/// <param name="json"> JSON string
|
||||||
/// <param name="type"> Object type
|
/// <param name="type"> Object type
|
||||||
/// <returns>Object representation of the JSON string</returns>
|
/// <returns>Object representation of the JSON string</returns>
|
||||||
public static object Deserialize(string json, Type type) {
|
public static object Deserialize(string content, Type type) {
|
||||||
|
if (type.GetType() == typeof(Object))
|
||||||
|
return (Object)content;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject(json, type);
|
return JsonConvert.DeserializeObject(content, type);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new ApiException(500, e.Message);
|
throw new ApiException(500, e.Message);
|
||||||
|
@ -18,6 +18,7 @@ import javax.ws.rs.core.MediaType;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -198,48 +199,43 @@ public class ApiInvoker {
|
|||||||
response = (ClientResponse) builder.get(ClientResponse.class);
|
response = (ClientResponse) builder.get(ClientResponse.class);
|
||||||
}
|
}
|
||||||
else if ("POST".equals(method)) {
|
else if ("POST".equals(method)) {
|
||||||
if(body == null)
|
if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||||
|
String encodedFormParams = this
|
||||||
|
.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
response = builder.type(contentType).post(ClientResponse.class,
|
||||||
|
encodedFormParams);
|
||||||
|
} else if (body == null) {
|
||||||
response = builder.post(ClientResponse.class, null);
|
response = builder.post(ClientResponse.class, null);
|
||||||
else if(body instanceof FormDataMultiPart) {
|
} else if(body instanceof FormDataMultiPart) {
|
||||||
response = builder.type(contentType).post(ClientResponse.class, body);
|
response = builder.type(contentType).post(ClientResponse.class, body);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
else if ("PUT".equals(method)) {
|
else if ("PUT".equals(method)) {
|
||||||
if(body == null)
|
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||||
|
String encodedFormParams = this
|
||||||
|
.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
response = builder.type(contentType).put(ClientResponse.class,
|
||||||
|
encodedFormParams);
|
||||||
|
} else if(body == null) {
|
||||||
response = builder.put(ClientResponse.class, serialize(body));
|
response = builder.put(ClientResponse.class, serialize(body));
|
||||||
else {
|
} else {
|
||||||
if("application/x-www-form-urlencoded".equals(contentType)) {
|
|
||||||
StringBuilder formParamBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
// encode the form params
|
|
||||||
for(String key : formParams.keySet()) {
|
|
||||||
String value = formParams.get(key);
|
|
||||||
if(value != null && !"".equals(value.trim())) {
|
|
||||||
if(formParamBuilder.length() > 0) {
|
|
||||||
formParamBuilder.append("&");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
// move on to next
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response = builder.type(contentType).put(ClientResponse.class, formParamBuilder.toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ("DELETE".equals(method)) {
|
else if ("DELETE".equals(method)) {
|
||||||
if(body == null)
|
if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||||
|
String encodedFormParams = this
|
||||||
|
.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
response = builder.type(contentType).delete(ClientResponse.class,
|
||||||
|
encodedFormParams);
|
||||||
|
} else if(body == null) {
|
||||||
response = builder.delete(ClientResponse.class);
|
response = builder.delete(ClientResponse.class);
|
||||||
else
|
} else {
|
||||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
@ -271,13 +267,37 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processAuthParams(String[] authNames, Map<String, String> queryParams, Map<String, String> headerParams) {
|
private void processAuthParams(String[] authNames, Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||||
for(String authName : authNames) {
|
for (String authName : authNames) {
|
||||||
Authentication auth = Configuration.getAuthentication(authName);
|
Authentication auth = Configuration.getAuthentication(authName);
|
||||||
if(auth == null) throw new RuntimeException("Authentication has not been setup for " + authName);
|
if (auth == null) throw new RuntimeException("Authentication has not been setup for " + authName);
|
||||||
auth.processParams(queryParams, headerParams);
|
auth.processParams(queryParams, headerParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getXWWWFormUrlencodedParams(Map<String, String> formParams) {
|
||||||
|
StringBuilder formParamBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (Entry<String, String> param : formParams.entrySet()) {
|
||||||
|
String keyStr = ApiInvoker.parameterToString(param.getKey());
|
||||||
|
String valueStr = ApiInvoker.parameterToString(param.getValue());
|
||||||
|
|
||||||
|
try {
|
||||||
|
formParamBuilder.append(URLEncoder.encode(keyStr, "utf8"))
|
||||||
|
.append("=")
|
||||||
|
.append(URLEncoder.encode(valueStr, "utf8"));
|
||||||
|
formParamBuilder.append("&");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// move on to next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String encodedFormParams = formParamBuilder.toString();
|
||||||
|
if (encodedFormParams.endsWith("&")) {
|
||||||
|
encodedFormParams = encodedFormParams.substring(0,
|
||||||
|
encodedFormParams.length() - 1);
|
||||||
|
}
|
||||||
|
return encodedFormParams;
|
||||||
|
}
|
||||||
|
|
||||||
private Client getClient(String host) {
|
private Client getClient(String host) {
|
||||||
if(!hostMap.containsKey(host)) {
|
if(!hostMap.containsKey(host)) {
|
||||||
Client client = Client.create();
|
Client client = Client.create();
|
||||||
|
@ -112,7 +112,7 @@ public class PetApiTest {
|
|||||||
api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null);
|
api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null);
|
||||||
Pet updated = api.getPetById(fetched.getId());
|
Pet updated = api.getPetById(fetched.getId());
|
||||||
|
|
||||||
assertEquals(updated.getName(), fetched.getName());
|
assertEquals(updated.getName(), "furt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
BA525648922D4C0E9F44D4F1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73DA4F1067C343C3962F1542 /* libPods.a */; };
|
BA525648922D4C0E9F44D4F1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73DA4F1067C343C3962F1542 /* libPods.a */; };
|
||||||
|
CF31D0991B105E4B00509935 /* SWGApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF31D0981B105E4B00509935 /* SWGApiClientTest.m */; };
|
||||||
CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; };
|
CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; };
|
||||||
CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; };
|
CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; };
|
||||||
EA66999A1811D2FA00A70D03 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA6699991811D2FA00A70D03 /* Foundation.framework */; };
|
EA66999A1811D2FA00A70D03 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA6699991811D2FA00A70D03 /* Foundation.framework */; };
|
||||||
@ -55,6 +56,7 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
73DA4F1067C343C3962F1542 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
73DA4F1067C343C3962F1542 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
A425648B5C0A4849C7668069 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
A425648B5C0A4849C7668069 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
CF31D0981B105E4B00509935 /* SWGApiClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClientTest.m; sourceTree = "<group>"; };
|
||||||
CFD1B66E1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSONValueTransformer+ISO8601.h"; sourceTree = "<group>"; };
|
CFD1B66E1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSONValueTransformer+ISO8601.h"; sourceTree = "<group>"; };
|
||||||
CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSONValueTransformer+ISO8601.m"; sourceTree = "<group>"; };
|
CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSONValueTransformer+ISO8601.m"; sourceTree = "<group>"; };
|
||||||
E2B6DA00BE52336E23783686 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
E2B6DA00BE52336E23783686 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
@ -207,6 +209,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
EA8CD3EB1AC274BE00C47D0B /* PetApiTest.h */,
|
EA8CD3EB1AC274BE00C47D0B /* PetApiTest.h */,
|
||||||
|
CF31D0981B105E4B00509935 /* SWGApiClientTest.m */,
|
||||||
EA6699C71811D2FB00A70D03 /* PetApiTest.m */,
|
EA6699C71811D2FB00A70D03 /* PetApiTest.m */,
|
||||||
EA6699C21811D2FB00A70D03 /* Supporting Files */,
|
EA6699C21811D2FB00A70D03 /* Supporting Files */,
|
||||||
);
|
);
|
||||||
@ -417,6 +420,7 @@
|
|||||||
EAB26B0C1AC8DF78002F5C7A /* PetApiTest.h in Sources */,
|
EAB26B0C1AC8DF78002F5C7A /* PetApiTest.h in Sources */,
|
||||||
CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */,
|
CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */,
|
||||||
EAB26B0D1AC8DF78002F5C7A /* PetApiTest.m in Sources */,
|
EAB26B0D1AC8DF78002F5C7A /* PetApiTest.m in Sources */,
|
||||||
|
CF31D0991B105E4B00509935 /* SWGApiClientTest.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <XCTest/XCTest.h>
|
||||||
|
#import "SWGApiClient.h"
|
||||||
|
|
||||||
|
@interface SWGApiClientTest : XCTestCase
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SWGApiClientTest
|
||||||
|
|
||||||
|
- (void)setUp {
|
||||||
|
[super setUp];
|
||||||
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)tearDown {
|
||||||
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
|
[super tearDown];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testSelectHeaderAccept {
|
||||||
|
NSArray *accepts = nil;
|
||||||
|
|
||||||
|
accepts = @[@"APPLICATION/JSON", @"APPLICATION/XML"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderAccept:accepts], @"application/json");
|
||||||
|
|
||||||
|
accepts = @[@"application/json", @"application/xml"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderAccept:accepts], @"application/json");
|
||||||
|
|
||||||
|
accepts = @[@"APPLICATION/xml", @"APPLICATION/json"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderAccept:accepts], @"application/json");
|
||||||
|
|
||||||
|
accepts = @[@"text/plain", @"application/xml"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderAccept:accepts], @"text/plain, application/xml");
|
||||||
|
|
||||||
|
accepts = @[];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderAccept:accepts], @"");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testSelectHeaderContentType {
|
||||||
|
NSArray *contentTypes = nil;
|
||||||
|
|
||||||
|
contentTypes = @[@"APPLICATION/JSON", @"APPLICATION/XML"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderContentType:contentTypes], @"application/json");
|
||||||
|
|
||||||
|
contentTypes = @[@"application/json", @"application/xml"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderContentType:contentTypes], @"application/json");
|
||||||
|
|
||||||
|
contentTypes = @[@"APPLICATION/xml", @"APPLICATION/json"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderContentType:contentTypes], @"application/json");
|
||||||
|
|
||||||
|
contentTypes = @[@"text/plain", @"application/xml"];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderContentType:contentTypes], @"text/plain");
|
||||||
|
|
||||||
|
contentTypes = @[];
|
||||||
|
XCTAssertEqualObjects([SWGApiClient selectHeaderContentType:contentTypes], @"application/json");
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -1,23 +1,23 @@
|
|||||||
PODS:
|
PODS:
|
||||||
- AFNetworking (2.5.3):
|
- AFNetworking (2.5.4):
|
||||||
- AFNetworking/NSURLConnection (= 2.5.3)
|
- AFNetworking/NSURLConnection (= 2.5.4)
|
||||||
- AFNetworking/NSURLSession (= 2.5.3)
|
- AFNetworking/NSURLSession (= 2.5.4)
|
||||||
- AFNetworking/Reachability (= 2.5.3)
|
- AFNetworking/Reachability (= 2.5.4)
|
||||||
- AFNetworking/Security (= 2.5.3)
|
- AFNetworking/Security (= 2.5.4)
|
||||||
- AFNetworking/Serialization (= 2.5.3)
|
- AFNetworking/Serialization (= 2.5.4)
|
||||||
- AFNetworking/UIKit (= 2.5.3)
|
- AFNetworking/UIKit (= 2.5.4)
|
||||||
- AFNetworking/NSURLConnection (2.5.3):
|
- AFNetworking/NSURLConnection (2.5.4):
|
||||||
- AFNetworking/Reachability
|
- AFNetworking/Reachability
|
||||||
- AFNetworking/Security
|
- AFNetworking/Security
|
||||||
- AFNetworking/Serialization
|
- AFNetworking/Serialization
|
||||||
- AFNetworking/NSURLSession (2.5.3):
|
- AFNetworking/NSURLSession (2.5.4):
|
||||||
- AFNetworking/Reachability
|
- AFNetworking/Reachability
|
||||||
- AFNetworking/Security
|
- AFNetworking/Security
|
||||||
- AFNetworking/Serialization
|
- AFNetworking/Serialization
|
||||||
- AFNetworking/Reachability (2.5.3)
|
- AFNetworking/Reachability (2.5.4)
|
||||||
- AFNetworking/Security (2.5.3)
|
- AFNetworking/Security (2.5.4)
|
||||||
- AFNetworking/Serialization (2.5.3)
|
- AFNetworking/Serialization (2.5.4)
|
||||||
- AFNetworking/UIKit (2.5.3):
|
- AFNetworking/UIKit (2.5.4):
|
||||||
- AFNetworking/NSURLConnection
|
- AFNetworking/NSURLConnection
|
||||||
- AFNetworking/NSURLSession
|
- AFNetworking/NSURLSession
|
||||||
- ISO8601 (0.2.0)
|
- ISO8601 (0.2.0)
|
||||||
@ -29,8 +29,8 @@ DEPENDENCIES:
|
|||||||
- JSONModel (~> 1.0)
|
- JSONModel (~> 1.0)
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
AFNetworking: e1d86c2a96bb5d2e7408da36149806706ee122fe
|
AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e
|
||||||
ISO8601: 962282de75074c38bbfaa7b133b0e743ed6deb8d
|
ISO8601: 962282de75074c38bbfaa7b133b0e743ed6deb8d
|
||||||
JSONModel: ec77e9865236a7a09d9cf7668df6b4b328d9ec1d
|
JSONModel: ec77e9865236a7a09d9cf7668df6b4b328d9ec1d
|
||||||
|
|
||||||
COCOAPODS: 0.36.0
|
COCOAPODS: 0.37.1
|
||||||
|
@ -48,6 +48,9 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
|
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
||||||
|
|
||||||
|
+(NSString *) selectHeaderAccept:(NSArray *)accepts;
|
||||||
|
+(NSString *) selectHeaderContentType:(NSArray *)contentTypes;
|
||||||
|
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey;
|
forKey:(NSString*) forKey;
|
||||||
|
|
||||||
|
@ -79,6 +79,51 @@ static bool loggingEnabled = true;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect `Accept` from accepts
|
||||||
|
*/
|
||||||
|
+ (NSString *) selectHeaderAccept:(NSArray *)accepts
|
||||||
|
{
|
||||||
|
if (accepts == nil || [accepts count] == 0) {
|
||||||
|
return @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
|
||||||
|
[accepts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[lowerAccepts addObject:[obj lowercaseString]];
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
if ([lowerAccepts containsObject:@"application/json"]) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [lowerAccepts componentsJoinedByString:@", "];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect `Content-Type` from contentTypes
|
||||||
|
*/
|
||||||
|
+ (NSString *) selectHeaderContentType:(NSArray *)contentTypes
|
||||||
|
{
|
||||||
|
if (contentTypes == nil || [contentTypes count] == 0) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *lowerContentTypes = [[NSMutableArray alloc] initWithCapacity:[contentTypes count]];
|
||||||
|
[contentTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[lowerContentTypes addObject:[obj lowercaseString]];
|
||||||
|
}];
|
||||||
|
|
||||||
|
if ([lowerContentTypes containsObject:@"application/json"]) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return lowerContentTypes[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey {
|
forKey:(NSString*) forKey {
|
||||||
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
||||||
|
@ -77,18 +77,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -170,18 +182,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -263,12 +287,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
if(status != nil) {
|
if(status != nil) {
|
||||||
|
|
||||||
@ -281,6 +299,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -352,12 +388,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
if(tags != nil) {
|
if(tags != nil) {
|
||||||
|
|
||||||
@ -370,6 +400,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -445,18 +493,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -537,18 +597,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[@"application/x-www-form-urlencoded"];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -629,12 +701,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
@ -643,6 +709,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
headerParams[@"api_key"] = apiKey;
|
headerParams[@"api_key"] = apiKey;
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -709,18 +793,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[@"multipart/form-data"];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,18 +74,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -150,18 +162,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -261,18 +285,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -349,18 +385,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,18 +76,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -169,18 +181,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -262,18 +286,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -357,12 +393,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
if(username != nil) {
|
if(username != nil) {
|
||||||
|
|
||||||
@ -377,6 +407,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -445,18 +493,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -519,18 +579,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
@ -609,18 +681,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
id __body = body;
|
id __body = body;
|
||||||
@ -706,18 +790,30 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
|||||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]];
|
||||||
|
|
||||||
|
|
||||||
NSArray* requestContentTypes = @[];
|
|
||||||
NSString* requestContentType = [requestContentTypes count] > 0 ? requestContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSArray* responseContentTypes = @[@"application/json", @"application/xml"];
|
|
||||||
NSString* responseContentType = [responseContentTypes count] > 0 ? responseContentTypes[0] : @"application/json";
|
|
||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// HTTP header `Accept`
|
||||||
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
||||||
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response content type
|
||||||
|
NSString *responseContentType;
|
||||||
|
if ([headerParams objectForKey:@"Accept"]) {
|
||||||
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
responseContentType = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// request content type
|
||||||
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class APIClient {
|
|||||||
* @param string $host Base url of the API server (optional)
|
* @param string $host Base url of the API server (optional)
|
||||||
*/
|
*/
|
||||||
function __construct($host = null) {
|
function __construct($host = null) {
|
||||||
if ($host == null) {
|
if ($host === null) {
|
||||||
$this->host = 'http://petstore.swagger.io/v2';
|
$this->host = 'http://petstore.swagger.io/v2';
|
||||||
} else {
|
} else {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
@ -92,25 +92,48 @@ class APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* get the user agent of the api client
|
||||||
|
*
|
||||||
|
* @return string user agent
|
||||||
|
*/
|
||||||
|
public function getUserAgent($user_agent) {
|
||||||
|
return $this->user_agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the HTTP timeout value
|
||||||
|
*
|
||||||
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||||
*/
|
*/
|
||||||
public function setTimeout($seconds) {
|
public function setTimeout($seconds) {
|
||||||
if (!is_numeric($seconds))
|
if (!is_numeric($seconds) || $seconds < 0)
|
||||||
throw new \InvalidArgumentException('Timeout variable must be numeric.');
|
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
|
||||||
|
|
||||||
$this->curl_timeout = $seconds;
|
$this->curl_timeout = $seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the HTTP timeout value
|
||||||
|
*
|
||||||
|
* @return string HTTP timeout value
|
||||||
|
*/
|
||||||
|
public function getTimeout() {
|
||||||
|
return $this->curl_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get API key (with prefix if set)
|
* Get API key (with prefix if set)
|
||||||
* @param string key name
|
* @param string key name
|
||||||
* @return string API key with the prefix
|
* @return string API key with the prefix
|
||||||
*/
|
*/
|
||||||
public function getApiKeyWithPrefix($apiKey) {
|
public function getApiKeyWithPrefix($apiKey) {
|
||||||
if (Configuration::$apiKeyPrefix[$apiKey]) {
|
if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
|
||||||
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
||||||
} else {
|
} else if (isset(Configuration::$apiKey[$apiKey])) {
|
||||||
return Configuration::$apiKey[$apiKey];
|
return Configuration::$apiKey[$apiKey];
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +396,7 @@ class APIClient {
|
|||||||
$instance = new $class();
|
$instance = new $class();
|
||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
$original_property_name = $instance::$attributeMap[$property];
|
||||||
if (isset($original_property_name)) {
|
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,16 @@ class Configuration {
|
|||||||
public static $username = '';
|
public static $username = '';
|
||||||
public static $password = '';
|
public static $password = '';
|
||||||
|
|
||||||
|
// an instance of APIClient
|
||||||
|
public static $apiClient;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* manually initalize API client
|
||||||
|
*/
|
||||||
|
public static function init() {
|
||||||
|
if (self::$apiClient === null)
|
||||||
|
self::$apiClient = new APIClient();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,32 @@ namespace SwaggerClient;
|
|||||||
|
|
||||||
class PetApi {
|
class PetApi {
|
||||||
|
|
||||||
function __construct($apiClient) {
|
function __construct($apiClient = null) {
|
||||||
|
if (null === $apiClient) {
|
||||||
|
if (Configuration::$apiClient === null) {
|
||||||
|
Configuration::$apiClient = new APIClient(); // create a new API client if not present
|
||||||
|
$this->apiClient = Configuration::$apiClient;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||||
|
} else {
|
||||||
|
$this->apiClient = $apiClient; // use the one provided by the user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private $apiClient; // instance of the APIClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the API client
|
||||||
|
*/
|
||||||
|
public function getApiClient() {
|
||||||
|
return $this->apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the API client
|
||||||
|
*/
|
||||||
|
public function setApiClient($apiClient) {
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,32 @@ namespace SwaggerClient;
|
|||||||
|
|
||||||
class StoreApi {
|
class StoreApi {
|
||||||
|
|
||||||
function __construct($apiClient) {
|
function __construct($apiClient = null) {
|
||||||
|
if (null === $apiClient) {
|
||||||
|
if (Configuration::$apiClient === null) {
|
||||||
|
Configuration::$apiClient = new APIClient(); // create a new API client if not present
|
||||||
|
$this->apiClient = Configuration::$apiClient;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||||
|
} else {
|
||||||
|
$this->apiClient = $apiClient; // use the one provided by the user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private $apiClient; // instance of the APIClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the API client
|
||||||
|
*/
|
||||||
|
public function getApiClient() {
|
||||||
|
return $this->apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the API client
|
||||||
|
*/
|
||||||
|
public function setApiClient($apiClient) {
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,32 @@ namespace SwaggerClient;
|
|||||||
|
|
||||||
class UserApi {
|
class UserApi {
|
||||||
|
|
||||||
function __construct($apiClient) {
|
function __construct($apiClient = null) {
|
||||||
|
if (null === $apiClient) {
|
||||||
|
if (Configuration::$apiClient === null) {
|
||||||
|
Configuration::$apiClient = new APIClient(); // create a new API client if not present
|
||||||
|
$this->apiClient = Configuration::$apiClient;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||||
|
} else {
|
||||||
|
$this->apiClient = $apiClient; // use the one provided by the user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private $apiClient; // instance of the APIClient
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the API client
|
||||||
|
*/
|
||||||
|
public function getApiClient() {
|
||||||
|
return $this->apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the API client
|
||||||
|
*/
|
||||||
|
public function setApiClient($apiClient) {
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
||||||
public static function setUpBeforeClass() {
|
public static function setUpBeforeClass() {
|
||||||
// initialize the API client
|
// skip initializing the API client as it should be automatic
|
||||||
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
//$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||||
// new pet
|
// new pet
|
||||||
$new_pet_id = 10005;
|
$new_pet_id = 10005;
|
||||||
$new_pet = new SwaggerClient\models\Pet;
|
$new_pet = new SwaggerClient\models\Pet;
|
||||||
@ -23,10 +23,10 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
$category->id = $new_pet_id; // use the same id as pet
|
$category->id = $new_pet_id; // use the same id as pet
|
||||||
$category->name = "test php category";
|
$category->name = "test php category";
|
||||||
|
|
||||||
$new_pet->tags = [$tag];
|
$new_pet->tags = array($tag);
|
||||||
$new_pet->category = $category;
|
$new_pet->category = $category;
|
||||||
|
|
||||||
$pet_api = new SwaggerClient\PetAPI($api_client);
|
$pet_api = new SwaggerClient\PetAPI();
|
||||||
// add a new pet (model)
|
// add a new pet (model)
|
||||||
$add_response = $pet_api->addPet($new_pet);
|
$add_response = $pet_api->addPet($new_pet);
|
||||||
}
|
}
|
||||||
@ -34,25 +34,50 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
// test static functions defined in APIClient
|
// test static functions defined in APIClient
|
||||||
public function testAPIClient()
|
public function testAPIClient()
|
||||||
{
|
{
|
||||||
# test selectHeaderAccept
|
// test selectHeaderAccept
|
||||||
$this->assertSame('application/json', SwaggerClient\APIClient::selectHeaderAccept(array('application/xml','application/json')));
|
$this->assertSame('application/json', SwaggerClient\APIClient::selectHeaderAccept(array('application/xml','application/json')));
|
||||||
$this->assertSame(NULL, SwaggerClient\APIClient::selectHeaderAccept(array()));
|
$this->assertSame(NULL, SwaggerClient\APIClient::selectHeaderAccept(array()));
|
||||||
$this->assertSame('application/yaml,application/xml', SwaggerClient\APIClient::selectHeaderAccept(array('application/yaml','application/xml')));
|
$this->assertSame('application/yaml,application/xml', SwaggerClient\APIClient::selectHeaderAccept(array('application/yaml','application/xml')));
|
||||||
|
|
||||||
# test selectHeaderContentType
|
// test selectHeaderContentType
|
||||||
$this->assertSame('application/json', SwaggerClient\APIClient::selectHeaderContentType(array('application/xml','application/json')));
|
$this->assertSame('application/json', SwaggerClient\APIClient::selectHeaderContentType(array('application/xml','application/json')));
|
||||||
$this->assertSame('application/json', SwaggerClient\APIClient::selectHeaderContentType(array()));
|
$this->assertSame('application/json', SwaggerClient\APIClient::selectHeaderContentType(array()));
|
||||||
$this->assertSame('application/yaml,application/xml', SwaggerClient\APIClient::selectHeaderContentType(array('application/yaml','application/xml')));
|
$this->assertSame('application/yaml,application/xml', SwaggerClient\APIClient::selectHeaderContentType(array('application/yaml','application/xml')));
|
||||||
|
|
||||||
# test addDefaultHeader and getDefaultHeader
|
// test addDefaultHeader and getDefaultHeader
|
||||||
SwaggerClient\APIClient::addDefaultHeader('test1', 'value1');
|
SwaggerClient\APIClient::addDefaultHeader('test1', 'value1');
|
||||||
SwaggerClient\APIClient::addDefaultHeader('test2', 200);
|
SwaggerClient\APIClient::addDefaultHeader('test2', 200);
|
||||||
$this->assertSame('value1', SwaggerClient\APIClient::getDefaultHeader()['test1']);
|
$defaultHeader = SwaggerClient\APIClient::getDefaultHeader();
|
||||||
$this->assertSame(200, SwaggerClient\APIClient::getDefaultHeader()['test2']);
|
$this->assertSame('value1', $defaultHeader['test1']);
|
||||||
|
$this->assertSame(200, $defaultHeader['test2']);
|
||||||
|
|
||||||
# test deleteDefaultHeader
|
// test deleteDefaultHeader
|
||||||
SwaggerClient\APIClient::deleteDefaultHeader('test2');
|
SwaggerClient\APIClient::deleteDefaultHeader('test2');
|
||||||
$this->assertFalse(isset(SwaggerClient\APIClient::getDefaultHeader()['test2']));
|
$defaultHeader = SwaggerClient\APIClient::getDefaultHeader();
|
||||||
|
$this->assertFalse(isset($defaultHeader['test2']));
|
||||||
|
|
||||||
|
$pet_api = new SwaggerClient\PetAPI();
|
||||||
|
$pet_api2 = new SwaggerClient\PetAPI();
|
||||||
|
$apiClient3 = new SwaggerClient\APIClient();
|
||||||
|
$apiClient3->setUserAgent = 'api client 3';
|
||||||
|
$apiClient4 = new SwaggerClient\APIClient();
|
||||||
|
$apiClient4->setUserAgent = 'api client 4';
|
||||||
|
$pet_api3 = new SwaggerClient\PetAPI($apiClient3);
|
||||||
|
|
||||||
|
// same default api client
|
||||||
|
$this->assertSame($pet_api->getApiClient(), $pet_api2->getApiClient());
|
||||||
|
// confirm using the default api client in the Configuration
|
||||||
|
$this->assertSame($pet_api->getApiClient(), SwaggerClient\Configuration::$apiClient);
|
||||||
|
// 2 different api clients are not the same
|
||||||
|
$this->assertNotEquals($apiClient3, $apiClient4);
|
||||||
|
// customized pet api not using the default (configuration) api client
|
||||||
|
$this->assertNotEquals($pet_api3->getApiClient(), SwaggerClient\Configuration::$apiClient);
|
||||||
|
// customied pet api not using the old pet api's api client
|
||||||
|
$this->assertNotEquals($pet_api2->getApiClient(), $pet_api3->getApiClient());
|
||||||
|
|
||||||
|
// both pet api and pet api2 share the same api client and confirm using timeout value
|
||||||
|
$pet_api->getApiClient()->setTimeout(999);
|
||||||
|
$this->assertSame(999, $pet_api2->getApiClient()->getTimeout());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
require_once('SwaggerClient-php/SwaggerClient.php');
|
require_once('SwaggerClient-php/SwaggerClient.php');
|
||||||
|
|
||||||
// initialize the API client
|
// initialize the API client
|
||||||
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
//$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||||
$api_client->addDefaultHeader("test1", "value1");
|
//$api_client->addDefaultHeader("test1", "value1");
|
||||||
|
|
||||||
$petId = 10005; // ID of pet that needs to be fetched
|
$petId = 10005; // ID of pet that needs to be fetched
|
||||||
try {
|
try {
|
||||||
$pet_api = new SwaggerClient\PetAPI($api_client);
|
//$pet_api = new SwaggerClient\PetAPI($api_client);
|
||||||
|
$pet_api = new SwaggerClient\PetAPI();
|
||||||
// return Pet (model)
|
// return Pet (model)
|
||||||
$response = $pet_api->getPetById($petId);
|
$response = $pet_api->getPetById($petId);
|
||||||
var_dump($response);
|
var_dump($response);
|
||||||
|
@ -29,6 +29,8 @@ from six import iteritems
|
|||||||
|
|
||||||
from ..util import remove_none
|
from ..util import remove_none
|
||||||
|
|
||||||
|
from ..swagger import ApiClient
|
||||||
|
|
||||||
class PetApi(object):
|
class PetApi(object):
|
||||||
|
|
||||||
def __init__(self, api_client):
|
def __init__(self, api_client):
|
||||||
@ -63,11 +65,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = ['application/json', 'application/xml']
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type(['application/json', 'application/xml'])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -102,11 +106,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = ['application/json', 'application/xml']
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type(['application/json', 'application/xml'])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -141,11 +147,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -182,11 +190,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -227,11 +237,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -274,11 +286,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = ['application/x-www-form-urlencoded']
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type(['application/x-www-form-urlencoded'])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -318,11 +332,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -363,11 +379,13 @@ class PetApi(object):
|
|||||||
files = remove_none(dict(file=params.get('file')))
|
files = remove_none(dict(file=params.get('file')))
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = ['multipart/form-data']
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type(['multipart/form-data'])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
|
@ -29,6 +29,8 @@ from six import iteritems
|
|||||||
|
|
||||||
from ..util import remove_none
|
from ..util import remove_none
|
||||||
|
|
||||||
|
from ..swagger import ApiClient
|
||||||
|
|
||||||
class StoreApi(object):
|
class StoreApi(object):
|
||||||
|
|
||||||
def __init__(self, api_client):
|
def __init__(self, api_client):
|
||||||
@ -62,11 +64,13 @@ class StoreApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -103,11 +107,13 @@ class StoreApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -148,11 +154,13 @@ class StoreApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -193,11 +201,13 @@ class StoreApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
|
@ -29,6 +29,8 @@ from six import iteritems
|
|||||||
|
|
||||||
from ..util import remove_none
|
from ..util import remove_none
|
||||||
|
|
||||||
|
from ..swagger import ApiClient
|
||||||
|
|
||||||
class UserApi(object):
|
class UserApi(object):
|
||||||
|
|
||||||
def __init__(self, api_client):
|
def __init__(self, api_client):
|
||||||
@ -63,11 +65,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -102,11 +106,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -141,11 +147,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -181,11 +189,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -221,11 +231,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -264,11 +276,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -310,11 +324,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = params.get('body')
|
body_params = params.get('body')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
@ -353,11 +369,13 @@ class UserApi(object):
|
|||||||
files = remove_none(dict())
|
files = remove_none(dict())
|
||||||
body_params = None
|
body_params = None
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
# HTTP header `Accept`
|
||||||
header_params['Accept'] = ', '.join(accepts)
|
header_params['Accept'] = ApiClient.select_header_accept(['application/json', 'application/xml'])
|
||||||
|
if not header_params['Accept']:
|
||||||
|
del header_params['Accept']
|
||||||
|
|
||||||
content_types = []
|
# HTTP header `Content-Type`
|
||||||
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
header_params['Content-Type'] = ApiClient.select_header_content_type([])
|
||||||
|
|
||||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||||
body=body_params, post_params=form_params, files=files,
|
body=body_params, post_params=form_params, files=files,
|
||||||
|
@ -253,7 +253,32 @@ class ApiClient(object):
|
|||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def select_header_accept(accepts):
|
||||||
|
"""
|
||||||
|
Return `Accept` based on an array of accepts provided
|
||||||
|
"""
|
||||||
|
if not accepts:
|
||||||
|
return
|
||||||
|
|
||||||
|
accepts = list(map(lambda x: x.lower(), accepts))
|
||||||
|
|
||||||
|
if 'application/json' in accepts:
|
||||||
|
return 'application/json'
|
||||||
|
else:
|
||||||
|
return ', '.join(accepts)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def select_header_content_type(content_types):
|
||||||
|
"""
|
||||||
|
Return `Content-Type` baseed on an array of content_types provided
|
||||||
|
"""
|
||||||
|
if not content_types:
|
||||||
|
return 'application/json'
|
||||||
|
|
||||||
|
content_types = list(map(lambda x: x.lower(), content_types))
|
||||||
|
|
||||||
|
if 'application/json' in content_types:
|
||||||
|
return 'application/json'
|
||||||
|
else:
|
||||||
|
return content_types[0]
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
Run the tests.
|
||||||
|
$ pip install nose (optional)
|
||||||
|
$ cd SwaggerPetstore-python
|
||||||
|
$ nosetests -v
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import SwaggerPetstore
|
||||||
|
|
||||||
|
HOST = 'http://petstore.swagger.io/v2'
|
||||||
|
|
||||||
|
|
||||||
|
class ApiClientTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.api_client = SwaggerPetstore.ApiClient(HOST)
|
||||||
|
|
||||||
|
def test_select_header_accept(self):
|
||||||
|
accepts = ['APPLICATION/JSON', 'APPLICATION/XML']
|
||||||
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
|
self.assertEqual(accept, 'application/json')
|
||||||
|
|
||||||
|
accepts = ['application/json', 'application/xml']
|
||||||
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
|
self.assertEqual(accept, 'application/json')
|
||||||
|
|
||||||
|
accepts = ['application/xml', 'application/json']
|
||||||
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
|
self.assertEqual(accept, 'application/json')
|
||||||
|
|
||||||
|
accepts = ['text/plain', 'application/xml']
|
||||||
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
|
self.assertEqual(accept, 'text/plain, application/xml')
|
||||||
|
|
||||||
|
accepts = []
|
||||||
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
|
self.assertEqual(accept, None)
|
||||||
|
|
||||||
|
def test_select_header_content_type(self):
|
||||||
|
content_types = ['APPLICATION/JSON', 'APPLICATION/XML']
|
||||||
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
|
self.assertEqual(content_type, 'application/json')
|
||||||
|
|
||||||
|
content_types = ['application/json', 'application/xml']
|
||||||
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
|
self.assertEqual(content_type, 'application/json')
|
||||||
|
|
||||||
|
content_types = ['application/xml', 'application/json']
|
||||||
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
|
self.assertEqual(content_type, 'application/json')
|
||||||
|
|
||||||
|
content_types = ['text/plain', 'application/xml']
|
||||||
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
|
self.assertEqual(content_type, 'text/plain')
|
||||||
|
|
||||||
|
content_types = []
|
||||||
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
|
self.assertEqual(content_type, 'application/json')
|
||||||
|
|
||||||
|
|
@ -431,7 +431,7 @@ SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
|
|||||||
emit updatePetWithFormSignal();
|
emit updatePetWithFormSignal();
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
SWGPetApi::deletePet(QString* api_key, qint64 petId) {
|
SWGPetApi::deletePet(QString* apiKey, qint64 petId) {
|
||||||
QString fullPath;
|
QString fullPath;
|
||||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
void findPetsByTags(QList<QString*>* tags);
|
void findPetsByTags(QList<QString*>* tags);
|
||||||
void getPetById(qint64 petId);
|
void getPetById(qint64 petId);
|
||||||
void updatePetWithForm(QString* petId, QString* name, QString* status);
|
void updatePetWithForm(QString* petId, QString* name, QString* status);
|
||||||
void deletePet(QString* api_key, qint64 petId);
|
void deletePet(QString* apiKey, qint64 petId);
|
||||||
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
|
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -9,7 +9,7 @@ module SwaggerClient
|
|||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.update_pet(opts = {})
|
def self.update_pet(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -38,13 +38,14 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new pet to the store
|
# Add a new pet to the store
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.add_pet(opts = {})
|
def self.add_pet(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -73,13 +74,14 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds Pets by status
|
# Finds Pets by status
|
||||||
# Multiple status values can be provided with comma seperated strings
|
# Multiple status values can be provided with comma seperated strings
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [array[string]] :status Status values that need to be considered for filter
|
# @option opts [array[string]] :status Status values that need to be considered for filter
|
||||||
# @return array[Pet]
|
# @return [array[Pet]]
|
||||||
def self.find_pets_by_status(opts = {})
|
def self.find_pets_by_status(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +118,7 @@ module SwaggerClient
|
|||||||
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [array[string]] :tags Tags to filter by
|
# @option opts [array[string]] :tags Tags to filter by
|
||||||
# @return array[Pet]
|
# @return [array[Pet]]
|
||||||
def self.find_pets_by_tags(opts = {})
|
def self.find_pets_by_tags(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ module SwaggerClient
|
|||||||
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
# @param pet_id ID of pet that needs to be fetched
|
# @param pet_id ID of pet that needs to be fetched
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return Pet
|
# @return [Pet]
|
||||||
def self.get_pet_by_id(pet_id, opts = {})
|
def self.get_pet_by_id(pet_id, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'pet_id' is set
|
# verify the required parameter 'pet_id' is set
|
||||||
@ -194,7 +196,7 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [string] :name Updated name of the pet
|
# @option opts [string] :name Updated name of the pet
|
||||||
# @option opts [string] :status Updated status of the pet
|
# @option opts [string] :status Updated status of the pet
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.update_pet_with_form(pet_id, opts = {})
|
def self.update_pet_with_form(pet_id, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'pet_id' is set
|
# verify the required parameter 'pet_id' is set
|
||||||
@ -228,6 +230,7 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes a pet
|
# Deletes a pet
|
||||||
@ -235,7 +238,7 @@ module SwaggerClient
|
|||||||
# @param pet_id Pet id to delete
|
# @param pet_id Pet id to delete
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [string] :api_key
|
# @option opts [string] :api_key
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.delete_pet(pet_id, opts = {})
|
def self.delete_pet(pet_id, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'pet_id' is set
|
# verify the required parameter 'pet_id' is set
|
||||||
@ -268,6 +271,7 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# uploads an image
|
# uploads an image
|
||||||
@ -276,7 +280,7 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [string] :additional_metadata Additional data to pass to server
|
# @option opts [string] :additional_metadata Additional data to pass to server
|
||||||
# @option opts [file] :file file to upload
|
# @option opts [file] :file file to upload
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.upload_file(pet_id, opts = {})
|
def self.upload_file(pet_id, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'pet_id' is set
|
# verify the required parameter 'pet_id' is set
|
||||||
@ -310,6 +314,7 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ module SwaggerClient
|
|||||||
# Returns pet inventories by status
|
# Returns pet inventories by status
|
||||||
# Returns a map of status codes to quantities
|
# Returns a map of status codes to quantities
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return map[string,int]
|
# @return [map[string,int]]
|
||||||
def self.get_inventory(opts = {})
|
def self.get_inventory(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ module SwaggerClient
|
|||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [Order] :body order placed for purchasing the pet
|
# @option opts [Order] :body order placed for purchasing the pet
|
||||||
# @return Order
|
# @return [Order]
|
||||||
def self.place_order(opts = {})
|
def self.place_order(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ module SwaggerClient
|
|||||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
# @param order_id ID of pet that needs to be fetched
|
# @param order_id ID of pet that needs to be fetched
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return Order
|
# @return [Order]
|
||||||
def self.get_order_by_id(order_id, opts = {})
|
def self.get_order_by_id(order_id, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'order_id' is set
|
# verify the required parameter 'order_id' is set
|
||||||
@ -119,7 +119,7 @@ module SwaggerClient
|
|||||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
# @param order_id ID of the order that needs to be deleted
|
# @param order_id ID of the order that needs to be deleted
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.delete_order(order_id, opts = {})
|
def self.delete_order(order_id, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'order_id' is set
|
# verify the required parameter 'order_id' is set
|
||||||
@ -151,6 +151,7 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ module SwaggerClient
|
|||||||
# This can only be done by the logged in user.
|
# This can only be done by the logged in user.
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [User] :body Created user object
|
# @option opts [User] :body Created user object
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.create_user(opts = {})
|
def self.create_user(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -38,13 +38,14 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [array[User]] :body List of user object
|
# @option opts [array[User]] :body List of user object
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.create_users_with_array_input(opts = {})
|
def self.create_users_with_array_input(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -73,13 +74,14 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [array[User]] :body List of user object
|
# @option opts [array[User]] :body List of user object
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.create_users_with_list_input(opts = {})
|
def self.create_users_with_list_input(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -108,6 +110,7 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logs user into the system
|
# Logs user into the system
|
||||||
@ -115,7 +118,7 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [string] :username The user name for login
|
# @option opts [string] :username The user name for login
|
||||||
# @option opts [string] :password The password for login in clear text
|
# @option opts [string] :password The password for login in clear text
|
||||||
# @return string
|
# @return [string]
|
||||||
def self.login_user(opts = {})
|
def self.login_user(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -152,7 +155,7 @@ module SwaggerClient
|
|||||||
# Logs out current logged in user session
|
# Logs out current logged in user session
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.logout_user(opts = {})
|
def self.logout_user(opts = {})
|
||||||
|
|
||||||
|
|
||||||
@ -181,13 +184,14 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get user by user name
|
# Get user by user name
|
||||||
#
|
#
|
||||||
# @param username The name that needs to be fetched. Use user1 for testing.
|
# @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return User
|
# @return [User]
|
||||||
def self.get_user_by_name(username, opts = {})
|
def self.get_user_by_name(username, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
@ -227,7 +231,7 @@ module SwaggerClient
|
|||||||
# @param username name that need to be deleted
|
# @param username name that need to be deleted
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [User] :body Updated user object
|
# @option opts [User] :body Updated user object
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.update_user(username, opts = {})
|
def self.update_user(username, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
@ -259,13 +263,14 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete user
|
# Delete user
|
||||||
# This can only be done by the logged in user.
|
# This can only be done by the logged in user.
|
||||||
# @param username The name that needs to be deleted
|
# @param username The name that needs to be deleted
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return [nil]
|
||||||
def self.delete_user(username, opts = {})
|
def self.delete_user(username, opts = {})
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
@ -297,6 +302,7 @@ module SwaggerClient
|
|||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -75,7 +75,9 @@ describe "Pet" do
|
|||||||
|
|
||||||
it "should create a pet" do
|
it "should create a pet" do
|
||||||
pet = SwaggerClient::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING")
|
pet = SwaggerClient::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING")
|
||||||
SwaggerClient::PetApi.add_pet(:body => pet)
|
result = SwaggerClient::PetApi.add_pet(:body => pet)
|
||||||
|
# nothing is returned
|
||||||
|
result.should be_nil
|
||||||
|
|
||||||
pet = SwaggerClient::PetApi.get_pet_by_id(10002)
|
pet = SwaggerClient::PetApi.get_pet_by_id(10002)
|
||||||
pet.id.should == 10002
|
pet.id.should == 10002
|
||||||
|
@ -123,7 +123,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
|||||||
* @param status Status values that need to be considered for filter
|
* @param status Status values that need to be considered for filter
|
||||||
* @return List[Pet]
|
* @return List[Pet]
|
||||||
*/
|
*/
|
||||||
def findPetsByStatus (status: List[String] = available) : Option[List[Pet]] = {
|
def findPetsByStatus (status: List[String] /* = available */) : Option[List[Pet]] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = "/pet/findByStatus".replaceAll("\\{format\\}","json")
|
val path = "/pet/findByStatus".replaceAll("\\{format\\}","json")
|
||||||
|
|
||||||
@ -325,11 +325,11 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
|||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*
|
*
|
||||||
* @param api_key
|
* @param apiKey
|
||||||
* @param petId Pet id to delete
|
* @param petId Pet id to delete
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
def deletePet (api_key: String, petId: Long) = {
|
def deletePet (apiKey: String, petId: Long) = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
|
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
headerParams += "api_key" -> api_key
|
headerParams += "api_key" -> apiKey
|
||||||
|
|
||||||
|
|
||||||
var postBody: AnyRef = null
|
var postBody: AnyRef = null
|
||||||
|
2
samples/client/petstore/swift/PetstoreClient/Cartfile
Normal file
2
samples/client/petstore/swift/PetstoreClient/Cartfile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github "Alamofire/Alamofire" >= 1.2
|
||||||
|
github "mxcl/PromiseKit"
|
@ -380,7 +380,7 @@ deletePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiErro
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SamiPetApi::deletePetWithCompletion(String* api_key, Long* petId, void(*success)(SamiError*)) {
|
SamiPetApi::deletePetWithCompletion(String* apiKey, Long* petId, void(*success)(SamiError*)) {
|
||||||
client = new SamiApiClient();
|
client = new SamiApiClient();
|
||||||
|
|
||||||
client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success);
|
client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success);
|
||||||
@ -388,7 +388,7 @@ SamiPetApi::deletePetWithCompletion(String* api_key, Long* petId, void(*success)
|
|||||||
headerParams->Construct();
|
headerParams->Construct();
|
||||||
|
|
||||||
|
|
||||||
headerParams->Add(new String("api_key"), api_key);
|
headerParams->Add(new String("api_key"), apiKey);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(* handler)(SamiError*));
|
updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(* handler)(SamiError*));
|
||||||
|
|
||||||
void
|
void
|
||||||
deletePetWithCompletion(String* api_key, Long* petId, void(* handler)(SamiError*));
|
deletePetWithCompletion(String* apiKey, Long* petId, void(* handler)(SamiError*));
|
||||||
|
|
||||||
void
|
void
|
||||||
uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(* handler)(SamiError*));
|
uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(* handler)(SamiError*));
|
||||||
|
@ -209,7 +209,7 @@
|
|||||||
|
|
||||||
<span class="param-in">Header: </span>
|
<span class="param-in">Header: </span>
|
||||||
|
|
||||||
<span class="param-name">api_key</span>
|
<span class="param-name">apiKey</span>
|
||||||
<span class="param-type">String</span>
|
<span class="param-type">String</span>
|
||||||
|
|
||||||
<p class="param-description"></p>
|
<p class="param-description"></p>
|
||||||
|
@ -235,7 +235,7 @@
|
|||||||
|
|
||||||
<h3 class="field-label">Parameters</h3>
|
<h3 class="field-label">Parameters</h3>
|
||||||
<div class="field-items">
|
<div class="field-items">
|
||||||
<div class="param">api_key (optional)</div>
|
<div class="param">apiKey (optional)</div>
|
||||||
|
|
||||||
<div class="param-desc"><span class="param-type">Header Parameter</span> — </div>
|
<div class="param-desc"><span class="param-type">Header Parameter</span> — </div>
|
||||||
<div class="param">petId (required)</div>
|
<div class="param">petId (required)</div>
|
||||||
@ -332,7 +332,7 @@
|
|||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou",
|
"status" : "aeiou",
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2015-05-21T05:49:06.118+0000"
|
"shipDate" : "2015-05-23T15:56:49.441+0000"
|
||||||
}</code></pre>
|
}</code></pre>
|
||||||
|
|
||||||
<h3 class="field-label">Example data</h3>
|
<h3 class="field-label">Example data</h3>
|
||||||
@ -341,7 +341,7 @@
|
|||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2015-05-20T22:49:06.120Z</shipDate>
|
<shipDate>2015-05-23T08:56:49.444Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order></code></pre>
|
</Order></code></pre>
|
||||||
@ -375,7 +375,7 @@
|
|||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou",
|
"status" : "aeiou",
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2015-05-21T05:49:06.121+0000"
|
"shipDate" : "2015-05-23T15:56:49.445+0000"
|
||||||
}</code></pre>
|
}</code></pre>
|
||||||
|
|
||||||
<h3 class="field-label">Example data</h3>
|
<h3 class="field-label">Example data</h3>
|
||||||
@ -384,7 +384,7 @@
|
|||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2015-05-20T22:49:06.122Z</shipDate>
|
<shipDate>2015-05-23T08:56:49.445Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order></code></pre>
|
</Order></code></pre>
|
||||||
|
@ -62,6 +62,25 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<version>1.9.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>add-source</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>src/gen/java</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -0,0 +1,156 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.model.*;
|
||||||
|
import io.swagger.api.PetApiService;
|
||||||
|
import io.swagger.api.factories.PetApiServiceFactory;
|
||||||
|
|
||||||
|
import com.wordnik.swagger.annotations.ApiParam;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import io.swagger.model.Pet;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
|
||||||
|
@Path("/pet")
|
||||||
|
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.Api(value = "/pet", description = "the pet API")
|
||||||
|
public class PetApi {
|
||||||
|
|
||||||
|
private final PetApiService delegate = PetApiServiceFactory.getPetApi();
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
|
||||||
|
@Consumes({ "application/json", "application/xml" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||||
|
|
||||||
|
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.updatePet(body);
|
||||||
|
}
|
||||||
|
@POST
|
||||||
|
|
||||||
|
@Consumes({ "application/json", "application/xml" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
|
||||||
|
|
||||||
|
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.addPet(body);
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/findByStatus")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
|
||||||
|
|
||||||
|
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List<String> status)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.findPetsByStatus(status);
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/findByTags")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") })
|
||||||
|
|
||||||
|
public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List<String> tags)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.findPetsByTags(tags);
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/{petId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||||
|
|
||||||
|
public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.getPetById(petId);
|
||||||
|
}
|
||||||
|
@POST
|
||||||
|
@Path("/{petId}")
|
||||||
|
@Consumes({ "application/x-www-form-urlencoded" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
|
||||||
|
|
||||||
|
public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId,
|
||||||
|
@ApiParam(value = "Updated name of the pet" )@FormParam("name") String name,
|
||||||
|
@ApiParam(value = "Updated status of the pet" )@FormParam("status") String status)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.updatePetWithForm(petId,name,status);
|
||||||
|
}
|
||||||
|
@DELETE
|
||||||
|
@Path("/{petId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") })
|
||||||
|
|
||||||
|
public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey,
|
||||||
|
@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.deletePet(apiKey,petId);
|
||||||
|
}
|
||||||
|
@POST
|
||||||
|
@Path("/{petId}/uploadImage")
|
||||||
|
@Consumes({ "multipart/form-data" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||||
|
|
||||||
|
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId,
|
||||||
|
@ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata,
|
||||||
|
@ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream,
|
||||||
|
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.uploadFile(petId,additionalMetadata,fileDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.api.*;
|
||||||
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import io.swagger.model.Pet;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public abstract class PetApiService {
|
||||||
|
|
||||||
|
public abstract Response updatePet(Pet body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response addPet(Pet body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response findPetsByStatus(List<String> status)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response findPetsByTags(List<String> tags)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response getPetById(Long petId)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response updatePetWithForm(String petId,String name,String status)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response deletePet(String apiKey,Long petId)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.model.*;
|
||||||
|
import io.swagger.api.StoreApiService;
|
||||||
|
import io.swagger.api.factories.StoreApiServiceFactory;
|
||||||
|
|
||||||
|
import com.wordnik.swagger.annotations.ApiParam;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import io.swagger.model.Order;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
|
||||||
|
@Path("/store")
|
||||||
|
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.Api(value = "/store", description = "the store API")
|
||||||
|
public class StoreApi {
|
||||||
|
|
||||||
|
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/inventory")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map")
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
|
||||||
|
|
||||||
|
public Response getInventory()
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.getInventory();
|
||||||
|
}
|
||||||
|
@POST
|
||||||
|
@Path("/order")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") })
|
||||||
|
|
||||||
|
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.placeOrder(body);
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/order/{orderId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||||
|
|
||||||
|
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.getOrderById(orderId);
|
||||||
|
}
|
||||||
|
@DELETE
|
||||||
|
@Path("/order/{orderId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||||
|
|
||||||
|
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.deleteOrder(orderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.api.*;
|
||||||
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import io.swagger.model.Order;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public abstract class StoreApiService {
|
||||||
|
|
||||||
|
public abstract Response getInventory()
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response placeOrder(Order body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response getOrderById(String orderId)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response deleteOrder(String orderId)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.model.*;
|
||||||
|
import io.swagger.api.UserApiService;
|
||||||
|
import io.swagger.api.factories.UserApiServiceFactory;
|
||||||
|
|
||||||
|
import com.wordnik.swagger.annotations.ApiParam;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import io.swagger.model.User;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
|
||||||
|
@Path("/user")
|
||||||
|
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.Api(value = "/user", description = "the user API")
|
||||||
|
public class UserApi {
|
||||||
|
|
||||||
|
private final UserApiService delegate = UserApiServiceFactory.getUserApi();
|
||||||
|
|
||||||
|
@POST
|
||||||
|
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||||
|
|
||||||
|
public Response createUser(@ApiParam(value = "Created user object" ) User body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.createUser(body);
|
||||||
|
}
|
||||||
|
@POST
|
||||||
|
@Path("/createWithArray")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||||
|
|
||||||
|
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List<User> body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.createUsersWithArrayInput(body);
|
||||||
|
}
|
||||||
|
@POST
|
||||||
|
@Path("/createWithList")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||||
|
|
||||||
|
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List<User> body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.createUsersWithListInput(body);
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/login")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") })
|
||||||
|
|
||||||
|
public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username,
|
||||||
|
@ApiParam(value = "The password for login in clear text") @QueryParam("password") String password)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.loginUser(username,password);
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/logout")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||||
|
|
||||||
|
public Response logoutUser()
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.logoutUser();
|
||||||
|
}
|
||||||
|
@GET
|
||||||
|
@Path("/{username}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
|
||||||
|
|
||||||
|
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.getUserByName(username);
|
||||||
|
}
|
||||||
|
@PUT
|
||||||
|
@Path("/{username}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") })
|
||||||
|
|
||||||
|
public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username,
|
||||||
|
@ApiParam(value = "Updated user object" ) User body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.updateUser(username,body);
|
||||||
|
}
|
||||||
|
@DELETE
|
||||||
|
@Path("/{username}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@com.wordnik.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
||||||
|
|
||||||
|
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
|
||||||
|
|
||||||
|
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return delegate.deleteUser(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.api.*;
|
||||||
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import io.swagger.model.User;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public abstract class UserApiService {
|
||||||
|
|
||||||
|
public abstract Response createUser(User body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response createUsersWithArrayInput(List<User> body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response createUsersWithListInput(List<User> body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response loginUser(String username,String password)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response logoutUser()
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response getUserByName(String username)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response updateUser(String username,User body)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
public abstract Response deleteUser(String username)
|
||||||
|
throws NotFoundException;
|
||||||
|
|
||||||
|
}
|
@ -1,167 +0,0 @@
|
|||||||
package io.swagger.api;
|
|
||||||
|
|
||||||
import io.swagger.model.*;
|
|
||||||
|
|
||||||
import com.wordnik.swagger.annotations.ApiParam;
|
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
|
||||||
|
|
||||||
import io.swagger.model.Pet;
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import io.swagger.api.NotFoundException;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import com.sun.jersey.core.header.FormDataContentDisposition;
|
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
|
|
||||||
@Path("/pet")
|
|
||||||
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.Api(value = "/pet", description = "the pet API")
|
|
||||||
public class PetApi {
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
|
|
||||||
@Consumes({ "application/json", "application/xml" })
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
|
||||||
|
|
||||||
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
|
|
||||||
@Consumes({ "application/json", "application/xml" })
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
|
|
||||||
|
|
||||||
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/findByStatus")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
|
|
||||||
|
|
||||||
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List<String> status)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/findByTags")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") })
|
|
||||||
|
|
||||||
public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List<String> tags)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/{petId}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
|
||||||
|
|
||||||
public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/{petId}")
|
|
||||||
@Consumes({ "application/x-www-form-urlencoded" })
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
|
|
||||||
|
|
||||||
public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId,
|
|
||||||
@ApiParam(value = "Updated name of the pet" )@FormParam("name") String name,
|
|
||||||
@ApiParam(value = "Updated status of the pet" )@FormParam("status") String status)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("/{petId}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") })
|
|
||||||
|
|
||||||
public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey,
|
|
||||||
@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/{petId}/uploadImage")
|
|
||||||
@Consumes({ "multipart/form-data" })
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
|
||||||
|
|
||||||
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId,
|
|
||||||
@ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata,
|
|
||||||
@ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream,
|
|
||||||
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
package io.swagger.api;
|
|
||||||
|
|
||||||
import io.swagger.model.*;
|
|
||||||
|
|
||||||
import com.wordnik.swagger.annotations.ApiParam;
|
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import io.swagger.model.Order;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import io.swagger.api.NotFoundException;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import com.sun.jersey.core.header.FormDataContentDisposition;
|
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
|
|
||||||
@Path("/store")
|
|
||||||
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.Api(value = "/store", description = "the store API")
|
|
||||||
public class StoreApi {
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/inventory")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map")
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
|
|
||||||
|
|
||||||
public Response getInventory()
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/order")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") })
|
|
||||||
|
|
||||||
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/order/{orderId}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
|
||||||
|
|
||||||
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("/order/{orderId}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
|
||||||
|
|
||||||
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
package io.swagger.api;
|
|
||||||
|
|
||||||
import io.swagger.model.*;
|
|
||||||
|
|
||||||
import com.wordnik.swagger.annotations.ApiParam;
|
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
|
||||||
|
|
||||||
import io.swagger.model.User;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import io.swagger.api.NotFoundException;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import com.sun.jersey.core.header.FormDataContentDisposition;
|
|
||||||
import com.sun.jersey.multipart.FormDataParam;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
|
|
||||||
@Path("/user")
|
|
||||||
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.Api(value = "/user", description = "the user API")
|
|
||||||
public class UserApi {
|
|
||||||
|
|
||||||
@POST
|
|
||||||
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
|
||||||
|
|
||||||
public Response createUser(@ApiParam(value = "Created user object" ) User body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/createWithArray")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
|
||||||
|
|
||||||
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List<User> body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/createWithList")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
|
||||||
|
|
||||||
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List<User> body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/login")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") })
|
|
||||||
|
|
||||||
public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username,
|
|
||||||
@ApiParam(value = "The password for login in clear text") @QueryParam("password") String password)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/logout")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
|
||||||
|
|
||||||
public Response logoutUser()
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/{username}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
|
|
||||||
|
|
||||||
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("/{username}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") })
|
|
||||||
|
|
||||||
public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username,
|
|
||||||
@ApiParam(value = "Updated user object" ) User body)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("/{username}")
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@com.wordnik.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponses(value = {
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
|
||||||
|
|
||||||
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
|
|
||||||
|
|
||||||
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username)
|
|
||||||
throws NotFoundException {
|
|
||||||
// do some magic!
|
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.swagger.api.factories;
|
||||||
|
|
||||||
|
import io.swagger.api.PetApiService;
|
||||||
|
import io.swagger.api.impl.PetApiServiceImpl;
|
||||||
|
|
||||||
|
public class PetApiServiceFactory {
|
||||||
|
|
||||||
|
private final static PetApiService service = new PetApiServiceImpl();
|
||||||
|
|
||||||
|
public static PetApiService getPetApi()
|
||||||
|
{
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.swagger.api.factories;
|
||||||
|
|
||||||
|
import io.swagger.api.StoreApiService;
|
||||||
|
import io.swagger.api.impl.StoreApiServiceImpl;
|
||||||
|
|
||||||
|
public class StoreApiServiceFactory {
|
||||||
|
|
||||||
|
private final static StoreApiService service = new StoreApiServiceImpl();
|
||||||
|
|
||||||
|
public static StoreApiService getStoreApi()
|
||||||
|
{
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.swagger.api.factories;
|
||||||
|
|
||||||
|
import io.swagger.api.UserApiService;
|
||||||
|
import io.swagger.api.impl.UserApiServiceImpl;
|
||||||
|
|
||||||
|
public class UserApiServiceFactory {
|
||||||
|
|
||||||
|
private final static UserApiService service = new UserApiServiceImpl();
|
||||||
|
|
||||||
|
public static UserApiService getUserApi()
|
||||||
|
{
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package io.swagger.api.impl;
|
||||||
|
|
||||||
|
import io.swagger.api.*;
|
||||||
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import io.swagger.model.Pet;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class PetApiServiceImpl extends PetApiService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response updatePet(Pet body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response addPet(Pet body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response findPetsByStatus(List<String> status)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response findPetsByTags(List<String> tags)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response getPetById(Long petId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response updatePetWithForm(String petId,String name,String status)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response deletePet(String apiKey,Long petId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package io.swagger.api.impl;
|
||||||
|
|
||||||
|
import io.swagger.api.*;
|
||||||
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import io.swagger.model.Order;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class StoreApiServiceImpl extends StoreApiService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response getInventory()
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response placeOrder(Order body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response getOrderById(String orderId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response deleteOrder(String orderId)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package io.swagger.api.impl;
|
||||||
|
|
||||||
|
import io.swagger.api.*;
|
||||||
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import io.swagger.model.User;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class UserApiServiceImpl extends UserApiService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response createUser(User body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response createUsersWithArrayInput(List<User> body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response createUsersWithListInput(List<User> body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response loginUser(String username,String password)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response logoutUser()
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response getUserByName(String username)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response updateUser(String username,User body)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response deleteUser(String username)
|
||||||
|
throws NotFoundException {
|
||||||
|
// do some magic!
|
||||||
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user