forked from loafle/openapi-generator-original
Merge branch 'develop_2.0' into add_springdox
This commit is contained in:
@@ -16,7 +16,7 @@ Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additi
|
||||
## Compatability
|
||||
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
|
||||
|
||||
Swagger Codegen Version | Release Date | Swagger Spec compatability | Notes
|
||||
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
|
||||
----------------------- | ------------ | -------------------------- | -----
|
||||
2.1.3-M1-SNAPSHOT | 2015-02-23 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.0-M1](https://github.com/swagger-api/swagger-codegen)
|
||||
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
|
||||
@@ -64,9 +64,9 @@ usage: Codegen
|
||||
-i,--input-spec <arg> location of the swagger spec, as URL or file
|
||||
-l,--lang <arg> client language to generate.
|
||||
Available languages include:
|
||||
[android, java, jaxrs, nodejs, objc, scalatra,
|
||||
scala, dynamic-html, html, swagger, tizen, php,
|
||||
python]
|
||||
[android, async-scala, java, jaxrs, nodejs,
|
||||
objc, scalatra, scala, dynamic-html, html,
|
||||
swagger, tizen, php, ruby, python]
|
||||
-o,--output <arg> where to write the generated files
|
||||
-t,--template-dir <arg> folder containing the template files
|
||||
```
|
||||
|
||||
@@ -33,4 +33,4 @@ fi
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l nodejs -o samples/server/petstore/nodejs"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
java $JAVA_OPTS -Dservice -jar $executable $ags
|
||||
|
||||
@@ -26,6 +26,7 @@ public interface CodegenConfig {
|
||||
String getTypeDeclaration(Property p);
|
||||
String getTypeDeclaration(String name);
|
||||
void processOpts();
|
||||
String generateExamplePath(String path, Operation operation);
|
||||
|
||||
Set<String> reservedWords();
|
||||
|
||||
@@ -35,7 +36,7 @@ public interface CodegenConfig {
|
||||
String getOutputDir();
|
||||
|
||||
CodegenModel fromModel(String name, Model model);
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation);
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
|
||||
List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes);
|
||||
|
||||
Set<String> defaultIncludes();
|
||||
|
||||
@@ -6,7 +6,8 @@ import java.util.*;
|
||||
|
||||
public class CodegenOperation {
|
||||
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
|
||||
returnSimpleType, subresourceOperation, isMapContainer, isListContainer;
|
||||
returnSimpleType, subresourceOperation, isMapContainer, isListContainer,
|
||||
hasMore = Boolean.TRUE;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, notes, baseName, defaultResponse;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ public class CodegenParameter {
|
||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
|
||||
public String baseName, paramName, dataType, collectionFormat, description, baseType;
|
||||
public String jsonSchema;
|
||||
|
||||
/**
|
||||
* Determines whether this parameter is mandatory. If the parameter is in "path",
|
||||
* this property is required and its value MUST be true. Otherwise, the property
|
||||
@@ -31,6 +33,7 @@ public class CodegenParameter {
|
||||
output.isCookieParam = this.isCookieParam;
|
||||
output.isBodyParam = this.isBodyParam;
|
||||
output.required = this.required;
|
||||
output.jsonSchema = this.jsonSchema;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class CodegenProperty {
|
||||
/** A free-form property to include an example of an instance for this schema. */
|
||||
public String example;
|
||||
|
||||
public String jsonSchema;
|
||||
public Double minimum, maximum, exclusiveMinimum, exclusiveMaximum;
|
||||
public Boolean hasMore = null, required = null, secondaryParam = null;
|
||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
|
||||
@@ -6,10 +6,12 @@ public class CodegenResponse {
|
||||
public String code, message;
|
||||
public Boolean hasMore;
|
||||
public List<Map<String, String>> examples;
|
||||
public final List<CodegenProperty> headers = new ArrayList<CodegenProperty>();
|
||||
public String dataType, baseType, containerType;
|
||||
public Boolean simpleType;
|
||||
public Boolean primitiveType;
|
||||
public Boolean isMapContainer;
|
||||
public Boolean isListContainer;
|
||||
Object schema;
|
||||
public Object schema;
|
||||
public String jsonSchema;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.examples.ExampleGenerator;
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.auth.ApiKeyAuthDefinition;
|
||||
import com.wordnik.swagger.models.auth.BasicAuthDefinition;
|
||||
@@ -8,7 +9,9 @@ import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
|
||||
import com.wordnik.swagger.models.parameters.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -141,7 +144,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
public String toModelFilename(String name) {
|
||||
return name;
|
||||
return initialCaps(name);
|
||||
}
|
||||
|
||||
public String toOperationId(String operationId) { return operationId; }
|
||||
@@ -233,6 +236,55 @@ public class DefaultCodegen {
|
||||
importMapping.put("LocalTime", "org.joda.time.*");
|
||||
}
|
||||
|
||||
|
||||
public String generateExamplePath(String path, Operation operation) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(path);
|
||||
|
||||
if(operation.getParameters() != null) {
|
||||
int count = 0;
|
||||
|
||||
for(Parameter param : operation.getParameters()) {
|
||||
if(param instanceof QueryParameter) {
|
||||
StringBuilder paramPart = new StringBuilder();
|
||||
QueryParameter qp = (QueryParameter) param;
|
||||
|
||||
if(count == 0)
|
||||
paramPart.append("?");
|
||||
else
|
||||
paramPart.append(",");
|
||||
count += 1;
|
||||
if(!param.getRequired())
|
||||
paramPart.append("[");
|
||||
paramPart.append(param.getName()).append("=");
|
||||
paramPart.append("{");
|
||||
if(qp.getCollectionFormat() != null) {
|
||||
paramPart.append(param.getName() + "1");
|
||||
if("csv".equals(qp.getCollectionFormat()))
|
||||
paramPart.append(",");
|
||||
else if("pipes".equals(qp.getCollectionFormat()))
|
||||
paramPart.append("|");
|
||||
else if("tsv".equals(qp.getCollectionFormat()))
|
||||
paramPart.append("\t");
|
||||
else if("multi".equals(qp.getCollectionFormat())) {
|
||||
paramPart.append("&").append(param.getName()).append("=");
|
||||
paramPart.append(param.getName() + "2");
|
||||
}
|
||||
}
|
||||
else {
|
||||
paramPart.append(param.getName());
|
||||
}
|
||||
paramPart.append("}");
|
||||
if(!param.getRequired())
|
||||
paramPart.append("]");
|
||||
sb.append(paramPart.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String toInstantiationType(Property p) {
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
@@ -317,7 +369,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
public String snakeCase(String name) {
|
||||
return Character.toLowerCase(name.charAt(0)) + name.substring(1);
|
||||
return (name.length() > 0) ? (Character.toLowerCase(name.charAt(0)) + name.substring(1)) : "";
|
||||
}
|
||||
|
||||
public String initialCaps(String name) {
|
||||
@@ -479,9 +531,9 @@ public class DefaultCodegen {
|
||||
property.setter = "set" + getterAndSetterCapitalize(name);
|
||||
property.example = p.getExample();
|
||||
property.defaultValue = toDefaultValue(p);
|
||||
property.jsonSchema = Json.pretty(p);
|
||||
|
||||
String type = getSwaggerType(p);
|
||||
|
||||
if(p instanceof AbstractNumericProperty) {
|
||||
AbstractNumericProperty np = (AbstractNumericProperty) p;
|
||||
property.minimum = np.getMinimum();
|
||||
@@ -554,14 +606,18 @@ public class DefaultCodegen {
|
||||
property.isPrimitiveType = true;
|
||||
}
|
||||
else {
|
||||
property.isNotContainer = true;
|
||||
setNonArrayMapProperty(property, type);
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
property.isNotContainer = true;
|
||||
if(languageSpecificPrimitives().contains(type))
|
||||
property.isPrimitiveType = true;
|
||||
else
|
||||
property.complexType = property.baseType;
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
private Response findMethodResponse(Map<String, Response> responses) {
|
||||
|
||||
@@ -578,7 +634,7 @@ public class DefaultCodegen {
|
||||
return responses.get(code);
|
||||
}
|
||||
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation){
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions) {
|
||||
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
|
||||
Set<String> imports = new HashSet<String>();
|
||||
|
||||
@@ -621,6 +677,8 @@ public class DefaultCodegen {
|
||||
count += 1;
|
||||
if (count < operation.getConsumes().size())
|
||||
mediaType.put("hasMore", "true");
|
||||
else
|
||||
mediaType.put("hasMore", null);
|
||||
c.add(mediaType);
|
||||
}
|
||||
op.consumes = c;
|
||||
@@ -636,6 +694,8 @@ public class DefaultCodegen {
|
||||
count += 1;
|
||||
if (count < operation.getProduces().size())
|
||||
mediaType.put("hasMore", "true");
|
||||
else
|
||||
mediaType.put("hasMore", null);
|
||||
c.add(mediaType);
|
||||
}
|
||||
op.produces = c;
|
||||
@@ -643,7 +703,6 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
||||
|
||||
Response methodResponse = findMethodResponse(operation.getResponses());
|
||||
CodegenResponse methodCodegenResponse = null;
|
||||
|
||||
@@ -662,24 +721,40 @@ public class DefaultCodegen {
|
||||
}
|
||||
op.responses.get(op.responses.size() - 1).hasMore = false;
|
||||
|
||||
if (methodResponse != null) {
|
||||
op.returnType = methodCodegenResponse.dataType;
|
||||
op.returnBaseType = methodCodegenResponse.baseType;
|
||||
op.returnSimpleType = methodCodegenResponse.simpleType;
|
||||
op.returnTypeIsPrimitive = methodCodegenResponse.primitiveType;
|
||||
op.returnContainer = methodCodegenResponse.containerType;
|
||||
op.isListContainer = methodCodegenResponse.isListContainer;
|
||||
op.isMapContainer = methodCodegenResponse.isMapContainer;
|
||||
if (methodResponse.getSchema() != null) {
|
||||
Property responseProperty = methodResponse.getSchema();
|
||||
responseProperty.setRequired(true);
|
||||
CodegenProperty cm = fromProperty("response", responseProperty);
|
||||
op.examples = toExamples(methodResponse.getExamples());
|
||||
op.defaultResponse = toDefaultValue(responseProperty);
|
||||
addHeaders(methodResponse, op.responseHeaders);
|
||||
}
|
||||
if(methodResponse != null) {
|
||||
if (methodResponse.getSchema() != null) {
|
||||
CodegenProperty cm = fromProperty("response", methodResponse.getSchema());
|
||||
|
||||
Property responseProperty = methodResponse.getSchema();
|
||||
|
||||
if(responseProperty instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) responseProperty;
|
||||
CodegenProperty innerProperty = fromProperty("response", ap.getItems());
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
}
|
||||
else {
|
||||
if(cm.complexType != null)
|
||||
op.returnBaseType = cm.complexType;
|
||||
else
|
||||
op.returnBaseType = cm.baseType;
|
||||
}
|
||||
op.examples = new ExampleGenerator(definitions).generate(methodResponse.getExamples(), operation.getProduces(), responseProperty);
|
||||
op.defaultResponse = toDefaultValue(responseProperty);
|
||||
op.returnType = cm.datatype;
|
||||
if(cm.isContainer != null) {
|
||||
op.returnContainer = cm.containerType;
|
||||
if("map".equals(cm.containerType))
|
||||
op.isMapContainer = Boolean.TRUE;
|
||||
else if ("list".equalsIgnoreCase(cm.containerType))
|
||||
op.isListContainer = Boolean.TRUE;
|
||||
}
|
||||
else
|
||||
op.returnSimpleType = true;
|
||||
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null)
|
||||
op.returnTypeIsPrimitive = true;
|
||||
}
|
||||
addHeaders(methodResponse, op.responseHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
List<Parameter> parameters = operation.getParameters();
|
||||
@@ -761,6 +836,8 @@ public class DefaultCodegen {
|
||||
r.message = response.getDescription();
|
||||
r.schema = response.getSchema();
|
||||
r.examples = toExamples(response.getExamples());
|
||||
r.jsonSchema = Json.pretty(response);
|
||||
addHeaders(response, r.headers);
|
||||
|
||||
if (r.schema != null) {
|
||||
Property responseProperty = response.getSchema();
|
||||
@@ -803,6 +880,7 @@ public class DefaultCodegen {
|
||||
p.baseName = param.getName();
|
||||
p.description = param.getDescription();
|
||||
p.required = param.getRequired();
|
||||
p.jsonSchema = Json.pretty(param);
|
||||
|
||||
if(param instanceof SerializableParameter) {
|
||||
SerializableParameter qp = (SerializableParameter) param;
|
||||
|
||||
@@ -56,6 +56,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if(license.getUrl() != null)
|
||||
config.additionalProperties().put("licenseUrl", license.getUrl());
|
||||
}
|
||||
if(info.getVersion() != null) {
|
||||
config.additionalProperties().put("version", info.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder hostBuilder = new StringBuilder();
|
||||
@@ -65,8 +68,15 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
else
|
||||
hostBuilder.append("https://");
|
||||
hostBuilder.append(swagger.getHost()).append(swagger.getBasePath());
|
||||
String contextPath = swagger.getBasePath();
|
||||
if(swagger.getHost() != null)
|
||||
hostBuilder.append(swagger.getHost());
|
||||
else
|
||||
hostBuilder.append("localhost");
|
||||
if(swagger.getBasePath() != null)
|
||||
hostBuilder.append(swagger.getBasePath());
|
||||
else
|
||||
hostBuilder.append("/");
|
||||
String contextPath = swagger.getBasePath() == null ? "/" : swagger.getBasePath();
|
||||
String basePath = hostBuilder.toString();
|
||||
|
||||
|
||||
@@ -119,7 +129,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
operation.putAll(config.additionalProperties());
|
||||
operation.put("classname", config.toApiName(tag));
|
||||
operation.put("classVarName", config.toApiVarName(tag));
|
||||
allOperations.add(operation);
|
||||
|
||||
allOperations.add(new HashMap<String, Object>(operation));
|
||||
for(int i = 0; i < allOperations.size(); i++) {
|
||||
Map<String, Object> oo = (Map<String, Object>) allOperations.get(i);
|
||||
if(i < (allOperations.size() -1))
|
||||
oo.put("hasMore", "true");
|
||||
}
|
||||
|
||||
for(String templateName : config.apiTemplateFiles().keySet()) {
|
||||
String suffix = config.apiTemplateFiles().get(templateName);
|
||||
String filename = config.apiFileFolder() +
|
||||
@@ -153,9 +170,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
Map<String, Object> apis = new HashMap<String, Object>();
|
||||
apis.put("apis", allOperations);
|
||||
if(swagger.getBasePath() != null) {
|
||||
bundle.put("basePath", basePath);
|
||||
if(swagger.getHost() != null) {
|
||||
bundle.put("host", swagger.getHost());
|
||||
}
|
||||
bundle.put("basePath", basePath);
|
||||
bundle.put("contextPath", contextPath);
|
||||
bundle.put("apiInfo", apis);
|
||||
bundle.put("models", allModels);
|
||||
bundle.put("apiFolder", config.apiPackage().replace('.', File.separatorChar));
|
||||
@@ -252,7 +271,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
for (String tag : tags) {
|
||||
CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation);
|
||||
CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions());
|
||||
co.tags = new ArrayList<String>();
|
||||
co.tags.add(sanitizeTag(tag));
|
||||
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
|
||||
@@ -319,6 +338,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
operations.put("imports", imports);
|
||||
config.postProcessOperations(operations);
|
||||
if(objs.size() > 0) {
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
|
||||
|
||||
if(os != null && os.size() > 0) {
|
||||
CodegenOperation op = os.get(os.size() - 1);
|
||||
op.hasMore = null;
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.wordnik.swagger.codegen.examples;
|
||||
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class ExampleGenerator {
|
||||
protected Map<String, Model> examples;
|
||||
|
||||
public ExampleGenerator(Map<String, Model> examples) {
|
||||
this.examples = examples;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> generate(Map<String, String> examples, List<String> mediaTypes, Property property) {
|
||||
List<Map<String, String>> output = new ArrayList<Map<String, String>>();
|
||||
if(examples == null ) {
|
||||
if(mediaTypes == null) {
|
||||
// assume application/json for this
|
||||
mediaTypes = Arrays.asList("application/json");
|
||||
}
|
||||
for(String mediaType : mediaTypes) {
|
||||
Map<String, String> kv = new HashMap<String, String>();
|
||||
kv.put("contentType", mediaType);
|
||||
if(property != null && mediaType.startsWith("application/json")) {
|
||||
String example = Json.pretty(resolvePropertyToExample(mediaType, property));
|
||||
|
||||
if(example != null) {
|
||||
example = example.replaceAll("\n", "\\\\n");
|
||||
kv.put("example", example);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
else if(property != null && mediaType.startsWith("application/xml")) {
|
||||
String example = new XmlExampleGenerator(this.examples).toXml(property);
|
||||
if(example != null) {
|
||||
example = example.replaceAll("\n", "\\\\n");
|
||||
kv.put("example", example);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(String key: examples.keySet()) {
|
||||
String value = examples.get(key);
|
||||
|
||||
Map<String, String> kv = new HashMap<String, String>();
|
||||
kv.put("contentType", key);
|
||||
kv.put("example", value);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
if(output.size() == 0) {
|
||||
Map<String, String> kv = new HashMap<String, String>();
|
||||
kv.put("output", "none");
|
||||
output.add(kv);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
protected Object resolvePropertyToExample(String mediaType, Property property) {
|
||||
if(property.getExample() != null) {
|
||||
return property.getExample();
|
||||
}
|
||||
else if(property instanceof StringProperty) {
|
||||
return "aeiou";
|
||||
}
|
||||
else if(property instanceof BooleanProperty) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
else if(property instanceof ArrayProperty) {
|
||||
Property innerType = ((ArrayProperty)property).getItems();
|
||||
if(innerType != null) {
|
||||
Object[] output = new Object[]{
|
||||
resolvePropertyToExample(mediaType, innerType)
|
||||
};
|
||||
return output;
|
||||
}
|
||||
}
|
||||
else if(property instanceof DateProperty) {
|
||||
return new java.util.Date(System.currentTimeMillis());
|
||||
}
|
||||
else if(property instanceof DateTimeProperty) {
|
||||
return new java.util.Date(System.currentTimeMillis());
|
||||
}
|
||||
else if(property instanceof DecimalProperty) {
|
||||
return new BigDecimal(1.3579);
|
||||
}
|
||||
else if(property instanceof DoubleProperty) {
|
||||
return new Double(3.149);
|
||||
}
|
||||
else if(property instanceof FileProperty) {
|
||||
return ""; // TODO
|
||||
}
|
||||
else if(property instanceof FloatProperty) {
|
||||
return new Float(1.23);
|
||||
}
|
||||
else if(property instanceof IntegerProperty) {
|
||||
return new Integer(123);
|
||||
}
|
||||
else if(property instanceof LongProperty) {
|
||||
return new Long(123456789);
|
||||
}
|
||||
else if(property instanceof MapProperty) {
|
||||
Map<String, Object> mp = new HashMap<String, Object>();
|
||||
if(property.getName() != null) {
|
||||
mp.put(property.getName(),
|
||||
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties()));
|
||||
}
|
||||
else {
|
||||
mp.put("key",
|
||||
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties()));
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
else if(property instanceof ObjectProperty) {
|
||||
return "{}";
|
||||
}
|
||||
else if(property instanceof RefProperty) {
|
||||
Model model = examples.get(((RefProperty)property).getSimpleRef());
|
||||
if(model != null)
|
||||
return resolveModelToExample(mediaType, model);
|
||||
}
|
||||
else if(property instanceof UUIDProperty) {
|
||||
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public Object resolveModelToExample(String mediaType, Model model) {
|
||||
if(model instanceof ModelImpl) {
|
||||
ModelImpl impl = (ModelImpl) model;
|
||||
Map<String, Object> values = new HashMap<String, Object>();
|
||||
|
||||
for(String name : impl.getProperties().keySet()) {
|
||||
Property property = impl.getProperties().get(name);
|
||||
values.put(name, resolvePropertyToExample(mediaType, property));
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.wordnik.swagger.codegen.examples;
|
||||
|
||||
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class XmlExampleGenerator {
|
||||
public static String NEWLINE = "\n";
|
||||
public static String TAG_START = "<";
|
||||
public static String CLOSE_TAG = ">";
|
||||
public static String TAG_END = "</";
|
||||
protected Map<String, Model> examples;
|
||||
protected SimpleDateFormat dtFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
protected SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
|
||||
public XmlExampleGenerator(Map<String, Model> examples) {
|
||||
this.examples = examples;
|
||||
if(examples == null)
|
||||
examples = new HashMap<String, Model>();
|
||||
}
|
||||
|
||||
public String toXml(Property property) {
|
||||
return toXml(null, property, 0);
|
||||
}
|
||||
|
||||
protected String toXml(Model model, int indent) {
|
||||
if(model instanceof RefModel) {
|
||||
RefModel ref = (RefModel) model;
|
||||
Model actualModel = examples.get(ref.getSimpleRef());
|
||||
if(actualModel instanceof ModelImpl)
|
||||
return modelImplToXml((ModelImpl)actualModel, indent);
|
||||
}
|
||||
else if(model instanceof ModelImpl) {
|
||||
return modelImplToXml((ModelImpl)model, indent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String modelImplToXml(ModelImpl model, int indent) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// attributes
|
||||
Map<String, Property> attributes = new LinkedHashMap<String, Property>();
|
||||
Map<String, Property> elements = new LinkedHashMap<String, Property>();
|
||||
|
||||
String name = model.getName();
|
||||
String namespace;
|
||||
String prefix;
|
||||
Boolean wrapped;
|
||||
|
||||
Xml xml = model.getXml();
|
||||
if(xml != null) {
|
||||
if(xml.getName() != null)
|
||||
name = xml.getName();
|
||||
}
|
||||
for(String pName : model.getProperties().keySet()) {
|
||||
Property p = model.getProperties().get(pName);
|
||||
if(p != null && p.getXml() != null && p.getXml().getAttribute() != null && p.getXml().getAttribute())
|
||||
attributes.put(pName, p);
|
||||
else
|
||||
elements.put(pName, p);
|
||||
}
|
||||
sb.append(indent(indent)).append(TAG_START);
|
||||
sb.append(name);
|
||||
for(String pName : attributes.keySet()) {
|
||||
Property p = attributes.get(pName);
|
||||
sb.append(" ").append(pName).append("=").append(quote(toXml(null, p, 0)));
|
||||
}
|
||||
sb.append(CLOSE_TAG);
|
||||
sb.append(NEWLINE);
|
||||
for(String pName : elements.keySet()) {
|
||||
Property p = elements.get(pName);
|
||||
sb.append(toXml(pName, p, indent + 1));
|
||||
sb.append(NEWLINE);
|
||||
}
|
||||
sb.append(indent(indent)).append(TAG_END).append(name).append(CLOSE_TAG);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String quote(String string) {
|
||||
return "\"" + string + "\"";
|
||||
}
|
||||
|
||||
protected String toXml(String name, Property property, int indent) {
|
||||
if(property == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if(property instanceof ArrayProperty) {
|
||||
ArrayProperty p = (ArrayProperty) property;
|
||||
Property inner = p.getItems();
|
||||
boolean wrapped = false;
|
||||
if(property.getXml() != null && property.getXml().getWrapped())
|
||||
wrapped = true;
|
||||
if(wrapped) {
|
||||
if(name != null) {
|
||||
sb.append(indent(indent));
|
||||
sb.append(openTag(name));
|
||||
sb.append(NEWLINE);
|
||||
}
|
||||
sb.append(toXml(name, inner, indent + 1));
|
||||
if(name != null) {
|
||||
sb.append(NEWLINE);
|
||||
sb.append(indent(indent));
|
||||
sb.append(closeTag(name));
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.append(toXml(name, inner, indent));
|
||||
}
|
||||
else if(property instanceof RefProperty) {
|
||||
RefProperty ref = (RefProperty) property;
|
||||
Model actualModel = examples.get(ref.getSimpleRef());
|
||||
sb.append(toXml(actualModel, indent));
|
||||
}
|
||||
else {
|
||||
if(name != null) {
|
||||
sb.append(indent(indent));
|
||||
sb.append(openTag(name));
|
||||
}
|
||||
sb.append(getExample(property));
|
||||
if(name != null)
|
||||
sb.append(closeTag(name));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String getExample(Property property) {
|
||||
if(property instanceof DateTimeProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return dtFormat.format(new Date());
|
||||
}
|
||||
else if(property instanceof StringProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "string";
|
||||
}
|
||||
else if(property instanceof DateProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return dateFormat.format(new Date());
|
||||
}
|
||||
else if(property instanceof IntegerProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "0";
|
||||
}
|
||||
else if(property instanceof BooleanProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "true";
|
||||
}
|
||||
else if(property instanceof LongProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "123456";
|
||||
}
|
||||
return "not implemented " + property;
|
||||
}
|
||||
|
||||
protected String openTag(String name) {
|
||||
return "<" + name + ">";
|
||||
}
|
||||
|
||||
protected String closeTag(String name) {
|
||||
return "</" + name + ">";
|
||||
}
|
||||
|
||||
protected String indent(int indent) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for(int i = 0; i < indent; i++) {
|
||||
sb.append(" ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,110 +1,192 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.Model;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String apiVersion = "1.0.0";
|
||||
protected int serverPort = 8080;
|
||||
protected String projectName = "swagger-server";
|
||||
|
||||
public String apiPackage() {
|
||||
return "controllers";
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the type of generator.
|
||||
*
|
||||
* @return the CodegenType for this generator
|
||||
* @see com.wordnik.swagger.codegen.CodegenType
|
||||
*/
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a friendly name for the generator. This will be used by the generator
|
||||
* to select the library with the -l flag.
|
||||
*
|
||||
* @return the friendly name for the generator
|
||||
*/
|
||||
public String getName() {
|
||||
return "nodejs";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human-friendly help for the generator. Provide the consumer with help
|
||||
* tips, parameters here
|
||||
*
|
||||
* @return A string value for the help message
|
||||
*/
|
||||
public String getHelp() {
|
||||
return "Generates a node.js server application compatible with the 1.2 swagger specification.";
|
||||
return "Generates a nodejs server library using the swagger-tools project. By default, " +
|
||||
"it will also generate service classes--which you can disable with the `-Dnoservice` environment variable.";
|
||||
}
|
||||
|
||||
public NodeJSServerCodegen() {
|
||||
super();
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/nodejs";
|
||||
apiTemplateFiles.put("api.mustache", ".js");
|
||||
|
||||
/**
|
||||
* Models. You can write model files using the modelTemplateFiles map.
|
||||
* if you want to create one template for file, you can do so here.
|
||||
* for multiple files for model, just put another entry in the `modelTemplateFiles` with
|
||||
* a different extension
|
||||
*/
|
||||
modelTemplateFiles.clear();
|
||||
|
||||
/**
|
||||
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
|
||||
* as with models, add multiple entries with different extensions for multiple files per
|
||||
* class
|
||||
*/
|
||||
apiTemplateFiles.put(
|
||||
"controller.mustache", // the template to use
|
||||
".js"); // the extension for each file to write
|
||||
|
||||
/**
|
||||
* Template Location. This is the location which templates will be read from. The generator
|
||||
* will use the resource stream to attempt to read the templates.
|
||||
*/
|
||||
templateDir = "nodejs";
|
||||
apiPackage = "app.apis";
|
||||
modelPackage = "app";
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
supportingFiles.add(new SupportingFile("models.mustache", modelPackage, "models.js"));
|
||||
supportingFiles.add(new SupportingFile("main.mustache", "", "main.js"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
/**
|
||||
* Reserved words. Override this with reserved words specific to your language
|
||||
*/
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float")
|
||||
);
|
||||
typeMapping.put("array", "array");
|
||||
"break", "case", "class", "catch", "const", "continue", "debugger",
|
||||
"default", "delete", "do", "else", "export", "extends", "finally",
|
||||
"for", "function", "if", "import", "in", "instanceof", "let", "new",
|
||||
"return", "super", "switch", "this", "throw", "try", "typeof", "var",
|
||||
"void", "while", "with", "yield")
|
||||
);
|
||||
|
||||
/**
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
* are available in models, apis, and supporting files
|
||||
*/
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
additionalProperties.put("serverPort", serverPort);
|
||||
|
||||
/**
|
||||
* Supporting Files. You can write single files for the generator with the
|
||||
* entire object tree available. If the input file has a suffix of `.mustache
|
||||
* it will be processed by the template engine. Otherwise, it will be copied
|
||||
*/
|
||||
// supportingFiles.add(new SupportingFile("controller.mustache",
|
||||
// "controllers",
|
||||
// "controller.js")
|
||||
// );
|
||||
supportingFiles.add(new SupportingFile("swagger.mustache",
|
||||
"api",
|
||||
"swagger.json")
|
||||
);
|
||||
supportingFiles.add(new SupportingFile("index.mustache",
|
||||
"",
|
||||
"index.js")
|
||||
);
|
||||
supportingFiles.add(new SupportingFile("package.mustache",
|
||||
"",
|
||||
"package.json")
|
||||
);
|
||||
if(System.getProperty("noservice") == null) {
|
||||
apiTemplateFiles.put(
|
||||
"service.mustache", // the template to use
|
||||
"Service.js"); // the extension for each file to write
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if(name.length() == 0)
|
||||
return "DefaultController";
|
||||
return initialCaps(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return toApiName(name);
|
||||
}
|
||||
/**
|
||||
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
|
||||
* those terms here. This logic is only called if a variable matches the reseved words
|
||||
*
|
||||
* @return the escaped term
|
||||
*/
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
List<Map<String, Object>> o = (List<Map<String, Object>>)objs.get("models");
|
||||
|
||||
for(Map<String, Object> modelMap : o) {
|
||||
try {
|
||||
CodegenModel m = (CodegenModel) modelMap.get("model");
|
||||
ObjectNode on = (ObjectNode) Json.mapper().readTree(m.modelJson);
|
||||
// inject the id field
|
||||
on.put("id", m.name);
|
||||
|
||||
// remove the definitions qualifier with this nasty hack
|
||||
m.modelJson = Json.pretty(on).replaceAll("\"#/definitions/", "\"");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// skip conversion
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
return "_" + name; // add an underscore to the name
|
||||
}
|
||||
|
||||
/**
|
||||
* Location to write api files. You can use the apiPackage() as defined when the class is
|
||||
* instantiated
|
||||
*/
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
return typeMapping.get(swaggerType);
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>)objs.get("operations");
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>)objectMap.get("operation");
|
||||
for(CodegenOperation operation : operations) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase();
|
||||
List<CodegenParameter> params = operation.allParams;
|
||||
if(params != null && params.size() == 0)
|
||||
operation.allParams = null;
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if(responses != null) {
|
||||
for(CodegenResponse resp : responses) {
|
||||
if("0".equals(resp.code))
|
||||
resp.code = "default";
|
||||
}
|
||||
}
|
||||
if(operation.examples != null && operation.examples.size() > 0) {
|
||||
List<Map<String, String>> examples = operation.examples;
|
||||
for(int i = examples.size() - 1; i >= 0; i--) {
|
||||
Map<String, String> example = examples.get(i);
|
||||
String contentType = example.get("contentType");
|
||||
if(contentType != null && contentType.indexOf("application/json") == 0) {
|
||||
String jsonExample = example.get("example");
|
||||
if(jsonExample != null) {
|
||||
jsonExample = jsonExample.replaceAll("\\\\n", "\n");
|
||||
example.put("example", jsonExample);
|
||||
}
|
||||
}
|
||||
else
|
||||
examples.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,18 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
super.setNonArrayMapProperty(property, type);
|
||||
if("NSDictionary".equals(type)) {
|
||||
property.setter = "initWithDictionary";
|
||||
}
|
||||
else {
|
||||
property.setter = "initWithValues";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
if("".equals(modelPackage()))
|
||||
return name;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
protected String sourceFolder = "src/main/scala";
|
||||
protected String authScheme = "";
|
||||
protected boolean authPreemptive = false;
|
||||
protected boolean asyncHttpClient = !authScheme.isEmpty();
|
||||
|
||||
@@ -23,7 +23,10 @@ public class SwaggerGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
public SwaggerGenerator() {
|
||||
super();
|
||||
templateDir = "swagger";
|
||||
outputFolder = "generated-code/swagger";
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.*;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SwaggerYamlGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "swagger-yaml";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Creates a static swagger.yaml file.";
|
||||
}
|
||||
|
||||
public SwaggerYamlGenerator() {
|
||||
super();
|
||||
templateDir = "swagger";
|
||||
outputFolder = "generated-code/swagger";
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSwagger(Swagger swagger) {
|
||||
try{
|
||||
String swaggerString = Yaml.mapper().writeValueAsString(swagger);
|
||||
String outputFile = outputFolder + File.separator + "swagger.yaml";
|
||||
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
|
||||
System.out.println("wrote file to " + outputFile);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,9 @@ public class {{classname}} {
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
{{#queryParams}}if ({{paramName}} != null)
|
||||
queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
|
||||
queryParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
|
||||
{{#headerParams}}headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
|
||||
{{/headerParams}}
|
||||
String[] contentTypes = {
|
||||
{{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
|
||||
@@ -74,7 +74,7 @@ public class {{classname}} {
|
||||
FormDataMultiPart mp = new FormDataMultiPart();
|
||||
{{#formParams}}{{#notFile}}
|
||||
hasFields = true;
|
||||
mp.field("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
mp.field("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
{{/notFile}}{{#isFile}}
|
||||
hasFields = true;
|
||||
mp.field("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
@@ -83,7 +83,7 @@ public class {{classname}} {
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
{{#formParams}}{{#notFile}}formParams.put("{{baseName}}", {{paramName}});{{/notFile}}
|
||||
{{#formParams}}{{#notFile}}formParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));{{/notFile}}
|
||||
{{/formParams}}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,75 @@ import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.ParseException;
|
||||
|
||||
public class ApiInvoker {
|
||||
private static ApiInvoker INSTANCE = new ApiInvoker();
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
private boolean isDebug = false;
|
||||
|
||||
/**
|
||||
* ISO 8601 date time format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
||||
|
||||
/**
|
||||
* ISO 8601 date format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
static {
|
||||
// Use UTC as the default time zone.
|
||||
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public static Date parseDateTime(String str) {
|
||||
try {
|
||||
return DATE_TIME_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Date parseDate(String str) {
|
||||
try {
|
||||
return DATE_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDateTime(Date datetime) {
|
||||
return DATE_TIME_FORMAT.format(datetime);
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
return DATE_FORMAT.format(date);
|
||||
}
|
||||
|
||||
public static String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDateTime((Date) param);
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableDebug() {
|
||||
isDebug = true;
|
||||
}
|
||||
@@ -106,12 +165,12 @@ public class ApiInvoker {
|
||||
|
||||
Builder builder = client.resource(host + path + querystring).accept("application/json");
|
||||
for(String key : headerParams.keySet()) {
|
||||
builder.header(key, headerParams.get(key));
|
||||
builder = builder.header(key, headerParams.get(key));
|
||||
}
|
||||
|
||||
for(String key : defaultHeaderMap.keySet()) {
|
||||
if(!headerParams.containsKey(key)) {
|
||||
builder.header(key, defaultHeaderMap.get(key));
|
||||
builder = builder.header(key, defaultHeaderMap.get(key));
|
||||
}
|
||||
}
|
||||
ClientResponse response = null;
|
||||
|
||||
@@ -10,6 +10,7 @@ com.wordnik.swagger.codegen.languages.ScalaClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.StaticDocCodegen
|
||||
com.wordnik.swagger.codegen.languages.StaticHtmlGenerator
|
||||
com.wordnik.swagger.codegen.languages.SwaggerGenerator
|
||||
com.wordnik.swagger.codegen.languages.SwaggerYamlGenerator
|
||||
com.wordnik.swagger.codegen.languages.TizenClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.PhpClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.RubyClientCodegen
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<div class="app-desc">{{{appDescription}}} for {{partner}}</div>
|
||||
{{#infoUrl}}<div class="app-desc">More information: <a href="{{{infoUrl}}}">{{{infoUrl}}}</a></div>{{/infoUrl}}
|
||||
{{#infoEmail}}<div class="app-desc">Contact Info: <a href="{{{infoEmail}}}">{{{infoEmail}}}</a></div>{{/infoEmail}}
|
||||
{{#version}}<div class="app-desc">Version: {{{version}}}</div>{{/version}}
|
||||
<div class="license-info">{{{licenseInfo}}}</div>
|
||||
<div class="license-url">{{{licenseUrl}}}</div>
|
||||
<h2>Access</h2>
|
||||
|
||||
@@ -5,4 +5,20 @@ This server was generated by the [swagger-codegen](https://github.com/swagger-ap
|
||||
|
||||
This example uses the [expressjs](http://expressjs.com/) framework. To see how to make this your own, look here:
|
||||
|
||||
[README](https://github.com/wordnik/swagger-codegen/README.md)
|
||||
[README](https://github.com/wordnik/swagger-codegen/README.md)
|
||||
|
||||
### Running the server
|
||||
To run the server, follow these simple steps:
|
||||
|
||||
```
|
||||
npm install
|
||||
node .
|
||||
```
|
||||
|
||||
To view the Swagger UI interface:
|
||||
|
||||
```
|
||||
open http://localhost:8080/docs
|
||||
```
|
||||
|
||||
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.
|
||||
@@ -1,62 +0,0 @@
|
||||
var swagger = require("swagger-node-express");
|
||||
var url = require("url");
|
||||
var errors = swagger.errors;
|
||||
var params = swagger.params;
|
||||
|
||||
/* add model includes */
|
||||
|
||||
function writeResponse (response, data) {
|
||||
response.header('Access-Control-Allow-Origin', "*");
|
||||
response.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||
response.header("Access-Control-Allow-Headers", "Content-Type");
|
||||
response.header("Content-Type", "application/json; charset=utf-8");
|
||||
response.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
exports.models = models = require("../models.js");
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
exports.{{nickname}} = {
|
||||
'spec': {
|
||||
"description" : "the {{baseName}} API",
|
||||
"path" : "{{path}}",
|
||||
"notes" : "{{{notes}}}",
|
||||
"summary" : "{{{summary}}}",
|
||||
"method": "{{httpMethod}}",
|
||||
"params" : [{{#queryParams}}
|
||||
params.query("{{paramName}}", "{{description}}", "{{swaggerDataType}}", {{#required}}true{{/required}}{{^required}}false{{/required}}, {{#allowMultiple}}true{{/allowMultiple}}{{^allowMultiple}}false{{/allowMultiple}}, "{{{allowableValues}}}"{{#defaultValue}}, {{{defaultValue}}}{{/defaultValue}}){{#hasMore}},{{/hasMore}}
|
||||
{{/queryParams}}].concat([{{#pathParams}}
|
||||
params.path("{{paramName}}", "{{description}}"){{#hasMore}},{{/hasMore}}
|
||||
{{/pathParams}}]).concat([{{#headerParams}}
|
||||
params.header("{{paramName}}", "{{description}}"){{#hasMore}},{{/hasMore}}
|
||||
{{/headerParams}}]).concat([{{#bodyParams}}
|
||||
params.body("body", "{{swaggerDataType}}", "{{description}}", {{#required}}{{required}}{{/required}}{{^required}}false{{/required}})
|
||||
{{/bodyParams}}]),
|
||||
{{#returnContainer}}
|
||||
"type": "{{returnType}}",
|
||||
"items": {
|
||||
{{#returnTypeIsPrimitive}}"type": "{{returnContainer}}"{{/returnTypeIsPrimitive}}
|
||||
{{^returnTypeIsPrimitive}}"$ref": "{{returnContainer}}"{{/returnTypeIsPrimitive}}
|
||||
},
|
||||
// container
|
||||
{{/returnContainer}}
|
||||
{{^returnContainer}}
|
||||
"type" : "{{returnType}}",
|
||||
{{/returnContainer}}
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('{{returnType}}')],
|
||||
"nickname" : "{{nickname}}"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
{{#requiredParamCount}}
|
||||
{{#requiredParams}}
|
||||
if (!req.params.{{baseName}}) {
|
||||
throw errors.invalid('{{baseName}}');
|
||||
}
|
||||
{{/requiredParams}}
|
||||
{{/requiredParamCount}}
|
||||
writeResponse(res, {message: "how about implementing {{nickname}} as a {{httpMethod}} method?"});
|
||||
}
|
||||
};
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var url = require('url');
|
||||
|
||||
{{#operations}}
|
||||
|
||||
var {{classname}} = require('./{{classname}}Service');
|
||||
|
||||
{{#operation}}
|
||||
|
||||
module.exports.{{nickname}} = function {{nickname}} (req, res, next) {
|
||||
{{#allParams}}var {{paramName}} = req.swagger.params['{{baseName}}'].value;
|
||||
{{/allParams}}
|
||||
|
||||
var result = {{classname}}.{{nickname}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
var app = require('connect')();
|
||||
var http = require('http');
|
||||
var swaggerTools = require('swagger-tools');
|
||||
|
||||
var serverPort = {{serverPort}};
|
||||
|
||||
// swaggerRouter configuration
|
||||
var options = {
|
||||
swaggerUi: '/swagger.json',
|
||||
controllers: './controllers',
|
||||
useStubs: process.env.NODE_ENV === 'development' ? true : false // Conditionally turn on stubs (mock mode)
|
||||
};
|
||||
|
||||
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
||||
var swaggerDoc = require('./api/swagger.json');
|
||||
|
||||
// Initialize the Swagger middleware
|
||||
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
|
||||
// Interpret Swagger resources and attach metadata to request - must be first in swagger-tools middleware chain
|
||||
app.use(middleware.swaggerMetadata());
|
||||
|
||||
// Validate Swagger requests
|
||||
app.use(middleware.swaggerValidator());
|
||||
|
||||
// Route validated requests to appropriate controller
|
||||
app.use(middleware.swaggerRouter(options));
|
||||
|
||||
// Serve the Swagger documents and Swagger UI
|
||||
app.use(middleware.swaggerUi());
|
||||
|
||||
// Start the server
|
||||
http.createServer(app).listen({{serverPort}}, function () {
|
||||
console.log('Your server is listening on port %d (http://localhost:%d)', {{serverPort}}, {{serverPort}});
|
||||
console.log('Swagger-ui is available on http://localhost:%d/docs', {{serverPort}});
|
||||
});
|
||||
});
|
||||
@@ -1,53 +0,0 @@
|
||||
var express = require("express")
|
||||
, url = require("url")
|
||||
, cors = require("cors")
|
||||
, app = express()
|
||||
, swagger = require("swagger-node-express")
|
||||
, db = false
|
||||
|
||||
|
||||
var corsOptions = {
|
||||
credentials: true,
|
||||
origin: function(origin,callback) {
|
||||
if(origin===undefined) {
|
||||
callback(null,false);
|
||||
} else {
|
||||
callback(null,true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded());
|
||||
app.use(cors(corsOptions));
|
||||
|
||||
{{#basePath}}
|
||||
var subpath = express();
|
||||
|
||||
app.use("{{{basePath}}}", subpath);
|
||||
|
||||
swagger.setAppHandler(subpath);
|
||||
{{/basePath}}
|
||||
{{^basePath}}
|
||||
swagger.setAppHandler(app);
|
||||
{{/basePath}}
|
||||
|
||||
swagger.configureSwaggerPaths("", "api-docs", "")
|
||||
|
||||
var models = require("./app/models.js");
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
var {{classname}} = require("./{{apiFolder}}/{{classname}}.js");
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
swagger.addModels(models)
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}.add{{httpMethod}}({{classname}}.{{nickname}})
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}};
|
||||
|
||||
// configures the app
|
||||
swagger.configure("http://localhost:8002{{basePath}}", "0.1");
|
||||
|
||||
// start the server
|
||||
app.listen(8002);
|
||||
@@ -1,3 +0,0 @@
|
||||
exports.models = {
|
||||
{{#models}}{{#model}}"{{classVarName}}": {{{modelJson}}}{{#hasMoreModels}},{{/hasMoreModels}}{{/model}}{{/models}}
|
||||
}
|
||||
25
modules/swagger-codegen/src/main/resources/nodejs/package.mustache
Executable file → Normal file
25
modules/swagger-codegen/src/main/resources/nodejs/package.mustache
Executable file → Normal file
@@ -1,16 +1,15 @@
|
||||
{
|
||||
"name": "{{{artifactId}}}",
|
||||
"description": "Wordnik node.js server generator",
|
||||
"version": "{{{artifactVersion}}}",
|
||||
"homepage": "{{{homepage}}}",
|
||||
"main": "./main.js",
|
||||
"engines": {
|
||||
"node": ">= 0.8.x"
|
||||
},
|
||||
"name": "{{projectName}}",
|
||||
"version": "{{appVersion}}",
|
||||
"description": "{{appDescription}}",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"swagger"
|
||||
],
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"swagger-node-express": ">= 2.0.x",
|
||||
"connect": ">= 1.8.x",
|
||||
"cors": "2.1.1",
|
||||
"express": "3.x"
|
||||
"connect": "^3.2.0",
|
||||
"swagger-tools": "0.8.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
exports.{{nickname}} = function({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
|
||||
var examples = {};
|
||||
{{#examples}}
|
||||
examples['{{contentType}}'] = {{{example}}};
|
||||
{{/examples}}
|
||||
|
||||
{{#returnType}}
|
||||
if(Object.keys(examples).length > 0)
|
||||
return examples[Object.keys(examples)[0]];
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "{{appName}}",
|
||||
"description": "{{appDescription}}",
|
||||
"version": "{{apiVersion}}"
|
||||
},
|
||||
{{#apiInfo}}
|
||||
"produces": ["application/json"],
|
||||
"host": "localhost:{{serverPort}}",
|
||||
"basePath": "{{contextPath}}",
|
||||
"paths": {
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
"{{{path}}}": {
|
||||
"{{httpMethod}}": {
|
||||
"x-swagger-router-controller": "{{classname}}",
|
||||
"tags": ["{{baseName}}"],
|
||||
"operationId": "{{operationId}}",{{#hasParams}}
|
||||
"parameters": [
|
||||
{{#allParams}}
|
||||
{{{jsonSchema}}}{{#hasMore}},{{/hasMore}}
|
||||
{{/allParams}}
|
||||
],{{/hasParams}}
|
||||
"responses": {
|
||||
{{#responses}}
|
||||
"{{code}}": {{{jsonSchema}}}
|
||||
{{#hasMore}},{{/hasMore}}
|
||||
{{/responses}}
|
||||
}
|
||||
}
|
||||
} {{#hasMore}},{{/hasMore}}
|
||||
{{/operation}}
|
||||
{{#hasMore}},{{/hasMore}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
}, "definitions": {
|
||||
{{#models}}{{#model}}"{{classVarName}}": {{{modelJson}}}{{#hasMoreModels}},{{/hasMoreModels}}{{/model}}{{/models}}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
{{/isContainer}}{{#isNotContainer}}
|
||||
if({{name}}_dict != nil)
|
||||
_{{name}} = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{complexType}}} {{/instantiationType}} alloc]initWithValues:{{name}}_dict];
|
||||
_{{name}} = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{complexType}}} {{/instantiationType}} alloc]{{setter}}:{{name}}_dict];
|
||||
{{/isNotContainer}}
|
||||
{{/complexType}}
|
||||
{{/vars}}{{newline}}
|
||||
|
||||
@@ -182,7 +182,7 @@ class APIClient {
|
||||
} else if (is_object($data)) {
|
||||
$values = array();
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
$values[$property] = $this->sanitizeForSerialization($data->$property);
|
||||
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
|
||||
}
|
||||
$sanitized = $values;
|
||||
} else {
|
||||
@@ -295,7 +295,8 @@ class APIClient {
|
||||
$instance = new $class();
|
||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||
if (isset($data->$property)) {
|
||||
$instance->$property = self::deserialize($data->$property, $type);
|
||||
$original_property_name = $instance::$attributeMap[$property];
|
||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
|
||||
@@ -28,7 +28,12 @@ class {{classname}} implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
{{#vars}}{{#description}}
|
||||
/**
|
||||
|
||||
@@ -226,7 +226,7 @@ class ApiClient:
|
||||
subValues.append(self.deserialize(subValue, subClass))
|
||||
setattr(instance, attr, subValues)
|
||||
else:
|
||||
setattr(instance, attr, self.deserialize(value, objClass))
|
||||
setattr(instance, attr, self.deserialize(value, attrType))
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
@@ -23,10 +23,8 @@ class {{classname}}
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
{{#allParams}}
|
||||
:{{paramName}} => {{paramName}}{{#hasMore}},
|
||||
{{/hasMore}}
|
||||
{{/allParams}}
|
||||
{{#allParams}}:'{{paramName}}' => {{paramName}}{{#hasMore}},{{/hasMore}}
|
||||
{{/allParams}}
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -38,12 +36,10 @@ class {{classname}}
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
{{#headerParams}}headers = {
|
||||
{{{paramName}}}: {{{paramName}}},
|
||||
}
|
||||
{{/headerParams}}
|
||||
{{^headerParams}}headers = nil
|
||||
{{/headerParams}}
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
{{#headerParams}}{{#optional}}headers[:'{{{baseName}}}'] = options[:'{{{paramName}}}'] if options[:'{{{paramName}}}']{{/optional}}{{/headerParams}}
|
||||
{{#headerParams}}{{^optional}}headers[:'{{{baseName}}}'] = {{{paramName}}}{{/optional}}{{/headerParams}}
|
||||
|
||||
# http body (model)
|
||||
post_body = nil
|
||||
|
||||
@@ -6,8 +6,7 @@ class {{classname}}
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
{{#vars}}
|
||||
:{{{name}}} => :{{{baseName}}}{{#hasMore}},{{/hasMore}}
|
||||
{{#vars}}:{{{name}}} => :'{{{baseName}}}'{{#hasMore}},{{/hasMore}}
|
||||
{{/vars}}
|
||||
}
|
||||
end
|
||||
@@ -17,13 +16,9 @@ class {{classname}}
|
||||
# Morph attribute keys into undescored rubyish style
|
||||
{{#vars}}
|
||||
if self.class.attribute_map[:"{{{name}}}"]
|
||||
{{#isContainer}}
|
||||
if (value = attributes["{{{baseName}}}"]).is_a?(Array)
|
||||
@{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}{{newline}}
|
||||
end
|
||||
{{/isContainer}}{{^isContainer}}
|
||||
@{{{name}}} = attributes["{{{baseName}}}"]
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}if (value = attributes["{{{baseName}}}"]).is_a?(Array)
|
||||
@{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}
|
||||
end{{/isContainer}}{{^isContainer}}@{{{name}}} = attributes["{{{baseName}}}"]{{/isContainer}}
|
||||
end
|
||||
{{/vars}}
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ module Swagger
|
||||
class Configuration
|
||||
require 'swagger/version'
|
||||
|
||||
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params
|
||||
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params, :user_agent
|
||||
|
||||
# Defaults go in here..
|
||||
def initialize
|
||||
@@ -11,7 +11,7 @@ module Swagger
|
||||
@scheme = 'http'
|
||||
@host = 'api.wordnik.com'
|
||||
@base_path = '/v4'
|
||||
@user_agent = "ruby-#{Swagger::VERSION}"
|
||||
@user_agent = "ruby-swagger-#{Swagger::VERSION}"
|
||||
@inject_format = true
|
||||
@force_ending_format = false
|
||||
@camelize_params = true
|
||||
@@ -19,4 +19,4 @@ module Swagger
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,8 @@ module Swagger
|
||||
# Set default headers
|
||||
default_headers = {
|
||||
'Content-Type' => "application/#{attributes[:format].downcase}",
|
||||
:api_key => Swagger.configuration.api_key
|
||||
:api_key => Swagger.configuration.api_key,
|
||||
'User-Agent' => Swagger.configuration.user_agent
|
||||
}
|
||||
|
||||
# api_key from headers hash trumps the default, even if its value is blank
|
||||
|
||||
@@ -17,6 +17,7 @@ import scala.collection.JavaConverters._
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule
|
||||
import com.fasterxml.jackson.core.JsonGenerator.Feature
|
||||
import com.fasterxml.jackson.databind._
|
||||
import com.fasterxml.jackson.annotation._
|
||||
@@ -26,6 +27,7 @@ object ScalaJsonUtil {
|
||||
def getJsonMapper = {
|
||||
val mapper = new ObjectMapper()
|
||||
mapper.registerModule(new DefaultScalaModule())
|
||||
mapper.registerModule(new JodaModule());
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# Swagger JSON
|
||||
This is a swagger JSON built by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project.
|
||||
@@ -22,7 +22,7 @@ class CodegenTest extends FlatSpec with Matchers {
|
||||
val codegen = new DefaultCodegen()
|
||||
val path = "/pet/{petId}/uploadImage"
|
||||
val p = model.getPaths().get(path).getPost()
|
||||
val op = codegen.fromOperation(path, "post", p)
|
||||
val op = codegen.fromOperation(path, "post", p, model.getDefinitions())
|
||||
|
||||
op.operationId should be ("uploadFile")
|
||||
op.httpMethod should be ("POST")
|
||||
@@ -52,7 +52,7 @@ class CodegenTest extends FlatSpec with Matchers {
|
||||
val codegen = new DefaultCodegen()
|
||||
val path = "/pet/{petId}"
|
||||
val p = model.getPaths().get(path).getPost()
|
||||
val op = codegen.fromOperation(path, "post", p)
|
||||
val op = codegen.fromOperation(path, "post", p, model.getDefinitions())
|
||||
|
||||
op.operationId should be ("updatePetWithForm")
|
||||
op.httpMethod should be ("POST")
|
||||
@@ -103,7 +103,7 @@ class CodegenTest extends FlatSpec with Matchers {
|
||||
|
||||
val path = "/tests/withTwoHundredAndDefault"
|
||||
val p = model.getPaths().get(path).getGet()
|
||||
val op = codegen.fromOperation(path, "get", p)
|
||||
val op = codegen.fromOperation(path, "get", p, model.getDefinitions())
|
||||
op.returnType should be("String")
|
||||
|
||||
}
|
||||
@@ -116,9 +116,7 @@ class CodegenTest extends FlatSpec with Matchers {
|
||||
|
||||
val path = "/tests/withoutTwoHundredButDefault"
|
||||
val p = model.getPaths().get(path).getGet()
|
||||
val op = codegen.fromOperation(path, "get", p)
|
||||
val op = codegen.fromOperation(path, "get", p, model.getDefinitions())
|
||||
op.returnType should be("String")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -248,14 +248,14 @@ class ObjcModelTest extends FlatSpec with Matchers {
|
||||
val animalPaths = model.getPaths()
|
||||
val animalOps = animalPaths.get("/animals")
|
||||
animalOps.getPost() should not be (null)
|
||||
val animalCo = codegen.fromOperation("/animals", "POST", animalOps.getPost())
|
||||
val animalCo = codegen.fromOperation("/animals", "POST", animalOps.getPost(), model.getDefinitions())
|
||||
animalCo.imports.size should be (1)
|
||||
animalCo.imports.contains("SWGAnimal") should equal (true)
|
||||
|
||||
val insectPaths = model.getPaths()
|
||||
val insectOps = insectPaths.get("/insects")
|
||||
insectOps.getPost() should not be (null)
|
||||
val insectCo = codegen.fromOperation("/insects", "POST", insectOps.getPost())
|
||||
val insectCo = codegen.fromOperation("/insects", "POST", insectOps.getPost(), model.getDefinitions())
|
||||
insectCo.imports.size should be (1)
|
||||
insectCo.imports.contains("SWGInsect") should equal (true)
|
||||
}
|
||||
|
||||
@@ -245,14 +245,14 @@ class PhpModelTest extends FlatSpec with Matchers {
|
||||
val animalPaths = model.getPaths()
|
||||
val animalOps = animalPaths.get("/animals")
|
||||
animalOps.getPost() should not be (null)
|
||||
val animalCo = codegen.fromOperation("/animals", "POST", animalOps.getPost())
|
||||
val animalCo = codegen.fromOperation("/animals", "POST", animalOps.getPost(), model.getDefinitions())
|
||||
animalCo.imports.size should be (1)
|
||||
animalCo.imports.contains("Animal") should equal (true)
|
||||
|
||||
val insectPaths = model.getPaths()
|
||||
val insectOps = insectPaths.get("/insects")
|
||||
insectOps.getPost() should not be (null)
|
||||
val insectCo = codegen.fromOperation("/insects", "POST", insectOps.getPost())
|
||||
val insectCo = codegen.fromOperation("/insects", "POST", insectOps.getPost(), model.getDefinitions())
|
||||
insectCo.imports.size should be (1)
|
||||
insectCo.imports.contains("Insect") should equal (true)
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class Generator {
|
||||
List<File> files = new Codegen().opts(clientOptInput).generate();
|
||||
if(files.size() > 0) {
|
||||
List<File> filesToAdd = new ArrayList<File>();
|
||||
System.out.println("adding to " + outputFolder);
|
||||
filesToAdd.add(new File(outputFolder));
|
||||
ZipUtil zip = new ZipUtil();
|
||||
zip.compressFiles(filesToAdd, outputFilename);
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -347,7 +347,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-parser-version>1.0.3-SNAPSHOT</swagger-parser-version>
|
||||
<swagger-parser-version>1.0.3</swagger-parser-version>
|
||||
<scala-version>2.11.1</scala-version>
|
||||
<felix-version>2.3.4</felix-version>
|
||||
<swagger-core-version>1.5.3-M1-SNAPSHOT</swagger-core-version>
|
||||
|
||||
@@ -19,16 +19,75 @@ import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.ParseException;
|
||||
|
||||
public class ApiInvoker {
|
||||
private static ApiInvoker INSTANCE = new ApiInvoker();
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
private boolean isDebug = false;
|
||||
|
||||
/**
|
||||
* ISO 8601 date time format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
||||
|
||||
/**
|
||||
* ISO 8601 date format.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601
|
||||
*/
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
static {
|
||||
// Use UTC as the default time zone.
|
||||
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public static Date parseDateTime(String str) {
|
||||
try {
|
||||
return DATE_TIME_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Date parseDate(String str) {
|
||||
try {
|
||||
return DATE_FORMAT.parse(str);
|
||||
} catch (java.text.ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDateTime(Date datetime) {
|
||||
return DATE_TIME_FORMAT.format(datetime);
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
return DATE_FORMAT.format(date);
|
||||
}
|
||||
|
||||
public static String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDateTime((Date) param);
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableDebug() {
|
||||
isDebug = true;
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ public class PetApi {
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if(!"null".equals(String.valueOf(status)))
|
||||
queryParams.put("status", String.valueOf(status));
|
||||
if (status != null)
|
||||
queryParams.put("status", ApiInvoker.parameterToString(status));
|
||||
|
||||
|
||||
String[] contentTypes = {
|
||||
@@ -200,8 +200,8 @@ public class PetApi {
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if(!"null".equals(String.valueOf(tags)))
|
||||
queryParams.put("tags", String.valueOf(tags));
|
||||
if (tags != null)
|
||||
queryParams.put("tags", ApiInvoker.parameterToString(tags));
|
||||
|
||||
|
||||
String[] contentTypes = {
|
||||
@@ -317,17 +317,17 @@ public class PetApi {
|
||||
FormDataMultiPart mp = new FormDataMultiPart();
|
||||
|
||||
hasFields = true;
|
||||
mp.field("name", name, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
mp.field("name", ApiInvoker.parameterToString(name), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
|
||||
hasFields = true;
|
||||
mp.field("status", status, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
mp.field("status", ApiInvoker.parameterToString(status), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
formParams.put("name", name);
|
||||
formParams.put("status", status);
|
||||
formParams.put("name", ApiInvoker.parameterToString(name));
|
||||
formParams.put("status", ApiInvoker.parameterToString(status));
|
||||
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ public class PetApi {
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
|
||||
headerParams.put("api_key", api_key);
|
||||
headerParams.put("api_key", ApiInvoker.parameterToString(api_key));
|
||||
|
||||
String[] contentTypes = {
|
||||
|
||||
@@ -428,7 +428,7 @@ public class PetApi {
|
||||
FormDataMultiPart mp = new FormDataMultiPart();
|
||||
|
||||
hasFields = true;
|
||||
mp.field("additionalMetadata", additionalMetadata, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
mp.field("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
|
||||
hasFields = true;
|
||||
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
@@ -437,7 +437,7 @@ public class PetApi {
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
formParams.put("additionalMetadata", additionalMetadata);
|
||||
formParams.put("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -198,10 +198,10 @@ public class UserApi {
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
Map<String, String> formParams = new HashMap<String, String>();
|
||||
|
||||
if(!"null".equals(String.valueOf(username)))
|
||||
queryParams.put("username", String.valueOf(username));
|
||||
if(!"null".equals(String.valueOf(password)))
|
||||
queryParams.put("password", String.valueOf(password));
|
||||
if (username != null)
|
||||
queryParams.put("username", ApiInvoker.parameterToString(username));
|
||||
if (password != null)
|
||||
queryParams.put("password", ApiInvoker.parameterToString(password));
|
||||
|
||||
|
||||
String[] contentTypes = {
|
||||
|
||||
@@ -110,28 +110,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
|
||||
@@ -193,28 +171,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status
|
||||
@@ -443,28 +399,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deletePetWithCompletionBlock: (NSString*) api_key
|
||||
@@ -509,28 +443,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
|
||||
|
||||
@@ -303,28 +303,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -554,28 +554,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username
|
||||
@@ -617,28 +595,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ class APIClient {
|
||||
} else if (is_object($data)) {
|
||||
$values = array();
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
$values[$property] = $this->sanitizeForSerialization($data->$property);
|
||||
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
|
||||
}
|
||||
$sanitized = $values;
|
||||
} else {
|
||||
@@ -295,7 +295,8 @@ class APIClient {
|
||||
$instance = new $class();
|
||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||
if (isset($data->$property)) {
|
||||
$instance->$property = self::deserialize($data->$property, $type);
|
||||
$original_property_name = $instance::$attributeMap[$property];
|
||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
|
||||
@@ -22,13 +22,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class Category {
|
||||
class Category implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class Order {
|
||||
class Order implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'petId' => 'int',
|
||||
@@ -30,7 +30,16 @@ class Order {
|
||||
'shipDate' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
);
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'petId' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'shipDate' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
@@ -42,4 +51,29 @@ class Order {
|
||||
*/
|
||||
public $status; /* string */
|
||||
public $complete; /* boolean */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->petId = $data["petId"];
|
||||
$this->quantity = $data["quantity"];
|
||||
$this->shipDate = $data["shipDate"];
|
||||
$this->status = $data["status"];
|
||||
$this->complete = $data["complete"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class Pet {
|
||||
class Pet implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
@@ -30,7 +30,16 @@ class Pet {
|
||||
'photoUrls' => 'array[string]',
|
||||
'tags' => 'array[Tag]',
|
||||
'status' => 'string'
|
||||
);
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photoUrls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
@@ -42,4 +51,29 @@ class Pet {
|
||||
* pet status in the store
|
||||
*/
|
||||
public $status; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->category = $data["category"];
|
||||
$this->name = $data["name"];
|
||||
$this->photoUrls = $data["photoUrls"];
|
||||
$this->tags = $data["tags"];
|
||||
$this->status = $data["status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class Tag {
|
||||
class Tag implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class User {
|
||||
class User implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
@@ -32,7 +32,18 @@ class User {
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'userStatus' => 'int'
|
||||
);
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'firstName' => 'firstName',
|
||||
'lastName' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'userStatus' => 'userStatus'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
@@ -46,4 +57,31 @@ class User {
|
||||
* User Status
|
||||
*/
|
||||
public $userStatus; /* int */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->username = $data["username"];
|
||||
$this->firstName = $data["firstName"];
|
||||
$this->lastName = $data["lastName"];
|
||||
$this->email = $data["email"];
|
||||
$this->password = $data["password"];
|
||||
$this->phone = $data["phone"];
|
||||
$this->userStatus = $data["userStatus"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,8 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:body => body
|
||||
|
||||
:'body' => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -29,8 +28,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -77,9 +77,8 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:body => body
|
||||
|
||||
:'body' => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -90,8 +89,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -138,9 +138,8 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:status => status
|
||||
|
||||
:'status' => status
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -151,8 +150,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -180,9 +180,8 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:tags => tags
|
||||
|
||||
:'tags' => tags
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -193,8 +192,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -222,9 +222,8 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:petId => petId
|
||||
|
||||
:'petId' => petId
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -236,8 +235,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -264,15 +264,10 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:petId => petId,
|
||||
:'petId' => petId,
|
||||
:'name' => name,
|
||||
:'status' => status
|
||||
|
||||
|
||||
:name => name,
|
||||
|
||||
|
||||
:status => status
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -284,8 +279,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -313,12 +309,9 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:api_key => api_key,
|
||||
:'api_key' => api_key,
|
||||
:'petId' => petId
|
||||
|
||||
|
||||
:petId => petId
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -330,11 +323,10 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
headers = {
|
||||
api_key: api_key,
|
||||
}
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers[:'api_key'] = api_key
|
||||
|
||||
# http body (model)
|
||||
post_body = nil
|
||||
@@ -359,15 +351,10 @@ class PetApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:petId => petId,
|
||||
:'petId' => petId,
|
||||
:'additionalMetadata' => additionalMetadata,
|
||||
:'file' => file
|
||||
|
||||
|
||||
:additionalMetadata => additionalMetadata,
|
||||
|
||||
|
||||
:file => file
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -379,8 +366,9 @@ class PetApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
|
||||
@@ -16,7 +16,7 @@ class StoreApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -27,8 +27,9 @@ class StoreApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -56,9 +57,8 @@ class StoreApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:body => body
|
||||
|
||||
:'body' => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -69,8 +69,9 @@ class StoreApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -118,9 +119,8 @@ class StoreApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:orderId => orderId
|
||||
|
||||
:'orderId' => orderId
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -132,8 +132,9 @@ class StoreApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -160,9 +161,8 @@ class StoreApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:orderId => orderId
|
||||
|
||||
:'orderId' => orderId
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -174,8 +174,9 @@ class StoreApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
|
||||
@@ -16,9 +16,8 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:body => body
|
||||
|
||||
:'body' => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -29,8 +28,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -77,9 +77,8 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:body => body
|
||||
|
||||
:'body' => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -90,8 +89,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -138,9 +138,8 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:body => body
|
||||
|
||||
:'body' => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -151,8 +150,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -199,12 +199,9 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:username => username,
|
||||
:'username' => username,
|
||||
:'password' => password
|
||||
|
||||
|
||||
:password => password
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -215,8 +212,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -243,7 +241,7 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -254,8 +252,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -281,9 +280,8 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:username => username
|
||||
|
||||
:'username' => username
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -295,8 +293,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -323,12 +322,9 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:username => username,
|
||||
:'username' => username,
|
||||
:'body' => body
|
||||
|
||||
|
||||
:body => body
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -340,8 +336,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
@@ -388,9 +385,8 @@ class UserApi
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
|
||||
:username => username
|
||||
|
||||
:'username' => username
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#resource path
|
||||
@@ -402,8 +398,9 @@ class UserApi
|
||||
query_param_keys.include? key
|
||||
end
|
||||
|
||||
# header parameters, if any
|
||||
headers = {}
|
||||
|
||||
headers = nil
|
||||
|
||||
|
||||
# http body (model)
|
||||
|
||||
@@ -3,7 +3,7 @@ module Swagger
|
||||
class Configuration
|
||||
require 'swagger/version'
|
||||
|
||||
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params
|
||||
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params, :user_agent
|
||||
|
||||
# Defaults go in here..
|
||||
def initialize
|
||||
@@ -11,7 +11,7 @@ module Swagger
|
||||
@scheme = 'http'
|
||||
@host = 'api.wordnik.com'
|
||||
@base_path = '/v4'
|
||||
@user_agent = "ruby-#{Swagger::VERSION}"
|
||||
@user_agent = "ruby-swagger-#{Swagger::VERSION}"
|
||||
@inject_format = true
|
||||
@force_ending_format = false
|
||||
@camelize_params = true
|
||||
@@ -19,4 +19,4 @@ module Swagger
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,8 @@ module Swagger
|
||||
# Set default headers
|
||||
default_headers = {
|
||||
'Content-Type' => "application/#{attributes[:format].downcase}",
|
||||
:api_key => Swagger.configuration.api_key
|
||||
:api_key => Swagger.configuration.api_key,
|
||||
'User-Agent' => Swagger.configuration.user_agent
|
||||
}
|
||||
|
||||
# api_key from headers hash trumps the default, even if its value is blank
|
||||
|
||||
@@ -4,10 +4,8 @@ class Category
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
|
||||
:id => :id,
|
||||
|
||||
:name => :name
|
||||
:id => :'id',
|
||||
:name => :'name'
|
||||
|
||||
}
|
||||
end
|
||||
@@ -17,15 +15,11 @@ class Category
|
||||
# Morph attribute keys into undescored rubyish style
|
||||
|
||||
if self.class.attribute_map[:"id"]
|
||||
|
||||
@id = attributes["id"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"name"]
|
||||
|
||||
@name = attributes["name"]
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,18 +4,12 @@ class Order
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
|
||||
:id => :id,
|
||||
|
||||
:petId => :petId,
|
||||
|
||||
:quantity => :quantity,
|
||||
|
||||
:shipDate => :shipDate,
|
||||
|
||||
:status => :status,
|
||||
|
||||
:complete => :complete
|
||||
:id => :'id',
|
||||
:petId => :'petId',
|
||||
:quantity => :'quantity',
|
||||
:shipDate => :'shipDate',
|
||||
:status => :'status',
|
||||
:complete => :'complete'
|
||||
|
||||
}
|
||||
end
|
||||
@@ -25,39 +19,27 @@ class Order
|
||||
# Morph attribute keys into undescored rubyish style
|
||||
|
||||
if self.class.attribute_map[:"id"]
|
||||
|
||||
@id = attributes["id"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"petId"]
|
||||
|
||||
@petId = attributes["petId"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"quantity"]
|
||||
|
||||
@quantity = attributes["quantity"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"shipDate"]
|
||||
|
||||
@shipDate = attributes["shipDate"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"status"]
|
||||
|
||||
@status = attributes["status"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"complete"]
|
||||
|
||||
@complete = attributes["complete"]
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,18 +4,12 @@ class Pet
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
|
||||
:id => :id,
|
||||
|
||||
:category => :category,
|
||||
|
||||
:name => :name,
|
||||
|
||||
:photoUrls => :photoUrls,
|
||||
|
||||
:tags => :tags,
|
||||
|
||||
:status => :status
|
||||
:id => :'id',
|
||||
:category => :'category',
|
||||
:name => :'name',
|
||||
:photoUrls => :'photoUrls',
|
||||
:tags => :'tags',
|
||||
:status => :'status'
|
||||
|
||||
}
|
||||
end
|
||||
@@ -25,43 +19,31 @@ class Pet
|
||||
# Morph attribute keys into undescored rubyish style
|
||||
|
||||
if self.class.attribute_map[:"id"]
|
||||
|
||||
@id = attributes["id"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"category"]
|
||||
|
||||
@category = attributes["category"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"name"]
|
||||
|
||||
@name = attributes["name"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"photoUrls"]
|
||||
|
||||
if (value = attributes["photoUrls"]).is_a?(Array)
|
||||
@photoUrls = value
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"tags"]
|
||||
|
||||
if (value = attributes["tags"]).is_a?(Array)
|
||||
@tags = value.map{ |v| Tag.new(v) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"status"]
|
||||
|
||||
@status = attributes["status"]
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,10 +4,8 @@ class Tag
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
|
||||
:id => :id,
|
||||
|
||||
:name => :name
|
||||
:id => :'id',
|
||||
:name => :'name'
|
||||
|
||||
}
|
||||
end
|
||||
@@ -17,15 +15,11 @@ class Tag
|
||||
# Morph attribute keys into undescored rubyish style
|
||||
|
||||
if self.class.attribute_map[:"id"]
|
||||
|
||||
@id = attributes["id"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"name"]
|
||||
|
||||
@name = attributes["name"]
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,22 +4,14 @@ class User
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
|
||||
:id => :id,
|
||||
|
||||
:username => :username,
|
||||
|
||||
:firstName => :firstName,
|
||||
|
||||
:lastName => :lastName,
|
||||
|
||||
:email => :email,
|
||||
|
||||
:password => :password,
|
||||
|
||||
:phone => :phone,
|
||||
|
||||
:userStatus => :userStatus
|
||||
:id => :'id',
|
||||
:username => :'username',
|
||||
:firstName => :'firstName',
|
||||
:lastName => :'lastName',
|
||||
:email => :'email',
|
||||
:password => :'password',
|
||||
:phone => :'phone',
|
||||
:userStatus => :'userStatus'
|
||||
|
||||
}
|
||||
end
|
||||
@@ -29,51 +21,35 @@ class User
|
||||
# Morph attribute keys into undescored rubyish style
|
||||
|
||||
if self.class.attribute_map[:"id"]
|
||||
|
||||
@id = attributes["id"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"username"]
|
||||
|
||||
@username = attributes["username"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"firstName"]
|
||||
|
||||
@firstName = attributes["firstName"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"lastName"]
|
||||
|
||||
@lastName = attributes["lastName"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"email"]
|
||||
|
||||
@email = attributes["email"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"password"]
|
||||
|
||||
@password = attributes["password"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"phone"]
|
||||
|
||||
@phone = attributes["phone"]
|
||||
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"userStatus"]
|
||||
|
||||
@userStatus = attributes["userStatus"]
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import com.wordnik.petstore.api._
|
||||
import com.wordnik.petstore.model._
|
||||
import io.swagger.client._
|
||||
import io.swagger.client.api._
|
||||
import io.swagger.client.model._
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
@@ -30,7 +31,7 @@ class PetApiTest extends FlatSpec with Matchers {
|
||||
Category(1, "sold"),
|
||||
"dragon",
|
||||
(for (i <- (1 to 10)) yield "http://foo.com/photo/" + i).toList,
|
||||
(for (i <- (1 to 5)) yield com.wordnik.petstore.model.Tag(i, "tag-" + i)).toList,
|
||||
(for (i <- (1 to 5)) yield io.swagger.client.model.Tag(i, "tag-" + i)).toList,
|
||||
"lost"
|
||||
)
|
||||
|
||||
@@ -55,7 +56,7 @@ class PetApiTest extends FlatSpec with Matchers {
|
||||
Category(1, "sold"),
|
||||
"programmer",
|
||||
(for (i <- (1 to 10)) yield "http://foo.com/photo/" + i).toList,
|
||||
(for (i <- (1 to 5)) yield com.wordnik.petstore.model.Tag(i, "tag-" + i)).toList,
|
||||
(for (i <- (1 to 5)) yield io.swagger.client.model.Tag(i, "tag-" + i)).toList,
|
||||
"confused"
|
||||
)
|
||||
|
||||
@@ -80,7 +81,7 @@ class PetApiTest extends FlatSpec with Matchers {
|
||||
}
|
||||
|
||||
it should "find pets by status" in {
|
||||
api.findPetsByStatus("available") match {
|
||||
api.findPetsByStatus(List("available")) match {
|
||||
case Some(pets) => {
|
||||
pets.foreach(pet => pet.status should be("available"))
|
||||
}
|
||||
@@ -90,7 +91,7 @@ class PetApiTest extends FlatSpec with Matchers {
|
||||
|
||||
it should "find pets by tag" in {
|
||||
println("finding by tags")
|
||||
api.findPetsByTags("tag1,tag2") match {
|
||||
api.findPetsByTags(List("tag1", "tag2")) match {
|
||||
case Some(pets) => {
|
||||
pets.foreach(pet => {
|
||||
val tags = (for (tag <- pet.tags) yield tag.name).toSet
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import com.wordnik.client._
|
||||
import com.wordnik.petstore.api._
|
||||
import com.wordnik.petstore.model._
|
||||
import io.swagger.client._
|
||||
import io.swagger.client.api._
|
||||
import io.swagger.client.model._
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
@@ -30,13 +30,14 @@ class StoreApiTest extends FlatSpec with Matchers {
|
||||
}
|
||||
|
||||
it should "place an order" in {
|
||||
val now = new java.util.Date
|
||||
val now = new org.joda.time.DateTime
|
||||
val order = Order (
|
||||
10,
|
||||
1000,
|
||||
101,
|
||||
"pending",
|
||||
now)
|
||||
petId = 10,
|
||||
id = 1000,
|
||||
quantity = 101,
|
||||
status = "pending",
|
||||
shipDate = now,
|
||||
complete = true)
|
||||
|
||||
api.placeOrder(order)
|
||||
|
||||
@@ -45,20 +46,21 @@ class StoreApiTest extends FlatSpec with Matchers {
|
||||
order.id should be(1000)
|
||||
order.petId should be(10)
|
||||
order.quantity should be(101)
|
||||
order.shipDate should be (now)
|
||||
order.shipDate.equals(now) should be (true)
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
|
||||
it should "delete an order" in {
|
||||
val now = new java.util.Date
|
||||
val now = new org.joda.time.DateTime
|
||||
val order = Order(
|
||||
1001,
|
||||
10,
|
||||
101,
|
||||
"pending",
|
||||
now)
|
||||
id = 1001,
|
||||
petId = 10,
|
||||
quantity = 101,
|
||||
status = "pending",
|
||||
shipDate = now,
|
||||
complete = true)
|
||||
|
||||
api.placeOrder(order)
|
||||
|
||||
@@ -67,7 +69,7 @@ class StoreApiTest extends FlatSpec with Matchers {
|
||||
order.id should be(1001)
|
||||
order.petId should be(10)
|
||||
order.quantity should be(101)
|
||||
order.shipDate should be (now)
|
||||
order.shipDate.equals(now) should be (true)
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import com.wordnik.petstore.api._
|
||||
import com.wordnik.petstore.model._
|
||||
import io.swagger.client._
|
||||
import io.swagger.client.api._
|
||||
import io.swagger.client.model._
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
|
||||
@@ -148,31 +148,31 @@ SamiCategory::asJsonObject() {
|
||||
|
||||
|
||||
JsonString *pIdKey = new JsonString(L"id");
|
||||
pJsonObject->Add(pIdKey, toJson(getId(), "Long", ""));
|
||||
pJsonObject->Add(pIdKey, toJson(getpId(), "Long", ""));
|
||||
|
||||
|
||||
JsonString *pNameKey = new JsonString(L"name");
|
||||
pJsonObject->Add(pNameKey, toJson(getName(), "String", ""));
|
||||
pJsonObject->Add(pNameKey, toJson(getpName(), "String", ""));
|
||||
|
||||
|
||||
return pJsonObject;
|
||||
}
|
||||
|
||||
Long*
|
||||
SamiCategory::getId() {
|
||||
SamiCategory::getpId() {
|
||||
return pId;
|
||||
}
|
||||
void
|
||||
SamiCategory::setId(Long* pId) {
|
||||
SamiCategory::setpId(Long* pId) {
|
||||
this->pId = pId;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiCategory::getName() {
|
||||
SamiCategory::getpName() {
|
||||
return pName;
|
||||
}
|
||||
void
|
||||
SamiCategory::setName(String* pName) {
|
||||
SamiCategory::setpName(String* pName) {
|
||||
this->pName = pName;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ public:
|
||||
SamiCategory* fromJson(String* obj);
|
||||
|
||||
|
||||
Long* getId();
|
||||
void setId(Long* pId);
|
||||
Long* getpId();
|
||||
void setpId(Long* pId);
|
||||
|
||||
String* getName();
|
||||
void setName(String* pName);
|
||||
String* getpName();
|
||||
void setpName(String* pName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -208,83 +208,83 @@ SamiOrder::asJsonObject() {
|
||||
|
||||
|
||||
JsonString *pIdKey = new JsonString(L"id");
|
||||
pJsonObject->Add(pIdKey, toJson(getId(), "Long", ""));
|
||||
pJsonObject->Add(pIdKey, toJson(getpId(), "Long", ""));
|
||||
|
||||
|
||||
JsonString *pPetIdKey = new JsonString(L"petId");
|
||||
pJsonObject->Add(pPetIdKey, toJson(getPetId(), "Long", ""));
|
||||
pJsonObject->Add(pPetIdKey, toJson(getpPetId(), "Long", ""));
|
||||
|
||||
|
||||
JsonString *pQuantityKey = new JsonString(L"quantity");
|
||||
pJsonObject->Add(pQuantityKey, toJson(getQuantity(), "Integer", ""));
|
||||
pJsonObject->Add(pQuantityKey, toJson(getpQuantity(), "Integer", ""));
|
||||
|
||||
|
||||
JsonString *pShipDateKey = new JsonString(L"shipDate");
|
||||
pJsonObject->Add(pShipDateKey, toJson(getShipDate(), "DateTime", ""));
|
||||
pJsonObject->Add(pShipDateKey, toJson(getpShipDate(), "DateTime", ""));
|
||||
|
||||
|
||||
JsonString *pStatusKey = new JsonString(L"status");
|
||||
pJsonObject->Add(pStatusKey, toJson(getStatus(), "String", ""));
|
||||
pJsonObject->Add(pStatusKey, toJson(getpStatus(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pCompleteKey = new JsonString(L"complete");
|
||||
pJsonObject->Add(pCompleteKey, toJson(getComplete(), "Boolean", ""));
|
||||
pJsonObject->Add(pCompleteKey, toJson(getpComplete(), "Boolean", ""));
|
||||
|
||||
|
||||
return pJsonObject;
|
||||
}
|
||||
|
||||
Long*
|
||||
SamiOrder::getId() {
|
||||
SamiOrder::getpId() {
|
||||
return pId;
|
||||
}
|
||||
void
|
||||
SamiOrder::setId(Long* pId) {
|
||||
SamiOrder::setpId(Long* pId) {
|
||||
this->pId = pId;
|
||||
}
|
||||
|
||||
Long*
|
||||
SamiOrder::getPetId() {
|
||||
SamiOrder::getpPetId() {
|
||||
return pPetId;
|
||||
}
|
||||
void
|
||||
SamiOrder::setPetId(Long* pPetId) {
|
||||
SamiOrder::setpPetId(Long* pPetId) {
|
||||
this->pPetId = pPetId;
|
||||
}
|
||||
|
||||
Integer*
|
||||
SamiOrder::getQuantity() {
|
||||
SamiOrder::getpQuantity() {
|
||||
return pQuantity;
|
||||
}
|
||||
void
|
||||
SamiOrder::setQuantity(Integer* pQuantity) {
|
||||
SamiOrder::setpQuantity(Integer* pQuantity) {
|
||||
this->pQuantity = pQuantity;
|
||||
}
|
||||
|
||||
DateTime*
|
||||
SamiOrder::getShipDate() {
|
||||
SamiOrder::getpShipDate() {
|
||||
return pShipDate;
|
||||
}
|
||||
void
|
||||
SamiOrder::setShipDate(DateTime* pShipDate) {
|
||||
SamiOrder::setpShipDate(DateTime* pShipDate) {
|
||||
this->pShipDate = pShipDate;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiOrder::getStatus() {
|
||||
SamiOrder::getpStatus() {
|
||||
return pStatus;
|
||||
}
|
||||
void
|
||||
SamiOrder::setStatus(String* pStatus) {
|
||||
SamiOrder::setpStatus(String* pStatus) {
|
||||
this->pStatus = pStatus;
|
||||
}
|
||||
|
||||
Boolean*
|
||||
SamiOrder::getComplete() {
|
||||
SamiOrder::getpComplete() {
|
||||
return pComplete;
|
||||
}
|
||||
void
|
||||
SamiOrder::setComplete(Boolean* pComplete) {
|
||||
SamiOrder::setpComplete(Boolean* pComplete) {
|
||||
this->pComplete = pComplete;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,23 +45,23 @@ public:
|
||||
SamiOrder* fromJson(String* obj);
|
||||
|
||||
|
||||
Long* getId();
|
||||
void setId(Long* pId);
|
||||
Long* getpId();
|
||||
void setpId(Long* pId);
|
||||
|
||||
Long* getPetId();
|
||||
void setPetId(Long* pPetId);
|
||||
Long* getpPetId();
|
||||
void setpPetId(Long* pPetId);
|
||||
|
||||
Integer* getQuantity();
|
||||
void setQuantity(Integer* pQuantity);
|
||||
Integer* getpQuantity();
|
||||
void setpQuantity(Integer* pQuantity);
|
||||
|
||||
DateTime* getShipDate();
|
||||
void setShipDate(DateTime* pShipDate);
|
||||
DateTime* getpShipDate();
|
||||
void setpShipDate(DateTime* pShipDate);
|
||||
|
||||
String* getStatus();
|
||||
void setStatus(String* pStatus);
|
||||
String* getpStatus();
|
||||
void setpStatus(String* pStatus);
|
||||
|
||||
Boolean* getComplete();
|
||||
void setComplete(Boolean* pComplete);
|
||||
Boolean* getpComplete();
|
||||
void setpComplete(Boolean* pComplete);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -208,83 +208,83 @@ SamiPet::asJsonObject() {
|
||||
|
||||
|
||||
JsonString *pIdKey = new JsonString(L"id");
|
||||
pJsonObject->Add(pIdKey, toJson(getId(), "Long", ""));
|
||||
pJsonObject->Add(pIdKey, toJson(getpId(), "Long", ""));
|
||||
|
||||
|
||||
JsonString *pCategoryKey = new JsonString(L"category");
|
||||
pJsonObject->Add(pCategoryKey, toJson(getCategory(), "SamiCategory", ""));
|
||||
pJsonObject->Add(pCategoryKey, toJson(getpCategory(), "SamiCategory", ""));
|
||||
|
||||
|
||||
JsonString *pNameKey = new JsonString(L"name");
|
||||
pJsonObject->Add(pNameKey, toJson(getName(), "String", ""));
|
||||
pJsonObject->Add(pNameKey, toJson(getpName(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pPhotoUrlsKey = new JsonString(L"photoUrls");
|
||||
pJsonObject->Add(pPhotoUrlsKey, toJson(getPhotoUrls(), "String", "array"));
|
||||
pJsonObject->Add(pPhotoUrlsKey, toJson(getpPhotoUrls(), "String", "array"));
|
||||
|
||||
|
||||
JsonString *pTagsKey = new JsonString(L"tags");
|
||||
pJsonObject->Add(pTagsKey, toJson(getTags(), "SamiTag", "array"));
|
||||
pJsonObject->Add(pTagsKey, toJson(getpTags(), "SamiTag", "array"));
|
||||
|
||||
|
||||
JsonString *pStatusKey = new JsonString(L"status");
|
||||
pJsonObject->Add(pStatusKey, toJson(getStatus(), "String", ""));
|
||||
pJsonObject->Add(pStatusKey, toJson(getpStatus(), "String", ""));
|
||||
|
||||
|
||||
return pJsonObject;
|
||||
}
|
||||
|
||||
Long*
|
||||
SamiPet::getId() {
|
||||
SamiPet::getpId() {
|
||||
return pId;
|
||||
}
|
||||
void
|
||||
SamiPet::setId(Long* pId) {
|
||||
SamiPet::setpId(Long* pId) {
|
||||
this->pId = pId;
|
||||
}
|
||||
|
||||
SamiCategory*
|
||||
SamiPet::getCategory() {
|
||||
SamiPet::getpCategory() {
|
||||
return pCategory;
|
||||
}
|
||||
void
|
||||
SamiPet::setCategory(SamiCategory* pCategory) {
|
||||
SamiPet::setpCategory(SamiCategory* pCategory) {
|
||||
this->pCategory = pCategory;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiPet::getName() {
|
||||
SamiPet::getpName() {
|
||||
return pName;
|
||||
}
|
||||
void
|
||||
SamiPet::setName(String* pName) {
|
||||
SamiPet::setpName(String* pName) {
|
||||
this->pName = pName;
|
||||
}
|
||||
|
||||
IList*
|
||||
SamiPet::getPhotoUrls() {
|
||||
SamiPet::getpPhotoUrls() {
|
||||
return pPhotoUrls;
|
||||
}
|
||||
void
|
||||
SamiPet::setPhotoUrls(IList* pPhotoUrls) {
|
||||
SamiPet::setpPhotoUrls(IList* pPhotoUrls) {
|
||||
this->pPhotoUrls = pPhotoUrls;
|
||||
}
|
||||
|
||||
IList*
|
||||
SamiPet::getTags() {
|
||||
SamiPet::getpTags() {
|
||||
return pTags;
|
||||
}
|
||||
void
|
||||
SamiPet::setTags(IList* pTags) {
|
||||
SamiPet::setpTags(IList* pTags) {
|
||||
this->pTags = pTags;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiPet::getStatus() {
|
||||
SamiPet::getpStatus() {
|
||||
return pStatus;
|
||||
}
|
||||
void
|
||||
SamiPet::setStatus(String* pStatus) {
|
||||
SamiPet::setpStatus(String* pStatus) {
|
||||
this->pStatus = pStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,23 +45,23 @@ public:
|
||||
SamiPet* fromJson(String* obj);
|
||||
|
||||
|
||||
Long* getId();
|
||||
void setId(Long* pId);
|
||||
Long* getpId();
|
||||
void setpId(Long* pId);
|
||||
|
||||
SamiCategory* getCategory();
|
||||
void setCategory(SamiCategory* pCategory);
|
||||
SamiCategory* getpCategory();
|
||||
void setpCategory(SamiCategory* pCategory);
|
||||
|
||||
String* getName();
|
||||
void setName(String* pName);
|
||||
String* getpName();
|
||||
void setpName(String* pName);
|
||||
|
||||
IList* getPhotoUrls();
|
||||
void setPhotoUrls(IList* pPhotoUrls);
|
||||
IList* getpPhotoUrls();
|
||||
void setpPhotoUrls(IList* pPhotoUrls);
|
||||
|
||||
IList* getTags();
|
||||
void setTags(IList* pTags);
|
||||
IList* getpTags();
|
||||
void setpTags(IList* pTags);
|
||||
|
||||
String* getStatus();
|
||||
void setStatus(String* pStatus);
|
||||
String* getpStatus();
|
||||
void setpStatus(String* pStatus);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -148,31 +148,31 @@ SamiTag::asJsonObject() {
|
||||
|
||||
|
||||
JsonString *pIdKey = new JsonString(L"id");
|
||||
pJsonObject->Add(pIdKey, toJson(getId(), "Long", ""));
|
||||
pJsonObject->Add(pIdKey, toJson(getpId(), "Long", ""));
|
||||
|
||||
|
||||
JsonString *pNameKey = new JsonString(L"name");
|
||||
pJsonObject->Add(pNameKey, toJson(getName(), "String", ""));
|
||||
pJsonObject->Add(pNameKey, toJson(getpName(), "String", ""));
|
||||
|
||||
|
||||
return pJsonObject;
|
||||
}
|
||||
|
||||
Long*
|
||||
SamiTag::getId() {
|
||||
SamiTag::getpId() {
|
||||
return pId;
|
||||
}
|
||||
void
|
||||
SamiTag::setId(Long* pId) {
|
||||
SamiTag::setpId(Long* pId) {
|
||||
this->pId = pId;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiTag::getName() {
|
||||
SamiTag::getpName() {
|
||||
return pName;
|
||||
}
|
||||
void
|
||||
SamiTag::setName(String* pName) {
|
||||
SamiTag::setpName(String* pName) {
|
||||
this->pName = pName;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ public:
|
||||
SamiTag* fromJson(String* obj);
|
||||
|
||||
|
||||
Long* getId();
|
||||
void setId(Long* pId);
|
||||
Long* getpId();
|
||||
void setpId(Long* pId);
|
||||
|
||||
String* getName();
|
||||
void setName(String* pName);
|
||||
String* getpName();
|
||||
void setpName(String* pName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -238,109 +238,109 @@ SamiUser::asJsonObject() {
|
||||
|
||||
|
||||
JsonString *pIdKey = new JsonString(L"id");
|
||||
pJsonObject->Add(pIdKey, toJson(getId(), "Long", ""));
|
||||
pJsonObject->Add(pIdKey, toJson(getpId(), "Long", ""));
|
||||
|
||||
|
||||
JsonString *pUsernameKey = new JsonString(L"username");
|
||||
pJsonObject->Add(pUsernameKey, toJson(getUsername(), "String", ""));
|
||||
pJsonObject->Add(pUsernameKey, toJson(getpUsername(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pFirstNameKey = new JsonString(L"firstName");
|
||||
pJsonObject->Add(pFirstNameKey, toJson(getFirstName(), "String", ""));
|
||||
pJsonObject->Add(pFirstNameKey, toJson(getpFirstName(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pLastNameKey = new JsonString(L"lastName");
|
||||
pJsonObject->Add(pLastNameKey, toJson(getLastName(), "String", ""));
|
||||
pJsonObject->Add(pLastNameKey, toJson(getpLastName(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pEmailKey = new JsonString(L"email");
|
||||
pJsonObject->Add(pEmailKey, toJson(getEmail(), "String", ""));
|
||||
pJsonObject->Add(pEmailKey, toJson(getpEmail(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pPasswordKey = new JsonString(L"password");
|
||||
pJsonObject->Add(pPasswordKey, toJson(getPassword(), "String", ""));
|
||||
pJsonObject->Add(pPasswordKey, toJson(getpPassword(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pPhoneKey = new JsonString(L"phone");
|
||||
pJsonObject->Add(pPhoneKey, toJson(getPhone(), "String", ""));
|
||||
pJsonObject->Add(pPhoneKey, toJson(getpPhone(), "String", ""));
|
||||
|
||||
|
||||
JsonString *pUserStatusKey = new JsonString(L"userStatus");
|
||||
pJsonObject->Add(pUserStatusKey, toJson(getUserStatus(), "Integer", ""));
|
||||
pJsonObject->Add(pUserStatusKey, toJson(getpUserStatus(), "Integer", ""));
|
||||
|
||||
|
||||
return pJsonObject;
|
||||
}
|
||||
|
||||
Long*
|
||||
SamiUser::getId() {
|
||||
SamiUser::getpId() {
|
||||
return pId;
|
||||
}
|
||||
void
|
||||
SamiUser::setId(Long* pId) {
|
||||
SamiUser::setpId(Long* pId) {
|
||||
this->pId = pId;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiUser::getUsername() {
|
||||
SamiUser::getpUsername() {
|
||||
return pUsername;
|
||||
}
|
||||
void
|
||||
SamiUser::setUsername(String* pUsername) {
|
||||
SamiUser::setpUsername(String* pUsername) {
|
||||
this->pUsername = pUsername;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiUser::getFirstName() {
|
||||
SamiUser::getpFirstName() {
|
||||
return pFirstName;
|
||||
}
|
||||
void
|
||||
SamiUser::setFirstName(String* pFirstName) {
|
||||
SamiUser::setpFirstName(String* pFirstName) {
|
||||
this->pFirstName = pFirstName;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiUser::getLastName() {
|
||||
SamiUser::getpLastName() {
|
||||
return pLastName;
|
||||
}
|
||||
void
|
||||
SamiUser::setLastName(String* pLastName) {
|
||||
SamiUser::setpLastName(String* pLastName) {
|
||||
this->pLastName = pLastName;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiUser::getEmail() {
|
||||
SamiUser::getpEmail() {
|
||||
return pEmail;
|
||||
}
|
||||
void
|
||||
SamiUser::setEmail(String* pEmail) {
|
||||
SamiUser::setpEmail(String* pEmail) {
|
||||
this->pEmail = pEmail;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiUser::getPassword() {
|
||||
SamiUser::getpPassword() {
|
||||
return pPassword;
|
||||
}
|
||||
void
|
||||
SamiUser::setPassword(String* pPassword) {
|
||||
SamiUser::setpPassword(String* pPassword) {
|
||||
this->pPassword = pPassword;
|
||||
}
|
||||
|
||||
String*
|
||||
SamiUser::getPhone() {
|
||||
SamiUser::getpPhone() {
|
||||
return pPhone;
|
||||
}
|
||||
void
|
||||
SamiUser::setPhone(String* pPhone) {
|
||||
SamiUser::setpPhone(String* pPhone) {
|
||||
this->pPhone = pPhone;
|
||||
}
|
||||
|
||||
Integer*
|
||||
SamiUser::getUserStatus() {
|
||||
SamiUser::getpUserStatus() {
|
||||
return pUserStatus;
|
||||
}
|
||||
void
|
||||
SamiUser::setUserStatus(Integer* pUserStatus) {
|
||||
SamiUser::setpUserStatus(Integer* pUserStatus) {
|
||||
this->pUserStatus = pUserStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,29 +43,29 @@ public:
|
||||
SamiUser* fromJson(String* obj);
|
||||
|
||||
|
||||
Long* getId();
|
||||
void setId(Long* pId);
|
||||
Long* getpId();
|
||||
void setpId(Long* pId);
|
||||
|
||||
String* getUsername();
|
||||
void setUsername(String* pUsername);
|
||||
String* getpUsername();
|
||||
void setpUsername(String* pUsername);
|
||||
|
||||
String* getFirstName();
|
||||
void setFirstName(String* pFirstName);
|
||||
String* getpFirstName();
|
||||
void setpFirstName(String* pFirstName);
|
||||
|
||||
String* getLastName();
|
||||
void setLastName(String* pLastName);
|
||||
String* getpLastName();
|
||||
void setpLastName(String* pLastName);
|
||||
|
||||
String* getEmail();
|
||||
void setEmail(String* pEmail);
|
||||
String* getpEmail();
|
||||
void setpEmail(String* pEmail);
|
||||
|
||||
String* getPassword();
|
||||
void setPassword(String* pPassword);
|
||||
String* getpPassword();
|
||||
void setpPassword(String* pPassword);
|
||||
|
||||
String* getPhone();
|
||||
void setPhone(String* pPhone);
|
||||
String* getpPhone();
|
||||
void setpPhone(String* pPhone);
|
||||
|
||||
Integer* getUserStatus();
|
||||
void setUserStatus(Integer* pUserStatus);
|
||||
Integer* getpUserStatus();
|
||||
void setpUserStatus(Integer* pUserStatus);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -123,8 +123,17 @@
|
||||
<version>${servlet-api-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-core-version>1.5.1-M1</swagger-core-version>
|
||||
<swagger-core-version>1.5.3-M1-SNAPSHOT</swagger-core-version>
|
||||
<jetty-version>8.1.11.v20130520</jetty-version>
|
||||
<jersey-version>1.13</jersey-version>
|
||||
<slf4j-version>1.6.3</slf4j-version>
|
||||
|
||||
@@ -64,6 +64,8 @@ public class PetApi {
|
||||
@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") @QueryParam("status") List<String> status)
|
||||
@@ -79,6 +81,8 @@ public class PetApi {
|
||||
@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)
|
||||
@@ -96,6 +100,8 @@ public class PetApi {
|
||||
@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)
|
||||
@@ -143,7 +149,8 @@ public class PetApi {
|
||||
@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.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,
|
||||
|
||||
@@ -29,7 +29,8 @@ public class StoreApi {
|
||||
|
||||
@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.ApiResponses(value = {
|
||||
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
|
||||
|
||||
public Response getInventory()
|
||||
throws NotFoundException {
|
||||
@@ -44,6 +45,8 @@ public class StoreApi {
|
||||
@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)
|
||||
@@ -61,6 +64,8 @@ public class StoreApi {
|
||||
@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)
|
||||
|
||||
@@ -29,7 +29,8 @@ public class UserApi {
|
||||
|
||||
@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.ApiResponses(value = {
|
||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||
|
||||
public Response createUser(@ApiParam(value = "Created user object" ) User body)
|
||||
throws NotFoundException {
|
||||
@@ -43,7 +44,8 @@ public class UserApi {
|
||||
|
||||
@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.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 {
|
||||
@@ -57,7 +59,8 @@ public class UserApi {
|
||||
|
||||
@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.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 {
|
||||
@@ -72,6 +75,8 @@ public class UserApi {
|
||||
@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,
|
||||
@@ -87,7 +92,8 @@ public class UserApi {
|
||||
|
||||
@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.ApiResponses(value = {
|
||||
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
||||
|
||||
public Response logoutUser()
|
||||
throws NotFoundException {
|
||||
@@ -104,6 +110,8 @@ public class UserApi {
|
||||
@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)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# Swagger generated server
|
||||
|
||||
## Overview
|
||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate a server stub. This is an example of building a node.js server.
|
||||
|
||||
This example uses the [expressjs](http://expressjs.com/) framework. To see how to make this your own, look here:
|
||||
|
||||
[README](https://github.com/wordnik/swagger-codegen/README.md)
|
||||
559
samples/server/petstore/nodejs/api/swagger.json
Normal file
559
samples/server/petstore/nodejs/api/swagger.json
Normal file
@@ -0,0 +1,559 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Swagger Petstore",
|
||||
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"host": "localhost:8080",
|
||||
"basePath": "/v2",
|
||||
"paths": {
|
||||
"/user": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "User",
|
||||
"tags": [
|
||||
"User"
|
||||
],
|
||||
"operationId": "createUser",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "Created user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/createWithArray": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "User",
|
||||
"tags": [
|
||||
"User"
|
||||
],
|
||||
"operationId": "createUsersWithArrayInput",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/createWithList": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "User",
|
||||
"tags": [
|
||||
"User"
|
||||
],
|
||||
"operationId": "createUsersWithListInput",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "List of user object",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/User"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/login": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "User",
|
||||
"tags": [
|
||||
"User"
|
||||
],
|
||||
"operationId": "loginUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "query",
|
||||
"description": "The user name for login",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"in": "query",
|
||||
"description": "The password for login in clear text",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username/password supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/logout": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "User",
|
||||
"tags": [
|
||||
"User"
|
||||
],
|
||||
"operationId": "logoutUser",
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{username}": {
|
||||
"delete": {
|
||||
"x-swagger-router-controller": "User",
|
||||
"tags": [
|
||||
"User"
|
||||
],
|
||||
"operationId": "deleteUser",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"description": "The name that needs to be deleted",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "User not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid username supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pet": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Pet",
|
||||
"tags": [
|
||||
"Pet"
|
||||
],
|
||||
"operationId": "addPet",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "Pet object that needs to be added to the store",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Invalid input"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pet/findByStatus": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Pet",
|
||||
"tags": [
|
||||
"Pet"
|
||||
],
|
||||
"operationId": "findPetsByStatus",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "status",
|
||||
"in": "query",
|
||||
"description": "Status values that need to be considered for filter",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi",
|
||||
"default": "available"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid status value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pet/findByTags": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Pet",
|
||||
"tags": [
|
||||
"Pet"
|
||||
],
|
||||
"operationId": "findPetsByTags",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "tags",
|
||||
"in": "query",
|
||||
"description": "Tags to filter by",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"collectionFormat": "multi"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid tag value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pet/{petId}": {
|
||||
"delete": {
|
||||
"x-swagger-router-controller": "Pet",
|
||||
"tags": [
|
||||
"Pet"
|
||||
],
|
||||
"operationId": "deletePet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "api_key",
|
||||
"in": "header",
|
||||
"description": "",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "Pet id to delete",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Invalid pet value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pet/{petId}/uploadImage": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Pet",
|
||||
"tags": [
|
||||
"Pet"
|
||||
],
|
||||
"operationId": "uploadFile",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet to update",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"name": "additionalMetadata",
|
||||
"in": "formData",
|
||||
"description": "Additional data to pass to server",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"description": "file to upload",
|
||||
"required": false,
|
||||
"type": "file"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/store/inventory": {
|
||||
"get": {
|
||||
"x-swagger-router-controller": "Store",
|
||||
"tags": [
|
||||
"Store"
|
||||
],
|
||||
"operationId": "getInventory",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/store/order": {
|
||||
"post": {
|
||||
"x-swagger-router-controller": "Store",
|
||||
"tags": [
|
||||
"Store"
|
||||
],
|
||||
"operationId": "placeOrder",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"description": "order placed for purchasing the pet",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Order"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/store/order/{orderId}": {
|
||||
"delete": {
|
||||
"x-swagger-router-controller": "Store",
|
||||
"tags": [
|
||||
"Store"
|
||||
],
|
||||
"operationId": "deleteOrder",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "ID of the order that needs to be deleted",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "Order not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"User": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"firstName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastName": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"userStatus": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": "User Status"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "User"
|
||||
}
|
||||
},
|
||||
"Category": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Category"
|
||||
}
|
||||
},
|
||||
"Pet": {
|
||||
"required": [
|
||||
"name",
|
||||
"photoUrls"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "#/definitions/Category"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "doggie"
|
||||
},
|
||||
"photoUrls": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Tag"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "pet status in the store",
|
||||
"enum": [
|
||||
"available",
|
||||
"pending",
|
||||
"sold"
|
||||
]
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Pet"
|
||||
}
|
||||
},
|
||||
"Tag": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Tag"
|
||||
}
|
||||
},
|
||||
"Order": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"petId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"shipDate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "Order Status",
|
||||
"enum": [
|
||||
"placed",
|
||||
"approved",
|
||||
"delivered"
|
||||
]
|
||||
},
|
||||
"complete": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
"name": "Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
var swagger = require("swagger-node-express");
|
||||
var url = require("url");
|
||||
var errors = swagger.errors;
|
||||
var params = swagger.params;
|
||||
|
||||
/* add model includes */
|
||||
|
||||
function writeResponse (response, data) {
|
||||
response.header('Access-Control-Allow-Origin', "*");
|
||||
response.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||
response.header("Access-Control-Allow-Headers", "Content-Type");
|
||||
response.header("Content-Type", "application/json; charset=utf-8");
|
||||
response.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
exports.models = models = require("../models.js");
|
||||
|
||||
exports.updatePet = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet",
|
||||
"notes" : "",
|
||||
"summary" : "Update an existing pet",
|
||||
"method": "PUT",
|
||||
"params" : [].concat([]).concat([]).concat([
|
||||
params.body("body", "", "Pet object that needs to be added to the store", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "updatePet"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing updatePet as a PUT method?"});
|
||||
}
|
||||
};
|
||||
exports.addPet = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet",
|
||||
"notes" : "",
|
||||
"summary" : "Add a new pet to the store",
|
||||
"method": "POST",
|
||||
"params" : [].concat([]).concat([]).concat([
|
||||
params.body("body", "", "Pet object that needs to be added to the store", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "addPet"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing addPet as a POST method?"});
|
||||
}
|
||||
};
|
||||
exports.findPetsByStatus = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet/findByStatus",
|
||||
"notes" : "Multiple status values can be provided with comma seperated strings",
|
||||
"summary" : "Finds Pets by status",
|
||||
"method": "GET",
|
||||
"params" : [
|
||||
params.query("status", "Status values that need to be considered for filter", "", false, false, "")
|
||||
].concat([]).concat([]).concat([]),
|
||||
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
"$ref": "array"
|
||||
},
|
||||
// container
|
||||
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('array')],
|
||||
"nickname" : "findPetsByStatus"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing findPetsByStatus as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.findPetsByTags = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet/findByTags",
|
||||
"notes" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
|
||||
"summary" : "Finds Pets by tags",
|
||||
"method": "GET",
|
||||
"params" : [
|
||||
params.query("tags", "Tags to filter by", "", false, false, "")
|
||||
].concat([]).concat([]).concat([]),
|
||||
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
"$ref": "array"
|
||||
},
|
||||
// container
|
||||
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('array')],
|
||||
"nickname" : "findPetsByTags"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing findPetsByTags as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.getPetById = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet/{petId}",
|
||||
"notes" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
|
||||
"summary" : "Find pet by ID",
|
||||
"method": "GET",
|
||||
"params" : [].concat([
|
||||
params.path("petId", "ID of pet that needs to be fetched")
|
||||
]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "Pet",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('Pet')],
|
||||
"nickname" : "getPetById"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing getPetById as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.updatePetWithForm = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet/{petId}",
|
||||
"notes" : "",
|
||||
"summary" : "Updates a pet in the store with form data",
|
||||
"method": "POST",
|
||||
"params" : [].concat([
|
||||
params.path("petId", "ID of pet that needs to be updated")
|
||||
]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "updatePetWithForm"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing updatePetWithForm as a POST method?"});
|
||||
}
|
||||
};
|
||||
exports.deletePet = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet/{petId}",
|
||||
"notes" : "",
|
||||
"summary" : "Deletes a pet",
|
||||
"method": "DELETE",
|
||||
"params" : [].concat([
|
||||
params.path("petId", "Pet id to delete")
|
||||
]).concat([
|
||||
params.header("api_key", "")
|
||||
]).concat([]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "deletePet"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing deletePet as a DELETE method?"});
|
||||
}
|
||||
};
|
||||
exports.uploadFile = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/pet/{petId}/uploadImage",
|
||||
"notes" : "",
|
||||
"summary" : "uploads an image",
|
||||
"method": "POST",
|
||||
"params" : [].concat([]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "uploadFile"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing uploadFile as a POST method?"});
|
||||
}
|
||||
};
|
||||
@@ -1,108 +0,0 @@
|
||||
var swagger = require("swagger-node-express");
|
||||
var url = require("url");
|
||||
var errors = swagger.errors;
|
||||
var params = swagger.params;
|
||||
|
||||
/* add model includes */
|
||||
|
||||
function writeResponse (response, data) {
|
||||
response.header('Access-Control-Allow-Origin', "*");
|
||||
response.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||
response.header("Access-Control-Allow-Headers", "Content-Type");
|
||||
response.header("Content-Type", "application/json; charset=utf-8");
|
||||
response.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
exports.models = models = require("../models.js");
|
||||
|
||||
exports.getInventory = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/store/inventory",
|
||||
"notes" : "Returns a map of status codes to quantities",
|
||||
"summary" : "Returns pet inventories by status",
|
||||
"method": "GET",
|
||||
"params" : [].concat([]).concat([]).concat([]),
|
||||
|
||||
"type": "Map",
|
||||
"items": {
|
||||
|
||||
"$ref": "map"
|
||||
},
|
||||
// container
|
||||
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('Map')],
|
||||
"nickname" : "getInventory"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing getInventory as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.placeOrder = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/store/order",
|
||||
"notes" : "",
|
||||
"summary" : "Place an order for a pet",
|
||||
"method": "POST",
|
||||
"params" : [].concat([]).concat([]).concat([
|
||||
params.body("body", "", "order placed for purchasing the pet", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "Order",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('Order')],
|
||||
"nickname" : "placeOrder"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing placeOrder as a POST method?"});
|
||||
}
|
||||
};
|
||||
exports.getOrderById = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/store/order/{orderId}",
|
||||
"notes" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
"summary" : "Find purchase order by ID",
|
||||
"method": "GET",
|
||||
"params" : [].concat([
|
||||
params.path("orderId", "ID of pet that needs to be fetched")
|
||||
]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "Order",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('Order')],
|
||||
"nickname" : "getOrderById"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing getOrderById as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.deleteOrder = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/store/order/{orderId}",
|
||||
"notes" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
"summary" : "Delete purchase order by ID",
|
||||
"method": "DELETE",
|
||||
"params" : [].concat([
|
||||
params.path("orderId", "ID of the order that needs to be deleted")
|
||||
]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "deleteOrder"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing deleteOrder as a DELETE method?"});
|
||||
}
|
||||
};
|
||||
@@ -1,195 +0,0 @@
|
||||
var swagger = require("swagger-node-express");
|
||||
var url = require("url");
|
||||
var errors = swagger.errors;
|
||||
var params = swagger.params;
|
||||
|
||||
/* add model includes */
|
||||
|
||||
function writeResponse (response, data) {
|
||||
response.header('Access-Control-Allow-Origin', "*");
|
||||
response.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||
response.header("Access-Control-Allow-Headers", "Content-Type");
|
||||
response.header("Content-Type", "application/json; charset=utf-8");
|
||||
response.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
exports.models = models = require("../models.js");
|
||||
|
||||
exports.createUser = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user",
|
||||
"notes" : "This can only be done by the logged in user.",
|
||||
"summary" : "Create user",
|
||||
"method": "POST",
|
||||
"params" : [].concat([]).concat([]).concat([
|
||||
params.body("body", "", "Created user object", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "createUser"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing createUser as a POST method?"});
|
||||
}
|
||||
};
|
||||
exports.createUsersWithArrayInput = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/createWithArray",
|
||||
"notes" : "",
|
||||
"summary" : "Creates list of users with given input array",
|
||||
"method": "POST",
|
||||
"params" : [].concat([]).concat([]).concat([
|
||||
params.body("body", "", "List of user object", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "createUsersWithArrayInput"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing createUsersWithArrayInput as a POST method?"});
|
||||
}
|
||||
};
|
||||
exports.createUsersWithListInput = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/createWithList",
|
||||
"notes" : "",
|
||||
"summary" : "Creates list of users with given input array",
|
||||
"method": "POST",
|
||||
"params" : [].concat([]).concat([]).concat([
|
||||
params.body("body", "", "List of user object", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "createUsersWithListInput"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing createUsersWithListInput as a POST method?"});
|
||||
}
|
||||
};
|
||||
exports.loginUser = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/login",
|
||||
"notes" : "",
|
||||
"summary" : "Logs user into the system",
|
||||
"method": "GET",
|
||||
"params" : [
|
||||
params.query("username", "The user name for login", "", false, false, ""),
|
||||
|
||||
params.query("password", "The password for login in clear text", "", false, false, "")
|
||||
].concat([]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "String",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('String')],
|
||||
"nickname" : "loginUser"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing loginUser as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.logoutUser = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/logout",
|
||||
"notes" : "",
|
||||
"summary" : "Logs out current logged in user session",
|
||||
"method": "GET",
|
||||
"params" : [].concat([]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "logoutUser"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing logoutUser as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.getUserByName = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/{username}",
|
||||
"notes" : "",
|
||||
"summary" : "Get user by user name",
|
||||
"method": "GET",
|
||||
"params" : [].concat([
|
||||
params.path("username", "The name that needs to be fetched. Use user1 for testing. ")
|
||||
]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "User",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('User')],
|
||||
"nickname" : "getUserByName"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing getUserByName as a GET method?"});
|
||||
}
|
||||
};
|
||||
exports.updateUser = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/{username}",
|
||||
"notes" : "This can only be done by the logged in user.",
|
||||
"summary" : "Updated user",
|
||||
"method": "PUT",
|
||||
"params" : [].concat([
|
||||
params.path("username", "name that need to be deleted")
|
||||
]).concat([]).concat([
|
||||
params.body("body", "", "Updated user object", false)
|
||||
]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "updateUser"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing updateUser as a PUT method?"});
|
||||
}
|
||||
};
|
||||
exports.deleteUser = {
|
||||
'spec': {
|
||||
"description" : "Operations about pets",
|
||||
"path" : "/user/{username}",
|
||||
"notes" : "This can only be done by the logged in user.",
|
||||
"summary" : "Delete user",
|
||||
"method": "DELETE",
|
||||
"params" : [].concat([
|
||||
params.path("username", "The name that needs to be deleted")
|
||||
]).concat([]).concat([]),
|
||||
|
||||
|
||||
"type" : "",
|
||||
|
||||
"responseMessages" : [errors.invalid('id'), errors.notFound('')],
|
||||
"nickname" : "deleteUser"
|
||||
},
|
||||
'action': function (req,res) {
|
||||
|
||||
writeResponse(res, {message: "how about implementing deleteUser as a DELETE method?"});
|
||||
}
|
||||
};
|
||||
@@ -1,132 +0,0 @@
|
||||
exports.models = {
|
||||
"User": {
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"username" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"firstName" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"lastName" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"email" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"password" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"phone" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"userStatus" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32",
|
||||
"description" : "User Status"
|
||||
}
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
},
|
||||
"id" : "User"
|
||||
},"Category": {
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Category"
|
||||
},
|
||||
"id" : "Category"
|
||||
},"Pet": {
|
||||
"required" : [ "name", "photoUrls" ],
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"category" : {
|
||||
"$ref" : "Category"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string",
|
||||
"example" : "doggie"
|
||||
},
|
||||
"photoUrls" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"tags" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "Tag"
|
||||
}
|
||||
},
|
||||
"status" : {
|
||||
"type" : "string",
|
||||
"description" : "pet status in the store",
|
||||
"enum" : [ "available", "pending", "sold" ]
|
||||
}
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Pet"
|
||||
},
|
||||
"id" : "Pet"
|
||||
},"Tag": {
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Tag"
|
||||
},
|
||||
"id" : "Tag"
|
||||
},"Order": {
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"petId" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"quantity" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"shipDate" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time"
|
||||
},
|
||||
"status" : {
|
||||
"type" : "string",
|
||||
"description" : "Order Status",
|
||||
"enum" : [ "placed", "approved", "delivered" ]
|
||||
},
|
||||
"complete" : {
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Order"
|
||||
},
|
||||
"id" : "Order"
|
||||
}
|
||||
}
|
||||
124
samples/server/petstore/nodejs/controllers/Pet.js
Normal file
124
samples/server/petstore/nodejs/controllers/Pet.js
Normal file
@@ -0,0 +1,124 @@
|
||||
'use strict';
|
||||
|
||||
var url = require('url');
|
||||
|
||||
|
||||
var Pet = require('./PetService');
|
||||
|
||||
|
||||
module.exports.updatePet = function updatePet (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
|
||||
|
||||
var result = Pet.updatePet(body);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.addPet = function addPet (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
|
||||
|
||||
var result = Pet.addPet(body);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) {
|
||||
var status = req.swagger.params['status'].value;
|
||||
|
||||
|
||||
var result = Pet.findPetsByStatus(status);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.findPetsByTags = function findPetsByTags (req, res, next) {
|
||||
var tags = req.swagger.params['tags'].value;
|
||||
|
||||
|
||||
var result = Pet.findPetsByTags(tags);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.getPetById = function getPetById (req, res, next) {
|
||||
var petId = req.swagger.params['petId'].value;
|
||||
|
||||
|
||||
var result = Pet.getPetById(petId);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
|
||||
var petId = req.swagger.params['petId'].value;
|
||||
var name = req.swagger.params['name'].value;
|
||||
var status = req.swagger.params['status'].value;
|
||||
|
||||
|
||||
var result = Pet.updatePetWithForm(petId, name, status);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.deletePet = function deletePet (req, res, next) {
|
||||
var api_key = req.swagger.params['api_key'].value;
|
||||
var petId = req.swagger.params['petId'].value;
|
||||
|
||||
|
||||
var result = Pet.deletePet(api_key, petId);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
|
||||
module.exports.uploadFile = function uploadFile (req, res, next) {
|
||||
var petId = req.swagger.params['petId'].value;
|
||||
var additionalMetadata = req.swagger.params['additionalMetadata'].value;
|
||||
var file = req.swagger.params['file'].value;
|
||||
|
||||
|
||||
var result = Pet.uploadFile(petId, additionalMetadata, file);
|
||||
|
||||
if(typeof result !== 'undefined') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(result || {}, null, 2));
|
||||
}
|
||||
else
|
||||
res.end();
|
||||
};
|
||||
112
samples/server/petstore/nodejs/controllers/PetService.js
Normal file
112
samples/server/petstore/nodejs/controllers/PetService.js
Normal file
@@ -0,0 +1,112 @@
|
||||
'use strict';
|
||||
|
||||
exports.updatePet = function(body) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
|
||||
|
||||
}
|
||||
exports.addPet = function(body) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
|
||||
|
||||
}
|
||||
exports.findPetsByStatus = function(status) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
examples['application/json'] = [ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ];
|
||||
|
||||
|
||||
|
||||
if(Object.keys(examples).length > 0)
|
||||
return examples[Object.keys(examples)[0]];
|
||||
|
||||
}
|
||||
exports.findPetsByTags = function(tags) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
examples['application/json'] = [ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ];
|
||||
|
||||
|
||||
|
||||
if(Object.keys(examples).length > 0)
|
||||
return examples[Object.keys(examples)[0]];
|
||||
|
||||
}
|
||||
exports.getPetById = function(petId) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
examples['application/json'] = {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
};
|
||||
|
||||
|
||||
|
||||
if(Object.keys(examples).length > 0)
|
||||
return examples[Object.keys(examples)[0]];
|
||||
|
||||
}
|
||||
exports.updatePetWithForm = function(petId, name, status) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
|
||||
|
||||
}
|
||||
exports.deletePet = function(api_key, petId) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
|
||||
|
||||
}
|
||||
exports.uploadFile = function(petId, additionalMetadata, file) {
|
||||
|
||||
var examples = {};
|
||||
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user