forked from loafle/openapi-generator-original
Merge pull request #2917 from Vrolijkx/feature/typescript_angular2_should_generate_correct_output
Feature/typescript angular2 should generate correct output
This commit is contained in:
commit
e1367ee743
@ -1,62 +1,73 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.CodegenType;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.FileProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
protected String modelPropertyNaming= "camelCase";
|
||||
protected Boolean supportsES6 = true;
|
||||
|
||||
public AbstractTypeScriptClientCodegen() {
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
setReservedWordsLowerCase(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
"varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
|
||||
"requestOptions",
|
||||
// Typescript reserved words
|
||||
"abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
|
||||
public AbstractTypeScriptClientCodegen() {
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
setReservedWordsLowerCase(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
"varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
|
||||
"requestOptions",
|
||||
// Typescript reserved words
|
||||
"abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(Arrays.asList(
|
||||
"string",
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object",
|
||||
languageSpecificPrimitives = new HashSet<String>(Arrays.asList(
|
||||
"string",
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object",
|
||||
"Array",
|
||||
"Date",
|
||||
"number",
|
||||
"any"
|
||||
));
|
||||
instantiationTypes.put("array", "Array");
|
||||
));
|
||||
instantiationTypes.put("array", "Array");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("Array", "Array");
|
||||
typeMapping.put("array", "Array");
|
||||
typeMapping.put("List", "Array");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("int", "number");
|
||||
typeMapping.put("float", "number");
|
||||
typeMapping.put("number", "number");
|
||||
typeMapping.put("long", "number");
|
||||
typeMapping.put("short", "number");
|
||||
typeMapping.put("char", "string");
|
||||
typeMapping.put("double", "number");
|
||||
typeMapping.put("object", "any");
|
||||
typeMapping.put("integer", "number");
|
||||
typeMapping.put("Map", "any");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("Array", "Array");
|
||||
typeMapping.put("array", "Array");
|
||||
typeMapping.put("List", "Array");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("int", "number");
|
||||
typeMapping.put("float", "number");
|
||||
typeMapping.put("number", "number");
|
||||
typeMapping.put("long", "number");
|
||||
typeMapping.put("short", "number");
|
||||
typeMapping.put("char", "string");
|
||||
typeMapping.put("double", "number");
|
||||
typeMapping.put("object", "any");
|
||||
typeMapping.put("integer", "number");
|
||||
typeMapping.put("Map", "any");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
@ -66,7 +77,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
@ -104,24 +115,24 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
public String toParamName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
// camelize the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
@ -130,70 +141,70 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
public String toModelName(String name) {
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = camelize("model_" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return "{ [key: string]: "+ getTypeDeclaration(inner) + "; }";
|
||||
} else if (p instanceof FileProperty) {
|
||||
return "any";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = camelize("model_" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return "{ [key: string]: "+ getTypeDeclaration(inner) + "; }";
|
||||
} else if (p instanceof FileProperty) {
|
||||
return "any";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return type;
|
||||
} else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return type;
|
||||
} else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
@ -217,8 +228,8 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
this.modelPropertyNaming = naming;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
naming + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
naming + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,9 +243,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
case camelCase: return camelize(name, true);
|
||||
case PascalCase: return camelize(name);
|
||||
case snake_case: return underscore(name);
|
||||
default: throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
default: throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
"'PascalCase' or 'snake_case'");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.BooleanProperty;
|
||||
import io.swagger.models.properties.FileProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.ObjectProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
@ -114,14 +115,19 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
||||
MapProperty mp = (MapProperty)p;
|
||||
inner = mp.getAdditionalProperties();
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||
} else if(p instanceof FileProperty || p instanceof ObjectProperty) {
|
||||
return "any";
|
||||
} else {
|
||||
return p instanceof FileProperty ? "any" : super.getTypeDeclaration(p);
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
if(languageSpecificPrimitives.contains(swaggerType)) {
|
||||
return swaggerType;
|
||||
}
|
||||
return addModelPrefix(swaggerType);
|
||||
}
|
||||
|
||||
@ -129,13 +135,25 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return type;
|
||||
} else
|
||||
} else {
|
||||
type = swaggerType;
|
||||
}
|
||||
|
||||
if (!startsWithLanguageSpecificPrimitiv(type)) {
|
||||
type = "models." + swaggerType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private boolean startsWithLanguageSpecificPrimitiv(String type) {
|
||||
for (String langPrimitive:languageSpecificPrimitives) {
|
||||
if (type.startsWith(langPrimitive)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import request = require('request');
|
||||
import http = require('http');
|
||||
{{^supportsES6}}
|
||||
import promise = require('bluebird');
|
||||
import Promise = require('bluebird');
|
||||
{{/supportsES6}}
|
||||
|
||||
let defaultBasePath = '{{basePath}}';
|
||||
@ -220,9 +220,6 @@ export class {{classname}} {
|
||||
{{/isFile}}
|
||||
|
||||
{{/formParams}}
|
||||
{{^supportsES6}}
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>();
|
||||
{{/supportsES6}}
|
||||
let requestOptions: request.Options = {
|
||||
method: '{{httpMethod}}',
|
||||
qs: queryParameters,
|
||||
@ -247,22 +244,7 @@ export class {{classname}} {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
{{^supportsES6}}
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
localVarDeferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
localVarDeferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
localVarDeferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
return localVarDeferred.promise;
|
||||
{{/supportsES6}}
|
||||
{{#supportsES6}}
|
||||
return new Promise<{ response: http.IncomingMessage; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => {
|
||||
return new Promise<{ response: http.{{#supportsES6}}IncomingMessage{{/supportsES6}}{{^supportsES6}}ClientResponse{{/supportsES6}}; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
@ -275,7 +257,6 @@ export class {{classname}} {
|
||||
}
|
||||
});
|
||||
});
|
||||
{{/supportsES6}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package io.swagger.codegen.typescript.typescriptangular2;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.codegen.AbstractIntegrationTest;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
||||
import io.swagger.codegen.testutils.IntegrationTestPathsConfig;
|
||||
|
||||
public class TypescriptAngular2ArrayAndObjectTest extends AbstractIntegrationTest {
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return new TypeScriptAngular2ClientCodegen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> configProperties() {
|
||||
Map<String, String> propeties = new HashMap<>();
|
||||
propeties.put("npmName", "arrayAndAnyTest");
|
||||
propeties.put("npmVersion", "1.0.2");
|
||||
propeties.put("snapshot", "false");
|
||||
|
||||
return propeties;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
|
||||
return new IntegrationTestPathsConfig("typescript/array-and-object");
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package io.swagger.codegen.typescript.typescriptnode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.codegen.AbstractIntegrationTest;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.languages.TypeScriptNodeClientCodegen;
|
||||
import io.swagger.codegen.testutils.IntegrationTestPathsConfig;
|
||||
|
||||
public class TypescriptNodeES5IntegrationTest extends AbstractIntegrationTest {
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return new TypeScriptNodeClientCodegen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> configProperties() {
|
||||
Map<String, String> propeties = new HashMap<>();
|
||||
propeties.put("npmName", "node-es6-test");
|
||||
propeties.put("npmVersion", "1.0.3");
|
||||
propeties.put("snapshot", "false");
|
||||
propeties.put("supportsES6", "false");
|
||||
|
||||
return propeties;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
|
||||
return new IntegrationTestPathsConfig("typescript/node-es5");
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,33 @@
|
||||
## arrayAndAnyTest@1.0.2
|
||||
|
||||
### Building
|
||||
|
||||
To build an compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### publishing
|
||||
|
||||
First build the package than run ```npm publish```
|
||||
|
||||
### consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of next commando's.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install arrayAndAnyTest@1.0.2 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
```
|
||||
|
||||
In your angular2 project:
|
||||
|
||||
TODO: paste example.
|
@ -0,0 +1,218 @@
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class ProjectApi {
|
||||
protected basePath = 'https://localhost/v1';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Project
|
||||
* Creates an empty Project
|
||||
* @param name
|
||||
* @param address
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
* @param meta
|
||||
*/
|
||||
public createProject (name?: string, address?: string, longitude?: number, latitude?: number, meta?: string, extraHttpRequestParams?: any ) : Observable<models.ProjectEntity> {
|
||||
const path = this.basePath + '/projects';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['name'] = name;
|
||||
|
||||
formParams['address'] = address;
|
||||
|
||||
formParams['longitude'] = longitude;
|
||||
|
||||
formParams['latitude'] = latitude;
|
||||
|
||||
formParams['meta'] = meta;
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Project
|
||||
* Returns a Project JSON object
|
||||
* @param id Project id
|
||||
*/
|
||||
public deleteProjectById (id: number, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/projects/{id}'
|
||||
.replace('{' + 'id' + '}', String(id));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'id' is set
|
||||
if (!id) {
|
||||
throw new Error('Missing required parameter id when calling deleteProjectById');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Project
|
||||
* Returns a Project JSON object
|
||||
* @param id Project id
|
||||
*/
|
||||
public getProjectById (id: number, extraHttpRequestParams?: any ) : Observable<models.ProjectEntity> {
|
||||
const path = this.basePath + '/projects/{id}'
|
||||
.replace('{' + 'id' + '}', String(id));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
// verify required parameter 'id' is set
|
||||
if (!id) {
|
||||
throw new Error('Missing required parameter id when calling getProjectById');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project list
|
||||
* Returns a Project JSON object
|
||||
* @param page
|
||||
* @param perPage
|
||||
* @param kind
|
||||
* @param q
|
||||
* @param filter
|
||||
* @param latitude Valid with kind as location
|
||||
* @param longitude Valid with kind as location
|
||||
* @param scope Valid with kind as location, and between 1~9
|
||||
*/
|
||||
public getProjectList (page?: number, perPage?: number, kind?: string, q?: string, filter?: string, latitude?: number, longitude?: number, scope?: number, extraHttpRequestParams?: any ) : Observable<models.ProjectList> {
|
||||
const path = this.basePath + '/projects';
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
if (page !== undefined) {
|
||||
queryParameters['page'] = page;
|
||||
}
|
||||
|
||||
if (perPage !== undefined) {
|
||||
queryParameters['per_page'] = perPage;
|
||||
}
|
||||
|
||||
if (kind !== undefined) {
|
||||
queryParameters['kind'] = kind;
|
||||
}
|
||||
|
||||
if (q !== undefined) {
|
||||
queryParameters['q'] = q;
|
||||
}
|
||||
|
||||
if (filter !== undefined) {
|
||||
queryParameters['filter'] = filter;
|
||||
}
|
||||
|
||||
if (latitude !== undefined) {
|
||||
queryParameters['latitude'] = latitude;
|
||||
}
|
||||
|
||||
if (longitude !== undefined) {
|
||||
queryParameters['longitude'] = longitude;
|
||||
}
|
||||
|
||||
if (scope !== undefined) {
|
||||
queryParameters['scope'] = scope;
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => response.json());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update project
|
||||
*
|
||||
* @param id Project id
|
||||
* @param name User ID
|
||||
* @param address Address
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
* @param meta
|
||||
* @param thumbnail Project thumbnail
|
||||
*/
|
||||
public updateProject (id: number, name?: string, address?: string, longitude?: number, latitude?: number, meta?: string, thumbnail?: any, extraHttpRequestParams?: any ) : Observable<models.ProjectEntity> {
|
||||
const path = this.basePath + '/projects/{id}'
|
||||
.replace('{' + 'id' + '}', String(id));
|
||||
|
||||
let queryParameters: any = ""; // This should probably be an object in the future
|
||||
let headerParams = this.defaultHeaders;
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'id' is set
|
||||
if (!id) {
|
||||
throw new Error('Missing required parameter id when calling updateProject');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['name'] = name;
|
||||
|
||||
formParams['address'] = address;
|
||||
|
||||
formParams['longitude'] = longitude;
|
||||
|
||||
formParams['latitude'] = latitude;
|
||||
|
||||
formParams['meta'] = meta;
|
||||
|
||||
formParams['thumbnail'] = thumbnail;
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => response.json());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
export * from './ProjectApi';
|
@ -0,0 +1,2 @@
|
||||
export * from './api/api';
|
||||
export * from './model/models';
|
@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface ProjectEntity {
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
kind?: ProjectEntity.KindEnum;
|
||||
|
||||
thumbnailUrl?: string;
|
||||
|
||||
name?: string;
|
||||
|
||||
state?: string;
|
||||
|
||||
meta?: any;
|
||||
|
||||
location?: models.ProjectEntityLocation;
|
||||
|
||||
createdAt?: Date;
|
||||
|
||||
updatedAt?: Date;
|
||||
|
||||
publishedAt?: Date;
|
||||
}
|
||||
export namespace ProjectEntity {
|
||||
|
||||
export enum KindEnum {
|
||||
project = <any> 'project',
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface ProjectEntityLocation {
|
||||
|
||||
|
||||
lat?: number;
|
||||
|
||||
lon?: number;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface ProjectList {
|
||||
|
||||
|
||||
contents?: Array<models.ProjectEntity>;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export * from './ProjectEntity';
|
||||
export * from './ProjectEntityLocation';
|
||||
export * from './ProjectList';
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "arrayAndAnyTest",
|
||||
"version": "1.0.2",
|
||||
"description": "swagger client for arrayAndAnyTest",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
"swagger-client"
|
||||
],
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"main": "./lib/index.js",
|
||||
"typings": "./lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "typings install && tsc"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/core": "^2.0.0-rc.1",
|
||||
"@angular/http": "^2.0.0-rc.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/common": "^2.0.0-rc.1",
|
||||
"@angular/compiler": "^2.0.0-rc.1",
|
||||
"@angular/core": "^2.0.0-rc.1",
|
||||
"@angular/http": "^2.0.0-rc.1",
|
||||
"@angular/platform-browser": "^2.0.0-rc.1",
|
||||
"@angular/platform-browser-dynamic": "^2.0.0-rc.1",
|
||||
"core-js": "^2.3.0",
|
||||
"rxjs": "^5.0.0-beta.6",
|
||||
"zone.js": "^0.6.12",
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.8.1",
|
||||
"es6-shim": "^0.35.0",
|
||||
"es7-reflect-metadata": "^1.6.0"
|
||||
}}
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": false,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"removeComments": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./lib",
|
||||
"noLib": false,
|
||||
"declaration": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"typings/main.d.ts",
|
||||
"typings/main",
|
||||
"lib"
|
||||
],
|
||||
"filesGlob": [
|
||||
"./model/*.ts",
|
||||
"./api/*.ts",
|
||||
"typings/browser.d.ts"
|
||||
]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"core-js": "registry:dt/core-js#0.0.0+20160317120654"
|
||||
}
|
||||
}
|
@ -0,0 +1,570 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info":
|
||||
{
|
||||
"version": "1.7.0",
|
||||
"title": "Cupix API",
|
||||
"contact":
|
||||
{
|
||||
"name": "inska.lee@cupix.com"
|
||||
}
|
||||
},
|
||||
"basePath": "/v1",
|
||||
"consumes":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"produces":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"schemes":
|
||||
[
|
||||
"https"
|
||||
],
|
||||
"paths":
|
||||
{
|
||||
"/projects":
|
||||
{
|
||||
"post":
|
||||
{
|
||||
"tags":
|
||||
[
|
||||
"Project"
|
||||
],
|
||||
"summary": "Create a Project",
|
||||
"operationId": "create_project",
|
||||
"description": "Creates an empty Project",
|
||||
"consumes":
|
||||
[
|
||||
"application/x-www-form-urlencoded"
|
||||
],
|
||||
"produces":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"parameters":
|
||||
[
|
||||
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "address",
|
||||
"type": "string",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "longitude",
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "latitude",
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "meta",
|
||||
"type": "string",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses":
|
||||
{
|
||||
"200":
|
||||
{
|
||||
"description": "Project information",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/ProjectEntity"
|
||||
}
|
||||
},
|
||||
"400":
|
||||
{
|
||||
"description": "Bad Request",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401":
|
||||
{
|
||||
"description": "Unauthorized request"
|
||||
},
|
||||
"403":
|
||||
{
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"404":
|
||||
{
|
||||
"description": "Project not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"get":
|
||||
{
|
||||
"tags":
|
||||
[
|
||||
"Project"
|
||||
],
|
||||
"summary": "Get project list",
|
||||
"operationId": "get_project_list",
|
||||
"description": "Returns a Project JSON object",
|
||||
"produces":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"security":
|
||||
[
|
||||
|
||||
{
|
||||
"key":
|
||||
[
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"token":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"parameters":
|
||||
[
|
||||
|
||||
{
|
||||
"name": "page",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"in": "query"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "per_page",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"in": "query"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "kind",
|
||||
"type": "string",
|
||||
"in": "query",
|
||||
"enum":
|
||||
[
|
||||
"my_models",
|
||||
"published",
|
||||
"location"
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "q",
|
||||
"type": "string",
|
||||
"in": "query"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "filter",
|
||||
"type": "string",
|
||||
"in": "query"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "latitude",
|
||||
"in": "query",
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"description": "Valid with kind as location"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "longitude",
|
||||
"in": "query",
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"description": "Valid with kind as location"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "scope",
|
||||
"in": "query",
|
||||
"type": "integer",
|
||||
"description": "Valid with kind as location, and between 1~9"
|
||||
}
|
||||
],
|
||||
"responses":
|
||||
{
|
||||
"200":
|
||||
{
|
||||
"description": "Project list",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/ProjectList"
|
||||
}
|
||||
},
|
||||
"400":
|
||||
{
|
||||
"description": "Bad Request",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401":
|
||||
{
|
||||
"description": "Unauthorized request"
|
||||
},
|
||||
"403":
|
||||
{
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"404":
|
||||
{
|
||||
"description": "Project not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/projects/{id}":
|
||||
{
|
||||
"get":
|
||||
{
|
||||
"tags":
|
||||
[
|
||||
"Project"
|
||||
],
|
||||
"summary": "Get a Project",
|
||||
"operationId": "get_project_by_id",
|
||||
"description": "Returns a Project JSON object",
|
||||
"produces":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"parameters":
|
||||
[
|
||||
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "Project id",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
],
|
||||
"responses":
|
||||
{
|
||||
"200":
|
||||
{
|
||||
"description": "Project information",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/ProjectEntity"
|
||||
}
|
||||
},
|
||||
"400":
|
||||
{
|
||||
"description": "Bad Request",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401":
|
||||
{
|
||||
"description": "Unauthorized request"
|
||||
},
|
||||
"403":
|
||||
{
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"404":
|
||||
{
|
||||
"description": "Project not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put":
|
||||
{
|
||||
"tags":
|
||||
[
|
||||
"Project"
|
||||
],
|
||||
"summary": "Update project",
|
||||
"operationId": "update_project",
|
||||
"consumes":
|
||||
[
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"parameters":
|
||||
[
|
||||
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "Project id",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "name",
|
||||
"in": "formData",
|
||||
"description": "User ID",
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "address",
|
||||
"in": "formData",
|
||||
"description": "Address",
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "longitude",
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "latitude",
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "meta",
|
||||
"type": "string",
|
||||
"in": "formData"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "thumbnail",
|
||||
"in": "formData",
|
||||
"description": "Project thumbnail",
|
||||
"type": "file"
|
||||
}
|
||||
],
|
||||
"responses":
|
||||
{
|
||||
"200":
|
||||
{
|
||||
"description": "Project information",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/ProjectEntity"
|
||||
}
|
||||
},
|
||||
"400":
|
||||
{
|
||||
"description": "Bad Request",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401":
|
||||
{
|
||||
"description": "Unauthorized request"
|
||||
},
|
||||
"403":
|
||||
{
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"404":
|
||||
{
|
||||
"description": "Project not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete":
|
||||
{
|
||||
"tags":
|
||||
[
|
||||
"Project"
|
||||
],
|
||||
"summary": "Delete a Project",
|
||||
"operationId": "delete_project_by_id",
|
||||
"description": "Returns a Project JSON object",
|
||||
"produces":
|
||||
[
|
||||
"application/json"
|
||||
],
|
||||
"parameters":
|
||||
[
|
||||
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "Project id",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
],
|
||||
"security":
|
||||
[
|
||||
|
||||
{
|
||||
"key":
|
||||
[
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"token":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses":
|
||||
{
|
||||
"200":
|
||||
{
|
||||
"description": "Empty"
|
||||
},
|
||||
"204":
|
||||
{
|
||||
"description": "Deleted"
|
||||
},
|
||||
"400":
|
||||
{
|
||||
"description": "Bad Request",
|
||||
"schema":
|
||||
{
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401":
|
||||
{
|
||||
"description": "Unauthorized request"
|
||||
},
|
||||
"403":
|
||||
{
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"404":
|
||||
{
|
||||
"description": "Project not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions":
|
||||
{
|
||||
"ProjectList":
|
||||
{
|
||||
"type": "object",
|
||||
"required":
|
||||
[
|
||||
"contents"
|
||||
],
|
||||
"properties":
|
||||
{
|
||||
"contents":
|
||||
{
|
||||
"type": "array",
|
||||
"items":
|
||||
{
|
||||
"$ref": "#/definitions/ProjectEntity"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ProjectEntity":
|
||||
{
|
||||
"type": "object",
|
||||
"required":
|
||||
[
|
||||
"id"
|
||||
],
|
||||
"properties":
|
||||
{
|
||||
"id":
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"kind":
|
||||
{
|
||||
"type": "string",
|
||||
"enum":
|
||||
[
|
||||
"project"
|
||||
]
|
||||
},
|
||||
"thumbnail_url":
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
"name":
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
"state":
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
"meta":
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
"location":
|
||||
{
|
||||
"type": "object",
|
||||
"properties":
|
||||
{
|
||||
"lat":
|
||||
{
|
||||
"type": "number",
|
||||
"format": "float"
|
||||
},
|
||||
"lon":
|
||||
{
|
||||
"type": "number",
|
||||
"format": "float"
|
||||
}
|
||||
}
|
||||
},
|
||||
"created_at":
|
||||
{
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"updated_at":
|
||||
{
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"published_at":
|
||||
{
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,594 @@
|
||||
import request = require('request');
|
||||
import http = require('http');
|
||||
import Promise = require('bluebird');
|
||||
|
||||
let defaultBasePath = 'http://petstore.swagger.io/v1';
|
||||
|
||||
// ===============================================
|
||||
// This file is autogenerated - Please do not edit
|
||||
// ===============================================
|
||||
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
export class Category {
|
||||
'id': number;
|
||||
'name': string;
|
||||
}
|
||||
|
||||
export class Pet {
|
||||
'id': number;
|
||||
'category': Category;
|
||||
'name': string;
|
||||
}
|
||||
|
||||
|
||||
export interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
*/
|
||||
applyToRequest(requestOptions: request.Options): void;
|
||||
}
|
||||
|
||||
export class HttpBasicAuth implements Authentication {
|
||||
public username: string;
|
||||
public password: string;
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
requestOptions.auth = {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class ApiKeyAuth implements Authentication {
|
||||
public apiKey: string;
|
||||
|
||||
constructor(private location: string, private paramName: string) {
|
||||
}
|
||||
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
if (this.location == "query") {
|
||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||
} else if (this.location == "header") {
|
||||
requestOptions.headers[this.paramName] = this.apiKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class OAuth implements Authentication {
|
||||
public accessToken: string;
|
||||
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
export class VoidAuth implements Authentication {
|
||||
public username: string;
|
||||
public password: string;
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
export enum PetApiApiKeys {
|
||||
}
|
||||
|
||||
export class PetApi {
|
||||
protected basePath = defaultBasePath;
|
||||
protected defaultHeaders : any = {};
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
||||
if (password) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
} else {
|
||||
if (basePathOrUsername) {
|
||||
this.basePath = basePathOrUsername
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setApiKey(key: PetApiApiKeys, value: string) {
|
||||
this.authentications[PetApiApiKeys[key]].apiKey = value;
|
||||
}
|
||||
private extendObj<T1,T2>(objA: T1, objB: T2) {
|
||||
for(let key in objB){
|
||||
if(objB.hasOwnProperty(key)){
|
||||
objA[key] = objB[key];
|
||||
}
|
||||
}
|
||||
return <T1&T2>objA;
|
||||
}
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/pet';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
body: body,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet (petId: number, apiKey?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
|
||||
}
|
||||
|
||||
headerParams['api_key'] = apiKey;
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'DELETE',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getPetById (petId: number) : Promise<{ response: http.ClientResponse; body: Pet; }> {
|
||||
const localVarPath = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body: Pet; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/pet';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'PUT',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
body: body,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
* @param petId ID of pet that needs to be updated
|
||||
* @param name Updated name of the pet
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
public updatePetWithForm (petId: string, name?: string, status?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
if (name !== undefined) {
|
||||
formParams['name'] = name;
|
||||
}
|
||||
|
||||
if (status !== undefined) {
|
||||
formParams['status'] = status;
|
||||
}
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
export enum StoreApiApiKeys {
|
||||
}
|
||||
|
||||
export class StoreApi {
|
||||
protected basePath = defaultBasePath;
|
||||
protected defaultHeaders : any = {};
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
||||
if (password) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
} else {
|
||||
if (basePathOrUsername) {
|
||||
this.basePath = basePathOrUsername
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setApiKey(key: StoreApiApiKeys, value: string) {
|
||||
this.authentications[StoreApiApiKeys[key]].apiKey = value;
|
||||
}
|
||||
private extendObj<T1,T2>(objA: T1, objB: T2) {
|
||||
for(let key in objB){
|
||||
if(objB.hasOwnProperty(key)){
|
||||
objA[key] = objB[key];
|
||||
}
|
||||
}
|
||||
return <T1&T2>objA;
|
||||
}
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder (orderId: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'orderId' is not null or undefined
|
||||
if (orderId === null || orderId === undefined) {
|
||||
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'DELETE',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*/
|
||||
public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> {
|
||||
const localVarPath = this.basePath + '/store/inventory';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById (orderId: string) : Promise<{ response: http.ClientResponse; body: Order; }> {
|
||||
const localVarPath = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'orderId' is not null or undefined
|
||||
if (orderId === null || orderId === undefined) {
|
||||
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body: Order; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> {
|
||||
const localVarPath = this.basePath + '/store/order';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
body: body,
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
return new Promise<{ response: http.ClientResponse; body: Order; }>((resolve, reject) => {
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
resolve({ response: response, body: body });
|
||||
} else {
|
||||
reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id=""
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id=""
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note=""
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "node-es6-test",
|
||||
"version": "1.0.3",
|
||||
"description": "NodeJS client for node-es6-test",
|
||||
"main": "api.js",
|
||||
"scripts": {
|
||||
"build": "typings install && tsc"
|
||||
},
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bluebird": "^3.3.5",
|
||||
"request": "^2.72.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.8.1"
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": false,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"target": "ES5",
|
||||
"moduleResolution": "node",
|
||||
"removeComments": true,
|
||||
"sourceMap": true,
|
||||
"noLib": false,
|
||||
"declaration": true
|
||||
},
|
||||
"files": [
|
||||
"api.ts",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
|
||||
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
|
||||
"node": "registry:dt/node#4.0.0+20160423143914"
|
||||
},
|
||||
"dependencies": {
|
||||
"request": "registry:npm/request#2.69.0+20160304121250"
|
||||
}
|
||||
}
|
@ -0,0 +1,418 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"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",
|
||||
"title": "Swagger Petstore",
|
||||
"termsOfService": "http://helloreverb.com/terms/",
|
||||
"contact": {
|
||||
"email": "apiteam@wordnik.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"host": "petstore.swagger.io",
|
||||
"basePath": "/v1",
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"paths": {
|
||||
"/pet": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Add a new pet to the store",
|
||||
"description": "",
|
||||
"operationId": "addPet",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Update an existing pet",
|
||||
"description": "",
|
||||
"operationId": "updatePet",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"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": "Validation exception"
|
||||
},
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/pet/{petId}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Find pet by ID",
|
||||
"description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
|
||||
"operationId": "getPetById",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
},
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": []
|
||||
},
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Updates a pet in the store with form data",
|
||||
"description": "",
|
||||
"operationId": "updatePetWithForm",
|
||||
"consumes": [
|
||||
"application/x-www-form-urlencoded"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be updated",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"in": "formData",
|
||||
"description": "Updated name of the pet",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"in": "formData",
|
||||
"description": "Updated status of the pet",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"405": {
|
||||
"description": "Invalid input"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"pet"
|
||||
],
|
||||
"summary": "Deletes a pet",
|
||||
"description": "",
|
||||
"operationId": "deletePet",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"petstore_auth": [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/store/inventory": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Returns pet inventories by status",
|
||||
"description": "Returns a map of status codes to quantities",
|
||||
"operationId": "getInventory",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/store/order": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Place an order for a pet",
|
||||
"description": "",
|
||||
"operationId": "placeOrder",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"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}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Find purchase order by ID",
|
||||
"description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
"operationId": "getOrderById",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "path",
|
||||
"description": "ID of pet that needs to be fetched",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"404": {
|
||||
"description": "Order not found"
|
||||
},
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid ID supplied"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"store"
|
||||
],
|
||||
"summary": "Delete purchase order by ID",
|
||||
"description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
"operationId": "deleteOrder",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"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": {
|
||||
"Category": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pet": {
|
||||
"required": [
|
||||
"name",
|
||||
"photoUrls"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "#/definitions/Category"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "doggie"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user